From 29402849ffe00f7ce6789efdfa114ab560e10037 Mon Sep 17 00:00:00 2001 From: Christos Zoulas Date: Mon, 22 Mar 2004 19:08:53 +0000 Subject: [PATCH] more defensive infinite loop detection --- src/readelf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/readelf.c b/src/readelf.c index e24e1b2d..43cc662a 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -39,7 +39,7 @@ #include "readelf.h" #ifndef lint -FILE_RCSID("@(#)$Id: readelf.c,v 1.37 2004/03/22 18:44:01 christos Exp $") +FILE_RCSID("@(#)$Id: readelf.c,v 1.38 2004/03/22 19:08:53 christos Exp $") #endif #ifdef ELFCORE @@ -261,6 +261,8 @@ dophn_core(struct magic_set *ms, int class, int swap, int fd, off_t off, break; offset = donote(ms, nbuf, offset, (size_t)bufsize, class, swap, 4); + if (offset == 0) + break; } } @@ -660,6 +662,8 @@ dophn_exec(struct magic_set *ms, int class, int swap, int fd, off_t off, break; offset = donote(ms, nbuf, offset, (size_t)bufsize, class, swap, align); + if (offset == 0) + break; } if (lseek(fd, savedoffset + offset, SEEK_SET) == (off_t)-1) { -- 2.40.0