From patchwork Mon Aug 31 08:01:59 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramin Moussavi X-Patchwork-Id: 2295028 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=U7B74fGw; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=uclibc-ng.org (client-ip=89.238.66.15; helo=helium.openadk.org; envelope-from=devel-bounces@uclibc-ng.org; receiver=patchwork.ozlabs.org) Received: from helium.openadk.org (helium.openadk.org [89.238.66.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hYMNC406Cz1xyQ for ; Mon, 31 Aug 2026 18:19:23 +1000 (AEST) Authentication-Results: helium.openadk.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=U7B74fGw; dkim-atps=neutral Received: from helium.openadk.org (localhost [127.0.0.1]) by helium.openadk.org (Postfix) with ESMTP id 47F3631E113D; Mon, 31 Aug 2026 10:19:06 +0200 (CEST) Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by helium.openadk.org (Postfix) with ESMTPS id 9F67431E0D86 for ; Mon, 31 Aug 2026 10:02:02 +0200 (CEST) Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-495590dde14so30105965e9.0 for ; Mon, 31 Aug 2026 01:02:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788163321; x=1788768121; darn=uclibc-ng.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=jQ7AI/RMHUKEhu0YrZiJy3/ACw17XGB1VSTSe9hihj0=; b=U7B74fGwB2OLoy2CwN539KY+YJdzaW8wn1wTTnpVO6TMgWH+7W4NxwIpc5sG/wWZ94 Z6taIdaR//pOHULFet4aB2TBRqS6TAqTmesSoN/lkRhOitKm/xxQzS7KpCjE5M84wVkw d6Zz5OTvZTQK2+lUXfhSG7ddERchnwlGjkKBexmQT/9zgzIjDmCQKSqAYIdsvDZp02b4 N+/KGQ4D5+E7GZx11obVGA1L10ilwSuUaCsa2nvrcuznOI2rk/EPz2sR9mkZpr8Q5se2 2GoigwgOwbJMZCmnCJmB8+S+SMp4pjRV6+F3KIC5Y06TrrGe4KCPm4xas0Uy89zVGrRU mC3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788163321; x=1788768121; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=jQ7AI/RMHUKEhu0YrZiJy3/ACw17XGB1VSTSe9hihj0=; b=ZnQqe1LgDNhzhOe7/xzD8ubB2Bzy+crMckT57bm3dybhnFn7HEA/+fJW+BUS6MyMKF gfpOMl3oalRqnr/byOt6Jg+pB0UqHfNDHIhPeAkBpnaiVWZhVCzvh+5sEKd3P6b+5vnz av8zG8x+U5DlhwMbwK5m6cv3yg3it3UuqvvJrRpNQQFnakudeo2JbGhgMlyOZuM+l6e6 xT/noUP7Eic3N/t1ejojx1/9N4WRhua2XR/Inukl3MAhL13Puvewle1darK0h/nQy040 yZKbT9BcxgOHZzkiu1rMlvVUHtyU3hSxsSe90LFsgUP1tJAXlhmfY2gxUPorBYso5RVM K6tw== X-Gm-Message-State: AFuF++nDOeD+XJTyS88Tw1vtv5guLBgIOwrngqU3z56N/yM5de0aurGc ZCKOyE2ut59CaY3Z1IFsi1Wmhs+sLehXl/pvOfApexoNIUfC378VqyiHCepclA== X-Gm-Gg: AR+sD104zK9yNInpNvCFkrDQN+o/FRgobtqNi4fyIi/1C+0cOqzZKEFAfN+VyGG95x/ 9aVfsWpiCv05A0BQWdAlYM94Pk3F1bob3HkpJER8PPVtHW++DE7jRmEm7wUHyz57pkAVrwW6lMr NgLoJQIDf0f7pKv+TW9ire7bsgnHqQBPHMBNud3+E3CQ7ouDzIU7Fklufg19yi/khHAbYUiT59r RrEjwzU4NfznUiUJ85ISd1pHDE+jO0Yvuwc1qBqg2UShONyijPv3zjYlktJx59OT1CVbDHgI/Tj 7jyfnbNFbZABhFksUJx1HuWr8dH1TR7jTGwMhMoSZPgHs3osr2nhGWUwh64nBIGSooo5xwWnxku 2NtG0Rq5TVi9/uoz17dLpdxx4168+GcELlL3acCFd4GYRqQV1YmRK72zSBA7SkTBqBLSuzoIBnR z9GwxaVNiQGLX2mQQDIgrhICxS8DizTWj1jlX6i6hEHAwabA1UQk61yBrhAppZl4mo3Z7hEv/kB rxpv74zabeG5fSRyw== X-Received: by 2002:a05:600c:4e8b:b0:499:dbae:43d3 with SMTP id 5b1f17b1804b1-49cd946101fmr23405305e9.9.1788163321173; Mon, 31 Aug 2026 01:02:01 -0700 (PDT) Received: from ramin-pc ([178.19.210.170]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49b961820ffsm122436685e9.3.2026.08.31.01.02.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Aug 2026 01:02:00 -0700 (PDT) From: Ramin Moussavi To: devel@uclibc-ng.org Date: Mon, 31 Aug 2026 10:01:59 +0200 Message-ID: <20260831080159.3552089-2-lordrasmus@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260831080159.3552089-1-lordrasmus@gmail.com> References: <20260831080159.3552089-1-lordrasmus@gmail.com> MIME-Version: 1.0 Message-ID-Hash: 3WIUB3LOGGWMVNMU4QA77Z3573B6WZRG X-Message-ID-Hash: 3WIUB3LOGGWMVNMU4QA77Z3573B6WZRG X-MailFrom: lordrasmus@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list Subject: [uclibc-ng-devel] [PATCH 2/2] stdio: make an open_memstream byte-oriented, as POSIX requires List-Id: uClibc-ng Development Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: ramin POSIX: "The stream associated with a call to open_memstream() shall be byte-oriented." fopencookie() leaves a new stream unoriented, so fwide(f, 0) answered 0 instead of a negative value and the first wide operation could have turned the stream wide. __STDIO_STREAM_SET_NARROW() is a no-op when UCLIBC_HAS_WCHAR is off, where there is no orientation to set, so no guard is needed. fmemopen() is deliberately left alone: its POSIX page says nothing about orientation. Found by tst-fmemopen in uclibc-ng-test, which now walks the whole open_memstream description. Signed-off-by: Ramin Moussavi --- libc/stdio/open_memstream.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libc/stdio/open_memstream.c b/libc/stdio/open_memstream.c index 7e8e2134f..716d8666e 100644 --- a/libc/stdio/open_memstream.c +++ b/libc/stdio/open_memstream.c @@ -188,6 +188,10 @@ FILE *open_memstream(char **bufloc, size_t *sizeloc) * nothing currently in the FILE's write buffer. */ if (fp != NULL) { + /* POSIX: "The stream associated with a call to + * open_memstream() shall be byte-oriented." fopencookie() + * leaves it unoriented. */ + __STDIO_STREAM_SET_NARROW(fp); __STDIO_STREAM_VALIDATE(fp); return fp; }