Skip to content

Commit

Permalink
Merge pull request #15 from hclander/master
Browse files Browse the repository at this point in the history
Modifications to deal with files with size > 4 Gb
  • Loading branch information
kakaroto authored Dec 7, 2016
2 parents 3f31941 + 5aa5968 commit e466feb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions archive.c
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ archive_find_file (ArchiveIndex *archive_index, const char *path,
}
current = current->next;
if (*position + file->fsstat.file_size >= (u64) stat_buf.st_size) {
*position = 0x50;
*position = 0x50 + (*position + file->fsstat.file_size) % stat_buf.st_size;
(*index)++;
snprintf (data_path, sizeof(data_path), "%s/%s_%02d.dat", path, archive_index->prefix, *index);
if (stat (data_path, &stat_buf) != 0)
Expand All @@ -551,7 +551,7 @@ archive_extract (ArchiveIndex *archive_index, const char *path, u32 index,
die ("Couldn't open output file : %s\n", output);

while (size > 0) {
int read;
u64 read; // fix a potential overflow

snprintf (filename, sizeof(filename), "%s/%s_%02d.dat", path, archive_index->prefix, index);
if (!archive_open (filename, &in, &dat_header))
Expand Down
4 changes: 2 additions & 2 deletions paged_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,12 @@ paged_file_splice (PagedFile *f, PagedFile *from, u64 len)
{
char buffer[1024];
u64 total = 0;
int size;
u64 size; // fixed to prevent overflow in size = len - total below
int read;

while (len == (u64)-1 || total < len) {
size = len - total;
if (len == (u64)-1 || (u32) size > sizeof(buffer))
if (len == (u64)-1 || size > sizeof(buffer))
size = sizeof(buffer);

read = paged_file_read (from, buffer, size);
Expand Down

0 comments on commit e466feb

Please sign in to comment.