From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id BB46D3858D1E for ; Mon, 3 Jul 2023 11:15:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BB46D3858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688382902; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=tDfLwzXFfzV0cA8eIpkGvFUJckMWd6zCfDvDXDolWxY=; b=BZT5oqDoLW4CY+RosEd1Csmo0FpkfASj/UJerbijdcfuL4ehfAfB6IRCeYARtstaqzu4xy 4HPLTFxIb4FevLT2spXllCAuvf6rKRbTxiEuyVbU+VwdNWdOxpD9MrCDRm3p8wb/hc/o7L hnySsO3y69NioVrikIRkD3EfmBgLyxw= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-453-7rYbiuydPR-1eswGbYmpMg-1; Mon, 03 Jul 2023 07:15:01 -0400 X-MC-Unique: 7rYbiuydPR-1eswGbYmpMg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AAC8F3C0DDB9; Mon, 3 Jul 2023 11:15:00 +0000 (UTC) Received: from calimero.vinschen.de (unknown [10.39.194.53]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 896512166B31; Mon, 3 Jul 2023 11:15:00 +0000 (UTC) Received: by calimero.vinschen.de (Postfix, from userid 500) id 3DAF0A80D55; Mon, 3 Jul 2023 13:14:59 +0200 (CEST) Date: Mon, 3 Jul 2023 13:14:59 +0200 From: Corinna Vinschen To: Jon Turney Cc: "newlib@sourceware.org" Subject: Re: bug with printf positional arguments? Message-ID: Reply-To: newlib@sourceware.org Mail-Followup-To: Jon Turney , "newlib@sourceware.org" References: MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,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 List-Id: On Jun 28 14:28, Jon Turney wrote: > > The following trivial program (extracted from a glib testcase) > > > #include > > > > int main() > > { > > printf ("%1$*2$.*3$s", "abc", 5, 2); > > } > > does not produce the expected output of " ab", on 64-bit Cygwin. > > From a bit of staring at and stepping through get_args() in > libc/stdio/vfprintf.c, it looks like the problem is (something like) we > don't have the knowledge that the first positional variadic argument should > be treated as a pointer, at the point that we store it's value, so it gets > treated as an integer (the default), which is going to lead to truncation on > LP64 platforms. > > A straightforward way to fix this eludes me. Can you point out where in the code this problem occurs, so maybe we can discuss the necessary code changes in this thread? Thanks, Corinna