This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch main in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=6c26447caa08c0b8400a47000cd49270b156ab23 commit 6c26447caa08c0b8400a47000cd49270b156ab23 (HEAD -> main) Author: Guillem Jover <[email protected]> AuthorDate: Fri Dec 23 04:17:18 2022 +0100 libdpkg: Mark tar on-disk members with attribute nonstring These tar fields are not necessarily NUL-terminated, and marking them as such helps the compiler analyze what's going on with such the memory management. --- lib/dpkg/macros.h | 6 ++++++ lib/dpkg/tarfn.c | 28 ++++++++++++++-------------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/lib/dpkg/macros.h b/lib/dpkg/macros.h index 5111cd3bc..72d2143e6 100644 --- a/lib/dpkg/macros.h +++ b/lib/dpkg/macros.h @@ -103,6 +103,12 @@ #define DPKG_ATTR_SENTINEL #endif +#if DPKG_GCC_VERSION >= 0x0801 || __has_attribute(__nonstring__) +#define DPKG_ATTR_NONSTRING __attribute__((__nonstring__)) +#else +#define DPKG_ATTR_NONSTRING +#endif + #if defined(__cplusplus) && __cplusplus >= 201103L #define DPKG_ATTR_THROW(exception) #define DPKG_ATTR_NOEXCEPT noexcept diff --git a/lib/dpkg/tarfn.c b/lib/dpkg/tarfn.c index f5ef155a6..142931d98 100644 --- a/lib/dpkg/tarfn.c +++ b/lib/dpkg/tarfn.c @@ -62,25 +62,25 @@ (type)tar_atosl(str, sizeof(str), TAR_TYPE_MIN(type), TAR_TYPE_MAX(type)) struct tar_header { - char name[100]; - char mode[8]; - char uid[8]; - char gid[8]; - char size[12]; - char mtime[12]; - char checksum[8]; + char name[100] DPKG_ATTR_NONSTRING; + char mode[8] DPKG_ATTR_NONSTRING; + char uid[8] DPKG_ATTR_NONSTRING; + char gid[8] DPKG_ATTR_NONSTRING; + char size[12] DPKG_ATTR_NONSTRING; + char mtime[12] DPKG_ATTR_NONSTRING; + char checksum[8] DPKG_ATTR_NONSTRING; char linkflag; - char linkname[100]; + char linkname[100] DPKG_ATTR_NONSTRING; /* Only valid on ustar and gnu. */ - char magic[8]; - char user[32]; - char group[32]; - char devmajor[8]; - char devminor[8]; + char magic[8] DPKG_ATTR_NONSTRING; + char user[32] DPKG_ATTR_NONSTRING; + char group[32] DPKG_ATTR_NONSTRING; + char devmajor[8] DPKG_ATTR_NONSTRING; + char devminor[8] DPKG_ATTR_NONSTRING; /* Only valid on ustar. */ - char prefix[155]; + char prefix[155] DPKG_ATTR_NONSTRING; }; static inline uintmax_t -- Dpkg.Org's dpkg

