arrfab / rpms / glibc

Forked from rpms/glibc 4 years ago
Clone

Blame SOURCES/glibc-rh1647490-4.patch

147e83
commit 07da99aad93c9364acb7efdab47c27ba698f6313
147e83
Author: Florian Weimer <fweimer@redhat.com>
147e83
Date:   Tue Oct 30 13:55:01 2018 +0100
147e83
147e83
    stdlib/tst-strtod-overflow: Switch to support_blob_repeat
147e83
    
147e83
    This is another test with an avoidable large memory allocation.
147e83
147e83
diff --git a/stdlib/tst-strtod-overflow.c b/stdlib/tst-strtod-overflow.c
147e83
index 6c5b2828551dd580..fd1be79f3f58c64b 100644
147e83
--- a/stdlib/tst-strtod-overflow.c
147e83
+++ b/stdlib/tst-strtod-overflow.c
147e83
@@ -19,6 +19,8 @@
147e83
 #include <stdio.h>
147e83
 #include <stdlib.h>
147e83
 #include <string.h>
147e83
+#include <support/blob_repeat.h>
147e83
+#include <support/test-driver.h>
147e83
 
147e83
 #define EXPONENT "e-2147483649"
147e83
 #define SIZE 214748364
147e83
@@ -26,21 +28,23 @@
147e83
 static int
147e83
 do_test (void)
147e83
 {
147e83
-  char *p = malloc (1 + SIZE + sizeof (EXPONENT));
147e83
-  if (p == NULL)
147e83
+  struct support_blob_repeat repeat = support_blob_repeat_allocate
147e83
+    ("0", 1, 1 + SIZE + sizeof (EXPONENT));
147e83
+  if (repeat.size == 0)
147e83
     {
147e83
-      puts ("malloc failed, cannot test for overflow");
147e83
-      return 0;
147e83
+      puts ("warning: memory allocation failed, cannot test for overflow");
147e83
+      return EXIT_UNSUPPORTED;
147e83
     }
147e83
+  char *p = repeat.start;
147e83
   p[0] = '1';
147e83
-  memset (p + 1, '0', SIZE);
147e83
   memcpy (p + 1 + SIZE, EXPONENT, sizeof (EXPONENT));
147e83
   double d = strtod (p, NULL);
147e83
   if (d != 0)
147e83
     {
147e83
-      printf ("strtod returned wrong value: %a\n", d);
147e83
+      printf ("error: strtod returned wrong value: %a\n", d);
147e83
       return 1;
147e83
     }
147e83
+  support_blob_repeat_free (&repeat);
147e83
   return 0;
147e83
 }
147e83