dictionary: Properly size string buffer in make_hinted_name().
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 4 Jun 2023 14:40:47 +0000 (07:40 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Sun, 4 Jun 2023 14:42:18 +0000 (07:42 -0700)
This causes a test failure on 32-bit platforms, where
INT_BUFSIZE_BOUND(unsigned long) is smaller than F26ADIC_STRLEN_MAX + 1.

Fixes: 2ba8dc2955f8 ("spreadsheet-reader: Merge duplicate code with libpspp/str.h.")
Thanks to Friedrich Beckmann for reporting the problem.

src/data/dictionary.c

index 653ed941f1becfb7d94f1dd99e260ba8b4245539..8b5f381296204a1e19c4fc103c462913427a7af2 100644 (file)
@@ -1167,7 +1167,7 @@ make_hinted_name (const struct dictionary *dict, const char *hint)
 
       for (i = 0; i < ULONG_MAX; i++)
         {
-          char suffix[INT_BUFSIZE_BOUND (i) + 1];
+          char suffix[1 + F26ADIC_STRLEN_MAX + 1];
 
           suffix[0] = '_';
           str_format_26adic (i + 1, true, &suffix[1], sizeof suffix - 1);