summaryrefslogtreecommitdiff
path: root/tests/libtest/libntlmconnect.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2016-04-01 10:14:06 +0200
committerDaniel Stenberg <daniel@haxx.se>2016-04-01 10:46:36 +0200
commit55452ebdff47f98bf3cc383f1dfc3623fcaefefd (patch)
treed17d3be8fd9482658f07ef6b4532da9502499cf0 /tests/libtest/libntlmconnect.c
parent7218b52c49aeb1452d1fb94b394b3de2da938f17 (diff)
downloadgnurl-55452ebdff47f98bf3cc383f1dfc3623fcaefefd.tar.gz
gnurl-55452ebdff47f98bf3cc383f1dfc3623fcaefefd.tar.bz2
gnurl-55452ebdff47f98bf3cc383f1dfc3623fcaefefd.zip
curl/mprintf.h: remove support for _MPRINTF_REPLACE
The define is not in our name space and is therefore not protected by our API promises. It was only really used by libcurl internals but was mostly erased from there already in 8aabbf5 (March 2015). This is supposedly the final death blow to that define from everywhere. As a side-effect, making sure _MPRINTF_REPLACE is gone and not used, I made the lib tests in tests/libtest/ use curl_printf.h for its redefine magic and then subsequently the use of sprintf() got banned in the tests as well (as it is in libcurl internals) and I then replaced them all with snprintf(). In the unlikely event that any users is actually using this define and gets sad by this change, it is very easily copied to the user's own code.
Diffstat (limited to 'tests/libtest/libntlmconnect.c')
-rw-r--r--tests/libtest/libntlmconnect.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/tests/libtest/libntlmconnect.c b/tests/libtest/libntlmconnect.c
index a9609673d..0e2e9f4a6 100644
--- a/tests/libtest/libntlmconnect.c
+++ b/tests/libtest/libntlmconnect.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2012 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2012 - 2016, 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
@@ -103,11 +103,12 @@ int test(char *url)
int i, j;
int num_handles = 0;
enum HandleState state = ReadyForNewHandle;
- char* full_url = malloc(strlen(url) + 4 + 1);
+ size_t urllen = strlen(url) + 4 + 1;
+ char* full_url = malloc(urllen);
start_test_timing();
- if (!full_url) {
+ if(!full_url) {
fprintf(stderr, "Not enough memory for full url\n");
return TEST_ERR_MAJOR_BAD;
}
@@ -141,14 +142,14 @@ int test(char *url)
bool found_new_socket = FALSE;
/* Start a new handle if we aren't at the max */
- if (state == ReadyForNewHandle) {
+ if(state == ReadyForNewHandle) {
easy_init(easy[num_handles]);
- if (num_handles % 3 == 2) {
- sprintf(full_url, "%s0200", url);
+ if(num_handles % 3 == 2) {
+ snprintf(full_url, urllen, "%s0200", url);
easy_setopt(easy[num_handles], CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
} else {
- sprintf(full_url, "%s0100", url);
+ snprintf(full_url, urllen, "%s0100", url);
easy_setopt(easy[num_handles], CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
}
easy_setopt(easy[num_handles], CURLOPT_FRESH_CONNECT, 1L);
@@ -185,30 +186,30 @@ int test(char *url)
bool socket_exists = FALSE;
curl_socket_t curfd = (curl_socket_t)i;
- if (!FD_ISSET(curfd, &fdread)) {
+ if(!FD_ISSET(curfd, &fdread)) {
continue;
}
/* Check if this socket was already detected for an earlier handle (or
for this handle, num_handles-1, in the callback */
for (j = 0; j < num_handles; ++j) {
- if (sockets[j] == curfd) {
+ if(sockets[j] == curfd) {
socket_exists = TRUE;
break;
}
}
- if (socket_exists) {
+ if(socket_exists) {
continue;
}
- if (found_new_socket || state != NeedSocketForNewHandle) {
+ if(found_new_socket || state != NeedSocketForNewHandle) {
fprintf(stderr, "Unexpected new socket\n");
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
/* Now we know the socket is for the most recent handle, num_handles-1 */
- if (sockets[num_handles-1] != CURL_SOCKET_BAD) {
+ if(sockets[num_handles-1] != CURL_SOCKET_BAD) {
/* A socket for this handle was already detected in the callback; if it
matched socket_exists should be true and we would never get here */
assert(curfd != sockets[num_handles-1]);
@@ -224,7 +225,7 @@ int test(char *url)
}
}
- if (state == NeedSocketForNewHandle) {
+ if(state == NeedSocketForNewHandle) {
if(maxfd != -1 && !found_new_socket) {
fprintf(stderr, "Warning: socket did not open immediately for new "
"handle (trying again)\n");