summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2017-06-23 20:57:52 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2017-06-23 20:57:52 +0000
commit7246b18e35223a39763f0e6278fad052e7f4c14d (patch)
treeb4714ffc44a64a48443f0e47ed98020cf780de7a /gnu
parent8d4d67a7288142fa4e995ad122e2e36565179268 (diff)
Make libiberty test programs compile and run without segfault.
Diffstat (limited to 'gnu')
-rw-r--r--gnu/lib/libiberty/src/testsuite/test-demangle.c12
-rw-r--r--gnu/lib/libiberty/src/testsuite/test-expandargv.c7
-rw-r--r--gnu/lib/libiberty/src/testsuite/test-pexecute.c20
3 files changed, 17 insertions, 22 deletions
diff --git a/gnu/lib/libiberty/src/testsuite/test-demangle.c b/gnu/lib/libiberty/src/testsuite/test-demangle.c
index 82f263e88af..086189e0f91 100644
--- a/gnu/lib/libiberty/src/testsuite/test-demangle.c
+++ b/gnu/lib/libiberty/src/testsuite/test-demangle.c
@@ -26,6 +26,8 @@
#include <stdio.h>
#include "libiberty.h"
#include "demangle.h"
+#include <string.h>
+#include <stdlib.h>
struct line
{
@@ -40,7 +42,7 @@ static unsigned int lineno;
#define LINELEN 80
static void
-getline(buf)
+get_line(buf)
struct line *buf;
{
char *data = buf->data;
@@ -65,7 +67,7 @@ getline(buf)
line: copy this line into the buffer and return. */
while (c != EOF && c != '\n')
{
- if (count >= alloc)
+ if (count + 1 >= alloc)
{
alloc *= 2;
data = xrealloc (data, alloc);
@@ -117,12 +119,12 @@ main(argc, argv)
for (;;)
{
- getline (&format);
+ get_line (&format);
if (feof (stdin))
break;
- getline (&input);
- getline (&expect);
+ get_line (&input);
+ get_line (&expect);
tests++;
diff --git a/gnu/lib/libiberty/src/testsuite/test-expandargv.c b/gnu/lib/libiberty/src/testsuite/test-expandargv.c
index 9d1af014545..96ab291ea62 100644
--- a/gnu/lib/libiberty/src/testsuite/test-expandargv.c
+++ b/gnu/lib/libiberty/src/testsuite/test-expandargv.c
@@ -34,12 +34,9 @@
#include "libiberty.h"
#include <stdio.h>
#include <errno.h>
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
-#ifdef HAVE_STRING_H
#include <string.h>
-#endif
+#include <unistd.h>
#ifndef EXIT_SUCCESS
#define EXIT_SUCCESS 0
@@ -172,7 +169,7 @@ writeout_test (int test, const char * test_data)
if (parse == NULL)
fatal_error (__LINE__, "Failed to malloc parse.", errno);
- memcpy (parse, test_data, sizeof (char) * len);
+ memcpy (parse, test_data, sizeof (char) * (len + 1));
/* Run all possible replaces */
run_replaces (parse);
diff --git a/gnu/lib/libiberty/src/testsuite/test-pexecute.c b/gnu/lib/libiberty/src/testsuite/test-pexecute.c
index 8e01fda479a..75856a02b66 100644
--- a/gnu/lib/libiberty/src/testsuite/test-pexecute.c
+++ b/gnu/lib/libiberty/src/testsuite/test-pexecute.c
@@ -27,25 +27,21 @@
#include <stdio.h>
#include <signal.h>
#include <errno.h>
-#ifdef HAVE_STRING_H
#include <string.h>
-#endif
#include <sys/types.h>
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
-#ifdef HAVE_UNISTD_H
#include <unistd.h>
-#endif
-#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
-#endif
-#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
-#endif
-#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
-#endif
+
+extern const char *pex_run (struct pex_obj *obj, int flags,
+ const char *executable, char * const *argv,
+ const char *outname, const char *errname,
+ int *err);
+extern FILE *pex_read_output (struct pex_obj *, int binary);
+extern int pex_get_status (struct pex_obj *, int count, int *vector);
+extern void pex_free (struct pex_obj *);
#ifndef WIFSIGNALED
#define WIFSIGNALED(S) (((S) & 0xff) != 0 && ((S) & 0xff) != 0x7f)