}
#endif
+#include <fcntl.h>
+#include <paths.h>
#include <setjmp.h>
#include <signal.h>
if (setjmp (chk_fail_buf) == 0)
{
res = CALL (impl, dst, src, dlen);
- error (0, 0, "Function %s (%zd; %zd) did not __chk_fail",
- impl->name, len, dlen);
+ printf ("*** Function %s (%zd; %zd) did not __chk_fail\n",
+ impl->name, len, dlen);
chk_fail_ok = 0;
ret = 1;
}
if (res != STRCPY_RESULT (dst, len))
{
- error (0, 0, "Wrong result in function %s %p %p", impl->name,
- res, STRCPY_RESULT (dst, len));
+ printf ("Wrong result in function %s %p %p\n", impl->name,
+ res, STRCPY_RESULT (dst, len));
ret = 1;
return;
}
if (strcmp (dst, src) != 0)
{
- error (0, 0, "Wrong result in function %s dst \"%s\" src \"%s\"",
- impl->name, dst, src);
+ printf ("Wrong result in function %s dst \"%s\" src \"%s\"\n",
+ impl->name, dst, src);
ret = 1;
return;
}
if (setjmp (chk_fail_buf) == 0)
{
res = CALL (impl, p2 + align2, p1 + align1, dlen);
- error (0, 0, "Iteration %zd - did not __chk_fail", n);
+ printf ("Iteration %zd - did not __chk_fail\n", n);
chk_fail_ok = 0;
ret = 1;
}
res = CALL (impl, p2 + align2, p1 + align1, dlen);
if (res != STRCPY_RESULT (p2 + align2, len))
{
- error (0, 0, "Iteration %zd - wrong result in function %s (%zd, %zd, %zd) %p != %p",
- n, impl->name, align1, align2, len, res,
- STRCPY_RESULT (p2 + align2, len));
+ printf ("\
+Iteration %zd - wrong result in function %s (%zd, %zd, %zd) %p != %p\n",
+ n, impl->name, align1, align2, len, res,
+ STRCPY_RESULT (p2 + align2, len));
ret = 1;
}
for (j = 0; j < align2 + 64; ++j)
{
if (p2[j - 64] != '\1')
{
- error (0, 0, "Iteration %zd - garbage before, %s (%zd, %zd, %zd)",
- n, impl->name, align1, align2, len);
+ printf ("\
+Iteration %zd - garbage before, %s (%zd, %zd, %zd)\n",
+ n, impl->name, align1, align2, len);
ret = 1;
break;
}
{
if (p2[j] != '\1')
{
- error (0, 0, "Iteration %zd - garbage after, %s (%zd, %zd, %zd)",
- n, impl->name, align1, align2, len);
+ printf ("\
+Iteration %zd - garbage after, %s (%zd, %zd, %zd)\n",
+ n, impl->name, align1, align2, len);
ret = 1;
break;
}
}
if (memcmp (p1 + align1, p2 + align2, len + 1))
{
- error (0, 0, "Iteration %zd - different strings, %s (%zd, %zd, %zd)",
- n, impl->name, align1, align2, len);
+ printf ("\
+Iteration %zd - different strings, %s (%zd, %zd, %zd)\n",
+ n, impl->name, align1, align2, len);
ret = 1;
}
}
sigaction (SIGABRT, &sa, NULL);
+ /* Avoid all the buffer overflow messages on stderr. */
+ int fd = open (_PATH_DEVNULL, O_WRONLY);
+ if (fd == -1)
+ close (STDERR_FILENO);
+ else
+ {
+ dup2 (fd, STDERR_FILENO);
+ close (fd);
+ }
+ setenv ("LIBC_FATAL_STDERR_", "1", 1);
+
test_init ();
printf ("%23s", "");
{
if (action & 1)
{
- /* output string will be ": ADDR ***\n" */
- static const char suffix[] = " ***\n";
- static const char prefix[] = ": 0x";
- char buf[sizeof (prefix) - 1 + sizeof (void *) * 2 + sizeof (suffix)];
- char *cp;
- if (action & 4)
- cp = memcpy (&buf[sizeof (buf) - 2], "\n", 2);
- else
- {
- cp = memcpy (&buf[sizeof (buf) - sizeof (suffix)], suffix,
- sizeof (suffix));
- cp = _itoa_word ((unsigned long int) ptr, cp, 16, 0);
- while (cp > &buf[sizeof (prefix) - 1])
- *--cp = '0';
- cp = memcpy (buf, prefix, sizeof (prefix) - 1);
- }
+ char buf[2 * sizeof (uintptr_t) + 1];
- struct iovec iov[3];
- int n = 0;
- if ((action & 4) == 0)
- {
- iov[0].iov_base = (char *) "*** glibc detected *** ";
- iov[0].iov_len = strlen (iov[0].iov_base);
- ++n;
- }
- iov[n].iov_base = (char *) str;
- iov[n].iov_len = strlen (str);
- ++n;
- iov[n].iov_base = cp;
- iov[n].iov_len = &buf[sizeof (buf) - 1] - cp;
- ++n;
- if (TEMP_FAILURE_RETRY (__writev (STDERR_FILENO, iov, n)) == -1
- && errno == EBADF)
- /* Standard error is not opened. Try using syslog. */
- syslog (LOG_ERR, "%s%s%s", (char *) iov[0].iov_base,
- (char *) iov[1].iov_base,
- n == 3 ? (const char *) iov[2].iov_base : "");
+ buf[sizeof (buf) - 1] = '\0';
+ char *cp = _itoa_word ((uintptr_t) ptr, &buf[sizeof (buf) - 1], 16, 0);
+ while (cp > buf)
+ *--cp = '0';
+
+ __libc_message (action & 2,
+ action & 4
+ ? "%s\n" : "*** glibc detected *** %s: 0x%s ***\n",
+ str, cp);
}
- if (action & 2)
+ else if (action & 2)
abort ();
}