diff options
author | Jim Meyering <jim@meyering.net> | 2003-05-02 21:42:51 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2003-05-02 21:42:51 +0000 |
commit | 35cad8ae0571cd1318d8281d9954ac60ee32759b (patch) | |
tree | 62792fe8e4c831ea794ec9cfaffca1cda397562f | |
parent | 478239f404954804c78fc84d0177a535daf6d7b8 (diff) | |
download | coreutils-35cad8ae0571cd1318d8281d9954ac60ee32759b.tar.xz |
(canonicalize_file_name) [!HAVE_RESOLVEPATH]:
A memory-allocation error could result in heap corruption. Fix it
by also updating `dest' when rpath may be changed by xrealloc.
-rw-r--r-- | lib/canonicalize.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/canonicalize.c b/lib/canonicalize.c index 453279d3c..6e58b282d 100644 --- a/lib/canonicalize.c +++ b/lib/canonicalize.c @@ -173,9 +173,11 @@ canonicalize_file_name (const char *name) if (!rpath) return NULL; dest = strchr (rpath, '\0'); - if (dest < rpath + PATH_MAX) + if (dest - rpath < PATH_MAX) { - rpath = xrealloc (rpath, PATH_MAX); + char *p = xrealloc (rpath, PATH_MAX); + dest = p + (dest - rpath); + rpath = p; rpath_limit = rpath + PATH_MAX; } else |