use_pack: handle signed off_t overflow
[gitweb.git] / sha1_file.c
index bd0f8f7c8db5731ef4e808ceff536860e97f6746..4a3a032d538c7a24af301adca5dec2c41c1a664b 100644 (file)
@@ -1041,6 +1041,8 @@ unsigned char *use_pack(struct packed_git *p,
                die("packfile %s cannot be accessed", p->pack_name);
        if (offset > (p->pack_size - 20))
                die("offset beyond end of packfile (truncated pack?)");
+       if (offset < 0)
+               die("offset before end of packfile (broken .idx?)");
 
        if (!win || !in_window(win, offset)) {
                if (win)