From: Sergei Trofimovich Date: Thu, 31 Dec 2020 12:11:42 +0000 (+0000) Subject: src/elflint.c: fix printing of unknown flags X-Git-Tag: elfutils-0.183~25 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=372b41d3cef5bfe706eb5a1a027aa87a5a5cb0e3;p=platform%2Fupstream%2Felfutils.git 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 --- diff --git a/src/ChangeLog b/src/ChangeLog index 5d0e384..a2f9603 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2020-12-31 Sergei Trofimovich + + * elflint.c (section_flags_string): Update cp pointer after + snprintf for unknown flags. + 2020-12-16 Érico Nogueira * readelf.c (qsort_r): Use qsort for improved portability. diff --git a/src/elflint.c b/src/elflint.c index b3cbaad..21cfa28 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;