mirror of
https://github.com/curl/curl.git
synced 2026-08-25 14:23:39 +03:00
snprintf: renamed and we now only use msnprintf()
The function does not return the same value as snprintf() normally does, so readers may be mislead into thinking the code works differently than it actually does. A different function name makes this easier to detect. Reported-by: Tomas Hoger Assisted-by: Daniel Gustafsson Fixes #3296 Closes #3297
This commit is contained in:
parent
9944d6ba33
commit
dcd6f81025
92 changed files with 632 additions and 631 deletions
|
|
@ -5,7 +5,7 @@
|
|||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 2004 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 2004 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
|
|
@ -681,7 +681,7 @@ const char *Curl_strerror(struct connectdata *conn, int err)
|
|||
if(!get_winsock_error(err, buf, max) &&
|
||||
!FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err,
|
||||
LANG_NEUTRAL, buf, (DWORD)max, NULL))
|
||||
snprintf(buf, max, "Unknown error %d (%#x)", err, err);
|
||||
msnprintf(buf, max, "Unknown error %d (%#x)", err, err);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -695,7 +695,7 @@ const char *Curl_strerror(struct connectdata *conn, int err)
|
|||
*/
|
||||
if(0 != strerror_r(err, buf, max)) {
|
||||
if('\0' == buf[0])
|
||||
snprintf(buf, max, "Unknown error %d", err);
|
||||
msnprintf(buf, max, "Unknown error %d", err);
|
||||
}
|
||||
#elif defined(HAVE_STRERROR_R) && defined(HAVE_GLIBC_STRERROR_R)
|
||||
/*
|
||||
|
|
@ -709,7 +709,7 @@ const char *Curl_strerror(struct connectdata *conn, int err)
|
|||
if(msg)
|
||||
strncpy(buf, msg, max);
|
||||
else
|
||||
snprintf(buf, max, "Unknown error %d", err);
|
||||
msnprintf(buf, max, "Unknown error %d", err);
|
||||
}
|
||||
#elif defined(HAVE_STRERROR_R) && defined(HAVE_VXWORKS_STRERROR_R)
|
||||
/*
|
||||
|
|
@ -721,7 +721,7 @@ const char *Curl_strerror(struct connectdata *conn, int err)
|
|||
if(OK == strerror_r(err, buffer))
|
||||
strncpy(buf, buffer, max);
|
||||
else
|
||||
snprintf(buf, max, "Unknown error %d", err);
|
||||
msnprintf(buf, max, "Unknown error %d", err);
|
||||
}
|
||||
#else
|
||||
{
|
||||
|
|
@ -729,7 +729,7 @@ const char *Curl_strerror(struct connectdata *conn, int err)
|
|||
if(msg)
|
||||
strncpy(buf, msg, max);
|
||||
else
|
||||
snprintf(buf, max, "Unknown error %d", err);
|
||||
msnprintf(buf, max, "Unknown error %d", err);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -1032,14 +1032,14 @@ const char *Curl_sspi_strerror (struct connectdata *conn, int err)
|
|||
if(err == SEC_E_OK)
|
||||
strncpy(outbuf, txt, outmax);
|
||||
else if(err == SEC_E_ILLEGAL_MESSAGE)
|
||||
snprintf(outbuf, outmax,
|
||||
"SEC_E_ILLEGAL_MESSAGE (0x%08X) - This error usually occurs "
|
||||
"when a fatal SSL/TLS alert is received (e.g. handshake failed). "
|
||||
"More detail may be available in the Windows System event log.",
|
||||
err);
|
||||
msnprintf(outbuf, outmax,
|
||||
"SEC_E_ILLEGAL_MESSAGE (0x%08X) - This error usually occurs "
|
||||
"when a fatal SSL/TLS alert is received (e.g. handshake failed)."
|
||||
" More detail may be available in the Windows System event log.",
|
||||
err);
|
||||
else {
|
||||
str = txtbuf;
|
||||
snprintf(txtbuf, sizeof(txtbuf), "%s (0x%08X)", txt, err);
|
||||
msnprintf(txtbuf, sizeof(txtbuf), "%s (0x%08X)", txt, err);
|
||||
txtbuf[sizeof(txtbuf)-1] = '\0';
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
|
|
@ -1075,7 +1075,7 @@ const char *Curl_sspi_strerror (struct connectdata *conn, int err)
|
|||
msg = msgbuf;
|
||||
}
|
||||
if(msg)
|
||||
snprintf(outbuf, outmax, "%s - %s", str, msg);
|
||||
msnprintf(outbuf, outmax, "%s - %s", str, msg);
|
||||
else
|
||||
strncpy(outbuf, str, outmax);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue