Make http logging code more robust against cases where the htp state is incomplete (out of memory conditions).

remotes/origin/master-1.1.x
Victor Julien 14 years ago
parent 7bf1de022c
commit 5395071c11

@ -616,8 +616,9 @@ int HtpTransactionGetLoggableId(Flow *f)
int id = 0;
HtpState *http_state = f->aldata[AlpGetStateIdx(ALPROTO_HTTP)];
if (http_state == NULL) {
SCLogDebug("no http state");
if (http_state == NULL || http_state->connp == NULL ||
http_state->connp->conn == NULL) {
SCLogDebug("no (void) http state");
goto error;
}

@ -118,7 +118,10 @@ static void LogHttpLogExtended(LogHttpFileCtx * hlog, htp_tx_t *tx)
fprintf(hlog->file_ctx->fp, " [**] ");
/* referer */
htp_header_t *h_referer = table_getc(tx->request_headers, "referer");
htp_header_t *h_referer = NULL;
if (tx->request_headers != NULL) {
h_referer = table_getc(tx->request_headers, "referer");
}
if (h_referer != NULL) {
PrintRawUriFp(hlog->file_ctx->fp,
(uint8_t *)bstr_ptr(h_referer->value),
@ -141,6 +144,8 @@ static void LogHttpLogExtended(LogHttpFileCtx * hlog, htp_tx_t *tx)
PrintRawUriFp(hlog->file_ctx->fp,
(uint8_t *)bstr_ptr(tx->request_protocol),
bstr_len(tx->request_protocol));
} else {
fprintf(hlog->file_ctx->fp, "<no protocol>");
}
fprintf(hlog->file_ctx->fp, " [**] ");
@ -159,6 +164,8 @@ static void LogHttpLogExtended(LogHttpFileCtx * hlog, htp_tx_t *tx)
bstr_len(h_location->value));
}
}
} else {
fprintf(hlog->file_ctx->fp, "<no status>");
}
/* length */
@ -204,7 +211,7 @@ static TmEcode LogHttpLogIPWrapper(ThreadVars *tv, Packet *p, void *data, Packet
goto end;
}
if (htp_state->connp == NULL)
if (htp_state->connp == NULL || htp_state->connp->conn == NULL)
goto end;
htp_tx_t *tx = NULL;
@ -279,7 +286,10 @@ static TmEcode LogHttpLogIPWrapper(ThreadVars *tv, Packet *p, void *data, Packet
fprintf(hlog->file_ctx->fp, " [**] ");
/* user agent */
htp_header_t *h_user_agent = table_getc(tx->request_headers, "user-agent");
htp_header_t *h_user_agent = NULL;
if (tx->request_headers != NULL) {
h_user_agent = table_getc(tx->request_headers, "user-agent");
}
if (h_user_agent != NULL) {
PrintRawUriFp(hlog->file_ctx->fp,
(uint8_t *)bstr_ptr(h_user_agent->value),

Loading…
Cancel
Save