From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1944) id 4F9F13852C59; Wed, 23 Nov 2022 14:39:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4F9F13852C59 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1669214381; bh=ADSyoZc8ZCtZqsAQWxhJuzjQRy9CY/zK9Q5TCrSp1wU=; h=From:To:Subject:Date:From; b=LM8hoyc+RQEoigvCh0yUfzMacX7DgShCsrNfQN12eQpQyZDD1zMcYeOELrHM8llXj PDcucLT3P0WmryirYGFmLD7evTc8AzngpNm6VNe+i0Uv2mf69yRHsk6j/Ryz5T6Gxd v2drt9bd5smzjxvEhha+2G8RFJBZmOHwqOVszV88= 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: 4054cc2093279d68092104b3f8c059b81cceb776 X-Git-Newrev: 44d649d3c4051391782d8c893004dd7efec2ce70 Message-Id: <20221123143941.4F9F13852C59@sourceware.org> Date: Wed, 23 Nov 2022 14:39:41 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=44d649d3c4051391782d8c893004dd7efec2ce70 commit 44d649d3c4051391782d8c893004dd7efec2ce70 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,