Changeset 4195


Ignore:
Timestamp:
03/12/08 18:09:35 (5 years ago)
Author:
thomas
Message:

opkg/libbb: Patch from Esben Haabendal <esbenhaabendal gmail com>
Fix the usage of dirname() in libbb/make_directory.c, as it is not correct according to the standard specification for dirname.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/target/opkg/libbb/make_directory.c

    r3837 r4195  
    5151                if (stat (path, &st) < 0 && errno == ENOENT) { 
    5252                        int status; 
    53                         char *buf, *parent; 
     53                        char *pathcopy, *parent, *parentcopy; 
    5454                        mode_t mask; 
    5555 
     
    5757                        umask (mask); 
    5858 
    59                         buf = xstrdup (path); 
    60                         parent = dirname (buf); 
    61                         status = make_directory (parent, (0777 & ~mask) | 0300, 
    62                                         FILEUTILS_RECUR); 
    63                         free (buf); 
     59                        /* dirname is unsafe, it may both modify the 
     60                           memory of the path argument and may return 
     61                           a pointer to static memory, which can then 
     62                           be modified by consequtive calls to dirname */ 
     63                         
     64                        pathcopy = xstrdup (path); 
     65                        parent = dirname (pathcopy); 
     66                        parentcopy = xstrdup (parent); 
     67                        status = make_directory (parentcopy, (0777 & ~mask) 
     68                                                                         | 0300, FILEUTILS_RECUR); 
     69                        free (pathcopy); 
     70                        free (parentcopy); 
     71 
    6472 
    6573                        if (status < 0 || make_directory (path, mode, 0) < 0) 
Note: See TracChangeset for help on using the changeset viewer.