Coverity complains of . toctou: Calling function mkdir that uses DIR after a check function. This can cause a time-of-check, time-of-use race condition
if (stat(DIR, &st) != 0)
{
if (mkdir(DIR, 0755) < 0)
{
return ERROR;
}
}
Is it good enough to change the code to ,I was using stat only for file exist check
if (mkdir(NDUID_DIR, 0755) < 0)
{
if(errno != EEXIST)
{
return ERROR;
}
}
Is there a better way to fix the code?