Skip to content

Commit

Permalink
fixes wrong head.bin when it is larger than 64KB
Browse files Browse the repository at this point in the history
  • Loading branch information
mmozeiko committed Sep 23, 2017
1 parent 0a7c295 commit 271f9be
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg2zip.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ static const char* get_region(const char* id)

int main(int argc, char* argv[])
{
printf("pkg2zip v1.0\n");
printf("pkg2zip v1.1\n");
if (argc < 2 || argc > 3)
{
fatal("Usage: %s file.pkg [NoNpDrmKey]\n", argv[0]);
Expand Down Expand Up @@ -301,13 +301,15 @@ int main(int argc, char* argv[])
snprintf(path, sizeof(path), "app/%.9s/sce_sys/package/head.bin", id);

zip_begin_file(&z, path);
size_t head_offset = 0;
while (head_size != 0)
{
uint8_t buffer[1 << 16];
uint32_t size = (uint32_t)min64(head_size, sizeof(buffer));
sys_read(pkg, 0, buffer, size);
sys_read(pkg, head_offset, buffer, size);
zip_write_file(&z, buffer, size);
head_size -= size;
head_offset += size;
}
zip_end_file(&z);

Expand Down

0 comments on commit 271f9be

Please sign in to comment.