Skip to content

Commit

Permalink
Check for backward-pointing directory entries to avoid endless looping
Browse files Browse the repository at this point in the history
Signed-off-by: John W. Linville <[email protected]>
  • Loading branch information
linvjw committed Apr 8, 2015
1 parent 35d7d76 commit 7c9a650
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions unzoo.c
Original file line number Diff line number Diff line change
Expand Up @@ -2405,9 +2405,11 @@ int ListArch ( ver, arc, filec, files )
/* loop over the members of the archive */
Entry.posnxt = Descript.posent;
while ( 1 ) {
unsigned long oldpos = Entry.posnxt;

/* read the directory entry for the next member */
if ( ! GotoReadArch( Entry.posnxt ) || ! EntrReadArch() ) {
if ( ! GotoReadArch( Entry.posnxt ) || ! EntrReadArch() ||
Entry.posnxt <= oldpos ) {
printf("unzoo: found bad directory entry in archive '%s'\n",arc);
return 0;
}
Expand Down Expand Up @@ -2561,9 +2563,11 @@ int ExtrArch ( bim, out, ovr, pre, arc, filec, files )
/* loop over the members of the archive */
Entry.posnxt = Descript.posent;
while ( 1 ) {
unsigned long oldpos = Entry.posnxt;

/* read the directory entry for the next member */
if ( ! GotoReadArch( Entry.posnxt ) || ! EntrReadArch() ) {
if ( ! GotoReadArch( Entry.posnxt ) || ! EntrReadArch() ||
Entry.posnxt <= oldpos ) {
printf("unzoo: found bad directory entry in archive '%s'\n",arc);
return 0;
}
Expand Down

0 comments on commit 7c9a650

Please sign in to comment.