mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-23 15:01:03 +03:00
stdlib/tst-strtod-overflow: Switch to support_blob_repeat
This is another test with an avoidable large memory allocation.
This commit is contained in:
@ -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>
|
2018-10-30 Florian Weimer <fweimer@redhat.com>
|
||||||
|
|
||||||
Avoid spurious test failures in stdlib/test-bz22786.
|
Avoid spurious test failures in stdlib/test-bz22786.
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <support/blob_repeat.h>
|
||||||
|
#include <support/test-driver.h>
|
||||||
|
|
||||||
#define EXPONENT "e-2147483649"
|
#define EXPONENT "e-2147483649"
|
||||||
#define SIZE 214748364
|
#define SIZE 214748364
|
||||||
@ -26,21 +28,23 @@
|
|||||||
static int
|
static int
|
||||||
do_test (void)
|
do_test (void)
|
||||||
{
|
{
|
||||||
char *p = malloc (1 + SIZE + sizeof (EXPONENT));
|
struct support_blob_repeat repeat = support_blob_repeat_allocate
|
||||||
if (p == NULL)
|
("0", 1, 1 + SIZE + sizeof (EXPONENT));
|
||||||
|
if (repeat.size == 0)
|
||||||
{
|
{
|
||||||
puts ("malloc failed, cannot test for overflow");
|
puts ("warning: memory allocation failed, cannot test for overflow");
|
||||||
return 0;
|
return EXIT_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
char *p = repeat.start;
|
||||||
p[0] = '1';
|
p[0] = '1';
|
||||||
memset (p + 1, '0', SIZE);
|
|
||||||
memcpy (p + 1 + SIZE, EXPONENT, sizeof (EXPONENT));
|
memcpy (p + 1 + SIZE, EXPONENT, sizeof (EXPONENT));
|
||||||
double d = strtod (p, NULL);
|
double d = strtod (p, NULL);
|
||||||
if (d != 0)
|
if (d != 0)
|
||||||
{
|
{
|
||||||
printf ("strtod returned wrong value: %a\n", d);
|
printf ("error: strtod returned wrong value: %a\n", d);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
support_blob_repeat_free (&repeat);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user