]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
fix bug where we were not printing http hostname(printing <unknown> 452/head
authorAnoop Saldanha <anoopsaldanha@gmail.com>
Fri, 19 Jul 2013 16:29:53 +0000 (21:59 +0530)
committerAnoop Saldanha <anoopsaldanha@gmail.com>
Fri, 19 Jul 2013 16:29:55 +0000 (21:59 +0530)
previously) in httplog, filestore meta and file log.

src/log-file.c
src/log-filestore.c
src/log-httplog.c

index 8d1c0b1dcbad79b38a67675766a47fa6f78c5166..5d13f35d077bc4c94844fcb92cf11bf593a3125c 100644 (file)
@@ -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;
         }
     }
 
index 2d6e3be3cd8f8cba1e86b5e0e850d2d4747f3719..3e19527f142b3390a15fffdc8aa1b0cac955e965 100644 (file)
@@ -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;
         }
     }
 
index f02252e7b5a57afd1e9ee118fa320779f13f86ef..1993ad1db214cc388b2333aaf03ddc01f37bcb3c 100644 (file)
@@ -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, "<hostname unknown>");
             }