]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
stdlib/tst-strtod-overflow: Switch to support_blob_repeat
authorFlorian Weimer <fweimer@redhat.com>
Tue, 30 Oct 2018 12:55:01 +0000 (13:55 +0100)
committerFlorian Weimer <fweimer@redhat.com>
Fri, 2 Nov 2018 09:47:16 +0000 (10:47 +0100)
This is another test with an avoidable large memory allocation.

(cherry picked from commit 07da99aad93c9364acb7efdab47c27ba698f6313)

ChangeLog
stdlib/tst-strtod-overflow.c

index b4c48644aea904719276670c336cf2ce5aca86c7..51a8f488d96661e7e99348af4cfc6c85e481e73a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+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.
index d14638d68ef4f471ed3e70abf8ab44826afed284..dc53c1e521443e1d41aaec374e2923d0c65b47db 100644 (file)
@@ -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
 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;
 }