[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

dirname() trailing slash Segfault bug




Dear Sirs,

I have came across a bug in dirname() function of GNU libc.

It is triggered by the following minimal source:

#include <stdio.h>
#include <string.h>

int main (int argc, char *argv[]) {
        char  *buf = "usr/";

        char *word = strdup (buf);
        printf ("dirname ('%s')='%s'\n", buf, dirname (word));
        free (word);
}

The trick is to use trailing slash ('/') on path that doesn't start with one.

At present I don't have a fix.

Best luck,
Mirsad Todorovac
mtodorov@grf.hr


Reply to: