Bugs - Program that Creates a Directory in C I have the following code that creates a directory in C. I tested it multiple times, reviewed it a few times and it looks fine at the moment.

What I really wanna know is what bugs does it have and how can I fix them ? (comparing it with the mkdir command from linux)

#include "ourhdr.h"
#include &lt;sys/stat.h&gt;
#include &lt;limits.h&gt;
#include &lt;dirent.h&gt;


int main(int argc, char **argv)
{

    if(argc != 2)
    {
        printf("./i78 /locatie/nume_director sau ./i78 nume_director\n");
        return 1;
    }

    char buff[PATH_MAX];
    strcpy(buff,argv[1]);

    if (mkdir(buff,S_IRWXU|S_IRWXG|S_IRWXO)&lt;0)
    {   
    printf("%s: cannot create directory '%s': File exists\n",argv[0],buff);
    }
    else

    printf("\n Creare director [%s]\n",buff);


}
There is a potential buffer overflow - the length of argv[1] may be up to ARG_MAX, which is likely larger than PATH_MAX.

The "File Exists" message may be misleading, mkdir can also fail because of permissions, out of space, invalid characters in the name, ...

It's good practice to put { } around all conditionals, including the else.