commit 6e78e8022576955e89ff3626d9019320bd5d2228
parent f8441dac5fed1ce873728a9b71276c9321999aec
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date: Thu, 6 Oct 2022 19:13:52 +0300
testcurl/https: added proper check for snprintf() result
Diffstat:
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/src/testcurl/https/tls_test_common.c b/src/testcurl/https/tls_test_common.c
@@ -320,15 +320,18 @@ gen_test_file_url (char *url,
size_t url_len,
uint16_t port)
{
- unsigned int ret = 0;
- /* construct url */
- if ((size_t) snprintf (url,
- url_len,
- "https://127.0.0.1:%u/urlpath",
- (unsigned int) port) >= url_len)
- ret = 1;
+ int res;
- return ret;
+ res = snprintf (url,
+ url_len,
+ "https://127.0.0.1:%u/urlpath",
+ (unsigned int) port);
+ if (res <= 0)
+ return 1;
+ if ((size_t) res >= url_len)
+ return 1;
+
+ return 0;
}