mirror of
https://github.com/nmap/nmap.git
synced 2026-08-03 22:29:06 +00:00
Limited unnecessary calls to alloc_vsprintf
This commit is contained in:
parent
78435476df
commit
c860732097
1 changed files with 13 additions and 11 deletions
24
output.cc
24
output.cc
|
|
@ -987,9 +987,6 @@ void log_vwrite(int logt, const char *fmt, va_list ap) {
|
|||
case LOG_MACHINE:
|
||||
case LOG_SKID:
|
||||
case LOG_XML:
|
||||
len = alloc_vsprintf(&writebuf, fmt, ap);
|
||||
if (writebuf == NULL)
|
||||
fatal("%s: alloc_vsprintf failed.", __func__);
|
||||
if (logtype == LOG_SKID_NOXLT)
|
||||
l = LOG_SKID;
|
||||
else
|
||||
|
|
@ -1000,17 +997,22 @@ void log_vwrite(int logt, const char *fmt, va_list ap) {
|
|||
l >>= 1;
|
||||
}
|
||||
assert(fileidx < LOG_NUM_FILES);
|
||||
if (o.logfd[fileidx] && len) {
|
||||
if ((logtype & (LOG_SKID|LOG_SKID_NOXLT)) && !skid_noxlate)
|
||||
skid_output(writebuf);
|
||||
if (o.logfd[fileidx]) {
|
||||
len = alloc_vsprintf(&writebuf, fmt, ap);
|
||||
if (writebuf == NULL)
|
||||
fatal("%s: alloc_vsprintf failed.", __func__);
|
||||
if (len) {
|
||||
if ((logtype & (LOG_SKID|LOG_SKID_NOXLT)) && !skid_noxlate)
|
||||
skid_output(writebuf);
|
||||
|
||||
rc = fwrite(writebuf, len, 1, o.logfd[fileidx]);
|
||||
if (rc != 1) {
|
||||
fatal("Failed to write %d bytes of data to (logt==%d) stream. fwrite returned %d. Quitting.", len, logtype, rc);
|
||||
rc = fwrite(writebuf, len, 1, o.logfd[fileidx]);
|
||||
if (rc != 1) {
|
||||
fatal("Failed to write %d bytes of data to (logt==%d) stream. fwrite returned %d. Quitting.", len, logtype, rc);
|
||||
}
|
||||
va_end(apcopy);
|
||||
}
|
||||
va_end(apcopy);
|
||||
free(writebuf);
|
||||
}
|
||||
free(writebuf);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue