From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HTML_MESSAGE,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 9103 invoked from network); 11 Aug 2022 11:22:15 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 11 Aug 2022 11:22:15 -0000 Received: (qmail 30634 invoked by uid 550); 11 Aug 2022 11:22:11 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 9783 invoked from network); 11 Aug 2022 11:14:21 -0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aucqA0z4VjocNJ9J4+QyO/wWqDKlgg4huCD99Ak9hs8VXao89WCR7A7oGsh7jX8cxkp8FNfgEmULK6HJwuvS3NhTAHkcRsZAi8FwmB+yrmJ3XoR1O24vf/nqDCcYf7BxFxTAicZhb21zkiWxBgydTW9xgteRzgQOW70mZvj8nIRY77/EpcBCCXLxNaNlfk3ZPtmFYUI7FfeiNEaLTwmNwSbaEeWd2gwva0uO7A1Yuxs7ADSa8kgMkBt0PDE/BIfbuLoUWfdrj6AmSHp2i7AtgoFByjHMSalOcRwxP3AX5LQ6jdyH+PDNelih4Dn/OQ3EHm4SKqgj8Hk3rAx5qi+8RQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LYAis814Fbq1ND1C/FaIhOADY3H+Ls6ZwhxE2F4yxnU=; b=Q0HMxPON9OS2Cdj0Ydqo4Ixk4KcR5piBsIy6FK+E4WDIZ52Hpl0hm+tFt2hmYzHqUI7awRAfARQPy6cv6e1xfQU+saEhDUMkRuBngIjTQovrO0S5XVxUenbTHfMbBQBLVFnQj7zI7mBEFzNcp4PgKW+Q1Iz4EWLxHTIhIfbQsUROipJg/qTLepD9NwF3DdWXL+25Wdmr2NEPcbsVzBj+of3TT+GVh/68SS7nIa+oxDEgsHN3g+0PrfMMJgVhnwzRaGgx/zz0CeT16ia6S82RmC/+ECz6YCJhaBfBlmA2rPXwwY/V7kxbeSZMn3dv/Mr7TGf8+LwozgJ1qw5M6/pZdQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=here.com; dmarc=pass action=none header.from=here.com; dkim=pass header.d=here.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=here.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LYAis814Fbq1ND1C/FaIhOADY3H+Ls6ZwhxE2F4yxnU=; b=XD5s5GkVHoJrrT39R6qBxH+3B9Fvd2r1z4Mjwl9QL4gFfKtYnKI4HnTnXfXZ1BGw8WLxROOOIy9MaE8NG7jJWAd37u7ouQpBpPaQLr6FVW9pnlkIgUat3gzxrqxsMnf8Ve/JOVVI2HSQjZ3kOcbT0EIFgGvLDgTyNyBHXoxcwl8= From: "Buchholz, Robert" To: "musl@lists.openwall.com" Thread-Topic: Bug: ftell() after fopen(..., "ab") returns 0 unless an explicit fseek() is used first Thread-Index: AQHYrXF7D5zlssT5H0G8RBJdETdZew== Date: Thu, 11 Aug 2022 11:14:09 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=here.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 63019cc2-e657-477a-fa3e-08da7b8a9cda x-ms-traffictypediagnostic: AM0PR04MB4915:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: fsJT9BqFV9cgpGK7X+Y2kJuKhEndekS9hgAj1MTfwpbuUMVkcEMkaOr/Vn5IPFwUjP7vF9iACsjSOLeSoeIFloDnNIngDePP5VDvjm3gi+KdNB1DAsmgsi5DSqVR17WwoIiOBDm8GIWFPN6QxERH3U9SHpc24th6UdrhZHQ/KAUG1NRiBspsoOMw2l3dYvF1sSOz2NHoFQQUs7jQzWen1/m3L5i/oF8j6Ch6I3mlah1tpEi4Zs1SAfq1e/jaXHiSi2Gh0aBHJ/ZCLqnbu2DqnkM+cvE64Wl8axsK62pkdOrtoD6/sn8hC4hwubDOxDrd9ZmJ5rMxkWTSCr1toCt5/dKPPgdERxxVJjdPFeqQplt8QV50m4HrI2UHm4nnNqTIG2RqporII97UuCjK6lyiO/u0dQdxdZCI0jnWxJ/9zjokDjWIZtdT/9o0mNFQEtru7E8uWWp4Y2UaJR+d3+0erCtweNTriGbJMGp3buAlT+11XEVGDcBu2XolhxR/riJvhMOYM5QQLFgfswlIRDr2X3Vo4YjDDPECyzxrAc7fgDP8CF2o7Gb9mno35R3MVug3nDE4h35OThWTvkUYRL4dImsdMmVoOm8c47LCiZSyNn2Xkt2lIJlWoi5KdRcMV242OIPM8Z4fb3z3+bgGbkubfjXCQT6jSo5KdwKkkQJzP/ZdJHks0OT+xQ1Hdf4CNZ6DyG2iF4vuCmHc2g71pMxnugm3MVVnZLCHO3CnVp3jx+QeKlW3E1COcSrLSUDpGp0Keu6bvZrqGX87PN2HP+lfY0HkdwM2gQ2+UqfbY1duexdbAdw9aXoVGvAQWPBl4oOq x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1PR04MB3081.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(346002)(396003)(136003)(376002)(39860400002)(366004)(6916009)(91956017)(316002)(71200400001)(41300700001)(478600001)(66946007)(55016003)(2906002)(64756008)(76116006)(66556008)(8676002)(66476007)(52536014)(66446008)(8936002)(5660300002)(38100700002)(122000001)(33656002)(86362001)(38070700005)(19627405001)(186003)(7696005)(6506007)(9686003)(83380400001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?ZiLmpUsI5STN3pL+hgJm/ipB3IAYFR38dBUugyR5VQubKRB6G8nzI3l6Rv?= =?iso-8859-1?Q?7Qj+oqq7w0jgmHxQWwWf5vN5hUH0VhZKefRCCvmpYGJcHl5spTNLrkdKjZ?= =?iso-8859-1?Q?EDNhrFvPoS8IMwgD+nd7yILesCDpljF2SSC7JE9THUoDSql5pX5JZjKYAq?= =?iso-8859-1?Q?XTu735AD2XBeHg0VF1X8x8Y9in/mz/0ukT89LeCb79ZTQFpm05+LrZH5zU?= =?iso-8859-1?Q?bL0iWsnW0/a1y0Go51uf/y+Pc4zw+PmFVP4SRyCBpFpJBhGoqR/ESghDuR?= =?iso-8859-1?Q?fY27VhkuROxjj3ICBlUujurxzAPci+Vs/cbSuzRs9fg+I54v8Cg9DAa3ia?= =?iso-8859-1?Q?6zyHnqxYIMQAID5XvhDxbp2sZ53PB7bDhSBrhLFhYHOtwZmMYg1smYJH4e?= =?iso-8859-1?Q?ZVIw26z+gHAPiuiRuBuo8I26tXc5PlPZr5M2s/SU186kumSqXIOWv2c9ox?= =?iso-8859-1?Q?YzaZbF4m8w04Nybt9FzvWpEKgswohJlk76k2ivAgd6+S0eeIG3LmqtS32p?= =?iso-8859-1?Q?cO9dWF2SiKeOUyCJtjRd+/iDxYw0MnoIXIVxmef/OgFSgkxjx080sgruyc?= =?iso-8859-1?Q?ShyHGGpzMJq2wNmu7PZ4UJA5Hs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= =?iso-8859-1?Q?VM0sSSLX2iYXd3bAJFx7AhRHt5y0MAJx+yONgAOV34Pl2SWAssmf78f/z6?= =?iso-8859-1?Q?ONy4909dCu2/pVKyc+AIyMJOonX2YC/3iIJe+iuUgj61/kwpONwWPblaKA?= =?iso-8859-1?Q?vikmh1e6W/4tPC/EKlH1p8Jr1eakOxBnK/ZOvcBzAV6pNaRKP5uD+cgYBv?= =?iso-8859-1?Q?erUUeq5vfQzIhxUReUW5OuxVzpucSFEgLc4zZQEl?= Content-Type: multipart/alternative; boundary="_000_HE1PR04MB30817A979774EB8803BE4B0490649HE1PR04MB3081eurp_" MIME-Version: 1.0 X-OriginatorOrg: here.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: HE1PR04MB3081.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 63019cc2-e657-477a-fa3e-08da7b8a9cda X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Aug 2022 11:14:09.3021 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 6d4034cd-7225-4f72-b853-91feaea64919 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: RldCUmV7PAAkYh2vFxmKEkbSuIkIlWbXRyao8c1QuYwKHBvlsB8A56rJbjXriFhvAAQLqMfNZghd91npdABT/DmyI+1jqYvqqF0VMLVy8zw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4915 Subject: [musl] Bug: ftell() after fopen(..., "ab") returns 0 unless an explicit fseek() is used first --_000_HE1PR04MB30817A979774EB8803BE4B0490649HE1PR04MB3081eurp_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I'm running Alpine Linux with MUSL as its standard library within a Docker = container based on the official openjdk:16-jdk-alpine3.13 Alpine image. I've used the following minimal test case: =3D=3D=3D=3D=3D=3D=3D=3D #include int main() { FILE* f =3D fopen("foo", "wb"); fwrite("42", 3, 1, f); fclose(f); f =3D fopen("foo", "ab"); printf("%d ", (int)ftell(f)); fwrite("42", 3, 1, f); fseek(f, 0, SEEK_END); printf("%d\n", (int)ftell(f)); } =3D=3D=3D=3D=3D=3D=3D On my Alpine/MUSL setup this prints "0 6" while on Ubuntu 22.04 with glibc = it prints "3 6" - which I'm assuming is the expected output. So, with MUSL = the second fwrite() correctly appends to the existing file, but ftell() nev= ertheless reports that the initial position within the file after opening i= t for appending is 0 and not 3. My GCC version is "gcc (Alpine 10.2.1_pre1) 10.2.1 20201203", ldd confirms = that the compiled output is linked only against "/lib/ld-musl-x86_64.so.1" = and not against glibc. I'm not subscribed to the MUSL mailing list, please CC me on replies. Best Regards, Robert Buchholz --_000_HE1PR04MB30817A979774EB8803BE4B0490649HE1PR04MB3081eurp_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
I'm running Alpine Linux with MUSL as its standard library within a Docker = container based on the official openjdk:16-jdk-alpine3.13 Alpine image.

I've used the following minimal test case:
=3D=3D=3D=3D=3D=3D=3D=3D
#include <stdio.h>

int main()
{
  FILE* f =3D fopen("foo", "wb");
  fwrite("42", 3, 1, f);
  fclose(f);

  f =3D fopen("foo", "ab");
  printf("%d ", (int)ftell(f));
  fwrite("42", 3, 1, f);
  fseek(f, 0, SEEK_END);
  printf("%d\n", (int)ftell(f));
}
=3D=3D=3D=3D=3D=3D=3D
On my Alpine/MUSL setup this prints "0 6" while on Ubuntu 22.04 w= ith glibc it prints "3 6" - which I'm assuming is the expected ou= tput. So, with MUSL the second fwrite() correctly appends to the existing f= ile, but ftell() nevertheless reports that the initial position within the file after opening it for appending is 0 and not 3.

My GCC version is "gcc (Alpine 10.2.1_pre1) 10.2.1 20201203", ldd= confirms that the compiled output is linked only against "/lib/ld-mus= l-x86_64.so.1" and not against glibc.

I'm not subscribed to the MUSL mailing list, please CC me on replies.

Best Regards,
Robert Buchholz
--_000_HE1PR04MB30817A979774EB8803BE4B0490649HE1PR04MB3081eurp_--