diff options
author | 2015-09-01 16:23:48 -0500 | |
---|---|---|
committer | 2015-09-01 16:23:48 -0500 | |
commit | 3cf27f952e7797c287c0bd367ee4618eaa205cb2 (patch) | |
tree | c50f1f90035617996ec1a12e9966adbc0daef0f0 | |
parent | 65c0b6ba05f8b86de18adc40530fd7ffae8c1643 (diff) | |
download | pseudo-3cf27f952e7797c287c0bd367ee4618eaa205cb2.tar.gz pseudo-3cf27f952e7797c287c0bd367ee4618eaa205cb2.tar.bz2 pseudo-3cf27f952e7797c287c0bd367ee4618eaa205cb2.zip |
realpath: allocate memory when null pointer given
When I trimmed the spurious free()s for the new lower-allocation
path strategy, I forgot to look for cases where I was relying on
the allocation, such as realpath(path, NULL).
Signed-off-by: Peter Seebach <peter.seebach@windriver.com>
-rw-r--r-- | ChangeLog.txt | 2 | ||||
-rw-r--r-- | ports/unix/guts/realpath.c | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/ChangeLog.txt b/ChangeLog.txt index cf098ed..54567ca 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -2,6 +2,8 @@ * (seebs) use PSEUDO_STATBUF and base_lstat in path resolution, because plain lstat can fail on XFS if an inode number is out of the 32-bit range. + * (seebs) if no pointer was provided to realpath, provide allocated + dup. 2015-08-24: * (seebs) drop unused/unimplemented "picky_fchmodat", since I diff --git a/ports/unix/guts/realpath.c b/ports/unix/guts/realpath.c index 48b2b34..a59808d 100644 --- a/ports/unix/guts/realpath.c +++ b/ports/unix/guts/realpath.c @@ -20,7 +20,7 @@ memcpy(resolved_name, rname, len + 1); rc = resolved_name; } else { - rc = rname; + rc = strdup(rname); } /* return rc; |