Compare commits

...

2 Commits

Author SHA1 Message Date
85a6d79151
fix: Shorten the 'name' field in minitar_entry_metadata
Sure, 256 characters might fit in 'path', but because of the way
paths are stored in a tar archive, basenames cannot exceed 100
characters. So, adding space for a null-terminator, this reduces
our 'name' field from 128 bytes to 101.

This change is backwards-compatible since any reasonable application
should not depend on the name field being 128 bytes (this was never
mentioned in any documentation, API.md describes it as 'char[]' without
a fixed length). sizeof(metadata.name) should always be used instead.
2023-02-09 16:41:26 +01:00
320231c70b
fix: Make the 'list' example show more metadata 2023-02-09 16:40:57 +01:00
2 changed files with 3 additions and 3 deletions

View File

@ -24,7 +24,7 @@ int main(int argc, char** argv)
} }
struct minitar_entry entry; struct minitar_entry entry;
do { do {
if (minitar_read_entry(&mp, &entry) == 0) { printf("%s\n", entry.metadata.path); } if (minitar_read_entry(&mp, &entry) == 0) { printf("%s (%s, %zu bytes, mode %o)\n", entry.metadata.path, entry.metadata.name, entry.metadata.size, entry.metadata.mode); }
else else
break; break;
} while (1); } while (1);

View File

@ -55,7 +55,7 @@ struct minitar_entry_internal
struct minitar_entry_metadata struct minitar_entry_metadata
{ {
char path[257]; char path[257];
char name[128]; char name[101];
char link[101]; char link[101];
mode_t mode; mode_t mode;
uid_t uid; uid_t uid;