← Commit list

424d24793e

Joshua Rogers
Joshua Rogers
2026-09-22
SUCCESS Duration: 400s

Subject

mprintf: use size_t width for the bare Windows %I modifier

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

lib/mprintf.c+1 -1
@@ -252,7 +252,7 @@ static int parse_flags(const char **fmtp, unsigned int *flagsp, int use_dollar,
fmt += 2;
}
else {
-#if SIZEOF_CURL_OFF_T > SIZEOF_LONG
+#if SIZEOF_SIZE_T > SIZEOF_LONG
flags |= FLAGS_LONGLONG;
#else
flags |= FLAGS_LONG;
tests/data/Makefile.am+1 -0
@@ -1470,6 +1470,7 @@ TESTCASES = \
test1448 \
test1449 \
test1450 \
+ test1451 \
test1452 \
test1453 \
test1454 \
tests/data/test1451+22 -0
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="US-ASCII"?>
+<testcase>
+<info>
+<keywords>
+mprintf
+libtest
+</keywords>
+</info>
+
+# Client-side
+<client>
+<features>
+win32
+</features>
+<tool>
+lib%TESTNUMBER
+</tool>
+<name>
+mprintf %I length modifier unit tests
+</name>
+</client>
+</testcase>
tests/libtest/Makefile.inc+1 -0
@@ -169,6 +169,7 @@ TESTS_C = \
lib1308.c \
lib1396.c \
lib1398.c \
+ lib1451.c \
lib1485.c \
lib1500.c \
lib1501.c \
tests/libtest/lib1451.c+70 -0
@@ -0,0 +1,70 @@
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) Daniel Stenberg, <[email protected]>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ * SPDX-License-Identifier: curl
+ *
+ ***************************************************************************/
+#include "unitcheck.h"
+
+#ifdef CURL_HAVE_DIAG
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat"
+#endif
+
+static CURLcode test_lib1451(const char *arg)
+{
+ UNITTEST_BEGIN_SIMPLE
+
+#ifdef _WIN32
+ /* bare "%I" must track native pointer/size_t width, not curl_off_t */
+ {
+ struct {
+ unsigned char guard1[8];
+ size_t count;
+ unsigned char guard2[8];
+ } canary;
+ unsigned char expect_guard[8];
+ char buf[64];
+ int rc;
+
+ memset(&canary, 0xaa, sizeof(canary));
+ memset(expect_guard, 0xaa, sizeof(expect_guard));
+
+ rc = curl_msnprintf(buf, sizeof(buf), "0123456789%In", &canary.count);
+ fail_unless(rc == 10, "curl_msnprintf returned unexpected length");
+ fail_unless(canary.count == 10, "%In wrote the wrong count");
+ verify_memory(canary.guard1, expect_guard, sizeof(expect_guard));
+ verify_memory(canary.guard2, expect_guard, sizeof(expect_guard));
+ }
+
+ {
+ char buf[64];
+ curl_msnprintf(buf, sizeof(buf), "%Iu-%d", (size_t)0x11223344, 42);
+ fail_unless(!strcmp(buf, "287454020-42"),
+ "%Iu did not consume a size_t-sized argument");
+ }
+#endif
+
+ UNITTEST_END_SIMPLE
+}
+
+#ifdef CURL_HAVE_DIAG
+#pragma GCC diagnostic pop
+#endif