From dcd6f810255785d52b89150e18460fb0899d4f7e Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 22 Nov 2018 09:01:24 +0100 Subject: 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 --- tests/unit/unit1604.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'tests/unit/unit1604.c') diff --git a/tests/unit/unit1604.c b/tests/unit/unit1604.c index fbfd2c423..c285ced43 100644 --- a/tests/unit/unit1604.c +++ b/tests/unit/unit1604.c @@ -46,11 +46,15 @@ static char *getflagstr(int flags) { char *buf = malloc(256); if(buf) { - snprintf(buf, 256, "%s,%s,%s,%s", - ((flags & SANITIZE_ALLOW_COLONS) ? "SANITIZE_ALLOW_COLONS" : ""), - ((flags & SANITIZE_ALLOW_PATH) ? "SANITIZE_ALLOW_PATH" : ""), - ((flags & SANITIZE_ALLOW_RESERVED) ? "SANITIZE_ALLOW_RESERVED" : ""), - ((flags & SANITIZE_ALLOW_TRUNCATE) ? "SANITIZE_ALLOW_TRUNCATE" : "")); + msnprintf(buf, 256, "%s,%s,%s,%s", + ((flags & SANITIZE_ALLOW_COLONS) ? + "SANITIZE_ALLOW_COLONS" : ""), + ((flags & SANITIZE_ALLOW_PATH) ? + "SANITIZE_ALLOW_PATH" : ""), + ((flags & SANITIZE_ALLOW_RESERVED) ? + "SANITIZE_ALLOW_RESERVED" : ""), + ((flags & SANITIZE_ALLOW_TRUNCATE) ? + "SANITIZE_ALLOW_TRUNCATE" : "")); } return buf; } @@ -59,13 +63,13 @@ static char *getcurlcodestr(int cc) { char *buf = malloc(256); if(buf) { - snprintf(buf, 256, "%s (%d)", - (cc == SANITIZE_ERR_OK ? "SANITIZE_ERR_OK" : - cc == SANITIZE_ERR_BAD_ARGUMENT ? "SANITIZE_ERR_BAD_ARGUMENT" : - cc == SANITIZE_ERR_INVALID_PATH ? "SANITIZE_ERR_INVALID_PATH" : - cc == SANITIZE_ERR_OUT_OF_MEMORY ? "SANITIZE_ERR_OUT_OF_MEMORY" : - "unexpected error code - add name"), - cc); + msnprintf(buf, 256, "%s (%d)", + (cc == SANITIZE_ERR_OK ? "SANITIZE_ERR_OK" : + cc == SANITIZE_ERR_BAD_ARGUMENT ? "SANITIZE_ERR_BAD_ARGUMENT" : + cc == SANITIZE_ERR_INVALID_PATH ? "SANITIZE_ERR_INVALID_PATH" : + cc == SANITIZE_ERR_OUT_OF_MEMORY ? "SANITIZE_ERR_OUT_OF_MEMORY": + "unexpected error code - add name"), + cc); } return buf; } -- cgit v1.2.3