Bug emanates from byte_test, byte_jump and byte_extract keyword being
unable to handle negative offsets when the inspection pointer is at the
end of the buffer.
ptr = payload + det_ctx->buffer_offset;
len = payload_len - det_ctx->buffer_offset;
- /* No match if there is no relative base */
- if (len == 0) {
- return 0;
- }
-
ptr += data->offset;
len -= data->offset;
+ /* No match if there is no relative base */
+ if (len <= 0) {
+ return 0;
+ }
//PrintRawDataFp(stdout,ptr,len);
} else {
SCLogDebug("absolute, data->offset %"PRIu32"", data->offset);
ptr = payload + det_ctx->buffer_offset;
len = payload_len - det_ctx->buffer_offset;
+ ptr += offset;
+ len -= offset;
+
/* No match if there is no relative base */
- if (ptr == NULL || len == 0) {
+ if (ptr == NULL || len <= 0) {
SCReturnInt(0);
}
-
- ptr += offset;
- len -= offset;
}
else {
ptr = payload + offset;
ptr = payload + det_ctx->buffer_offset;
len = payload_len - det_ctx->buffer_offset;
- /* No match if there is no relative base */
- if (ptr == NULL || len == 0) {
- SCReturnInt(0);
- }
-
ptr += offset;
len -= offset;
+ /* No match if there is no relative base */
+ if (ptr == NULL || len <= 0) {
+ SCReturnInt(0);
+ }
//PrintRawDataFp(stdout,ptr,len);
}
else {