mirror of
https://github.com/curl/curl.git
synced 2026-04-18 20:41:41 +03:00
tool_msgs: avoid null pointer deref for early errors
When errorf()/warnf() is used early on, before the global pointer is
setup, curl would previosly deref the null pointer.
Follow-up to 3b40128b0f
Found by Codex Security
Closes #20967
This commit is contained in:
parent
a43ea5943b
commit
acb4fcb2ef
1 changed files with 3 additions and 3 deletions
|
|
@ -78,7 +78,7 @@ static void voutf(const char *prefix, const char *fmt, va_list ap)
|
|||
*/
|
||||
void notef(const char *fmt, ...)
|
||||
{
|
||||
if(global->tracetype) {
|
||||
if(global && global->tracetype) {
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
voutf(NOTE_PREFIX, fmt, ap);
|
||||
|
|
@ -92,7 +92,7 @@ void notef(const char *fmt, ...)
|
|||
*/
|
||||
void warnf(const char *fmt, ...)
|
||||
{
|
||||
if(!global->silent) {
|
||||
if(!global || !global->silent) {
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
voutf(WARN_PREFIX, fmt, ap);
|
||||
|
|
@ -128,7 +128,7 @@ void helpf(const char *fmt, ...)
|
|||
*/
|
||||
void errorf(const char *fmt, ...)
|
||||
{
|
||||
if(!global->silent || global->showerror) {
|
||||
if(!global || !global->silent || global->showerror) {
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
voutf(ERROR_PREFIX, fmt, ap);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue