public inbox for annobin@sourceware.org
 help / color / mirror / Atom feed
From: Tulio Magno Quites Machado Filho <tuliom@ascii.art.br>
To: annobin@sourceware.org
Subject: [PATCH] Fix known_glibc_specials comparison
Date: Thu, 13 Jun 2024 15:08:11 -0300	[thread overview]
Message-ID: <20240613180811.126880-1-tuliom@ascii.art.br> (raw)

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


             reply	other threads:[~2024-06-13 18:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-13 18:08 Tulio Magno Quites Machado Filho [this message]
2024-06-14  8:53 ` Nick Clifton
2024-06-14 12:28   ` Tulio Magno Quites Machado Filho

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=20240613180811.126880-1-tuliom@ascii.art.br \
    --to=tuliom@ascii.art.br \
    --cc=annobin@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: link
Be 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).