projects
/
platform
/
upstream
/
coreutils.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
478239f
)
(canonicalize_file_name) [!HAVE_RESOLVEPATH]:
author
Jim Meyering
<jim@meyering.net>
Fri, 2 May 2003 21:42:51 +0000
(21:42 +0000)
committer
Jim Meyering
<jim@meyering.net>
Fri, 2 May 2003 21:42:51 +0000
(21:42 +0000)
A memory-allocation error could result in heap corruption. Fix it
by also updating `dest' when rpath may be changed by xrealloc.
lib/canonicalize.c
patch
|
blob
|
history
diff --git
a/lib/canonicalize.c
b/lib/canonicalize.c
index
453279d
..
6e58b28
100644
(file)
--- 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