* \param m byte jump sigmatch
* \param payload ptr to the payload
* \param payload_len length of the payload
- * \retval 1 match
- * \retval 0 no match
+ * \retval true match
+ * \retval false no match
*/
-int DetectBytejumpDoMatch(DetectEngineThreadCtx *det_ctx, const Signature *s,
+bool DetectBytejumpDoMatch(DetectEngineThreadCtx *det_ctx, const Signature *s,
const SigMatchCtx *ctx, const uint8_t *payload, uint32_t payload_len, uint16_t flags,
int32_t nbytes, int32_t offset)
{
int extbytes;
if (payload_len == 0) {
- SCReturnInt(0);
+ SCReturnBool(false);
}
/* Validate the number of bytes we are testing
SCLogDebug("Invalid byte_jump nbytes "
"seen in byte_jump - %d",
nbytes);
- SCReturnInt(0);
+ SCReturnBool(false);
}
}
/* No match if there is no relative base */
if (ptr == NULL || len <= 0) {
- SCReturnInt(0);
+ SCReturnBool(false);
}
}
else {
SCLogDebug("Data not within payload "
"pkt=%p, ptr=%p, len=%d, nbytes=%d",
payload, ptr, len, nbytes);
- SCReturnInt(0);
+ SCReturnBool(false);
}
/* Extract the byte data */
extbytes = ByteExtractStringUint64(&val, data->base, nbytes, (const char *)ptr);
if(extbytes <= 0) {
SCLogDebug("error extracting %d bytes of string data: %d", nbytes, extbytes);
- SCReturnInt(0);
+ SCReturnBool(false);
}
}
else {
extbytes = ByteExtractUint64(&val, endianness, (uint16_t)nbytes, ptr);
if (extbytes != nbytes) {
SCLogDebug("error extracting %d bytes of numeric data: %d", nbytes, extbytes);
- SCReturnInt(0);
+ SCReturnBool(false);
}
}
SCLogDebug("Jump location (%" PRIu64 ") is not within "
"payload (%" PRIu32 ")",
val, payload_len);
- SCReturnInt(0);
+ SCReturnBool(false);
}
#ifdef DEBUG
/* Adjust the detection context to the jump location. */
det_ctx->buffer_offset = val;
- SCReturnInt(1);
+ SCReturnBool(true);
}
static int DetectBytejumpMatch(DetectEngineThreadCtx *det_ctx,
* \param p pointer to the current packet
* \param m pointer to the sigmatch that we will cast into DetectBytejumpData
*
- * \retval -1 error
- * \retval 0 no match
- * \retval 1 match
- *
- * \todo The return seems backwards. We should return a non-zero error code.
- * One of the error codes is "no match". As-is if someone accidentally
- * does: if (DetectBytejumpMatch(...)) { match }, then they catch an
- * error as a match.
+ * \retval false no match
+ * \retval true
*/
-int DetectBytejumpDoMatch(DetectEngineThreadCtx *, const Signature *, const SigMatchCtx *,
+bool DetectBytejumpDoMatch(DetectEngineThreadCtx *, const Signature *, const SigMatchCtx *,
const uint8_t *, uint32_t, uint16_t, int32_t, int32_t);
#endif /* __DETECT_BYTEJUMP_H__ */
DETECT_BYTEJUMP_LITTLE: 0);
}
- if (DetectBytejumpDoMatch(
- det_ctx, s, smd->ctx, buffer, buffer_len, bjflags, nbytes, offset) != 1) {
+ if (!DetectBytejumpDoMatch(
+ det_ctx, s, smd->ctx, buffer, buffer_len, bjflags, nbytes, offset)) {
goto no_match;
}