public inbox for annobin@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix known_glibc_specials comparison
@ 2024-06-13 18:08 Tulio Magno Quites Machado Filho
  2024-06-14  8:53 ` Nick Clifton
  0 siblings, 1 reply; 3+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2024-06-13 18:08 UTC (permalink / raw)
  To: annobin

From: Tulio Magno Quites Machado Filho <tuliom@redhat.com>

Sometimes variable path stores a longer path instead of just the name of
a file, e.g. /usr/lib/libfoo.so instead of libfoo.so.
In those cases, we need to remove all the directories before calling
strcmp().
---
 annocheck/hardened.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/annocheck/hardened.c b/annocheck/hardened.c
index 604b6a1..2463101 100644
--- a/annocheck/hardened.c
+++ b/annocheck/hardened.c
@@ -2273,9 +2273,15 @@ is_special_glibc_binary (annocheck_data * data)
       "zic"
     };
 
+  char * file = strrchr(path, '/');
+  if (file == NULL)
+    file = (char *) path;
+  else
+    /* We also want to ignore the last '/' in the string.  */
+    file++;
   for (i = ARRAY_SIZE (known_glibc_specials); i--;)
     {
-      int res = strcmp (path, known_glibc_specials[i]);
+      int res = strcmp (file, known_glibc_specials[i]);
 
       if (res == 0)
 	return true;
-- 
2.45.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-06-14 12:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-13 18:08 [PATCH] Fix known_glibc_specials comparison Tulio Magno Quites Machado Filho
2024-06-14  8:53 ` Nick Clifton
2024-06-14 12:28   ` Tulio Magno Quites Machado Filho

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).