diff options
author | Denis Vlasenko | 2007-05-29 21:41:28 +0000 |
---|---|---|
committer | Denis Vlasenko | 2007-05-29 21:41:28 +0000 |
commit | 4ef7d3a2de3df27dde80a64987202f10aebfe925 (patch) | |
tree | c34efb08a5db806cdee923dd81fffdd8c46f0cdd /libbb/verror_msg.c | |
parent | fe3e1776ada6bf8cf39e08f4974bd6cc6d29175d (diff) | |
download | busybox-4ef7d3a2de3df27dde80a64987202f10aebfe925.zip busybox-4ef7d3a2de3df27dde80a64987202f10aebfe925.tar.gz |
verror_msg: don't printf(NULL)
Diffstat (limited to 'libbb/verror_msg.c')
-rw-r--r-- | libbb/verror_msg.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/libbb/verror_msg.c b/libbb/verror_msg.c index 526b9d3..082e7bf 100644 --- a/libbb/verror_msg.c +++ b/libbb/verror_msg.c @@ -20,6 +20,9 @@ void bb_verror_msg(const char *s, va_list p, const char* strerr) va_list p2; va_copy(p2, p); + if (!s) /* nomsg[_and_die] uses NULL fmt */ + s = ""; /* some libc don't like printf(NULL) */ + if (logmode & LOGMODE_STDIO) { fflush(stdout); fprintf(stderr, "%s: ", applet_name); @@ -28,7 +31,7 @@ void bb_verror_msg(const char *s, va_list p, const char* strerr) fputs(msg_eol, stderr); else fprintf(stderr, "%s%s%s", - s ? ": " : "", + s[0] ? ": " : "", strerr, msg_eol); } if (ENABLE_FEATURE_SYSLOG && (logmode & LOGMODE_SYSLOG)) { @@ -36,8 +39,10 @@ void bb_verror_msg(const char *s, va_list p, const char* strerr) vsyslog(LOG_ERR, s, p2); else { char *msg; - if (vasprintf(&msg, s, p2) < 0) - bb_error_msg_and_die(bb_msg_memory_exhausted); + if (vasprintf(&msg, s, p2) < 0) { + fprintf(stderr, "%s: %s\n", applet_name, bb_msg_memory_exhausted); + xfunc_die(); + } syslog(LOG_ERR, "%s: %s", msg, strerr); free(msg); } |