mirror of
https://github.com/nmap/nmap.git
synced 2025-12-29 10:59:02 +00:00
Adding Snprintf() and Vsnprintf() to nbase/nbase_str.c. This is because of Windows' stupid implementation where it doesn't write a NULL byte at the end of the buffer if the result is truncated. I would've just #defined snprintf and vsnprintf to some wrapper function for Windows, but this doesn't work as libdnet and libpcap (and libpcap includes under mswin32) define snprintf to _snprintf and vsnprintf to _vsnprintf like we do, and through the many defines they end up being available in the Nmap sources. Vsnprintf() uses vsnprintf() (and writes a NULL byte at the end if truncated), and Snprintf uses Vsnprintf().
This commit is contained in:
@@ -317,7 +317,7 @@ const char *Target::NameIP(char *buf, size_t buflen) {
|
||||
assert(buf);
|
||||
assert(buflen > 8);
|
||||
if (hostname) {
|
||||
snprintf(buf, buflen, "%s (%s)", hostname, targetipstring);
|
||||
Snprintf(buf, buflen, "%s (%s)", hostname, targetipstring);
|
||||
} else Strncpy(buf, targetipstring, buflen);
|
||||
return buf;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user