[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: write past end of buffer in vasnprintf() implementation of %f
From: |
Bruno Haible |
Subject: |
Re: write past end of buffer in vasnprintf() implementation of %f |
Date: |
Tue, 02 Oct 2018 10:55:25 +0200 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-134-generic; KDE/5.18.0; x86_64; ; ) |
> + for (size = 0; size <= 8; size++)
> + {
> + size_t length;
> + char *result;
> +
> + memcpy (buf, "DEADBEEF", 8);
> + length = size;
> + result = my_asnprintf (buf, &length, "%2.0f", 1.6314159265358979e+125);
> + ASSERT (result != NULL);
> + ASSERT (strcmp (result,
> "163141592653589790215729350939528493057529598899734151772468186268423257777068536614838678161083520756952076273094236944990208")
> == 0);
This new test case is a little bit too strict: it fails on Cygwin. This
patch fixes it.
2018-10-02 Bruno Haible <address@hidden>
vasnprintf tests: Avoid test failure on Cygwin.
* tests/test-vasnprintf.c (test_function): Change the test added on
2018-09-23 to check only the 42 most significant digits.
diff --git a/tests/test-vasnprintf.c b/tests/test-vasnprintf.c
index 93d81d7..0cd17f9 100644
--- a/tests/test-vasnprintf.c
+++ b/tests/test-vasnprintf.c
@@ -70,7 +70,13 @@ test_function (char * (*my_asnprintf) (char *, size_t *,
const char *, ...))
length = size;
result = my_asnprintf (buf, &length, "%2.0f", 1.6314159265358979e+125);
ASSERT (result != NULL);
- ASSERT (strcmp (result,
"163141592653589790215729350939528493057529598899734151772468186268423257777068536614838678161083520756952076273094236944990208")
== 0);
+ /* The exact result and the result on glibc systems is
+
163141592653589790215729350939528493057529598899734151772468186268423257777068536614838678161083520756952076273094236944990208
+ On Cygwin, the result is
+
163141592653589790215729350939528493057529600000000000000000000000000000000000000000000000000000000000000000000000000000000000
+ */
+ ASSERT (strlen (result) == 126);
+ ASSERT (memcmp (result, "163141592653589790215729350939528493057529",
42) == 0);
ASSERT (length == 126);
if (size < 126 + 1)
ASSERT (result != buf);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: write past end of buffer in vasnprintf() implementation of %f,
Bruno Haible <=