From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1944) id 39DB63851534; Thu, 27 Oct 2022 13:49:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 39DB63851534 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666878583; bh=UGUkprznWuGS34NIuZgAgDXMzWJPmEQvlVQzTodlghg=; h=From:To:Subject:Date:From; b=E063qaE3phs3qhEdsnkMVrOmftb0WFBTsQfqitNi3ZBEfcAqM6IGXu6Jr6aQvzQci C/HqwciXIEFFQ22Ys0aPlwtOg8Ewj4bEV9+eKXsITBFZJgWkhzhkXTd1ykIJH/FgAd JxgkfCUwgdf2GCKGA1wVAVPEtmE6t1/q18+4opSc= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Szabolcs Nagy To: glibc-cvs@sourceware.org Subject: [glibc/arm/morello/main] Fix off-by-one OOB write in iconv/tst-iconv-mt X-Act-Checkin: glibc X-Git-Author: Szabolcs Nagy X-Git-Refname: refs/heads/arm/morello/main X-Git-Oldrev: adeba2c19ae48a833cbf09267666e44c2375f2b4 X-Git-Newrev: dd9ec10913da97c0a5b64f5fd9ac195a61ef13b1 Message-Id: <20221027134943.39DB63851534@sourceware.org> Date: Thu, 27 Oct 2022 13:49:40 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=dd9ec10913da97c0a5b64f5fd9ac195a61ef13b1 commit dd9ec10913da97c0a5b64f5fd9ac195a61ef13b1 Author: Szabolcs Nagy Date: Mon Sep 26 15:38:19 2022 +0100 Fix off-by-one OOB write in iconv/tst-iconv-mt 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. Diff: --- iconv/tst-iconv-mt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iconv/tst-iconv-mt.c b/iconv/tst-iconv-mt.c index daaebd273b..0320885c06 100644 --- a/iconv/tst-iconv-mt.c +++ b/iconv/tst-iconv-mt.c @@ -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,