diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2016-02-25 15:46:59 +0100 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2016-02-25 15:46:59 +0100 |
commit | 6d97beb91f413f4e90bab76fc7e05495bb0aab70 (patch) | |
tree | 08685ab053b31b77b3210e2403a7c2bcb2e20df0 | |
parent | ea9e00cb5ca271b794cca686019d17cc378e23f2 (diff) | |
download | libgit2-cmn/idx-extra-check.tar.gz |
pack: don't allow a negative offsetcmn/idx-extra-check
-rw-r--r-- | src/pack.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/pack.c b/src/pack.c index b9b22a2ef..52c652178 100644 --- a/src/pack.c +++ b/src/pack.c @@ -365,9 +365,14 @@ static unsigned char *pack_window_open( * pointless to ask for an offset into the middle of that * hash, and the pack_window_contains function above wouldn't match * don't allow an offset too close to the end of the file. + * + * Don't allow a negative offset, as that means we've wrapped + * around. */ if (offset > (p->mwf.size - 20)) return NULL; + if (offset < 0) + return NULL; return git_mwindow_open(&p->mwf, w_cursor, offset, 20, left); } |