diff options
author | Florian Weimer <fweimer@redhat.com> | 2018-10-30 13:55:01 +0100 |
---|---|---|
committer | Andreas K. Hüttel <dilfridge@gentoo.org> | 2018-12-11 23:30:39 +0100 |
commit | 64d7c76199943badea6777151424bf342274fbc4 (patch) | |
tree | 42042e1d772c0d9d8a9c900c28de92fc8ff800d2 | |
parent | support_blob_repeat: Call mkstemp directory for the backing file (diff) | |
download | glibc-64d7c76199943badea6777151424bf342274fbc4.tar.gz glibc-64d7c76199943badea6777151424bf342274fbc4.tar.bz2 glibc-64d7c76199943badea6777151424bf342274fbc4.zip |
stdlib/tst-strtod-overflow: Switch to support_blob_repeat
This is another test with an avoidable large memory allocation.
(cherry picked from commit 07da99aad93c9364acb7efdab47c27ba698f6313)
(cherry picked from commit e1af1df694603c0dcd5118c30eea2cdeb01a1a0b)
Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | stdlib/tst-strtod-overflow.c | 16 |
2 files changed, 15 insertions, 6 deletions
@@ -1,5 +1,10 @@ 2018-10-30 Florian Weimer <fweimer@redhat.com> + * stdlib/tst-strtod-overflow.c (do_test): Switch to + support_blob_repeat. + +2018-10-30 Florian Weimer <fweimer@redhat.com> + * support/blob_repeat.c (allocate_big): Call mkstemp directly. 2018-10-30 Florian Weimer <fweimer@redhat.com> diff --git a/stdlib/tst-strtod-overflow.c b/stdlib/tst-strtod-overflow.c index d14638d68e..dc53c1e521 100644 --- a/stdlib/tst-strtod-overflow.c +++ b/stdlib/tst-strtod-overflow.c @@ -19,6 +19,8 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <support/blob_repeat.h> +#include <support/test-driver.h> #define EXPONENT "e-2147483649" #define SIZE 214748364 @@ -26,21 +28,23 @@ static int do_test (void) { - char *p = malloc (1 + SIZE + sizeof (EXPONENT)); - if (p == NULL) + struct support_blob_repeat repeat = support_blob_repeat_allocate + ("0", 1, 1 + SIZE + sizeof (EXPONENT)); + if (repeat.size == 0) { - puts ("malloc failed, cannot test for overflow"); - return 0; + puts ("warning: memory allocation failed, cannot test for overflow"); + return EXIT_UNSUPPORTED; } + char *p = repeat.start; p[0] = '1'; - memset (p + 1, '0', SIZE); memcpy (p + 1 + SIZE, EXPONENT, sizeof (EXPONENT)); double d = strtod (p, NULL); if (d != 0) { - printf ("strtod returned wrong value: %a\n", d); + printf ("error: strtod returned wrong value: %a\n", d); return 1; } + support_blob_repeat_free (&repeat); return 0; } |