Loading tests/server/fake_ntlm.c +10 −7 Original line number Diff line number Diff line Loading @@ -76,7 +76,7 @@ static char *printable(char *inbuf, size_t inlength) return NULL; if(!inlength) { sprintf(&outbuf[0], "%s", NOTHING_STR); snprintf(&outbuf[0], outsize, "%s", NOTHING_STR); return outbuf; } Loading @@ -98,7 +98,7 @@ static char *printable(char *inbuf, size_t inlength) o++; } else { sprintf(&outbuf[o], HEX_FMT_STR, inbuf[i]); snprintf(&outbuf[o], outsize - o, HEX_FMT_STR, inbuf[i]); o += HEX_STR_LEN; } Loading Loading @@ -171,7 +171,8 @@ int main(int argc, char *argv[]) exit(1); } testnum = lnum; } else { } else { logmsg("Test number not specified in CURL_NTLM_AUTH_TESTNUM"); exit(1); } Loading Loading @@ -230,7 +231,8 @@ int main(int argc, char *argv[]) } else { size = 0; error = getpart(&type1_output, &size, "ntlm_auth_type1", "output", stream); error = getpart(&type1_output, &size, "ntlm_auth_type1", "output", stream); fclose(stream); if(error || size == 0) { logmsg("getpart() type 1 output failed with error: %d", error); Loading @@ -251,7 +253,8 @@ int main(int argc, char *argv[]) } else { size = 0; error = getpart(&type3_output, &size, "ntlm_auth_type3", "output", stream); error = getpart(&type3_output, &size, "ntlm_auth_type3", "output", stream); fclose(stream); if(error || size == 0) { logmsg("getpart() type 3 output failed with error: %d", error); Loading tests/server/getpart.c +2 −2 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 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 Loading tests/server/resolve.c +3 −3 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 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 Loading tests/server/rtspd.c +59 −48 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 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 Loading Loading @@ -375,10 +375,10 @@ static int ProcessRequest(struct httprequest *req) char *filename; if((strlen(doc) + strlen(request)) < 200) sprintf(logbuf, "Got request: %s %s %s/%d.%d", snprintf(logbuf, sizeof(logbuf), "Got request: %s %s %s/%d.%d", request, doc, prot_str, prot_major, prot_minor); else sprintf(logbuf, "Got a *HUGE* request %s/%d.%d", snprintf(logbuf, sizeof(logbuf), "Got a *HUGE* request %s/%d.%d", prot_str, prot_major, prot_minor); logmsg("%s", logbuf); Loading Loading @@ -409,7 +409,7 @@ static int ProcessRequest(struct httprequest *req) else req->partno = 0; sprintf(logbuf, "Requested test number %ld part %ld", snprintf(logbuf, sizeof(logbuf), "Requested test number %ld part %ld", req->testno, req->partno); logmsg("%s", logbuf); Loading Loading @@ -501,14 +501,18 @@ static int ProcessRequest(struct httprequest *req) if(req->rtp_buffer == NULL) { req->rtp_buffer = rtp_scratch; req->rtp_buffersize = rtp_size + 4; } else { req->rtp_buffer = realloc(req->rtp_buffer, req->rtp_buffersize + rtp_size + 4); memcpy(req->rtp_buffer + req->rtp_buffersize, rtp_scratch, rtp_size + 4); } else { req->rtp_buffer = realloc(req->rtp_buffer, req->rtp_buffersize + rtp_size + 4); memcpy(req->rtp_buffer + req->rtp_buffersize, rtp_scratch, rtp_size + 4); req->rtp_buffersize += rtp_size + 4; free(rtp_scratch); } logmsg("rtp_buffersize is %zu, rtp_size is %d.", req->rtp_buffersize, rtp_size); logmsg("rtp_buffersize is %zu, rtp_size is %d.", req->rtp_buffersize, rtp_size); } } else { Loading @@ -529,7 +533,8 @@ static int ProcessRequest(struct httprequest *req) else { if(sscanf(req->reqbuf, "CONNECT %" MAXDOCNAMELEN_TXT "s HTTP/%d.%d", doc, &prot_major, &prot_minor) == 3) { sprintf(logbuf, "Received a CONNECT %s HTTP/%d.%d request", snprintf(logbuf, sizeof(logbuf), "Received a CONNECT %s HTTP/%d.%d request", doc, prot_major, prot_minor); logmsg("%s", logbuf); Loading Loading @@ -662,10 +667,11 @@ static int ProcessRequest(struct httprequest *req) req->ntlm = TRUE; /* NTLM found */ logmsg("Received NTLM type-1, sending back data %ld", req->partno); } else if((req->partno >= 1000) && strstr(req->reqbuf, "Authorization: Basic")) { /* If the client is passing this Basic-header and the part number is already >=1000, we add 1 to the part number. This allows simple Basic authentication negotiation to work in the test suite. */ else if((req->partno >= 1000) && strstr(req->reqbuf, "Authorization: Basic")) { /* If the client is passing this Basic-header and the part number is already >=1000, we add 1 to the part number. This allows simple Basic authentication negotiation to work in the test suite. */ req->partno += 1; logmsg("Received Basic request, sending back data %ld", req->partno); } Loading Loading @@ -815,9 +821,9 @@ static int get_request(curl_socket_t sock, struct httprequest *req) } else { if(req->skip) /* we are instructed to not read the entire thing, so we make sure to only read what we're supposed to and NOT read the enire thing the client wants to send! */ /* we are instructed to not read the entire thing, so we make sure to only read what we're supposed to and NOT read the enire thing the client wants to send! */ got = sread(sock, reqbuf + req->offset, req->cl); else got = sread(sock, reqbuf + req->offset, REQBUFSIZ-1 - req->offset); Loading Loading @@ -937,9 +943,11 @@ 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"); sprintf(msgbuf, "RTSP_SERVER WE ROOLZ: %ld\r\n", (long)getpid()); snprintf(msgbuf, sizeof(msgbuf), "RTSP_SERVER WE ROOLZ: %ld\r\n", (long)getpid()); msglen = strlen(msgbuf); sprintf(weare, "HTTP/1.1 200 OK\r\nContent-Length: %zu\r\n\r\n%s", snprintf(weare, sizeof(weare), "HTTP/1.1 200 OK\r\nContent-Length: %zu\r\n\r\n%s", msglen, msgbuf); buffer = weare; break; Loading @@ -959,7 +967,8 @@ static int send_doc(curl_socket_t sock, struct httprequest *req) logmsg("Replying to with a 404"); if(req->protocol == RPROT_HTTP) { buffer = doc404_HTTP; } else { } else { buffer = doc404_RTSP; } break; Loading @@ -971,7 +980,7 @@ static int send_doc(curl_socket_t sock, struct httprequest *req) char *filename = test2file(req->testno); if(0 != req->partno) sprintf(partbuf, "data%ld", req->partno); snprintf(partbuf, sizeof(partbuf), "data%ld", req->partno); stream=fopen(filename, "rb"); if(!stream) { Loading Loading @@ -1082,7 +1091,8 @@ static int send_doc(curl_socket_t sock, struct httprequest *req) size_t num = count; if(num > 200) num = 200; written = swrite(sock, req->rtp_buffer + (req->rtp_buffersize - count), num); written = swrite(sock, req->rtp_buffer + (req->rtp_buffersize - count), num); if(written < 0) { sendfailure = TRUE; break; Loading @@ -1108,7 +1118,8 @@ static int send_doc(curl_socket_t sock, struct httprequest *req) } if(sendfailure) { logmsg("Sending response failed. Only (%zu bytes) of (%zu bytes) were sent", logmsg("Sending response failed. Only (%zu bytes) of " "(%zu bytes) were sent", responsesize-count, responsesize); free(ptr); free(cmd); Loading tests/server/sockfilt.c +34 −25 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 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 Loading Loading @@ -53,31 +53,34 @@ * * This program is a single-threaded process. * * This program is intended to be highly portable and as such it must be kept as * simple as possible, due to this the only signal handling mechanisms used will * be those of ANSI C, and used only in the most basic form which is good enough * for the purpose of this program. * This program is intended to be highly portable and as such it must be kept * as simple as possible, due to this the only signal handling mechanisms used * will be those of ANSI C, and used only in the most basic form which is good * enough for the purpose of this program. * * For the above reason and the specific needs of this program signals SIGHUP, * SIGPIPE and SIGALRM will be simply ignored on systems where this can be done. * If possible, signals SIGINT and SIGTERM will be handled by this program as an * indication to cleanup and finish execution as soon as possible. This will be * achieved with a single signal handler 'exit_signal_handler' for both signals. * SIGPIPE and SIGALRM will be simply ignored on systems where this can be * done. If possible, signals SIGINT and SIGTERM will be handled by this * program as an indication to cleanup and finish execution as soon as * possible. This will be achieved with a single signal handler * 'exit_signal_handler' for both signals. * * The 'exit_signal_handler' upon the first SIGINT or SIGTERM received signal * will just set to one the global var 'got_exit_signal' storing in global var * 'exit_signal' the signal that triggered this change. * * Nothing fancy that could introduce problems is used, the program at certain * points in its normal flow checks if var 'got_exit_signal' is set and in case * this is true it just makes its way out of loops and functions in structured * and well behaved manner to achieve proper program cleanup and termination. * points in its normal flow checks if var 'got_exit_signal' is set and in * case this is true it just makes its way out of loops and functions in * structured and well behaved manner to achieve proper program cleanup and * termination. * * Even with the above mechanism implemented it is worthwile to note that other * signals might still be received, or that there might be systems on which it * is not possible to trap and ignore some of the above signals. This implies * that for increased portability and reliability the program must be coded as * if no signal was being ignored or handled at all. Enjoy it! * Even with the above mechanism implemented it is worthwile to note that * other signals might still be received, or that there might be systems on * which it is not possible to trap and ignore some of the above signals. * This implies that for increased portability and reliability the program * must be coded as if no signal was being ignored or handled at all. Enjoy * it! */ #ifdef HAVE_SIGNAL_H Loading Loading @@ -469,23 +472,28 @@ static void lograw(unsigned char *buffer, ssize_t len) unsigned char *ptr = buffer; char *optr = data; ssize_t width=0; int left = sizeof(data); for(i=0; i<len; i++) { switch(ptr[i]) { case '\n': sprintf(optr, "\\n"); snprintf(optr, left, "\\n"); width += 2; optr += 2; left-=2; break; case '\r': sprintf(optr, "\\r"); snprintf(optr, left, "\\r"); width += 2; optr += 2; left-=2; break; default: sprintf(optr, "%c", (ISGRAPH(ptr[i]) || ptr[i]==0x20) ?ptr[i]:'.'); snprintf(optr, left, "%c", (ISGRAPH(ptr[i]) || ptr[i]==0x20) ?ptr[i]:'.'); width++; optr++; left--; break; } Loading @@ -493,6 +501,7 @@ static void lograw(unsigned char *buffer, ssize_t len) logmsg("'%s'", data); width = 0; optr = data; left = sizeof(data); } } if(width) Loading Loading @@ -1049,7 +1058,7 @@ 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]" */ sprintf((char *)buffer, "%s/%hu\n", ipv_inuse, port); snprintf((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); if(!write_stdout(data, 10)) Loading Loading
tests/server/fake_ntlm.c +10 −7 Original line number Diff line number Diff line Loading @@ -76,7 +76,7 @@ static char *printable(char *inbuf, size_t inlength) return NULL; if(!inlength) { sprintf(&outbuf[0], "%s", NOTHING_STR); snprintf(&outbuf[0], outsize, "%s", NOTHING_STR); return outbuf; } Loading @@ -98,7 +98,7 @@ static char *printable(char *inbuf, size_t inlength) o++; } else { sprintf(&outbuf[o], HEX_FMT_STR, inbuf[i]); snprintf(&outbuf[o], outsize - o, HEX_FMT_STR, inbuf[i]); o += HEX_STR_LEN; } Loading Loading @@ -171,7 +171,8 @@ int main(int argc, char *argv[]) exit(1); } testnum = lnum; } else { } else { logmsg("Test number not specified in CURL_NTLM_AUTH_TESTNUM"); exit(1); } Loading Loading @@ -230,7 +231,8 @@ int main(int argc, char *argv[]) } else { size = 0; error = getpart(&type1_output, &size, "ntlm_auth_type1", "output", stream); error = getpart(&type1_output, &size, "ntlm_auth_type1", "output", stream); fclose(stream); if(error || size == 0) { logmsg("getpart() type 1 output failed with error: %d", error); Loading @@ -251,7 +253,8 @@ int main(int argc, char *argv[]) } else { size = 0; error = getpart(&type3_output, &size, "ntlm_auth_type3", "output", stream); error = getpart(&type3_output, &size, "ntlm_auth_type3", "output", stream); fclose(stream); if(error || size == 0) { logmsg("getpart() type 3 output failed with error: %d", error); Loading
tests/server/getpart.c +2 −2 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 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 Loading
tests/server/resolve.c +3 −3 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 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 Loading
tests/server/rtspd.c +59 −48 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 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 Loading Loading @@ -375,10 +375,10 @@ static int ProcessRequest(struct httprequest *req) char *filename; if((strlen(doc) + strlen(request)) < 200) sprintf(logbuf, "Got request: %s %s %s/%d.%d", snprintf(logbuf, sizeof(logbuf), "Got request: %s %s %s/%d.%d", request, doc, prot_str, prot_major, prot_minor); else sprintf(logbuf, "Got a *HUGE* request %s/%d.%d", snprintf(logbuf, sizeof(logbuf), "Got a *HUGE* request %s/%d.%d", prot_str, prot_major, prot_minor); logmsg("%s", logbuf); Loading Loading @@ -409,7 +409,7 @@ static int ProcessRequest(struct httprequest *req) else req->partno = 0; sprintf(logbuf, "Requested test number %ld part %ld", snprintf(logbuf, sizeof(logbuf), "Requested test number %ld part %ld", req->testno, req->partno); logmsg("%s", logbuf); Loading Loading @@ -501,14 +501,18 @@ static int ProcessRequest(struct httprequest *req) if(req->rtp_buffer == NULL) { req->rtp_buffer = rtp_scratch; req->rtp_buffersize = rtp_size + 4; } else { req->rtp_buffer = realloc(req->rtp_buffer, req->rtp_buffersize + rtp_size + 4); memcpy(req->rtp_buffer + req->rtp_buffersize, rtp_scratch, rtp_size + 4); } else { req->rtp_buffer = realloc(req->rtp_buffer, req->rtp_buffersize + rtp_size + 4); memcpy(req->rtp_buffer + req->rtp_buffersize, rtp_scratch, rtp_size + 4); req->rtp_buffersize += rtp_size + 4; free(rtp_scratch); } logmsg("rtp_buffersize is %zu, rtp_size is %d.", req->rtp_buffersize, rtp_size); logmsg("rtp_buffersize is %zu, rtp_size is %d.", req->rtp_buffersize, rtp_size); } } else { Loading @@ -529,7 +533,8 @@ static int ProcessRequest(struct httprequest *req) else { if(sscanf(req->reqbuf, "CONNECT %" MAXDOCNAMELEN_TXT "s HTTP/%d.%d", doc, &prot_major, &prot_minor) == 3) { sprintf(logbuf, "Received a CONNECT %s HTTP/%d.%d request", snprintf(logbuf, sizeof(logbuf), "Received a CONNECT %s HTTP/%d.%d request", doc, prot_major, prot_minor); logmsg("%s", logbuf); Loading Loading @@ -662,10 +667,11 @@ static int ProcessRequest(struct httprequest *req) req->ntlm = TRUE; /* NTLM found */ logmsg("Received NTLM type-1, sending back data %ld", req->partno); } else if((req->partno >= 1000) && strstr(req->reqbuf, "Authorization: Basic")) { /* If the client is passing this Basic-header and the part number is already >=1000, we add 1 to the part number. This allows simple Basic authentication negotiation to work in the test suite. */ else if((req->partno >= 1000) && strstr(req->reqbuf, "Authorization: Basic")) { /* If the client is passing this Basic-header and the part number is already >=1000, we add 1 to the part number. This allows simple Basic authentication negotiation to work in the test suite. */ req->partno += 1; logmsg("Received Basic request, sending back data %ld", req->partno); } Loading Loading @@ -815,9 +821,9 @@ static int get_request(curl_socket_t sock, struct httprequest *req) } else { if(req->skip) /* we are instructed to not read the entire thing, so we make sure to only read what we're supposed to and NOT read the enire thing the client wants to send! */ /* we are instructed to not read the entire thing, so we make sure to only read what we're supposed to and NOT read the enire thing the client wants to send! */ got = sread(sock, reqbuf + req->offset, req->cl); else got = sread(sock, reqbuf + req->offset, REQBUFSIZ-1 - req->offset); Loading Loading @@ -937,9 +943,11 @@ 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"); sprintf(msgbuf, "RTSP_SERVER WE ROOLZ: %ld\r\n", (long)getpid()); snprintf(msgbuf, sizeof(msgbuf), "RTSP_SERVER WE ROOLZ: %ld\r\n", (long)getpid()); msglen = strlen(msgbuf); sprintf(weare, "HTTP/1.1 200 OK\r\nContent-Length: %zu\r\n\r\n%s", snprintf(weare, sizeof(weare), "HTTP/1.1 200 OK\r\nContent-Length: %zu\r\n\r\n%s", msglen, msgbuf); buffer = weare; break; Loading @@ -959,7 +967,8 @@ static int send_doc(curl_socket_t sock, struct httprequest *req) logmsg("Replying to with a 404"); if(req->protocol == RPROT_HTTP) { buffer = doc404_HTTP; } else { } else { buffer = doc404_RTSP; } break; Loading @@ -971,7 +980,7 @@ static int send_doc(curl_socket_t sock, struct httprequest *req) char *filename = test2file(req->testno); if(0 != req->partno) sprintf(partbuf, "data%ld", req->partno); snprintf(partbuf, sizeof(partbuf), "data%ld", req->partno); stream=fopen(filename, "rb"); if(!stream) { Loading Loading @@ -1082,7 +1091,8 @@ static int send_doc(curl_socket_t sock, struct httprequest *req) size_t num = count; if(num > 200) num = 200; written = swrite(sock, req->rtp_buffer + (req->rtp_buffersize - count), num); written = swrite(sock, req->rtp_buffer + (req->rtp_buffersize - count), num); if(written < 0) { sendfailure = TRUE; break; Loading @@ -1108,7 +1118,8 @@ static int send_doc(curl_socket_t sock, struct httprequest *req) } if(sendfailure) { logmsg("Sending response failed. Only (%zu bytes) of (%zu bytes) were sent", logmsg("Sending response failed. Only (%zu bytes) of " "(%zu bytes) were sent", responsesize-count, responsesize); free(ptr); free(cmd); Loading
tests/server/sockfilt.c +34 −25 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 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 Loading Loading @@ -53,31 +53,34 @@ * * This program is a single-threaded process. * * This program is intended to be highly portable and as such it must be kept as * simple as possible, due to this the only signal handling mechanisms used will * be those of ANSI C, and used only in the most basic form which is good enough * for the purpose of this program. * This program is intended to be highly portable and as such it must be kept * as simple as possible, due to this the only signal handling mechanisms used * will be those of ANSI C, and used only in the most basic form which is good * enough for the purpose of this program. * * For the above reason and the specific needs of this program signals SIGHUP, * SIGPIPE and SIGALRM will be simply ignored on systems where this can be done. * If possible, signals SIGINT and SIGTERM will be handled by this program as an * indication to cleanup and finish execution as soon as possible. This will be * achieved with a single signal handler 'exit_signal_handler' for both signals. * SIGPIPE and SIGALRM will be simply ignored on systems where this can be * done. If possible, signals SIGINT and SIGTERM will be handled by this * program as an indication to cleanup and finish execution as soon as * possible. This will be achieved with a single signal handler * 'exit_signal_handler' for both signals. * * The 'exit_signal_handler' upon the first SIGINT or SIGTERM received signal * will just set to one the global var 'got_exit_signal' storing in global var * 'exit_signal' the signal that triggered this change. * * Nothing fancy that could introduce problems is used, the program at certain * points in its normal flow checks if var 'got_exit_signal' is set and in case * this is true it just makes its way out of loops and functions in structured * and well behaved manner to achieve proper program cleanup and termination. * points in its normal flow checks if var 'got_exit_signal' is set and in * case this is true it just makes its way out of loops and functions in * structured and well behaved manner to achieve proper program cleanup and * termination. * * Even with the above mechanism implemented it is worthwile to note that other * signals might still be received, or that there might be systems on which it * is not possible to trap and ignore some of the above signals. This implies * that for increased portability and reliability the program must be coded as * if no signal was being ignored or handled at all. Enjoy it! * Even with the above mechanism implemented it is worthwile to note that * other signals might still be received, or that there might be systems on * which it is not possible to trap and ignore some of the above signals. * This implies that for increased portability and reliability the program * must be coded as if no signal was being ignored or handled at all. Enjoy * it! */ #ifdef HAVE_SIGNAL_H Loading Loading @@ -469,23 +472,28 @@ static void lograw(unsigned char *buffer, ssize_t len) unsigned char *ptr = buffer; char *optr = data; ssize_t width=0; int left = sizeof(data); for(i=0; i<len; i++) { switch(ptr[i]) { case '\n': sprintf(optr, "\\n"); snprintf(optr, left, "\\n"); width += 2; optr += 2; left-=2; break; case '\r': sprintf(optr, "\\r"); snprintf(optr, left, "\\r"); width += 2; optr += 2; left-=2; break; default: sprintf(optr, "%c", (ISGRAPH(ptr[i]) || ptr[i]==0x20) ?ptr[i]:'.'); snprintf(optr, left, "%c", (ISGRAPH(ptr[i]) || ptr[i]==0x20) ?ptr[i]:'.'); width++; optr++; left--; break; } Loading @@ -493,6 +501,7 @@ static void lograw(unsigned char *buffer, ssize_t len) logmsg("'%s'", data); width = 0; optr = data; left = sizeof(data); } } if(width) Loading Loading @@ -1049,7 +1058,7 @@ 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]" */ sprintf((char *)buffer, "%s/%hu\n", ipv_inuse, port); snprintf((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); if(!write_stdout(data, 10)) Loading