Re: dirname() trailing slash Segfault bug
On Fri, Aug 15, 2008 at 9:03 AM, Mirsad Todorovac <mtodorov@grf.hr> wrote:
> 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.
Please file a bug against glibc if you think this is a bug present in
the debian libc6 package.
On libc6 2.7-10 for x86, your testcase works just fine:
carlos@systemhalted:~$ ./test3
dirname ('usr/')='.'
Cheers,
Carlos.
Reply to: