Skip to content

Commit

Permalink
VFSPAK: Make Seek sanity check pak-relative. (#897)
Browse files Browse the repository at this point in the history
From mvdsv 1765473df456c147c12881739ffbc452e9bb3728
fixes #880
  • Loading branch information
ciscon authored Feb 24, 2024
1 parent 16102c1 commit 39a0c62
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/vfs_pak.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ static int VFSPAK_WriteBytes (struct vfsfile_s *vfs, const void *buffer, int byt
static int VFSPAK_Seek (struct vfsfile_s *vfs, unsigned long offset, int whence)
{
vfspack_t *vfsp = (vfspack_t*)vfs;
int rel_offset;

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

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

Expand Down

0 comments on commit 39a0c62

Please sign in to comment.