diff --git a/libnetutil/netutil.cc b/libnetutil/netutil.cc index 4d6212bd5..15bafdb58 100644 --- a/libnetutil/netutil.cc +++ b/libnetutil/netutil.cc @@ -1401,7 +1401,7 @@ struct tcpopt_info_ctx { bool valid; tcpopt_info_ctx() : p(NULL), end(NULL), valid(true) {} bool check_length(size_t len) const { - return (end - p) >= len; + return end >= (p + len); } void put_str(const char *str) { if (p >= end) diff --git a/nping/EchoHeader.cc b/nping/EchoHeader.cc index 1e58bc2aa..57765e3dd 100644 --- a/nping/EchoHeader.cc +++ b/nping/EchoHeader.cc @@ -849,8 +849,7 @@ int EchoHeader::setErrorMessage(const char *err){ if(err==NULL){ return OP_FAILURE; }else{ - strncpy((char *)this->data_error->errmsg, err, ERROR_MSG_LEN); - this->data_error->errmsg[ERROR_MSG_LEN-1]='\0'; + Strncpy((char *)this->data_error->errmsg, err, ERROR_MSG_LEN); } return OP_SUCCESS; } /* End of setErrorMessage() */ diff --git a/nse_zlib.cc b/nse_zlib.cc index 26c996a3d..7a22e818e 100644 --- a/nse_zlib.cc +++ b/nse_zlib.cc @@ -844,7 +844,7 @@ static int lzlib_decompress(lua_State *L) zs.avail_in = avail_in; while(decompLimit > 0) { - unsigned int bufsize = LUAL_BUFFERSIZE; + int bufsize = LUAL_BUFFERSIZE; if (bufsize > decompLimit) bufsize = decompLimit; zs.next_out = (unsigned char*)luaL_prepbuffsize(&b, bufsize); diff --git a/output.cc b/output.cc index 24ab4acc2..995949f92 100644 --- a/output.cc +++ b/output.cc @@ -1996,7 +1996,7 @@ void printosscanoutput(const Target *currenths) { if (currenths->seq.responses > 3) { p = numlst; - size_t remaining = sizeof(numlst); + int remaining = sizeof(numlst); for (i = 0; i < currenths->seq.responses; i++) { int n = Snprintf(p, remaining, "%s%X", (p != numlst) ? "," : "", currenths->seq.seqs[i]); @@ -2020,7 +2020,7 @@ void printosscanoutput(const Target *currenths) { if (currenths->seq.responses > 2) { p = numlst; - size_t remaining = sizeof(numlst); + int remaining = sizeof(numlst); for (i = 0; i < currenths->seq.responses; i++) { int n = Snprintf(p, remaining, "%s%hX", (p != numlst) ? "," : "", currenths->seq.ipids[i]); diff --git a/tcpip.cc b/tcpip.cc index c38ed41c6..1110403d3 100644 --- a/tcpip.cc +++ b/tcpip.cc @@ -1121,7 +1121,7 @@ int readtcppacket(const u8 *packet, int readdata) { bullshit2.s_addr = ip->ip_dst.s_addr; realfrag = htons(ntohs(ip->ip_off) & IP_OFFMASK); tot_len = htons(ip->ip_len); - strncpy(sourcehost, inet_ntoa(bullshit), 16); + Strncpy(sourcehost, inet_ntoa(bullshit), sizeof(sourcehost)); if (ip->ip_hl >= 5 && tcp->th_off >= 5) { i = 4 * (ip->ip_hl + tcp->th_off); }