|
|
20062d |
commit cfb5a97a93ea656e3b2263e42142a4032986d9ba
|
|
|
20062d |
Author: Florian Weimer <fweimer@redhat.com>
|
|
|
20062d |
Date: Mon Oct 23 12:53:16 2023 +0200
|
|
|
20062d |
|
|
|
20062d |
ldconfig: Fixes for skipping temporary files.
|
|
|
20062d |
|
|
|
20062d |
Arguments to a memchr call were swapped, causing incorrect skipping
|
|
|
20062d |
of files.
|
|
|
20062d |
|
|
|
20062d |
Files related to dpkg have different names: they actually end in
|
|
|
20062d |
.dpkg-new and .dpkg-tmp, not .tmp as I mistakenly assumed.
|
|
|
20062d |
|
|
|
20062d |
Fixes commit 2aa0974d2573441bffd59 ("elf: ldconfig should skip
|
|
|
20062d |
temporary files created by package managers").
|
|
|
20062d |
|
|
|
20062d |
diff --git a/elf/ldconfig.c b/elf/ldconfig.c
|
|
|
20062d |
index 51de08f91fbaf093..fb19dd68d41c07a4 100644
|
|
|
20062d |
--- a/elf/ldconfig.c
|
|
|
20062d |
+++ b/elf/ldconfig.c
|
|
|
20062d |
@@ -771,6 +771,17 @@ struct dlib_entry
|
|
|
20062d |
struct dlib_entry *next;
|
|
|
20062d |
};
|
|
|
20062d |
|
|
|
20062d |
+/* Return true if the N bytes at NAME end with with the characters in
|
|
|
20062d |
+ the string SUFFIX. (NAME[N + 1] does not have to be a null byte.)
|
|
|
20062d |
+ Expected to be called with a string literal for SUFFIX. */
|
|
|
20062d |
+static inline bool
|
|
|
20062d |
+endswithn (const char *name, size_t n, const char *suffix)
|
|
|
20062d |
+{
|
|
|
20062d |
+ return (n >= strlen (suffix)
|
|
|
20062d |
+ && memcmp (name + n - strlen (suffix), suffix,
|
|
|
20062d |
+ strlen (suffix)) == 0);
|
|
|
20062d |
+}
|
|
|
20062d |
+
|
|
|
20062d |
/* Skip some temporary DSO files. These files may be partially written
|
|
|
20062d |
and lead to ldconfig crashes when examined. */
|
|
|
20062d |
static bool
|
|
|
20062d |
@@ -780,8 +791,7 @@ skip_dso_based_on_name (const char *name, size_t len)
|
|
|
20062d |
names like these are never really DSOs we want to look at. */
|
|
|
20062d |
if (len >= sizeof (".#prelink#") - 1)
|
|
|
20062d |
{
|
|
|
20062d |
- if (strcmp (name + len - sizeof (".#prelink#") + 1,
|
|
|
20062d |
- ".#prelink#") == 0)
|
|
|
20062d |
+ if (endswithn (name, len, ".#prelink#"))
|
|
|
20062d |
return true;
|
|
|
20062d |
if (len >= sizeof (".#prelink#.XXXXXX") - 1
|
|
|
20062d |
&& memcmp (name + len - sizeof (".#prelink#.XXXXXX")
|
|
|
20062d |
@@ -789,10 +799,11 @@ skip_dso_based_on_name (const char *name, size_t len)
|
|
|
20062d |
return true;
|
|
|
20062d |
}
|
|
|
20062d |
/* Skip temporary files created by RPM. */
|
|
|
20062d |
- if (memchr (name, len, ';') != NULL)
|
|
|
20062d |
+ if (memchr (name, ';', len) != NULL)
|
|
|
20062d |
return true;
|
|
|
20062d |
/* Skip temporary files created by dpkg. */
|
|
|
20062d |
- if (len > 4 && memcmp (name + len - 4, ".tmp", 4) == 0)
|
|
|
20062d |
+ if (endswithn (name, len, ".dpkg-new")
|
|
|
20062d |
+ || endswithn (name, len, ".dpkg-tmp"))
|
|
|
20062d |
return true;
|
|
|
20062d |
return false;
|
|
|
20062d |
}
|