From patchwork Mon Mar 29 18:06:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alyssa Ross X-Patchwork-Id: 42797 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 145823861002; Mon, 29 Mar 2021 18:07:05 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) by sourceware.org (Postfix) with ESMTPS id B1F993851C3E for ; Mon, 29 Mar 2021 18:07:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B1F993851C3E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=alyssa.is Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=qyliss@eve.qyliss.net Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 2978B168C; Mon, 29 Mar 2021 14:07:01 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Mon, 29 Mar 2021 14:07:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alyssa.is; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=1HHSw1G0PJlg9 /oNR72sucg344Te6nXbtjyoaJqmFLc=; b=rIya+bOr0I3eAWtV6qKiyeAHO7o49 p4Kj77ruGP/RnKJ11c0J/esIS6YHiNdi1dlTukHeblkwIw8Ksa2XLpJf++I+8PSL IPUNgPjy1JxV6m9/5Zv/xmEJ2DZp99+g8W0pXIhwVn6bAzWWfP9CndJlMWFY+jxh z1lNVeHuMUsJq6vCUDhCIvmXHyFMIblrfoR4VwiOuhOD1MvxjV+Z5suPnXoRNNi5 dEumRyGFYVua/7l3q/SnyASoKK2jktqzJ6WC4P/1mnG7RzMv93/FPg3qThbtEiKA 5GAgLZo53quid2eo/LORb0T7D9nWZvBxE5rK10PFIzJ7enZ6izhWgd+0w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=1HHSw1G0PJlg9/oNR72sucg344Te6nXbtjyoaJqmFLc=; b=j0mvNgg7 FHyrFqbR+kAZTw9sM0i/Bq0p0VJsCv5/h5iiueXBRHVsE3ggWPd/5tQ5SY6tTUSk BJeVRieKt1MNZWu1oxtVtCm8Dh+VlTmqd58P7wE/EAJwCtdLRDNzzE52mgI3WZ7W ATtRGCd+/FdizYkVzrC368nB/A/jbg9xiFD5+oybowgPqV0K5/gmmZWcyKBvPl+U 3Hr+2FxRiXLVf7gywicS5+h1p+enqnUXbcIqhK/+4FwtKki2nHbVXpHGwLYNX6pF gkW4TKy40GMlNA+Zt5FVxUgySPXEDFmRC/5cyD8e7VNgu0Q91b/Y+LeYW6XDe2IS cF37dojR3w3Fkg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudehkedguddvvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomheptehlhihs shgrucftohhsshcuoehhihesrghlhihsshgrrdhisheqnecuggftrfgrthhtvghrnhepgf efudekvdelieelledufeevheeglefggedvudejvddtffeuueevffehleejkedvnecukfhp peejledrvdefuddrvdegfedrvddtudenucevlhhushhtvghrufhiiigvpedtnecurfgrrh grmhepmhgrihhlfhhrohhmpehqhihlihhsshesvghvvgdrqhihlhhishhsrdhnvght X-ME-Proxy: Received: from eve.qyliss.net (p4fe7f3c9.dip0.t-ipconnect.de [79.231.243.201]) by mail.messagingengine.com (Postfix) with ESMTPA id C2EA324005C; Mon, 29 Mar 2021 14:06:59 -0400 (EDT) Received: by eve.qyliss.net (Postfix, from userid 1000) id 4303610CC; Mon, 29 Mar 2021 18:06:58 +0000 (UTC) From: Alyssa Ross To: libc-alpha@sourceware.org Subject: [PATCH 2/2] stdio: add test for scanf matches longer than INT_MAX (bug 27650) Date: Mon, 29 Mar 2021 18:06:40 +0000 Message-Id: <20210329180640.18722-1-hi@alyssa.is> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210325140102.31043-1-hi@alyssa.is> References: <20210325140102.31043-1-hi@alyssa.is> MIME-Version: 1.0 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alyssa Ross , Florian Weimer Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" This doesn't test the wchar_t variants. Won't run on s390 due to using more than INT_MAX bytes of address space. --- Applying this will need to wait until I have my copyright paperwork sorted. stdio-common/Makefile | 3 ++- stdio-common/tst-sscanf-bz27650.c | 42 +++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 stdio-common/tst-sscanf-bz27650.c diff --git a/stdio-common/Makefile b/stdio-common/Makefile index b2458ba4a6..281a154f5b 100644 --- a/stdio-common/Makefile +++ b/stdio-common/Makefile @@ -70,7 +70,8 @@ tests := tstscanf test_rdwr test-popen tstgetln test-fseek \ tst-vfprintf-width-prec-alloc \ tst-printf-fp-free \ tst-printf-fp-leak \ - test-strerr + test-strerr \ + tst-sscanf-bz27650 test-srcs = tst-unbputc tst-printf tst-printfsz-islongdouble diff --git a/stdio-common/tst-sscanf-bz27650.c b/stdio-common/tst-sscanf-bz27650.c new file mode 100644 index 0000000000..4636d26323 --- /dev/null +++ b/stdio-common/tst-sscanf-bz27650.c @@ -0,0 +1,42 @@ +#include +#include +#include +#include +#include +#include + +#include +#include + +/* Test that vfscanf can handle matches longer than INT_MAX bytes. */ +static int +do_test (void) +{ + char next_char; + struct support_blob_repeat blob = + support_blob_repeat_allocate ("a", 1, INT_MAX + 3U); + char *s = blob.start; + + if (s == NULL) + FAIL_UNSUPPORTED ("repeated blob allocation failed: %m"); + + s[INT_MAX + 1U] = 'b'; + s[INT_MAX + 2U] = '\0'; + + errno = 0; + switch (sscanf (s, "%*[^b]%c", &next_char)) + { + case EOF: + if (errno) + FAIL_EXIT1 ("sscanf: %m"); + FAIL_EXIT1 ("EOF reached and no 'b' found"); + case 0: + FAIL_EXIT1 ("pattern didn't match"); + } + + TEST_COMPARE (next_char, 'b'); + + return 0; +} + +#include