aboutsummaryrefslogtreecommitdiff
path: root/elf
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2004-06-10 02:16:08 +0000
committerRoland McGrath <roland@gnu.org>2004-06-10 02:16:08 +0000
commitf05a089da96014435cce5c9f17f386ba846a1a6e (patch)
treec1c015aec613464b5050d96889e72092c6622584 /elf
parente17f8b6119eb64d126422eda8a18d577cbdc9976 (diff)
downloadglibc-f05a089da96014435cce5c9f17f386ba846a1a6e.zip
glibc-f05a089da96014435cce5c9f17f386ba846a1a6e.tar.gz
glibc-f05a089da96014435cce5c9f17f386ba846a1a6e.tar.bz2
[BZ #199]
2004-06-08 Jakub Jelinek <jakub@redhat.com> [BZ #199] * crypt/md5-crypt.c (__md5_crypt): Only update buflen if realloc succeeds. Reported by Miles Ohlrich <miles@cray.com>. * elf/chroot_canon.c (chroot_canon): Avoid segfault if first malloc fails. Avoid memory leak if realloc fails.
Diffstat (limited to 'elf')
-rw-r--r--elf/chroot_canon.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/elf/chroot_canon.c b/elf/chroot_canon.c
index 6b7e444..d29a032 100644
--- a/elf/chroot_canon.c
+++ b/elf/chroot_canon.c
@@ -1,5 +1,6 @@
/* Return the canonical absolute name of a given file inside chroot.
- Copyright (C) 1996,1997,1998,1999,2000,2001 Free Software Foundation, Inc.
+ Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2004
+ Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -59,6 +60,9 @@ chroot_canon (const char *chroot, const char *name)
}
rpath = malloc (chroot_len + PATH_MAX);
+ if (rpath == NULL)
+ return NULL;
+
rpath_limit = rpath + chroot_len + PATH_MAX;
rpath_root = (char *) mempcpy (rpath, chroot, chroot_len) - 1;
@@ -108,7 +112,7 @@ chroot_canon (const char *chroot, const char *name)
new_size += PATH_MAX;
new_rpath = (char *) realloc (rpath, new_size);
if (new_rpath == NULL)
- return NULL;
+ goto error;
rpath = new_rpath;
rpath_limit = rpath + new_size;