diff options
author | Siddhesh Poyarekar <siddhesh@sourceware.org> | 2021-05-18 09:29:02 +0530 |
---|---|---|
committer | Siddhesh Poyarekar <siddhesh@sourceware.org> | 2021-05-18 09:29:02 +0530 |
commit | 468d772e81e9842f4f73431c164b4a12f13d8658 (patch) | |
tree | 173df635eadc05a255bcd1302d51c8fa0f4b0de2 /elf/ldconfig.c | |
parent | c8c3c5e89a5f6a9d41d244e9803ccaf4250e7e62 (diff) | |
download | glibc-468d772e81e9842f4f73431c164b4a12f13d8658.tar.gz glibc-468d772e81e9842f4f73431c164b4a12f13d8658.tar.xz glibc-468d772e81e9842f4f73431c164b4a12f13d8658.zip |
ldconfig: Fix memory leaks
Coverity discovered that paths allocated by chroot_canon are not freed in a couple of routines in ldconfig. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diffstat (limited to 'elf/ldconfig.c')
-rw-r--r-- | elf/ldconfig.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/elf/ldconfig.c b/elf/ldconfig.c index 28ed637a29..bd2b837ec2 100644 --- a/elf/ldconfig.c +++ b/elf/ldconfig.c @@ -709,16 +709,14 @@ manual_link (char *library) if (lstat64 (real_library, &stat_buf)) { error (0, errno, _("Cannot lstat %s"), library); - free (path); - return; + goto out; } /* We don't want links here! */ else if (!S_ISREG (stat_buf.st_mode)) { error (0, 0, _("Ignored file %s since it is not a regular file."), library); - free (path); - return; + goto out; } if (process_file (real_library, library, libname, &flag, &osversion, @@ -726,14 +724,16 @@ manual_link (char *library) { error (0, 0, _("No link created since soname could not be found for %s"), library); - free (path); - return; + goto out; } if (soname == NULL) soname = implicit_soname (libname, flag); create_links (real_path, path, libname, soname); free (soname); +out: free (path); + if (path != real_path) + free (real_path); } @@ -920,8 +920,16 @@ search_dir (const struct dir_entry *entry) /* Remove stale symlinks. */ if (opt_link && strstr (direntry->d_name, ".so.")) unlink (real_file_name); + + if (opt_chroot != NULL) + free (target_name); + continue; } + + if (opt_chroot != NULL) + free (target_name); + is_dir = S_ISDIR (stat_buf.st_mode); /* lstat_buf is later stored, update contents. */ |