olga / rpms / glibc

Forked from rpms/glibc 5 years ago
Clone

Blame SOURCES/glibc-rh1647490-4.patch

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