From 85a6d79151aefd62c6e43773dd434aea16af3756 Mon Sep 17 00:00:00 2001 From: apio Date: Thu, 9 Feb 2023 16:41:26 +0100 Subject: [PATCH] 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. --- minitar.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/minitar.h b/minitar.h index 3ddf49f..a5dfdd6 100644 --- a/minitar.h +++ b/minitar.h @@ -55,7 +55,7 @@ struct minitar_entry_internal struct minitar_entry_metadata { char path[257]; - char name[128]; + char name[101]; char link[101]; mode_t mode; uid_t uid;