1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-26 17:39:03 +00:00

Make hexify in nse_nsock.cc take an unsigned char * to work around an assertion

in Visual C++ in Debug mode. The isprint, isalpha, etc. functions from ctype.h
have an assertion that the value of the character passed in is <= 255. If you
pass a character whose value is >= 128, it is cast to an unsigned int, making
it a large positive number and failing the assertion. This is the same thing
that was reported in http://seclists.org/nmap-dev/2007/q2/0257.html, in regard
to non-ASCII characters in nmap-mac-prefixes.
This commit is contained in:
david
2009-05-04 17:57:27 +00:00
parent ed77fa1e48
commit 51e7f1f4f9

View File

@@ -88,7 +88,7 @@ static size_t table_length (lua_State *L, int index)
return len;
}
static std::string hexify (const char *str, size_t len)
static std::string hexify (const unsigned char *str, size_t len)
{
size_t num = 0;
std::ostringstream ret;
@@ -557,7 +557,7 @@ static int l_nsock_send(lua_State *L) {
}
if(o.scriptTrace())
l_nsock_trace(udata->nsiod, hexify(string, string_len).c_str(), TO);
l_nsock_trace(udata->nsiod, hexify((unsigned char *) string, string_len).c_str(), TO);
nsock_write(nsp, udata->nsiod, l_nsock_send_handler, udata->timeout, &udata->yield, string, string_len);
udata->yield.thread = L;
@@ -638,7 +638,7 @@ void l_nsock_receive_handler(nsock_pool nsp, nsock_event nse, void *yield) {
rcvd_string = nse_readbuf(nse, &rcvd_len);
if(o.scriptTrace())
l_nsock_trace(nse_iod(nse), hexify(rcvd_string, (size_t) rcvd_len).c_str(), FROM);
l_nsock_trace(nse_iod(nse), hexify((unsigned char *) rcvd_string, (size_t) rcvd_len).c_str(), FROM);
lua_pushlstring(L, rcvd_string, rcvd_len);
nse_restore(y->thread, 2);
@@ -870,7 +870,7 @@ void l_nsock_receive_buf_handler(nsock_pool nsp, nsock_event nse, void *yield) {
rcvd_string = nse_readbuf(nse, &rcvd_len);
if(o.scriptTrace())
l_nsock_trace(nse_iod(nse), hexify(rcvd_string, (size_t) rcvd_len).c_str(), FROM);
l_nsock_trace(nse_iod(nse), hexify((unsigned char *) rcvd_string, (size_t) rcvd_len).c_str(), FROM);
/* push the buffer and what we received from nsock on the stack and
* concatenate both*/
lua_rawgeti(L, LUA_REGISTRYINDEX, udata->bufidx);