From: bluhm Date: Fri, 23 Jun 2017 20:57:51 +0000 (+0000) Subject: Make libiberty test programs compile and run without segfault. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=0fb20bf6d6cddd6a78c1d4d7a1d63e7277f390f8;p=openbsd Make libiberty test programs compile and run without segfault. --- 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 #include "libiberty.h" #include "demangle.h" +#include +#include 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 #include -#ifdef HAVE_STDLIB_H #include -#endif -#ifdef HAVE_STRING_H #include -#endif +#include #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 #include #include -#ifdef HAVE_STRING_H #include -#endif #include -#ifdef HAVE_STDLIB_H #include -#endif -#ifdef HAVE_UNISTD_H #include -#endif -#ifdef HAVE_SYS_WAIT_H #include -#endif -#ifdef HAVE_SYS_TIME_H #include -#endif -#ifdef HAVE_SYS_RESOURCE_H #include -#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)