Skip to content

Commit 65437ce

Browse files
committed
Limit string printing to 100 chars, and add flags I forgot in the previous
commit.
1 parent ce90e05 commit 65437ce

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Diff for: src/readelf.c

+8-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include "file.h"
2828

2929
#ifndef lint
30-
FILE_RCSID("@(#)$File: readelf.c,v 1.115 2014/12/16 20:53:05 christos Exp $")
30+
FILE_RCSID("@(#)$File: readelf.c,v 1.116 2014/12/16 23:18:40 christos Exp $")
3131
#endif
3232

3333
#ifdef BUILTIN_ELF
@@ -900,26 +900,31 @@ donote(struct magic_set *ms, void *vbuf, size_t offset, size_t size,
900900
}
901901

902902
if (namesz == 7 && strcmp((char *)&nbuf[noff], "NetBSD") == 0) {
903+
if (descsz > 100)
904+
descsz = 100;
903905
switch (xnh_type) {
904906
case NT_NETBSD_VERSION:
905907
return size;
906908
case NT_NETBSD_MARCH:
907909
if (*flags & FLAGS_DID_NETBSD_MARCH)
908910
return size;
909-
if (file_printf(ms, ", compiled for: %.*s", (int)descsz,
910-
(const char *)&nbuf[doff]) == -1)
911+
*flags |= FLAGS_DID_NETBSD_MARCH;
912+
if (file_printf(ms, ", compiled for: %.*s",
913+
(int)descsz, (const char *)&nbuf[doff]) == -1)
911914
return size;
912915
break;
913916
case NT_NETBSD_CMODEL:
914917
if (*flags & FLAGS_DID_NETBSD_CMODEL)
915918
return size;
919+
*flags |= FLAGS_DID_NETBSD_CMODEL;
916920
if (file_printf(ms, ", compiler model: %.*s",
917921
(int)descsz, (const char *)&nbuf[doff]) == -1)
918922
return size;
919923
break;
920924
default:
921925
if (*flags & FLAGS_DID_NETBSD_UNKNOWN)
922926
return size;
927+
*flags |= FLAGS_DID_NETBSD_UNKNOWN;
923928
if (file_printf(ms, ", note=%u", xnh_type) == -1)
924929
return size;
925930
break;

0 commit comments

Comments
 (0)