mirror of
https://github.com/nmap/nmap.git
synced 2026-01-17 20:09:02 +00:00
merge soc07 r5225 - fix for systems which return -1 when vsnprintf doesn't have enough space rather than returning the amount of space needed.
This commit is contained in:
@@ -3,6 +3,10 @@
|
||||
o Performed a bunch of OS fingerprint text canonicalization thanks to
|
||||
reports of dozens of capitalization inconsistencies from Suicidal Bob.
|
||||
|
||||
o Fixed an output bug on systems like Windows which return -1 when
|
||||
vsnprintf is passed a too-small buffer rather than returning the
|
||||
size needed. Thanks to jah (jah(a)zadkiel.plus.com) for the report.
|
||||
|
||||
4.22SOC2
|
||||
|
||||
o NSE compilation fixes by Stoiko and Kris
|
||||
|
||||
16
output.cc
16
output.cc
@@ -883,13 +883,17 @@ void log_vwrite(int logt, const char *fmt, va_list ap) {
|
||||
if (len == 0) {
|
||||
va_end(apcopy);
|
||||
return;
|
||||
} else if (len < 0) {
|
||||
fatal("vsnprintf returned %d in %s -- bizarre. Quitting.", len, __func__);
|
||||
} else if (len >= writebuflen) {
|
||||
} else if (len < 0 || len >= writebuflen) {
|
||||
/* Didn't have enough space. Expand writebuf and try again */
|
||||
free(writebuf);
|
||||
writebuflen = len + 1024;
|
||||
writebuf = (char *) safe_malloc(writebuflen);
|
||||
if (len >= writebuflen) {
|
||||
writebuflen = len + 1024;
|
||||
} else {
|
||||
/* Windows seems to just give -1 rather than the amount of space we
|
||||
would need. So lets just gulp up a huge amount in the hope it
|
||||
will be enough */
|
||||
writebuflen *= 100;
|
||||
}
|
||||
writebuf = (char *) safe_realloc(writebuf, writebuflen);
|
||||
len = vsnprintf(writebuf, writebuflen, fmt, apcopy);
|
||||
if (len <= 0 || len >= writebuflen) {
|
||||
fatal("%s: vnsprintf failed. Even after increasing bufferlen to %d, vsnprintf returned %d (logt == %d). Please email this message to fyodor@insecure.org. Quitting.", __func__, writebuflen, len, logt);
|
||||
|
||||
Reference in New Issue
Block a user