allowfunc gmtime
allowfunc localtime
allowfunc open
+allowfunc snprintf
allowfunc socket
+allowfunc sscanf
+banfunc curl_maprintf
+banfunc curl_mfprintf
+banfunc curl_mprintf
+banfunc curl_msnprintf
+banfunc curl_mvaprintf
+banfunc curl_mvfprintf
+banfunc curl_mvprintf
+banfunc curl_mvsnprintf
smtp-tls \
smtp-vrfy \
sslbackend \
+ synctime \
unixsocket \
url2file \
urlapi \
multithread.c \
sessioninfo.c \
smooth-gtk-thread.c \
- synctime.c \
threaded-ssl.c \
usercertinmem.c \
version-check.pl \
case 'm':
case 'M':
if(argv[0][2] == '=') {
- long m = strtol((*argv) + 3, NULL, 10);
+ int m = atoi((*argv) + 3);
switch(m) {
case 1:
url = URL_1M;
#include <curl/curl.h>
#include <curl/mprintf.h>
+#if defined(_MSC_VER) && (_MSC_VER < 1900)
+#define snprintf _snprintf
+#endif
+
static int print_cookies(CURL *curl)
{
CURLcode res;
printf("-----------------------------------------------\n"
"Setting a cookie \"PREF\" via cookie interface:\n");
/* Netscape format cookie */
- curl_msnprintf(nline, sizeof(nline), "%s\t%s\t%s\t%s\t%.0f\t%s\t%s",
- ".example.com", "TRUE", "/", "FALSE",
- difftime(time(NULL) + 31337, (time_t)0),
- "PREF", "hello example, i like you!");
+ snprintf(nline, sizeof(nline), "%s\t%s\t%s\t%s\t%.0f\t%s\t%s",
+ ".example.com", "TRUE", "/", "FALSE",
+ difftime(time(NULL) + 31337, (time_t)0),
+ "PREF", "hello example, I like you!");
res = curl_easy_setopt(curl, CURLOPT_COOKIELIST, nline);
if(res != CURLE_OK) {
fprintf(stderr, "Curl curl_easy_setopt failed: %s\n",
modified, likely not what you intended. For more information refer to
the CURLOPT_COOKIELIST documentation.
*/
- curl_msnprintf(nline, sizeof(nline),
+ snprintf(nline, sizeof(nline),
"Set-Cookie: OLD_PREF=3d141414bf4209321; "
"expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/; domain=.example.com");
res = curl_easy_setopt(curl, CURLOPT_COOKIELIST, nline);
#include <curl/curl.h>
#include <curl/mprintf.h>
+#if defined(_MSC_VER) && (_MSC_VER < 1900)
+#define snprintf _snprintf
+#endif
+
#ifndef CURLPIPE_MULTIPLEX
/* This little trick makes sure that we do not enable pipelining for libcurls
old enough to not have this symbol. It is _not_ defined to zero in a recent
hnd = t->easy = curl_easy_init();
- curl_msnprintf(filename, 128, "dl-%d", num);
+ snprintf(filename, sizeof(filename), "dl-%d", num);
t->out = fopen(filename, "wb");
if(!t->out) {
#include <curl/curl.h>
#include <curl/mprintf.h>
+#if defined(_MSC_VER) && (_MSC_VER < 1900)
+#define snprintf _snprintf
+#endif
+
#ifndef CURLPIPE_MULTIPLEX
#error "too old libcurl, cannot do HTTP/2 server push!"
#endif
(void)parent;
- curl_msnprintf(filename, 128, "push%u", count++);
+ snprintf(filename, sizeof(filename), "push%u", count++);
/* here's a new stream, save it in a new file for each new push */
out = fopen(filename, "wb");
#ifndef _MSC_VER
#include <sys/time.h>
#include <unistd.h>
+#elif (_MSC_VER < 1900)
+#define snprintf _snprintf
#endif
#ifdef _WIN32
}
secs = epoch_offset + tv.tv_sec;
now = localtime(&secs); /* not thread safe but we do not care */
- curl_msnprintf(timebuf, sizeof(timebuf), "%02d:%02d:%02d.%06ld",
- now->tm_hour, now->tm_min, now->tm_sec, (long)tv.tv_usec);
+ snprintf(timebuf, sizeof(timebuf), "%02d:%02d:%02d.%06ld",
+ now->tm_hour, now->tm_min, now->tm_sec, (long)tv.tv_usec);
switch(type) {
case CURLINFO_TEXT:
hnd = i->hnd = NULL;
i->num = num;
- curl_msnprintf(filename, 128, "dl-%d", num);
+ snprintf(filename, sizeof(filename), "dl-%d", num);
out = fopen(filename, "wb");
if(!out) {
fprintf(stderr, "error: could not open file %s for writing: %s\n", upload,
return 1;
}
- curl_msnprintf(url, 256, "https://localhost:8443/upload-%d", num);
+ snprintf(url, sizeof(url), "https://localhost:8443/upload-%d", num);
i->in = fopen(upload, "rb");
if(!i->in) {
*/
#include <stdio.h>
-#include <time.h>
-#include <curl/curl.h>
-#ifdef _WIN32
-#include <windows.h>
+#ifndef _WIN32
+int main(void) { printf("Platform not supported.\n"); return 1; }
#else
-#error "This example requires Windows."
+
+#if (defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0602)) || \
+ defined(WINAPI_FAMILY)
+# include <winapifamily.h>
+# if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && \
+ !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+# define CURL_WINDOWS_UWP
+# endif
#endif
+#ifdef CURL_WINDOWS_UWP
+int main(void) { printf("Platform not supported.\n"); return 1; }
+#else
+
+#include <windows.h>
+#include <time.h>
+
+#include <curl/curl.h>
+
+#if defined(_MSC_VER) && (_MSC_VER < 1900)
+#define snprintf _snprintf
+#endif
#define MAX_STRING 256
#define MAX_STRING1 MAX_STRING + 1
*TmpStr1 = 0;
*TmpStr2 = 0;
if(strlen((char *)(ptr)) > 50) /* Can prevent buffer overflow to
- TmpStr1 & 2? */
+ TmpStr1 & 2? */
AutoSyncTime = 0;
else {
int RetVal = sscanf((char *)(ptr), "Date: %25s %hu %s %hu %hu:%hu:%hu",
tzonediffFloat = difftime(tt_local, tt_gmt);
tzonediffWord = (int)(tzonediffFloat/3600.0);
- if((double)(tzonediffWord * 3600) == tzonediffFloat)
+ if(tzonediffWord == (int)(tzonediffFloat/3600.0))
snprintf(tzoneBuf, sizeof(tzoneBuf), "%+03d'00'", tzonediffWord);
else
snprintf(tzoneBuf, sizeof(tzoneBuf), "%+03d'30'", tzonediffWord);
}
return RetValue;
}
+#endif /* CURL_WINDOWS_UWP */
+#endif /* _WIN32 */
strtok_r
strtol
strtoul
- vsnprint
+ vsnprintf
vsprintf
wcsdup
-banfunc snprintf
-banfunc sscanf
banfunc strerror
-banfunc strtol
-banfunc vsnprint
-banfunc snprintf
-banfunc sscanf
banfunc strerror
-banfunc strtol
-banfunc vsnprint
-banfunc snprintf
-banfunc sscanf
banfunc strerror
-banfunc strtol
-banfunc vsnprint
-banfunc snprintf
-banfunc sscanf
banfunc strerror
-banfunc strtol
-banfunc vsnprint
-banfunc snprintf
-banfunc sscanf
banfunc strerror
-banfunc strtol
-banfunc vsnprint
-banfunc snprintf
-banfunc sscanf
banfunc strerror
-banfunc strtol
-banfunc vsnprint
"gets" => 1,
"strtok" => 1,
"sprintf" => 1,
+ "snprintf" => 1,
"vsprintf" => 1,
+ "vsnprintf" => 1,
+ "sscanf" => 1,
"strcat" => 1,
"strncat" => 1,
"strncpy" => 1,
"strtok_r" => 1,
+ "strtol" => 1,
"strtoul" => 1,
"_mbscat" => 1,
"_mbsncat" => 1,
enable STDERR
-banfunc snprintf
-banfunc sscanf
-banfunc strtol
-banfunc vsnprint
forbid_reuse_d = 1;
break;
case 'm':
- max_parallel = (size_t)strtol(coptarg, NULL, 10);
+ max_parallel = (size_t)atol(coptarg);
break;
case 'n':
- transfer_count_d = (size_t)strtol(coptarg, NULL, 10);
+ transfer_count_d = (size_t)atol(coptarg);
break;
case 'x':
fresh_connect = 1;
break;
case 'A':
- abort_offset = (size_t)strtol(coptarg, NULL, 10);
+ abort_offset = (size_t)atol(coptarg);
break;
case 'F':
- fail_offset = (size_t)strtol(coptarg, NULL, 10);
+ fail_offset = (size_t)atol(coptarg);
break;
case 'M':
- max_host_conns = (size_t)strtol(coptarg, NULL, 10);
+ max_host_conns = (size_t)atol(coptarg);
break;
case 'P':
- pause_offset = (size_t)strtol(coptarg, NULL, 10);
+ pause_offset = (size_t)atol(coptarg);
break;
case 'r':
free(resolve);
resolve = strdup(coptarg);
break;
case 'T':
- max_total_conns = (size_t)strtol(coptarg, NULL, 10);
+ max_total_conns = (size_t)atol(coptarg);
break;
case 'V': {
if(!strcmp("http/1.1", coptarg))
announce_length = 1;
break;
case 'm':
- max_parallel = (size_t)strtol(coptarg, NULL, 10);
+ max_parallel = (size_t)atol(coptarg);
break;
case 'n':
- transfer_count_u = (size_t)strtol(coptarg, NULL, 10);
+ transfer_count_u = (size_t)atol(coptarg);
break;
case 'A':
- abort_offset = (size_t)strtol(coptarg, NULL, 10);
+ abort_offset = (size_t)atol(coptarg);
break;
case 'F':
- fail_offset = (size_t)strtol(coptarg, NULL, 10);
+ fail_offset = (size_t)atol(coptarg);
break;
case 'M':
method = coptarg;
break;
case 'P':
- pause_offset = (size_t)strtol(coptarg, NULL, 10);
+ pause_offset = (size_t)atol(coptarg);
break;
case 'r':
resolve = coptarg;
reuse_easy = 1;
break;
case 'S':
- send_total = (size_t)strtol(coptarg, NULL, 10);
+ send_total = (size_t)atol(coptarg);
break;
case 'V': {
if(!strcmp("http/1.1", coptarg))
res = CURLE_BAD_FUNCTION_ARGUMENT;
goto cleanup;
case 'c':
- count = (size_t)strtol(coptarg, NULL, 10);
+ count = (size_t)atol(coptarg);
break;
case 'm':
- plen_min = (size_t)strtol(coptarg, NULL, 10);
+ plen_min = (size_t)atol(coptarg);
break;
case 'M':
- plen_max = (size_t)strtol(coptarg, NULL, 10);
+ plen_max = (size_t)atol(coptarg);
break;
default:
test_ws_data_usage("invalid option");
/* if CURL_MEMLIMIT is set, this enables fail-on-alloc-number-N feature */
env = getenv("CURL_MEMLIMIT");
if(env) {
- char *endptr;
- long num = strtol(env, &endptr, 10);
- if((endptr != env) && (endptr == env + strlen(env)) && (num > 0))
+ long num = atol(env);
+ if(num > 0)
curl_dbg_memlimit(num);
}
}
memset(value, 0, sizeof(value)); /* Avoid valgrind false positive. */
memcpy(buf, p, n);
buf[n] = 0;
+ /* !checksrc! disable BANNEDFUNC 1 */
if(sscanf(buf, "%79[^=]=%79[^,]", part, value) == 2) {
CURLUPart what = part2id(part);
#if 0
curl_easy_setopt(hnd, CURLOPT_USERAGENT, "lib1568");
curl_easy_setopt(hnd, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L);
- curl_easy_setopt(hnd, CURLOPT_PORT, strtol(libtest_arg2, NULL, 10));
+ curl_easy_setopt(hnd, CURLOPT_PORT, atol(libtest_arg2));
ret = curl_easy_perform(hnd);
}
test_setopt(curl, CURLOPT_URL, URL);
- test_setopt(curl, CURLOPT_PORT, strtol(libtest_arg2, NULL, 10));
+ test_setopt(curl, CURLOPT_PORT, atol(libtest_arg2));
test_setopt(curl, CURLOPT_USERPWD, "xxx:yyy");
test_setopt(curl, CURLOPT_VERBOSE, 1L);
test_setopt(curl, CURLOPT_VERBOSE, 1L);
/* set port number */
- test_setopt(curl, CURLOPT_PORT, strtol(libtest_arg2, NULL, 10));
+ test_setopt(curl, CURLOPT_PORT, atol(libtest_arg2));
/* specify target */
test_setopt(curl, CURLOPT_URL, URL);
easy_setopt(easy, CURLOPT_FTPPORT, "-");
/* server connection timeout */
- easy_setopt(easy, CURLOPT_ACCEPTTIMEOUT_MS,
- strtol(libtest_arg2, NULL, 10)*1000);
+ easy_setopt(easy, CURLOPT_ACCEPTTIMEOUT_MS, atol(libtest_arg2)*1000);
multi_init(multi);
allowfunc open
allowfunc recv
allowfunc send
+allowfunc snprintf
allowfunc socket
-allowfunc strtoul
+allowfunc sscanf
+allowfunc vsnprintf
else if(!strcmp("--port", argv[arg])) {
arg++;
if(argc > arg) {
- char *endptr;
- unsigned long ulnum = strtoul(argv[arg], &endptr, 10);
- port = util_ultous(ulnum);
+ port = (unsigned short)atoi(argv[arg]);
arg++;
}
}
extern int bind_unix_socket(curl_socket_t sock, const char *unix_socket,
struct sockaddr_un *sau);
#endif
-extern unsigned short util_ultous(unsigned long ulnum);
extern curl_socket_t sockdaemon(curl_socket_t sock,
unsigned short *listenport,
const char *unix_socket,
else if(!strcmp("--port", argv[arg])) {
arg++;
if(argc > arg) {
- char *endptr;
- unsigned long ulnum = strtoul(argv[arg], &endptr, 10);
- if((endptr != argv[arg] + strlen(argv[arg])) ||
- ((ulnum != 0UL) && ((ulnum < 1025UL) || (ulnum > 65535UL)))) {
+ int inum = atoi(argv[arg]);
+ if(inum && ((inum < 1025) || (inum > 65535))) {
fprintf(stderr, "mqttd: invalid --port argument (%s)\n",
argv[arg]);
return 0;
}
- server_port = util_ultous(ulnum);
+ server_port = (unsigned short)inum;
arg++;
}
}
while(*ptr && !ISDIGIT(*ptr))
ptr++;
- req->testno = strtol(ptr, &ptr, 10);
+ req->testno = atol(ptr);
if(req->testno > 10000) {
req->partno = req->testno % 10000;
CONNECT line will be used as test number! */
char *portp = strchr(doc, ':');
if(portp && (*(portp + 1) != '\0') && ISDIGIT(*(portp + 1)))
- req->testno = strtol(portp + 1, NULL, 10);
+ req->testno = atol(portp + 1);
else
req->testno = DOCNUMBER_CONNECT;
}
else if(!strcmp("--port", argv[arg])) {
arg++;
if(argc > arg) {
- char *endptr;
- unsigned long ulnum = strtoul(argv[arg], &endptr, 10);
- port = util_ultous(ulnum);
+ port = (unsigned short)atol(argv[arg]);
arg++;
}
}
buffer[5] = '\0';
+ /* !checksrc! disable BANNEDFUNC 1 */
*buffer_len = (ssize_t)strtol((char *)buffer, NULL, 16);
if(*buffer_len > maxlen) {
logmsg("Buffer size (%zd bytes) too small for data size error "
else if(!strcmp("--port", argv[arg])) {
arg++;
if(argc > arg) {
- char *endptr;
- unsigned long ulnum = strtoul(argv[arg], &endptr, 10);
- server_port = util_ultous(ulnum);
+ server_port = (unsigned short)atol(argv[arg]);
arg++;
}
}
doing a passive server-style listening. */
arg++;
if(argc > arg) {
- char *endptr;
- unsigned long ulnum = strtoul(argv[arg], &endptr, 10);
- if((endptr != argv[arg] + strlen(argv[arg])) ||
- (ulnum < 1025UL) || (ulnum > 65535UL)) {
+ int inum = atoi(argv[arg]);
+ if(inum && ((inum < 1025) || (inum > 65535))) {
fprintf(stderr, "sockfilt: invalid --connect argument (%s)\n",
argv[arg]);
return 0;
}
- server_connectport = util_ultous(ulnum);
+ server_connectport = (unsigned short)inum;
arg++;
}
}
static unsigned short shortval(char *value)
{
- unsigned long num = strtoul(value, NULL, 10);
+ unsigned long num = (unsigned long)atol(value);
return num & 0xffff;
}
else if(!strcmp("--port", argv[arg])) {
arg++;
if(argc > arg) {
- char *endptr;
- unsigned long ulnum = strtoul(argv[arg], &endptr, 10);
- server_port = util_ultous(ulnum);
+ server_port = (unsigned short)atol(argv[arg]);
arg++;
}
}
ptr++; /* skip the slash */
- req->testno = strtol(ptr, &ptr, 10);
+ req->testno = atol(ptr);
if(req->testno > 10000) {
req->partno = req->testno % 10000;
in the 'part' variable and use as test case number!! */
while(*p && (ISXDIGIT(*p) || (*p == ':') || (*p == '.'))) {
char *endp;
+ /* !checksrc! disable BANNEDFUNC 1 */
part = strtoul(p, &endp, 16);
if(ISXDIGIT(*p))
p = endp;
portp = strchr(doc, ':');
if(portp && (*(portp + 1) != '\0') && ISDIGIT(*(portp + 1))) {
- unsigned long ulnum = strtoul(portp + 1, NULL, 10);
- if(!ulnum || (ulnum > 65535UL))
+ int inum = atoi(portp + 1);
+ if((inum <= 0) || (inum > 65535))
logmsg("Invalid CONNECT port received");
else
- req->connect_port = util_ultous(ulnum);
+ req->connect_port = (unsigned short)inum;
}
logmsg("Port number: %d, test case number: %ld",
/* check for a Testno: header with the test case number */
char *testno = strstr(line, "\nTestno: ");
if(testno) {
- req->testno = strtol(&testno[9], NULL, 10);
+ req->testno = atol(&testno[9]);
logmsg("Found test number %ld in Testno: header!", req->testno);
}
else {
while(*ptr && !ISDIGIT(*ptr))
ptr++;
- req->testno = strtol(ptr, &ptr, 10);
+ req->testno = atol(ptr);
if(req->testno > 10000) {
req->partno = req->testno % 10000;
else if(!strcmp("--port", argv[arg])) {
arg++;
if(argc > arg) {
- char *endptr;
- unsigned long ulnum = strtoul(argv[arg], &endptr, 10);
- if((endptr != argv[arg] + strlen(argv[arg])) ||
- (ulnum && ((ulnum < 1025UL) || (ulnum > 65535UL)))) {
+ int inum = atoi(argv[arg]);
+ if(inum && ((inum < 1025) || (inum > 65535))) {
fprintf(stderr, "sws: invalid --port argument (%s)\n",
argv[arg]);
return 0;
}
- port = util_ultous(ulnum);
+ port = (unsigned short)inum;
arg++;
}
}
else if(!strcmp("--keepalive", argv[arg])) {
arg++;
if(argc > arg) {
- char *endptr;
- unsigned long ulnum = strtoul(argv[arg], &endptr, 10);
- if((endptr != argv[arg] + strlen(argv[arg])) ||
- (ulnum && (ulnum > 65535UL))) {
+ int inum = atoi(argv[arg]);
+ if(inum && (inum > 65535)) {
fprintf(stderr, "sws: invalid --keepalive argument (%s), must "
"be number of seconds\n", argv[arg]);
return 0;
}
- keepalive_secs = util_ultous(ulnum);
+ keepalive_secs = (unsigned short)inum;
arg++;
}
}
else if(!strcmp("--port", argv[arg])) {
arg++;
if(argc > arg) {
- char *endptr;
- unsigned long ulnum = strtoul(argv[arg], &endptr, 10);
- port = util_ultous(ulnum);
+ port = (unsigned short)atol(argv[arg]);
arg++;
}
}
ptr++;
/* get the number */
- testno = strtol(ptr, &ptr, 10);
+ testno = atol(ptr);
if(testno > 10000) {
partno = testno % 10000;
unsigned char byteval(char *value)
{
- unsigned long num = strtoul(value, NULL, 10);
+ unsigned int num = (unsigned int)atoi(value);
return num & 0xff;
}
}
#endif
-/*
-** unsigned long to unsigned short
-*/
-#define CURL_MASK_USHORT ((unsigned short)~0)
-#define CURL_MASK_SSHORT (CURL_MASK_USHORT >> 1)
-
-unsigned short util_ultous(unsigned long ulnum)
-{
-#ifdef __INTEL_COMPILER
-# pragma warning(push)
-# pragma warning(disable:810) /* conversion may lose significant bits */
-#endif
-
- DEBUGASSERT(ulnum <= (unsigned long) CURL_MASK_USHORT);
- return (unsigned short)(ulnum & (unsigned long) CURL_MASK_USHORT);
-
-#ifdef __INTEL_COMPILER
-# pragma warning(pop)
-#endif
-}
-
curl_socket_t sockdaemon(curl_socket_t sock,
unsigned short *listenport,
const char *unix_socket,