log/pcap: exit on invalid filename

If the filename has to % sign and if pcap logging is using multi
mode, then the pcap capture will fail. So let's exit if ever this
is the case.
pull/5840/head
Eric Leblond 4 years ago committed by Victor Julien
parent 6a45064d4c
commit 921d44b262

@ -1125,6 +1125,13 @@ static int ParseFilename(PcapLogData *pl, const char *filename)
}
}
}
if ((tok == 0) && (pl->mode == LOGMODE_MULTI)) {
SCLogError(SC_ERR_INVALID_ARGUMENT,
"Invalid filename for multimode. Need at list one %%-sign option");
goto error;
}
if (s) {
if (tok >= MAX_TOKS) {
SCLogError(SC_ERR_INVALID_ARGUMENT,
@ -1222,11 +1229,6 @@ static OutputInitResult PcapLogInitCtx(ConfNode *conf)
pl->suffix = "";
if (filename) {
if (ParseFilename(pl, filename) != 0)
exit(EXIT_FAILURE);
}
pl->size_limit = DEFAULT_LIMIT;
if (conf != NULL) {
const char *s_limit = NULL;
@ -1418,6 +1420,11 @@ static OutputInitResult PcapLogInitCtx(ConfNode *conf)
compression_str ? compression_str : "none");
}
if (filename) {
if (ParseFilename(pl, filename) != 0)
exit(EXIT_FAILURE);
}
SCLogInfo("using %s logging", pl->mode == LOGMODE_SGUIL ?
"Sguil compatible" : (pl->mode == LOGMODE_MULTI ? "multi" : "normal"));

Loading…
Cancel
Save