From: Darrick J. Wong <djwong@xxxxxxxxxx> 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 <djwong@xxxxxxxxxx> Reviewed-by: Christoph Hellwig <hch@xxxxxx> --- scrub/unicrash.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) 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)