aboutsummaryrefslogtreecommitdiff
path: root/malloc
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-11-13 03:13:00 +0000
committerUlrich Drepper <drepper@redhat.com>2004-11-13 03:13:00 +0000
commita9055cab7ac609b96984179194c7a2ec410c8e2b (patch)
treed7bbccb32e96d87220932549049a48f3eb5c3dad /malloc
parent1327439fc6ef182c3ab8c69a55d3bee15b3c62a7 (diff)
downloadglibc-a9055cab7ac609b96984179194c7a2ec410c8e2b.tar
glibc-a9055cab7ac609b96984179194c7a2ec410c8e2b.tar.gz
glibc-a9055cab7ac609b96984179194c7a2ec410c8e2b.tar.bz2
glibc-a9055cab7ac609b96984179194c7a2ec410c8e2b.zip
Update.
2004-11-12 Ulrich Drepper <drepper@redhat.com> * sysdeps/unix/sysv/linux/libc_fatal.c: Add new function __libc_message which performs the printing and simple format string handling. The string is written to tty, stderr, syslog in this order, stopping after the first successful output. (__libc_fatal): Call __libc_message. * include/stdio.h: Declare __libc_message. * malloc/malloc.c (malloc_printerr): Use __libc_message. * debug/chk_fail.c: Also print message with __libc_message. * debug/test-strcpy_chk.c: Ensure that debug messages are not printed to the terminal or stderr. * debug/tst-chk1.c: Likewise. * posix/Makefile: Remove gpl2lgpl variable.
Diffstat (limited to 'malloc')
-rw-r--r--malloc/malloc.c48
1 files changed, 11 insertions, 37 deletions
diff --git a/malloc/malloc.c b/malloc/malloc.c
index 6d6294c6e6..3f4fd77807 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -5474,45 +5474,19 @@ malloc_printerr(int action, const char *str, void *ptr)
{
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 ();
}