public inbox for glibc-cvs@sourceware.org help / color / mirror / Atom feed
From: Florian Weimer <fw@sourceware.org> To: glibc-cvs@sourceware.org Subject: [glibc] elf: ldconfig should skip temporary files created by package managers Date: Fri, 20 Oct 2023 17:30:50 +0000 (GMT) [thread overview] Message-ID: <20231020173050.864DB3858D20@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=2aa0974d2573441bffd596b07bff8698b1f2f18c commit 2aa0974d2573441bffd596b07bff8698b1f2f18c Author: Florian Weimer <fweimer@redhat.com> Date: Fri Oct 20 14:29:50 2023 +0200 elf: ldconfig should skip temporary files created by package managers This avoids crashes due to partially written files, after a package update is interrupted. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Diff: --- NEWS | 4 +++- elf/ldconfig.c | 39 +++++++++++++++++++++++++++------------ 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/NEWS b/NEWS index cc4b81f0ac..9432564444 100644 --- a/NEWS +++ b/NEWS @@ -40,7 +40,9 @@ Major new features: Deprecated and removed features, and other changes affecting compatibility: - [Add deprecations, removals and changes affecting compatibility here] +* The ldconfig program now skips file names containing ';' or ending in + ".tmp", to avoid examining temporary files created by the RPM and dpkg + package managers. Changes to build and runtime requirements: diff --git a/elf/ldconfig.c b/elf/ldconfig.c index d26eef1fb4..02387a169c 100644 --- a/elf/ldconfig.c +++ b/elf/ldconfig.c @@ -661,6 +661,31 @@ struct dlib_entry struct dlib_entry *next; }; +/* Skip some temporary DSO files. These files may be partially written + and lead to ldconfig crashes when examined. */ +static bool +skip_dso_based_on_name (const char *name, size_t len) +{ + /* Skip temporary files created by the prelink program. Files with + names like these are never really DSOs we want to look at. */ + if (len >= sizeof (".#prelink#") - 1) + { + if (strcmp (name + len - sizeof (".#prelink#") + 1, + ".#prelink#") == 0) + return true; + if (len >= sizeof (".#prelink#.XXXXXX") - 1 + && memcmp (name + len - sizeof (".#prelink#.XXXXXX") + + 1, ".#prelink#.", sizeof (".#prelink#.") - 1) == 0) + return true; + } + /* Skip temporary files created by RPM. */ + if (memchr (name, len, ';') != NULL) + return true; + /* Skip temporary files created by dpkg. */ + if (len > 4 && memcmp (name + len - 4, ".tmp", 4) == 0) + return true; + return false; +} static void search_dir (const struct dir_entry *entry) @@ -711,18 +736,8 @@ search_dir (const struct dir_entry *entry) continue; size_t len = strlen (direntry->d_name); - /* Skip temporary files created by the prelink program. Files with - names like these are never really DSOs we want to look at. */ - if (len >= sizeof (".#prelink#") - 1) - { - if (strcmp (direntry->d_name + len - sizeof (".#prelink#") + 1, - ".#prelink#") == 0) - continue; - if (len >= sizeof (".#prelink#.XXXXXX") - 1 - && memcmp (direntry->d_name + len - sizeof (".#prelink#.XXXXXX") - + 1, ".#prelink#.", sizeof (".#prelink#.") - 1) == 0) - continue; - } + if (skip_dso_based_on_name (direntry->d_name, len)) + continue; if (asprintf (&file_name, "%s/%s", entry->path, direntry->d_name) < 0) error (EXIT_FAILURE, errno, _("Could not form library path")); if (opt_chroot != NULL)
reply other threads:[~2023-10-20 17:30 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20231020173050.864DB3858D20@sourceware.org \ --to=fw@sourceware.org \ --cc=glibc-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).