From patchwork Thu Jun 15 12:54:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Simmons-Talbott X-Patchwork-Id: 1795417 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=rKMOIjZy; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qhj1R1tsSz20WR for ; Thu, 15 Jun 2023 22:54:48 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B8AF73857438 for ; Thu, 15 Jun 2023 12:54:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B8AF73857438 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1686833685; bh=FX3mkMSf7xZbZOCDJJ5QGtkx5TFVcNx1YKeqfAXsELo=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=rKMOIjZyr4iFgarPhRkuJbGelBnClnx8ZCTP2QMPsWY05Rq/BHeJSIrFB9KTSR55R /R4phPoowv69QJVO/cORh91iO8JEdaZEMXf9/a866Sk7jgsCGcWpR1l6Ct3zx88hJW q40QqksxqbhpMhq6XtYpkk3P1YQKlSWG/1ForcOw= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 750B73857732 for ; Thu, 15 Jun 2023 12:54:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 750B73857732 Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-644-9JZh8PORPVSEjRk9UcSAdg-1; Thu, 15 Jun 2023 08:54:29 -0400 X-MC-Unique: 9JZh8PORPVSEjRk9UcSAdg-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-62ff7c6583cso1951416d6.1 for ; Thu, 15 Jun 2023 05:54:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686833667; x=1689425667; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FX3mkMSf7xZbZOCDJJ5QGtkx5TFVcNx1YKeqfAXsELo=; b=O6kkVIIibcmHbSbtoB9GYi2ExPSxKXoepKu1UbRyTA+kN71lKZmE+Rkb3T6XKDVXrb 5TjK810kZQCt9q4/2RDlQ8Goy1cNCv6X/c6tNI0pFMr92NOcw33f83e234vUgkrAvHiT dmbAOxfxqLneBP3zASGkFmpqn3HHZbfNOoM2nig4iNLv/BGyjgtXKqRe4t11dngUa8WG F8i9FP2Dq0GFs2SGrg+ozEGmXFFwDTDzexqWAJPIGo82q81DhBUCufhTYPFlxSwNx3q6 bFAN344b/ZaxGWj+NcBGcRKTPIXugAphJrDTsEG2i77BRlVdgTki4pAndZhDIqvYzOjD Q8+Q== X-Gm-Message-State: AC+VfDw9n2bloPPxDXpqBwxE+3PLkAwGmkcZ1QBmp+HcGi2r6BraeI4i bIuZtouQqi8J/kMb/MtQRMNscTBsH7vLkQ0CQRaKYzdUc4Te+BV+pgsC+Z5oH1smrq27NHtC85j sTF2nUVAaHq5hevEE2fBfzcmc8KmcgeNCzEhWzRov/+2rLP4HvOHtYZXz3oUotfM6L1QDd2Jt9D f5/eFh X-Received: by 2002:a05:6214:29e3:b0:62b:4184:681d with SMTP id jv3-20020a05621429e300b0062b4184681dmr21396633qvb.35.1686833667123; Thu, 15 Jun 2023 05:54:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4qxr0VLD6THGkLPwtSBWm9SY97Ex0KXEPVzHsPNLHkpoLeyeCHs4H49pFNGYKLWyZgJe/Icw== X-Received: by 2002:a05:6214:29e3:b0:62b:4184:681d with SMTP id jv3-20020a05621429e300b0062b4184681dmr21396615qvb.35.1686833666784; Thu, 15 Jun 2023 05:54:26 -0700 (PDT) Received: from oak.redhat.com (c-71-206-142-238.hsd1.va.comcast.net. [71.206.142.238]) by smtp.gmail.com with ESMTPSA id m1-20020a0ce6e1000000b00623839cba8csm5809141qvn.44.2023.06.15.05.54.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jun 2023 05:54:26 -0700 (PDT) To: libc-alpha@sourceware.org Cc: Joe Simmons-Talbott Subject: [PATCH] fileops: Don't process , ccs= as individual mode flags (BZ#18906) Date: Thu, 15 Jun 2023 08:54:24 -0400 Message-Id: <20230615125424.3600855-1-josimmon@redhat.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: , X-Patchwork-Original-From: Joe Simmons-Talbott via Libc-alpha From: Joe Simmons-Talbott Reply-To: Joe Simmons-Talbott Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" In processing the first 7 individual characters of the mode for fopen if ,ccs= is used those characters will be processed as well. Stop processing individual mode flags once a comma is encountered. This has the effect of requiring ,ccs= to be the last mode flag in the mode string. Add a testcase to check that the ,ccs= mode flag is not processed as individual mode flags. --- libio/fileops.c | 1 + libio/tst-fopenloc.c | 30 +++++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/libio/fileops.c b/libio/fileops.c index 58c9e985e4..1c1113e339 100644 --- a/libio/fileops.c +++ b/libio/fileops.c @@ -247,6 +247,7 @@ _IO_new_file_fopen (FILE *fp, const char *filename, const char *mode, switch (*++mode) { case '\0': + case ',': break; case '+': omode = O_RDWR; diff --git a/libio/tst-fopenloc.c b/libio/tst-fopenloc.c index 089c61bf41..540853d662 100644 --- a/libio/tst-fopenloc.c +++ b/libio/tst-fopenloc.c @@ -17,6 +17,7 @@ . */ #include +#include #include #include #include @@ -24,6 +25,7 @@ #include #include #include +#include #include #include @@ -55,6 +57,29 @@ do_bz17916 (void) return 0; } +static int +do_bz18906 (void) +{ + /* BZ #18906 -- check processing of ,ccs= as flags case. */ + + const char *ccs = "r,ccs=+ISO-8859-1"; + size_t retval; + + FILE *fp = fopen (inputfile, ccs); + int flags; + + TEST_VERIFY(fp != NULL); + + if (fp != NULL) + { + flags = fcntl(fileno(fp), F_GETFL); + retval = (flags & O_RDWR) | (flags & O_WRONLY); + TEST_COMPARE(retval, false); + } + + return EXIT_SUCCESS; +} + static int do_test (void) { @@ -78,7 +103,10 @@ do_test (void) xfclose (fp); - return do_bz17916 (); + TEST_COMPARE(do_bz17916 (), 0); + TEST_COMPARE(do_bz18906 (), 0); + + return EXIT_SUCCESS; } #include