From: Christos Zoulas Date: Wed, 2 Jan 2019 19:44:14 +0000 (+0000) Subject: Avoid OOB read (found by ASAN reported by F. Alonso) X-Git-Tag: FILE5_36~30 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2858eaf99f6cc5aae129bcbf1e24ad160240185f;p=file Avoid OOB read (found by ASAN reported by F. Alonso) --- diff --git a/src/readelf.c b/src/readelf.c index 4f4103a1..8d578966 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -27,7 +27,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: readelf.c,v 1.156 2018/10/19 00:33:04 christos Exp $") +FILE_RCSID("@(#)$File: readelf.c,v 1.157 2019/01/02 19:44:14 christos Exp $") #endif #ifdef BUILTIN_ELF @@ -752,7 +752,7 @@ do_core_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type, char sbuf[512]; struct NetBSD_elfcore_procinfo pi; memset(&pi, 0, sizeof(pi)); - memcpy(&pi, nbuf + doff, descsz); + memcpy(&pi, nbuf + doff, MIN(descsz, sizeof(pi))); if (file_printf(ms, ", from '%.31s', pid=%u, uid=%u, " "gid=%u, nlwps=%u, lwp=%u (signal %u/code %u)",