From: Darrick J. Wong Date: Wed, 3 Jul 2024 21:21:10 +0000 (-0700) Subject: xfs_scrub: reduce size of struct name_entry X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=26374e4340e765d2b5169968178b8ed42407aafe;p=users%2Fhch%2Fxfsprogs.git xfs_scrub: reduce size of struct name_entry libicu doesn't support processing strings longer than 2GB in length, and we never feed the unicrash code a name longer than about 300 bytes. Rearrange the structure to reduce the head structure size from 56 bytes to 44 bytes. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- diff --git a/scrub/unicrash.c b/scrub/unicrash.c index 63694c39a..74c0fe1f9 100644 --- a/scrub/unicrash.c +++ b/scrub/unicrash.c @@ -57,18 +57,20 @@ * In other words, skel = remove_invisible(nfd(remap_confusables(nfd(name)))). */ -typedef unsigned int __bitwise badname_t; +typedef uint16_t __bitwise badname_t; struct name_entry { struct name_entry *next; /* NFKC normalized name */ UChar *normstr; - size_t normstrlen; /* Unicode skeletonized name */ UChar *skelstr; - size_t skelstrlen; + + /* Lengths for normstr and skelstr */ + int32_t normstrlen; + int32_t skelstrlen; xfs_ino_t ino; @@ -76,7 +78,7 @@ struct name_entry { badname_t badflags; /* Raw dirent name */ - size_t namelen; + uint16_t namelen; char name[0]; }; #define NAME_ENTRY_SZ(nl) (sizeof(struct name_entry) + 1 + \ @@ -345,6 +347,12 @@ name_entry_create( struct name_entry *new_entry; size_t namelen = strlen(name); + /* should never happen */ + if (namelen > UINT16_MAX) { + ASSERT(namelen <= UINT16_MAX); + return false; + } + /* Create new entry */ new_entry = calloc(NAME_ENTRY_SZ(namelen), 1); if (!new_entry)