Subject: Limit string printing to 100 chars, and add flags I forgot in the previous commit ID: TEMP-0000000-E110B2 Upstream-Author: Christos Zoulas Date: Tue Dec 16 23:29:42 2014 +0000 Origin: FILE5_21-13-g65437ce Last-Update: 2015-01-05 Limit string printing to 100 chars, and add flags I forgot in the previous commit. diff --git a/src/readelf.c b/src/readelf.c index e1cf692..fb2febb 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -906,19 +906,23 @@ donote(struct magic_set *ms, void *vbuf, size_t offset, size_t size, } if (namesz == 7 && strcmp((char *)&nbuf[noff], "NetBSD") == 0) { + if (descsz > 100) + descsz = 100; switch (xnh_type) { case NT_NETBSD_VERSION: return size; case NT_NETBSD_MARCH: if (*flags & FLAGS_DID_NETBSD_MARCH) return size; - if (file_printf(ms, ", compiled for: %.*s", (int)descsz, - (const char *)&nbuf[doff]) == -1) + *flags |= FLAGS_DID_NETBSD_MARCH; + if (file_printf(ms, ", compiled for: %.*s", + (int)descsz, (const char *)&nbuf[doff]) == -1) return size; break; case NT_NETBSD_CMODEL: if (*flags & FLAGS_DID_NETBSD_CMODEL) return size; + *flags |= FLAGS_DID_NETBSD_CMODEL; if (file_printf(ms, ", compiler model: %.*s", (int)descsz, (const char *)&nbuf[doff]) == -1) return size; @@ -926,6 +930,7 @@ donote(struct magic_set *ms, void *vbuf, size_t offset, size_t size, default: if (*flags & FLAGS_DID_NETBSD_UNKNOWN) return size; + *flags |= FLAGS_DID_NETBSD_UNKNOWN; if (file_printf(ms, ", note=%u", xnh_type) == -1) return size; break;