]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
Fix and improvements
authorDuarte Silva <development@serializing.me>
Fri, 12 Dec 2014 18:21:24 +0000 (18:21 +0000)
committerVictor Julien <victor@inliniac.net>
Tue, 16 Dec 2014 10:27:34 +0000 (11:27 +0100)
- Added/removed missing/superfluous util-memrchr.h include
- Improved the extraction of a IP from the XFF chain of IPs

src/alert-unified2-alert.c
src/app-layer-htp-xff.c

index 4bfea39770fa12ac6145ddd534714ce8738736d3..26bacb28cc3160e08b560f5435f013b183c3b880 100644 (file)
@@ -69,8 +69,6 @@
 
 #include "util-optimize.h"
 
-#include "util-memrchr.h"
-
 #ifndef IPPROTO_SCTP
 #define IPPROTO_SCTP 132
 #endif
index 9337ba18f7a7a4e4a09b22847f287f3fb0c9e8e7..5be84bbdb75f306c448c8b49d4e7604a7120fa9e 100644 (file)
@@ -30,6 +30,7 @@
 #include "app-layer-htp-xff.h"
 
 #include "util-misc.h"
+#include "util-memrchr.h"
 
 /** XFF header value minimal length */
 #define XFF_CHAIN_MINLEN 7
@@ -94,7 +95,7 @@ int HttpXFFGetIPFromTx(const Packet *p, uint64_t tx_id, HttpXFFCfg *xff_cfg,
             /** Get the first IP address from the chain */
             p_xff = memchr(xff_chain, ',', bstr_len(h_xff->value));
             if (p_xff != NULL) {
-                xff_chain[bstr_len(h_xff->value) - strlen((char *)p_xff)]=0;
+                xff_chain[bstr_len(h_xff->value) - (p_xff - xff_chain)]=0;
             }
             p_xff = xff_chain;
         }