-/* 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
/* 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;
-/* 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.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;