This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
abort of addseverity(3)
- From: Shunichi Sagawa <s-sagawa at jp dot fujitsu dot com>
- To: libc-alpha <libc-alpha at sources dot redhat dot com>
- Date: Tue, 1 Feb 2005 18:55:34 +0900
- Subject: abort of addseverity(3)
Hello,
When I want to remove the severity class, the removal operation causes
the process abort.
I think that it is a cause to the argument "string" of
internal_addseverity().
This problem is solved by changing the argument of internal_addseverity()
from "string" to "new_string".
<test program start>
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
#include <stdlib.h>
#include <fmtmsg.h>
#define TST_SEVERITY 10 /* severity level for test */
int main()
{
const char *user_severity = "test";
/* Add new severity for severity level TST_SEVERITY */
addseverity(TST_SEVERITY, user_severity);
/* used the severity level TST_SEVERITY to fmtmsg */
fmtmsg(MM_PRINT, "UX:cat", TST_SEVERITY, "invalid syntax", \
"refer to manual", "UX:cat:001");
/* Remove the severity class for severity level TST_SEVERITY */
addseverity(TST_SEVERITY, NULL);
fmtmsg(MM_PRINT, "UX:cat", TST_SEVERITY, "invalid syntax", \
"refer to manual", "UX:cat:001");
return 0;
}
<test program end>
# ./tst-addseverity
UX:cat: test: invalid syntax
TO FIX: refer to manual UX:cat:001
*** glibc detected *** free(): invalid pointer: 0x08048534 ***
Aborted
#
<patch start>
diff -Nurp glibc-2.3.4/stdlib/fmtmsg.c glibc-2.3.4.new/stdlib/fmtmsg.c
--- glibc-2.3.4/stdlib/fmtmsg.c 2003-09-02 14:19:49.000000000 +0900
+++ glibc-2.3.4.new/stdlib/fmtmsg.c 2005-01-30 15:53:06.000000000 +0900
@@ -389,7 +389,7 @@ addseverity (int severity, const char *s
__libc_lock_lock (lock);
/* Do the real work. */
- result = internal_addseverity (severity, string);
+ result = internal_addseverity (severity, new_string);
if (result != MM_OK)
/* Free the allocated string. */
<patch end>
Best Regards,
Shunichi Sagawa