]> granicus.if.org Git - file/commitdiff
more defensive infinite loop detection
authorChristos Zoulas <christos@zoulas.com>
Mon, 22 Mar 2004 19:08:53 +0000 (19:08 +0000)
committerChristos Zoulas <christos@zoulas.com>
Mon, 22 Mar 2004 19:08:53 +0000 (19:08 +0000)
src/readelf.c

index e24e1b2d0df1fb2c5afef9cb065a2565db00a536..43cc662a202a202c0fc0856124be65e6e15f3297 100644 (file)
@@ -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) {