Skip to content

Commit a642587

Browse files
committed
Avoid reading past the end of buffer (Rui Reis)
1 parent 8ac1992 commit a642587

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Diff for: src/readelf.c

+3-2
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.142 2018/05/24 18:08:01 christos Exp $")
30+
FILE_RCSID("@(#)$File: readelf.c,v 1.143 2018/06/09 16:00:06 christos Exp $")
3131
#endif
3232

3333
#ifdef BUILTIN_ELF
@@ -842,7 +842,8 @@ do_core_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type,
842842

843843
cname = (unsigned char *)
844844
&nbuf[doff + prpsoffsets(i)];
845-
for (cp = cname; *cp && isprint(*cp); cp++)
845+
for (cp = cname; cp < nbuf + size && *cp
846+
&& isprint(*cp); cp++)
846847
continue;
847848
/*
848849
* Linux apparently appends a space at the end

0 commit comments

Comments
 (0)