diff options
author | Ian Moffett <ian@osmora.org> | 2025-04-29 17:41:12 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-04-29 17:41:12 -0400 |
commit | cc29eb5803c4652b509900ae3024be660ded9285 (patch) | |
tree | 55256a23efa20603b586b33caedc38a0aac07054 /omar.c | |
parent | 30514aa546485c75c9123c90deb55493416440d5 (diff) |
Set lengths before setting nextptr
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'omar.c')
-rw-r--r-- | omar.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -105,6 +105,10 @@ file_push(const char *pathname, const char *name) } } + /* Set the lengths */ + hdr.len = (pathname == NULL) ? 0 : sb.st_size; + hdr.namelen = strlen(name); + /* * The next pointer being 0 indicates that we * have reached the end of the archive. If we @@ -113,11 +117,10 @@ file_push(const char *pathname, const char *name) */ if (pathname != NULL) { hdr.nextptr = sizeof(hdr) + ALIGN_UP(hdr.len, BLOCK_SIZE); + printf("NEXT POINTER: %d\n", hdr.nextptr); } else { hdr.nextptr = 0; } - hdr.len = (pathname == NULL) ? 0 : sb.st_size; - hdr.namelen = strlen(name); memcpy(hdr.magic, "OMAR", sizeof(hdr.magic)); write(outfd, &hdr, sizeof(hdr)); write(outfd, name, hdr.namelen); |