mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-07 06:43:00 +03:00
Fix locking in fmtmsg
This commit is contained in:
@@ -1,7 +1,11 @@
|
|||||||
|
2012-02-24 Ulrich Drepper <drepper@gmail.com>
|
||||||
|
|
||||||
|
* stdlib/fmtmsg.c (fmtmsg): Lock around use of severity list.
|
||||||
|
Reported by Peng Haitao <penght@cn.fujitsu.com>.
|
||||||
|
|
||||||
2012-02-24 Joseph Myers <joseph@codesourcery.com>
|
2012-02-24 Joseph Myers <joseph@codesourcery.com>
|
||||||
|
|
||||||
* configure.in: Use -o not -a in test for unsupported multi-arch.
|
* configure.in: Use -o not -a in test for unsupported multi-arch.
|
||||||
* configure: Regenerated.
|
|
||||||
|
|
||||||
2012-02-24 Joseph Myers <joseph@codesourcery.com>
|
2012-02-24 Joseph Myers <joseph@codesourcery.com>
|
||||||
|
|
||||||
|
119
stdlib/fmtmsg.c
119
stdlib/fmtmsg.c
@@ -103,7 +103,6 @@ fmtmsg (long int classification, const char *label, int severity,
|
|||||||
const char *text, const char *action, const char *tag)
|
const char *text, const char *action, const char *tag)
|
||||||
{
|
{
|
||||||
__libc_once_define (static, once);
|
__libc_once_define (static, once);
|
||||||
int result = MM_OK;
|
|
||||||
struct severity_info *severity_rec;
|
struct severity_info *severity_rec;
|
||||||
|
|
||||||
/* Make sure everything is initialized. */
|
/* Make sure everything is initialized. */
|
||||||
@@ -124,17 +123,6 @@ fmtmsg (long int classification, const char *label, int severity,
|
|||||||
return MM_NOTOK;
|
return MM_NOTOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (severity_rec = severity_list; severity_rec != NULL;
|
|
||||||
severity_rec = severity_rec->next)
|
|
||||||
if (severity == severity_rec->severity)
|
|
||||||
/* Bingo. */
|
|
||||||
break;
|
|
||||||
|
|
||||||
/* If we don't know anything about the severity level return an error. */
|
|
||||||
if (severity_rec == NULL)
|
|
||||||
return MM_NOTOK;
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __libc_ptf_call
|
#ifdef __libc_ptf_call
|
||||||
/* We do not want this call to be cut short by a thread
|
/* We do not want this call to be cut short by a thread
|
||||||
cancellation. Therefore disable cancellation for now. */
|
cancellation. Therefore disable cancellation for now. */
|
||||||
@@ -143,53 +131,72 @@ fmtmsg (long int classification, const char *label, int severity,
|
|||||||
0);
|
0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Now we can print. */
|
__libc_lock_lock (lock);
|
||||||
if (classification & MM_PRINT)
|
|
||||||
{
|
|
||||||
int do_label = (print & label_mask) && label != MM_NULLLBL;
|
|
||||||
int do_severity = (print & severity_mask) && severity != MM_NULLSEV;
|
|
||||||
int do_text = (print & text_mask) && text != MM_NULLTXT;
|
|
||||||
int do_action = (print & action_mask) && action != MM_NULLACT;
|
|
||||||
int do_tag = (print & tag_mask) && tag != MM_NULLTAG;
|
|
||||||
|
|
||||||
if (__fxprintf (stderr, "%s%s%s%s%s%s%s%s%s%s\n",
|
for (severity_rec = severity_list; severity_rec != NULL;
|
||||||
do_label ? label : "",
|
severity_rec = severity_rec->next)
|
||||||
do_label && (do_severity | do_text | do_action | do_tag)
|
if (severity == severity_rec->severity)
|
||||||
? ": " : "",
|
/* Bingo. */
|
||||||
do_severity ? severity_rec->string : "",
|
break;
|
||||||
do_severity && (do_text | do_action | do_tag)
|
|
||||||
? ": " : "",
|
/* If we don't know anything about the severity level return an error. */
|
||||||
do_text ? text : "",
|
int result = MM_NOTOK;
|
||||||
do_text && (do_action | do_tag) ? "\n" : "",
|
if (severity_rec != NULL)
|
||||||
do_action ? "TO FIX: " : "",
|
{
|
||||||
do_action ? action : "",
|
result = MM_OK;
|
||||||
do_action && do_tag ? " " : "",
|
|
||||||
do_tag ? tag : "") < 0)
|
/* Now we can print. */
|
||||||
/* Oh, oh. An error occurred during the output. */
|
if (classification & MM_PRINT)
|
||||||
result = MM_NOMSG;
|
{
|
||||||
|
int do_label = (print & label_mask) && label != MM_NULLLBL;
|
||||||
|
int do_severity = (print & severity_mask) && severity != MM_NULLSEV;
|
||||||
|
int do_text = (print & text_mask) && text != MM_NULLTXT;
|
||||||
|
int do_action = (print & action_mask) && action != MM_NULLACT;
|
||||||
|
int do_tag = (print & tag_mask) && tag != MM_NULLTAG;
|
||||||
|
int need_colon = (do_label
|
||||||
|
&& (do_severity | do_text | do_action | do_tag));
|
||||||
|
|
||||||
|
if (__fxprintf (stderr, "%s%s%s%s%s%s%s%s%s%s\n",
|
||||||
|
do_label ? label : "",
|
||||||
|
need_colon ? ": " : "",
|
||||||
|
do_severity ? severity_rec->string : "",
|
||||||
|
do_severity && (do_text | do_action | do_tag)
|
||||||
|
? ": " : "",
|
||||||
|
do_text ? text : "",
|
||||||
|
do_text && (do_action | do_tag) ? "\n" : "",
|
||||||
|
do_action ? "TO FIX: " : "",
|
||||||
|
do_action ? action : "",
|
||||||
|
do_action && do_tag ? " " : "",
|
||||||
|
do_tag ? tag : "") < 0)
|
||||||
|
/* Oh, oh. An error occurred during the output. */
|
||||||
|
result = MM_NOMSG;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (classification & MM_CONSOLE)
|
||||||
|
{
|
||||||
|
int do_label = label != MM_NULLLBL;
|
||||||
|
int do_severity = severity != MM_NULLSEV;
|
||||||
|
int do_text = text != MM_NULLTXT;
|
||||||
|
int do_action = action != MM_NULLACT;
|
||||||
|
int do_tag = tag != MM_NULLTAG;
|
||||||
|
int need_colon = (do_label
|
||||||
|
&& (do_severity | do_text | do_action | do_tag));
|
||||||
|
|
||||||
|
syslog (LOG_ERR, "%s%s%s%s%s%s%s%s%s%s\n",
|
||||||
|
do_label ? label : "",
|
||||||
|
need_colon ? ": " : "",
|
||||||
|
do_severity ? severity_rec->string : "",
|
||||||
|
do_severity && (do_text | do_action | do_tag) ? ": " : "",
|
||||||
|
do_text ? text : "",
|
||||||
|
do_text && (do_action | do_tag) ? "\n" : "",
|
||||||
|
do_action ? "TO FIX: " : "",
|
||||||
|
do_action ? action : "",
|
||||||
|
do_action && do_tag ? " " : "",
|
||||||
|
do_tag ? tag : "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (classification & MM_CONSOLE)
|
__libc_lock_unlock (lock);
|
||||||
{
|
|
||||||
int do_label = label != MM_NULLLBL;
|
|
||||||
int do_severity = severity != MM_NULLSEV;
|
|
||||||
int do_text = text != MM_NULLTXT;
|
|
||||||
int do_action = action != MM_NULLACT;
|
|
||||||
int do_tag = tag != MM_NULLTAG;
|
|
||||||
|
|
||||||
syslog (LOG_ERR, "%s%s%s%s%s%s%s%s%s%s\n",
|
|
||||||
do_label ? label : "",
|
|
||||||
do_label && (do_severity | do_text | do_action | do_tag)
|
|
||||||
? ": " : "",
|
|
||||||
do_severity ? severity_rec->string : "",
|
|
||||||
do_severity && (do_text | do_action | do_tag) ? ": " : "",
|
|
||||||
do_text ? text : "",
|
|
||||||
do_text && (do_action | do_tag) ? "\n" : "",
|
|
||||||
do_action ? "TO FIX: " : "",
|
|
||||||
do_action ? action : "",
|
|
||||||
do_action && do_tag ? " " : "",
|
|
||||||
do_tag ? tag : "");
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __libc_ptf_call
|
#ifdef __libc_ptf_call
|
||||||
__libc_ptf_call (pthread_setcancelstate, (state, NULL), 0);
|
__libc_ptf_call (pthread_setcancelstate, (state, NULL), 0);
|
||||||
|
Reference in New Issue
Block a user