From 801e537697b10a3f23d3870702e8dac6179d192b Mon Sep 17 00:00:00 2001 From: sven Date: Wed, 3 Sep 2008 22:09:15 +0000 Subject: [PATCH] Fix a bug in --script-trace hex dump output resulting in bytes with highest bit set to be prefixed by ffffff. --- CHANGELOG | 3 +++ nse_nsock.cc | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 4f39303f4..855b7c0f6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ # Nmap Changelog ($Id$); -*-text-*- +o Fix a bug in --script-trace hex dump output resulting in bytes with + highest bit set to be prefixed by ffffff. [Sven Klemm] + o Updated rpcinfo NSE script to use the new pack/unpack (binlib) functions, use the new tab library, include better documentation, and fix some bugs. [Sven Klemm] diff --git a/nse_nsock.cc b/nse_nsock.cc index 3da87524c..37496cff7 100644 --- a/nse_nsock.cc +++ b/nse_nsock.cc @@ -87,7 +87,7 @@ static std::string hexify (const char *str, size_t len) if (isprint(str[i]) || isspace(str[i])) ret << str[i]; else - ret << std::setw(3) << "\\" << (unsigned int) str[i]; + ret << std::setw(3) << "\\" << (unsigned int)(unsigned char) str[i]; } return ret.str(); } @@ -98,7 +98,7 @@ static std::string hexify (const char *str, size_t len) ret << std::setw(8) << i << ": "; for (size_t j = i; j < i + 16; j++) if (j < len) - ret << std::setw(2) << (unsigned int) str[j] << " "; + ret << std::setw(2) << (unsigned int)(unsigned char) str[j] << " "; else ret << " "; for (size_t j = i; j < i + 16 && j < len; j++)