Skip to content

Commit d36d234

Browse files
committed
VFSPAK: Make Seek sanity check pak-relative.
From mvdsv 1765473df456c147c12881739ffbc452e9bb3728 fixes #880
1 parent 16102c1 commit d36d234

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/vfs_pak.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ static int VFSPAK_WriteBytes (struct vfsfile_s *vfs, const void *buffer, int byt
9696
static int VFSPAK_Seek (struct vfsfile_s *vfs, unsigned long offset, int whence)
9797
{
9898
vfspack_t *vfsp = (vfspack_t*)vfs;
99+
int rel_offset;
99100

100101
// VFS-FIXME Support other whence types
101102
switch(whence) {
@@ -113,7 +114,8 @@ static int VFSPAK_Seek (struct vfsfile_s *vfs, unsigned long offset, int whence)
113114
return -1;
114115
}
115116

116-
if (vfsp->currentpos > vfsp->length) {
117+
rel_offset = vfsp->currentpos - vfsp->startpos;
118+
if (rel_offset < 0 || rel_offset >= vfsp->length) {
117119
Com_Printf("VFSPAK_Seek: Warning seeking past the file's size\n");
118120
}
119121

0 commit comments

Comments
 (0)