]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
decode/template: minor updates
authorVictor Julien <victor@inliniac.net>
Wed, 19 Sep 2018 15:07:01 +0000 (17:07 +0200)
committerVictor Julien <victor@inliniac.net>
Wed, 19 Sep 2018 18:57:32 +0000 (20:57 +0200)
src/decode-template.c
src/decode-template.h

index be7acfe1b1bbc462cae418796306ab2ad4535deb..f2331066956e989a0e5a3c41f20e858fee4f0d26 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2015 Open Information Security Foundation
+/* Copyright (C) 2015-2018 Open Information Security Foundation
  *
  * You can copy, redistribute or modify this Program under the terms of
  * the GNU General Public License version 2 as published by the Free
 #include "decode-events.h"
 #include "decode-template.h"
 
-#include "util-unittest.h"
-#include "util-debug.h"
-
 /**
- * \brief Function to decode XXX packets
+ * \brief Function to decode TEMPLATE packets
  * \param tv thread vars
  * \param dtv decoder thread vars
  * \param p packet
@@ -78,12 +75,14 @@ int DecodeTEMPLATE(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
         /* in this example it's clear that hdr_len can't be bigger than
          * 'len', but in more complex cases checking that we can't underflow
          * len is very important
-        if (hdr_len < len) {
+        if (hdr_len >= len) {
+            ENGINE_SET_EVENT(p,TEMPLATE_MALFORMED_HDRLEN);
+            return TM_ECODE_FAILED;
+        }
          */
 
         /* invoke the next decoder on the remainder of the data */
         return DecodeUDP(tv, dtv, p, (uint8_t *)pkt + hdr_len, len - hdr_len, pq);
-        //}
     } else {
         //ENGINE_SET_EVENT(p,TEMPLATE_UNSUPPORTED_PROTOCOL);
         return TM_ECODE_FAILED;
index b6a976e0e4f1cc6be2011b921d45ce489899a974..5ee42e8cfe14cab8a2bf08682ac140f7784f6080 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2015 Open Information Security Foundation
+/* Copyright (C) 2015-2018 Open Information Security Foundation
  *
  * You can copy, redistribute or modify this Program under the terms of
  * the GNU General Public License version 2 as published by the Free
@@ -28,6 +28,9 @@
 #include "decode.h"
 #include "threadvars.h"
 
+/* Header layout. Keep things like alignment and endianess in
+ * mind while constructing this. */
+
 typedef struct TemplateHdr_ {
     uint8_t proto;
     uint8_t pad0;