summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2003-05-02 21:42:51 +0000
committerJim Meyering <jim@meyering.net>2003-05-02 21:42:51 +0000
commit35cad8ae0571cd1318d8281d9954ac60ee32759b (patch)
tree62792fe8e4c831ea794ec9cfaffca1cda397562f /lib
parent478239f404954804c78fc84d0177a535daf6d7b8 (diff)
downloadcoreutils-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.
Diffstat (limited to 'lib')
-rw-r--r--lib/canonicalize.c6
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