aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergei Trofimovich <slyfox@gentoo.org>2020-12-31 12:11:42 +0000
committerMark Wielaard <mark@klomp.org>2021-01-11 23:31:44 +0100
commit372b41d3cef5bfe706eb5a1a027aa87a5a5cb0e3 (patch)
treedac1372deab3734684f82d8decc71b7d8ed8ceab /src
parent2ad0758fddf1289077c43bbb125d0cd80c55aa72 (diff)
downloadelfutils-372b41d3cef5bfe706eb5a1a027aa87a5a5cb0e3.tar.gz
src/elflint.c: fix printing of unknown flags
before the change section_flags_string() ignored unknown section flags: snprintf() did write numeric value into buffer, but "*cp = '\0'" negated 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>
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog5
-rw-r--r--src/elflint.c8
2 files changed, 11 insertions, 2 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 5d0e384f..a2f9603c 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2020-12-31 Sergei Trofimovich <slyfox@gentoo.org>
+
+ * elflint.c (section_flags_string): Update cp pointer after
+ snprintf for unknown flags.
+
2020-12-16 Érico Nogueira <ericonr@disroot.org>
* readelf.c (qsort_r): Use qsort for improved portability.
diff --git a/src/elflint.c b/src/elflint.c
index b3cbaade..21cfa28f 100644
--- a/src/elflint.c
+++ b/src/elflint.c
@@ -2813,8 +2813,12 @@ section_flags_string (GElf_Word flags, char *buf, size_t len)
}
if (flags != 0 || cp == buf)
- snprintf (cp, len - 1, "%" PRIx64, (uint64_t) flags);
-
+ {
+ int r = snprintf (cp, len - 1, "%s%" PRIx64,
+ (cp == buf) ? "" : "|", (uint64_t) flags);
+ if (r > 0)
+ cp += r;
+ }
*cp = '\0';
return buf;