diff options
Diffstat (limited to 'tests/server')
-rw-r--r-- | tests/server/fake_ntlm.c | 8 | ||||
-rw-r--r-- | tests/server/rtspd.c | 32 | ||||
-rw-r--r-- | tests/server/sockfilt.c | 16 | ||||
-rw-r--r-- | tests/server/sws.c | 46 | ||||
-rw-r--r-- | tests/server/tftpd.c | 10 | ||||
-rw-r--r-- | tests/server/util.c | 15 |
6 files changed, 64 insertions, 63 deletions
diff --git a/tests/server/fake_ntlm.c b/tests/server/fake_ntlm.c index ec127a8af..c6e36b6f6 100644 --- a/tests/server/fake_ntlm.c +++ b/tests/server/fake_ntlm.c @@ -6,7 +6,7 @@ * \___|\___/|_| \_\_____| * * Copyright (C) 2010, Mandy Wu, <mandy.wu@intel.com> - * Copyright (C) 2011 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 2011 - 2018, 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 @@ -75,7 +75,7 @@ static char *printable(char *inbuf, size_t inlength) return NULL; if(!inlength) { - snprintf(&outbuf[0], outsize, "%s", NOTHING_STR); + msnprintf(&outbuf[0], outsize, "%s", NOTHING_STR); return outbuf; } @@ -97,7 +97,7 @@ static char *printable(char *inbuf, size_t inlength) o++; } else { - snprintf(&outbuf[o], outsize - o, HEX_FMT_STR, inbuf[i]); + msnprintf(&outbuf[o], outsize - o, HEX_FMT_STR, inbuf[i]); o += HEX_STR_LEN; } @@ -174,7 +174,7 @@ int main(int argc, char *argv[]) } /* logmsg cannot be used until this file name is set */ - snprintf(logfilename, sizeof(logfilename), LOGFILE, testnum); + msnprintf(logfilename, sizeof(logfilename), LOGFILE, testnum); serverlogfile = logfilename; logmsg("fake_ntlm (user: %s) (proto: %s) (domain: %s) (cached creds: %s)", diff --git a/tests/server/rtspd.c b/tests/server/rtspd.c index 0629d8a53..7563fd22a 100644 --- a/tests/server/rtspd.c +++ b/tests/server/rtspd.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2018, 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 @@ -382,11 +382,11 @@ static int ProcessRequest(struct httprequest *req) char *filename; if((strlen(doc) + strlen(request)) < 200) - snprintf(logbuf, sizeof(logbuf), "Got request: %s %s %s/%d.%d", - request, doc, prot_str, prot_major, prot_minor); + msnprintf(logbuf, sizeof(logbuf), "Got request: %s %s %s/%d.%d", + request, doc, prot_str, prot_major, prot_minor); else - snprintf(logbuf, sizeof(logbuf), "Got a *HUGE* request %s/%d.%d", - prot_str, prot_major, prot_minor); + msnprintf(logbuf, sizeof(logbuf), "Got a *HUGE* request %s/%d.%d", + prot_str, prot_major, prot_minor); logmsg("%s", logbuf); if(!strncmp("/verifiedserver", ptr, 15)) { @@ -416,8 +416,8 @@ static int ProcessRequest(struct httprequest *req) else req->partno = 0; - snprintf(logbuf, sizeof(logbuf), "Requested test number %ld part %ld", - req->testno, req->partno); + msnprintf(logbuf, sizeof(logbuf), "Requested test number %ld part %ld", + req->testno, req->partno); logmsg("%s", logbuf); filename = test2file(req->testno); @@ -540,9 +540,9 @@ static int ProcessRequest(struct httprequest *req) else { if(sscanf(req->reqbuf, "CONNECT %" MAXDOCNAMELEN_TXT "s HTTP/%d.%d", doc, &prot_major, &prot_minor) == 3) { - snprintf(logbuf, sizeof(logbuf), - "Received a CONNECT %s HTTP/%d.%d request", - doc, prot_major, prot_minor); + msnprintf(logbuf, sizeof(logbuf), + "Received a CONNECT %s HTTP/%d.%d request", + doc, prot_major, prot_minor); logmsg("%s", logbuf); if(req->prot_version == 10) @@ -947,12 +947,12 @@ static int send_doc(curl_socket_t sock, struct httprequest *req) case DOCNUMBER_WERULEZ: /* we got a "friends?" question, reply back that we sure are */ logmsg("Identifying ourselves as friends"); - snprintf(msgbuf, sizeof(msgbuf), "RTSP_SERVER WE ROOLZ: %ld\r\n", - (long)getpid()); + msnprintf(msgbuf, sizeof(msgbuf), "RTSP_SERVER WE ROOLZ: %ld\r\n", + (long)getpid()); msglen = strlen(msgbuf); - snprintf(weare, sizeof(weare), - "HTTP/1.1 200 OK\r\nContent-Length: %zu\r\n\r\n%s", - msglen, msgbuf); + msnprintf(weare, sizeof(weare), + "HTTP/1.1 200 OK\r\nContent-Length: %zu\r\n\r\n%s", + msglen, msgbuf); buffer = weare; break; case DOCNUMBER_INTERNAL: @@ -985,7 +985,7 @@ static int send_doc(curl_socket_t sock, struct httprequest *req) char partbuf[80]="data"; FILE *stream; if(0 != req->partno) - snprintf(partbuf, sizeof(partbuf), "data%ld", req->partno); + msnprintf(partbuf, sizeof(partbuf), "data%ld", req->partno); stream = fopen(filename, "rb"); if(!stream) { diff --git a/tests/server/sockfilt.c b/tests/server/sockfilt.c index 86a1ff52d..569be6f6c 100644 --- a/tests/server/sockfilt.c +++ b/tests/server/sockfilt.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2018, 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 @@ -486,20 +486,20 @@ static void lograw(unsigned char *buffer, ssize_t len) for(i = 0; i<len; i++) { switch(ptr[i]) { case '\n': - snprintf(optr, left, "\\n"); + msnprintf(optr, left, "\\n"); width += 2; optr += 2; left -= 2; break; case '\r': - snprintf(optr, left, "\\r"); + msnprintf(optr, left, "\\r"); width += 2; optr += 2; left -= 2; break; default: - snprintf(optr, left, "%c", (ISGRAPH(ptr[i]) || - ptr[i] == 0x20) ?ptr[i]:'.'); + msnprintf(optr, left, "%c", (ISGRAPH(ptr[i]) || + ptr[i] == 0x20) ?ptr[i]:'.'); width++; optr++; left--; @@ -1062,9 +1062,9 @@ static bool juggle(curl_socket_t *sockfdp, else if(!memcmp("PORT", buffer, 4)) { /* Question asking us what PORT number we are listening to. Replies to PORT with "IPv[num]/[port]" */ - snprintf((char *)buffer, sizeof(buffer), "%s/%hu\n", ipv_inuse, port); + msnprintf((char *)buffer, sizeof(buffer), "%s/%hu\n", ipv_inuse, port); buffer_len = (ssize_t)strlen((char *)buffer); - snprintf(data, sizeof(data), "PORT\n%04zx\n", buffer_len); + msnprintf(data, sizeof(data), "PORT\n%04zx\n", buffer_len); if(!write_stdout(data, 10)) return FALSE; if(!write_stdout(buffer, buffer_len)) @@ -1155,7 +1155,7 @@ static bool juggle(curl_socket_t *sockfdp, nread_socket = sread(sockfd, buffer, sizeof(buffer)); if(nread_socket > 0) { - snprintf(data, sizeof(data), "DATA\n%04zx\n", nread_socket); + msnprintf(data, sizeof(data), "DATA\n%04zx\n", nread_socket); if(!write_stdout(data, 10)) return FALSE; if(!write_stdout(buffer, nread_socket)) diff --git a/tests/server/sws.c b/tests/server/sws.c index 8df4d76e4..cf3d291d9 100644 --- a/tests/server/sws.c +++ b/tests/server/sws.c @@ -509,11 +509,11 @@ static int ProcessRequest(struct httprequest *req) /* get the number after it */ if(ptr) { if((strlen(doc) + strlen(request)) < 400) - snprintf(logbuf, sizeof(logbuf), "Got request: %s %s HTTP/%d.%d", - request, doc, prot_major, prot_minor); + msnprintf(logbuf, sizeof(logbuf), "Got request: %s %s HTTP/%d.%d", + request, doc, prot_major, prot_minor); else - snprintf(logbuf, sizeof(logbuf), "Got a *HUGE* request HTTP/%d.%d", - prot_major, prot_minor); + msnprintf(logbuf, sizeof(logbuf), "Got a *HUGE* request HTTP/%d.%d", + prot_major, prot_minor); logmsg("%s", logbuf); if(!strncmp("/verifiedserver", ptr, 15)) { @@ -545,8 +545,8 @@ static int ProcessRequest(struct httprequest *req) if(req->testno) { - snprintf(logbuf, sizeof(logbuf), "Requested test number %ld part %ld", - req->testno, req->partno); + msnprintf(logbuf, sizeof(logbuf), "Requested test number %ld part %ld", + req->testno, req->partno); logmsg("%s", logbuf); /* find and parse <servercmd> for this test */ @@ -565,9 +565,9 @@ static int ProcessRequest(struct httprequest *req) doc, &prot_major, &prot_minor) == 3) { char *portp = NULL; - snprintf(logbuf, sizeof(logbuf), - "Received a CONNECT %s HTTP/%d.%d request", - doc, prot_major, prot_minor); + msnprintf(logbuf, sizeof(logbuf), + "Received a CONNECT %s HTTP/%d.%d request", + doc, prot_major, prot_minor); logmsg("%s", logbuf); req->connect_request = TRUE; @@ -645,9 +645,9 @@ static int ProcessRequest(struct httprequest *req) else req->partno = 0; - snprintf(logbuf, sizeof(logbuf), - "Requested test number %ld part %ld (from host name)", - req->testno, req->partno); + msnprintf(logbuf, sizeof(logbuf), + "Requested test number %ld part %ld (from host name)", + req->testno, req->partno); logmsg("%s", logbuf); } @@ -696,9 +696,9 @@ static int ProcessRequest(struct httprequest *req) else req->partno = 0; - snprintf(logbuf, sizeof(logbuf), - "Requested GOPHER test number %ld part %ld", - req->testno, req->partno); + msnprintf(logbuf, sizeof(logbuf), + "Requested GOPHER test number %ld part %ld", + req->testno, req->partno); logmsg("%s", logbuf); } } @@ -1117,14 +1117,14 @@ static int send_doc(curl_socket_t sock, struct httprequest *req) case DOCNUMBER_WERULEZ: /* we got a "friends?" question, reply back that we sure are */ logmsg("Identifying ourselves as friends"); - snprintf(msgbuf, sizeof(msgbuf), "WE ROOLZ: %ld\r\n", (long)getpid()); + msnprintf(msgbuf, sizeof(msgbuf), "WE ROOLZ: %ld\r\n", (long)getpid()); msglen = strlen(msgbuf); if(use_gopher) - snprintf(weare, sizeof(weare), "%s", msgbuf); + msnprintf(weare, sizeof(weare), "%s", msgbuf); else - snprintf(weare, sizeof(weare), - "HTTP/1.1 200 OK\r\nContent-Length: %zu\r\n\r\n%s", - msglen, msgbuf); + msnprintf(weare, sizeof(weare), + "HTTP/1.1 200 OK\r\nContent-Length: %zu\r\n\r\n%s", + msglen, msgbuf); buffer = weare; break; case DOCNUMBER_404: @@ -1145,9 +1145,9 @@ static int send_doc(curl_socket_t sock, struct httprequest *req) const char *section = req->connect_request?"connect":"data"; if(req->partno) - snprintf(partbuf, sizeof(partbuf), "%s%ld", section, req->partno); + msnprintf(partbuf, sizeof(partbuf), "%s%ld", section, req->partno); else - snprintf(partbuf, sizeof(partbuf), "%s", section); + msnprintf(partbuf, sizeof(partbuf), "%s", section); logmsg("Send response test%ld section <%s>", req->testno, partbuf); @@ -2118,7 +2118,7 @@ int main(int argc, char *argv[]) } } - snprintf(port_str, sizeof(port_str), "port %hu", port); + msnprintf(port_str, sizeof(port_str), "port %hu", port); #ifdef WIN32 win32_init(); diff --git a/tests/server/tftpd.c b/tests/server/tftpd.c index c00731fa2..35419b0b9 100644 --- a/tests/server/tftpd.c +++ b/tests/server/tftpd.c @@ -15,7 +15,7 @@ */ /* - * Copyright (c) 1983, 2016 Regents of the University of California. + * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -569,7 +569,7 @@ static ssize_t write_behind(struct testcase *test, int convert) if(!test->ofile) { char outfile[256]; - snprintf(outfile, sizeof(outfile), "log/upload.%ld", test->testno); + msnprintf(outfile, sizeof(outfile), "log/upload.%ld", test->testno); #ifdef WIN32 test->ofile = open(outfile, O_CREAT|O_RDWR|O_BINARY, 0777); #else @@ -1141,8 +1141,8 @@ static int validate_access(struct testcase *test, if(!strncmp("verifiedserver", filename, 14)) { char weare[128]; - size_t count = snprintf(weare, sizeof(weare), - "WE ROOLZ: %ld\r\n", (long)getpid()); + size_t count = msnprintf(weare, sizeof(weare), + "WE ROOLZ: %ld\r\n", (long)getpid()); logmsg("Are-we-friendly question received"); test->buffer = strdup(weare); @@ -1187,7 +1187,7 @@ static int validate_access(struct testcase *test, file = test2file(testno); if(0 != partno) - snprintf(partbuf, sizeof(partbuf), "data%ld", partno); + msnprintf(partbuf, sizeof(partbuf), "data%ld", partno); if(file) { FILE *stream = fopen(file, "rb"); diff --git a/tests/server/util.c b/tests/server/util.c index 07ef63ee1..df1e35da0 100644 --- a/tests/server/util.c +++ b/tests/server/util.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2018, 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 @@ -87,7 +87,7 @@ char *data_to_hex(char *data, size_t len) if((data[i] >= 0x20) && (data[i] < 0x7f)) *optr++ = *iptr++; else { - snprintf(optr, 4, "%%%02x", *iptr++); + msnprintf(optr, 4, "%%%02x", *iptr++); optr += 3; } } @@ -121,11 +121,12 @@ void logmsg(const char *msg, ...) sec = epoch_offset + tv.tv_sec; now = localtime(&sec); /* not thread safe but we don't care */ - snprintf(timebuf, sizeof(timebuf), "%02d:%02d:%02d.%06ld", - (int)now->tm_hour, (int)now->tm_min, (int)now->tm_sec, (long)tv.tv_usec); + msnprintf(timebuf, sizeof(timebuf), "%02d:%02d:%02d.%06ld", + (int)now->tm_hour, (int)now->tm_min, (int)now->tm_sec, + (long)tv.tv_usec); va_start(ap, msg); - vsnprintf(buffer, sizeof(buffer), msg, ap); + mvsnprintf(buffer, sizeof(buffer), msg, ap); va_end(ap); logfp = fopen(serverlogfile, "ab"); @@ -151,7 +152,7 @@ void win32_perror(const char *msg) if(!FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, LANG_NEUTRAL, buf, sizeof(buf), NULL)) - snprintf(buf, sizeof(buf), "Unknown error %lu (%#lx)", err, err); + msnprintf(buf, sizeof(buf), "Unknown error %lu (%#lx)", err, err); if(msg) fprintf(stderr, "%s: ", msg); fprintf(stderr, "%s\n", buf); @@ -195,7 +196,7 @@ const char *path = "."; char *test2file(long testno) { static char filename[256]; - snprintf(filename, sizeof(filename), TEST_DATA_PATH, path, testno); + msnprintf(filename, sizeof(filename), TEST_DATA_PATH, path, testno); return filename; } |