* [PATCH] src/elflint.c: fix printing of unknown flags
@ 2020-12-31 12:11 Sergei Trofimovich
2021-01-11 22:39 ` Mark Wielaard
0 siblings, 1 reply; 2+ messages in thread
From: Sergei Trofimovich @ 2020-12-31 12:11 UTC (permalink / raw)
To: elfutils-devel; +Cc: Sergei Trofimovich
before the change section_flags_string() ignored unknown section
flags: snprintf() did write numeric value int obuffer, but
"*cp = '\0'" hegated the effect.
The change advances the 'cp' pointer'.
While at it add a '|' separator between known and unknown flags.
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
---
src/elflint.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/elflint.c b/src/elflint.c
index 7b7f7937..8f5227b3 100644
--- a/src/elflint.c
+++ b/src/elflint.c
@@ -2815,9 +2815,11 @@ section_flags_string (GElf_Word flags, char *buf, size_t len)
flags ^= known_flags[cnt].flag;
}
- if (flags != 0 || cp == buf)
- snprintf (cp, len - 1, "%" PRIx64, (uint64_t) flags);
-
+ if (flags != 0 || cp == buf) {
+ int r = snprintf (cp, len - 1, "%s%" PRIx64, (cp == buf) ? "" : "|", (uint64_t) flags);
+ if (r > 0)
+ cp += r;
+ }
*cp = '\0';
return buf;
--
2.30.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] src/elflint.c: fix printing of unknown flags
2020-12-31 12:11 [PATCH] src/elflint.c: fix printing of unknown flags Sergei Trofimovich
@ 2021-01-11 22:39 ` Mark Wielaard
0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2021-01-11 22:39 UTC (permalink / raw)
To: Sergei Trofimovich; +Cc: elfutils-devel
Hi Sergei,
On Thu, Dec 31, 2020 at 12:11:42PM +0000, Sergei Trofimovich via Elfutils-devel wrote:
> before the change section_flags_string() ignored unknown section
> flags: snprintf() did write numeric value int obuffer, but
> "*cp = '\0'" hegated the effect.
>
> The change advances the 'cp' pointer'.
>
> While at it add a '|' separator between known and unknown flags.
Nice. Thanks for finding this.
Added with a ChangeLog entry and slightly updating the code formatting.
Cheers,
Mark
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-01-11 22:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-31 12:11 [PATCH] src/elflint.c: fix printing of unknown flags Sergei Trofimovich
2021-01-11 22:39 ` Mark Wielaard
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).