Blob Blame History Raw
From 8616080aecf07436e80a27f68c336382c1d1c22d Mon Sep 17 00:00:00 2001
From: Christos Zoulas <christos@zoulas.com>
Date: Sat, 9 Jun 2018 16:00:06 +0000
Subject: [PATCH] Avoid reading past the end of buffer (Rui Reis)

Upstream-commit: a642587a9c9e2dd7feacdf513c3643ce26ad3c22
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
 src/readelf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/readelf.c b/src/readelf.c
index 3df0836..d96a538 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -966,7 +966,8 @@ core:
 
 				cname = (unsigned char *)
 				    &nbuf[doff + prpsoffsets(i)];
-				for (cp = cname; *cp && isprint(*cp); cp++)
+				for (cp = cname; cp < nbuf + size && *cp
+				    && isprint(*cp); cp++)
 					continue;
 				/*
 				 * Linux apparently appends a space at the end
-- 
2.14.4