]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix off-by-one error in iconv/tst-iconv-mt
authorSzabolcs Nagy <szabolcs.nagy@arm.com>
Mon, 26 Sep 2022 14:38:19 +0000 (15:38 +0100)
committerSzabolcs Nagy <szabolcs.nagy@arm.com>
Wed, 12 Oct 2022 11:54:07 +0000 (12:54 +0100)
The iconv buffer sizes must not include the \0 string terminator.
(When \0 cannot be part of a valid character encoding glibc iconv
would copy it to the output as expected, but then later the explicit
output termination with *outbufpos = '\0' is out of bounds.)

iconv/tst-iconv-mt.c

index daaebd273bbc38dc50e2d136558ab1129cac4f89..0320885c0695cc657f409ecf8c65d8955b825a97 100644 (file)
@@ -58,11 +58,11 @@ worker (void * arg)
 
   char ascii[] = CONV_INPUT;
   char *inbufpos = ascii;
-  size_t inbytesleft = sizeof (CONV_INPUT);
+  size_t inbytesleft = sizeof (CONV_INPUT) - 1;
 
   char *utf8 = xcalloc (sizeof (CONV_INPUT), 1);
   char *outbufpos = utf8;
-  size_t outbytesleft = sizeof (CONV_INPUT);
+  size_t outbytesleft = sizeof (CONV_INPUT) - 1;
 
   if (tidx < TCOUNT/2)
     /* The first half of the worker thread pool synchronize together here,