From: Anoop Saldanha Date: Fri, 19 Jul 2013 16:29:53 +0000 (+0530) Subject: fix bug where we were not printing http hostname(printing X-Git-Tag: suricata-2.0beta2~494 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ee0b21652b00f9398869b097c3ddceb9f86600a9;p=thirdparty%2Fsuricata.git fix bug where we were not printing http hostname(printing previously) in httplog, filestore meta and file log. --- diff --git a/src/log-file.c b/src/log-file.c index 8d1c0b1dcb..5d13f35d07 100644 --- a/src/log-file.c +++ b/src/log-file.c @@ -123,15 +123,10 @@ static void LogFileMetaGetHost(FILE *fp, Packet *p, File *ff) { HtpState *htp_state = (HtpState *)p->flow->alstate; if (htp_state != NULL) { htp_tx_t *tx = AppLayerGetTx(ALPROTO_HTTP, htp_state, ff->txid); - if (tx != NULL) { - htp_header_t *h = NULL; - h = (htp_header_t *)htp_table_get_c(tx->request_headers, - "Host"); - if (h != NULL) { - PrintRawJsonFp(fp, (uint8_t *)bstr_ptr(h->value), - bstr_len(h->value)); - return; - } + if (tx != NULL && tx->request_hostname != NULL) { + PrintRawJsonFp(fp, (uint8_t *)bstr_ptr(tx->request_hostname), + bstr_len(tx->request_hostname)); + return; } } diff --git a/src/log-filestore.c b/src/log-filestore.c index 2d6e3be3cd..3e19527f14 100644 --- a/src/log-filestore.c +++ b/src/log-filestore.c @@ -125,15 +125,10 @@ static void LogFilestoreMetaGetHost(FILE *fp, Packet *p, File *ff) { HtpState *htp_state = (HtpState *)p->flow->alstate; if (htp_state != NULL) { htp_tx_t *tx = AppLayerGetTx(ALPROTO_HTTP, htp_state, ff->txid); - if (tx != NULL) { - htp_header_t *h = NULL; - h = (htp_header_t *)htp_table_get_c(tx->request_headers, - "Host"); - if (h != NULL) { - PrintRawUriFp(fp, (uint8_t *)bstr_ptr(h->value), - bstr_len(h->value)); - return; - } + if (tx != NULL && tx->request_hostname != NULL) { + PrintRawUriFp(fp, (uint8_t *)bstr_ptr(tx->request_hostname), + bstr_len(tx->request_hostname)); + return; } } diff --git a/src/log-httplog.c b/src/log-httplog.c index f02252e7b5..1993ad1db2 100644 --- a/src/log-httplog.c +++ b/src/log-httplog.c @@ -232,11 +232,11 @@ static void LogHttpLogCustom(LogHttpLogThread *aft, htp_tx_t *tx, const struct t break; case LOG_HTTP_CF_REQUEST_HOST: /* HOSTNAME */ - if (tx->parsed_uri != NULL && tx->parsed_uri->hostname != NULL) + if (tx->request_hostname != NULL) { PrintRawUriBuf((char *)aft->buffer->buffer, &aft->buffer->offset, - aft->buffer->size, (uint8_t *)bstr_ptr(tx->parsed_uri->hostname), - bstr_len(tx->parsed_uri->hostname)); + aft->buffer->size, (uint8_t *)bstr_ptr(tx->request_hostname), + bstr_len(tx->request_hostname)); } else { MemBufferWriteString(aft->buffer, LOG_HTTP_CF_NONE); } @@ -476,12 +476,10 @@ static TmEcode LogHttpLogIPWrapper(ThreadVars *tv, Packet *p, void *data, Packet MemBufferWriteString(aft->buffer, "%s ", timebuf); /* hostname */ - if (tx->parsed_uri != NULL && - tx->parsed_uri->hostname != NULL) - { + if (tx->request_hostname != NULL) { PrintRawUriBuf((char *)aft->buffer->buffer, &aft->buffer->offset, aft->buffer->size, - (uint8_t *)bstr_ptr(tx->parsed_uri->hostname), - bstr_len(tx->parsed_uri->hostname)); + (uint8_t *)bstr_ptr(tx->request_hostname), + bstr_len(tx->request_hostname)); } else { MemBufferWriteString(aft->buffer, ""); }