Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6d97beb

Browse files
committed
pack: don't allow a negative offset
1 parent ea9e00c commit 6d97beb

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/pack.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,9 +365,14 @@ static unsigned char *pack_window_open(
365365
* pointless to ask for an offset into the middle of that
366366
* hash, and the pack_window_contains function above wouldn't match
367367
* don't allow an offset too close to the end of the file.
368+
*
369+
* Don't allow a negative offset, as that means we've wrapped
370+
* around.
368371
*/
369372
if (offset > (p->mwf.size - 20))
370373
return NULL;
374+
if (offset < 0)
375+
return NULL;
371376

372377
return git_mwindow_open(&p->mwf, w_cursor, offset, 20, left);
373378
}

0 commit comments

Comments
 (0)