From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: from second.openwall.net (second.openwall.net [193.110.157.125]) by inbox.vuxu.org (Postfix) with SMTP id B05392150A for ; Sat, 11 May 2024 17:25:13 +0200 (CEST) Received: (qmail 1406 invoked by uid 550); 11 May 2024 15:25:09 -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 1364 invoked from network); 11 May 2024 15:25:08 -0000 Date: Sat, 11 May 2024 17:24:59 +0200 From: Petr Pisar To: musl@lists.openwall.com Message-ID: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="nKbYZcG0dF7Nf71R" Content-Disposition: inline Subject: [musl] strptime(s, "%Y-%j", &tm) does not update month and day --nKbYZcG0dF7Nf71R Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hello, When debugging a libisds test failure with musl-1.2.5 , I found that musl's strptime() does not handle "%Y-%j" properly. It accepts the format, it parses the input string, it returns a correct pointer past the input string, but it does not update tm.tm_mon and tm.tm_mday fileds of the third argument. A reproducer: #define _XOPEN_SOURCE #include #include #include int main(void) { const char *input = "2001-34"; /* 34th day of 2001 year, i.e. 2001-02-03 */ struct tm time = {.tm_year=42, .tm_mon=42, .tm_mday=42, }; /* To detect changes */ char *ret = strptime(input, "%Y-%j", &time); printf("Expected: ret=%p(%p+%td) tm_year=%d, tm_mon=%d, tm_mday=%d\n", input + 7, input, (ptrdiff_t)7, 101, 1, 3); printf("Got: ret=%p(%p+%td) tm_year=%d, tm_mon=%d, tm_mday=%d\n", ret, input, ret - input, time.tm_year, time.tm_mon, time.tm_mday); return 0; } $ gcc test.c && ./a.out Expected: ret=0x560c1cd64007(0x560c1cd64000+7) tm_year=101, tm_mon=1, tm_mday=3 Got: ret=0x560c1cd64007(0x560c1cd64000+7) tm_year=101, tm_mon=42, tm_mday=42 Compare to glibc-2.38: $ gcc test.c && ./a.out Expected: ret=0x55fd94c4f00f(0x55fd94c4f008+7) tm_year=101, tm_mon=1, tm_mday=3 Got: ret=0x55fd94c4f00f(0x55fd94c4f008+7) tm_year=101, tm_mon=1, tm_mday=3 Tested on x86_64 platform with gcc-13.2.1_p20240210, binutils-2.42 and musl-1.2.5 -- Petr --nKbYZcG0dF7Nf71R Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEE4/QvzhVoMKgDWObpT9GuwzZa978FAmY/jcQACgkQT9GuwzZa 97/CGQ//RJw0VyxqlukpabXDvOsoQAsbQYZfZo5YKtXKcEFrrplP7H8r6LUOb2+H ZuBi/oj7VTehpUP9njS+Ru3z7E71YmF7AgySzr7Yp+/3vkS8qORwqsBhChAXE4Z4 QmG6CsskMDW8Bfzfv00vxX22VnV2SJ/4IsfLWBsKIZCTJuOuYkY5KwPgfU/bDrOE IYvKpOuRr+vpdDbl8cLoplC6uJEKHFsFb9r6xG7RdiXPxO0QMDhTOHsMcLvj1J3o 7uv4XKOW3Kn6YHdfRiyRre2mfnB3gHlCmKgIMqoHwTnMzXX8srjPcUHvU37kU+dj ZFakCGv5S2VVimT67KBBCfIX2a3kwD9sCrndYy7smLO92Tahz8BTkml2wSB+VBPQ Dxba9zY+mI7Aq3XJNijiuvjdx3L62ZTkaa7OG66A8poi7VGiMVbX/fV4BiHtvAOt fuTWUkBBxCvGslZuJrye/plIlMLGP6pHN40vWhPuHyrlLixh45rFUPk6JuYxQbwb 2gpxMFH8oKzqDgkSYWBryT6FcEN2q1MJhaXxr6DK1pz9lzQ4nEEvYevbuVWvw3Ti 6LyVADYoMMAJBwEcB4VWDTTtiTbDavW8dp9c37dnk/Rim7eKEp4Qm/rWMRtvVl+W bUxDPlUQN1UDwSClkltyAv9VZSqmhtArMsN1MEzLA4iU+wxLsj8= =/pDr -----END PGP SIGNATURE----- --nKbYZcG0dF7Nf71R--