detect: fix integer warnings for app-layer-event

Ticket: #4516
pull/7511/head
Philippe Antoine 3 years ago committed by Victor Julien
parent 79d7edb3e0
commit 57fb183d32

@ -145,7 +145,7 @@ static DetectAppLayerEventData *DetectAppLayerEventParsePkt(const char *arg,
{ {
int event_id = 0; int event_id = 0;
int r = AppLayerGetPktEventInfo(arg, &event_id); int r = AppLayerGetPktEventInfo(arg, &event_id);
if (r < 0) { if (r < 0 || r > UINT8_MAX) {
SCLogError(SC_ERR_INVALID_SIGNATURE, "app-layer-event keyword " SCLogError(SC_ERR_INVALID_SIGNATURE, "app-layer-event keyword "
"supplied with packet based event - \"%s\" that isn't " "supplied with packet based event - \"%s\" that isn't "
"supported yet.", arg); "supported yet.", arg);
@ -155,7 +155,7 @@ static DetectAppLayerEventData *DetectAppLayerEventParsePkt(const char *arg,
DetectAppLayerEventData *aled = SCCalloc(1, sizeof(DetectAppLayerEventData)); DetectAppLayerEventData *aled = SCCalloc(1, sizeof(DetectAppLayerEventData));
if (unlikely(aled == NULL)) if (unlikely(aled == NULL))
return NULL; return NULL;
aled->event_id = event_id; aled->event_id = (uint8_t)event_id;
*event_type = APP_LAYER_EVENT_TYPE_PACKET; *event_type = APP_LAYER_EVENT_TYPE_PACKET;
return aled; return aled;
@ -231,7 +231,11 @@ static int DetectAppLayerEventParseAppP2(DetectAppLayerEventData *data,
return -3; return -3;
} }
} }
data->event_id = event_id; if (event_id > UINT8_MAX) {
SCLogWarning(SC_ERR_INVALID_SIGNATURE, "app-layer-event keyword's id has invalid value");
return -4;
}
data->event_id = (uint8_t)event_id;
return 0; return 0;
} }

@ -26,7 +26,7 @@
typedef struct DetectAppLayerEventData_ { typedef struct DetectAppLayerEventData_ {
AppProto alproto; AppProto alproto;
int event_id; uint8_t event_id;
/* it's used to check if there are event set into the detect engine */ /* it's used to check if there are event set into the detect engine */
bool needs_detctx; bool needs_detctx;

Loading…
Cancel
Save