[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC PATCH 1/2] elf: Port ldconfig away from stack-allocated paths
From: |
Florian Weimer |
Subject: |
Re: [RFC PATCH 1/2] elf: Port ldconfig away from stack-allocated paths |
Date: |
Fri, 19 May 2023 14:25:52 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) |
* Sergey Bugaev via Libc-alpha:
> @@ -733,25 +723,11 @@ search_dir (const struct dir_entry *entry)
> + 1, ".#prelink#.", sizeof (".#prelink#.") - 1) == 0)
> continue;
> }
> - len += strlen (entry->path) + 2;
> - if (len > file_name_len)
> - {
> - file_name_len = len;
> - file_name = alloca (file_name_len);
> - if (!opt_chroot)
> - real_file_name = file_name;
> - }
> - sprintf (file_name, "%s/%s", entry->path, direntry->d_name);
> + asprintf (&file_name, "%s/%s", entry->path, direntry->d_name);
> if (opt_chroot != NULL)
> - {
> - len = strlen (dir_name) + strlen (direntry->d_name) + 2;
> - if (len > real_file_name_len)
> - {
> - real_file_name_len = len;
> - real_file_name = alloca (real_file_name_len);
> - }
> - sprintf (real_file_name, "%s/%s", dir_name, direntry->d_name);
> - }
> + asprintf (&real_file_name, "%s/%s", dir_name, direntry->d_name);
> + else
> + real_file_name = file_name;
>
> struct stat lstat_buf;
> /* We optimize and try to do the lstat call only if needed. */
Missing error checking?
I think we use x* functions such a xstrdup elsewhere in ldconfig, so you
could add xasprintf as well.
Thanks,
Florian