This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/3426] New: canonicalize_file_name's behavior differs from documentation

In GNU libc 2.3.5, the header file /usr/lib/stdlib.h reads:

#ifdef  __USE_GNU                                                               
/* Return a malloc'd string containing the canonical absolute name of the       
   named file.  The last file name component need not exist, and may be a       
   symlink to a nonexistent file.  */                                           
extern char *canonicalize_file_name (__const char *__name)                      
     __THROW __nonnull ((1));                                                   

However, canonicalize_file_name() returns NULL when passed a path where the last
component does not exist.

// file: can-test.c

#define _GNU_SOURCE                                                             
#include <stdlib.h>                                                             
#include <stdio.h>                                                              

int main(void)                                                                  
   char *p = canonicalize_file_name("no-such-file");                            
   if (!p)                                                                      
   return 0;                                                                    

The same applies to realpath() and its description. As of version 2.3.5, either
the documentation or the implementation is wrong.


Juergen Lemke

           Summary: canonicalize_file_name's behavior differs from
           Product: glibc
           Version: 2.3.5
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: lemke_juergen at yahoo dot de
                CC: glibc-bugs at sources dot redhat dot com,lemke_juergen
                    at yahoo dot de

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]