diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2022-10-06 19:13:52 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2022-10-10 11:54:32 +0300 |
commit | 6e78e8022576955e89ff3626d9019320bd5d2228 (patch) | |
tree | 9cbd1b85606462b0958e398adc14910f7f2f8ed9 | |
parent | f8441dac5fed1ce873728a9b71276c9321999aec (diff) | |
download | libmicrohttpd-6e78e8022576955e89ff3626d9019320bd5d2228.tar.gz libmicrohttpd-6e78e8022576955e89ff3626d9019320bd5d2228.zip |
testcurl/https: added proper check for snprintf() result
-rw-r--r-- | src/testcurl/https/tls_test_common.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/testcurl/https/tls_test_common.c b/src/testcurl/https/tls_test_common.c index 639bccf1..f27813a2 100644 --- 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, | |||
320 | size_t url_len, | 320 | size_t url_len, |
321 | uint16_t port) | 321 | uint16_t port) |
322 | { | 322 | { |
323 | unsigned int ret = 0; | 323 | int res; |
324 | /* construct url */ | ||
325 | if ((size_t) snprintf (url, | ||
326 | url_len, | ||
327 | "https://127.0.0.1:%u/urlpath", | ||
328 | (unsigned int) port) >= url_len) | ||
329 | ret = 1; | ||
330 | 324 | ||
331 | return ret; | 325 | res = snprintf (url, |
326 | url_len, | ||
327 | "https://127.0.0.1:%u/urlpath", | ||
328 | (unsigned int) port); | ||
329 | if (res <= 0) | ||
330 | return 1; | ||
331 | if ((size_t) res >= url_len) | ||
332 | return 1; | ||
333 | |||
334 | return 0; | ||
332 | } | 335 | } |
333 | 336 | ||
334 | 337 | ||