Skip to content

Commit 2858eaf

Browse files
committed
Avoid OOB read (found by ASAN reported by F. Alonso)
1 parent 580927e commit 2858eaf

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: src/readelf.c

+2-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.156 2018/10/19 00:33:04 christos Exp $")
30+
FILE_RCSID("@(#)$File: readelf.c,v 1.157 2019/01/02 19:44:14 christos Exp $")
3131
#endif
3232

3333
#ifdef BUILTIN_ELF
@@ -752,7 +752,7 @@ do_core_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type,
752752
char sbuf[512];
753753
struct NetBSD_elfcore_procinfo pi;
754754
memset(&pi, 0, sizeof(pi));
755-
memcpy(&pi, nbuf + doff, descsz);
755+
memcpy(&pi, nbuf + doff, MIN(descsz, sizeof(pi)));
756756

757757
if (file_printf(ms, ", from '%.31s', pid=%u, uid=%u, "
758758
"gid=%u, nlwps=%u, lwp=%u (signal %u/code %u)",

0 commit comments

Comments
 (0)