Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

var: Use 16-bit container for type #12272

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/detect-engine-register.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ enum DetectKeywordId {
DETECT_FLOW,
/* end prefilter sort */

/* values used in util-var.c go here, to avoid int overflows
* TODO update var logic to use a larger type, see #6855. */
/* values used in util-var.c go here, to avoid int overflows */
DETECT_THRESHOLD,
DETECT_FLOWBITS,
DETECT_FLOWVAR,
Expand Down
4 changes: 2 additions & 2 deletions src/detect-engine-threshold.c
Original file line number Diff line number Diff line change
Expand Up @@ -524,8 +524,8 @@ static void FlowThresholdEntryListFree(FlowThresholdEntryList *list)
/** struct for storing per flow thresholds. This will be stored in the Flow::flowvar list, so it
* needs to follow the GenericVar header format. */
typedef struct FlowVarThreshold_ {
uint8_t type;
uint8_t pad[7];
uint16_t type;
uint8_t pad[6];
struct GenericVar_ *next;
FlowThresholdEntryList *thresholds;
} FlowVarThreshold;
Expand Down
4 changes: 2 additions & 2 deletions src/flow-bit.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
#include "util-var.h"

typedef struct FlowBit_ {
uint8_t type; /* type, DETECT_FLOWBITS in this case */
uint8_t pad[3];
uint16_t type; /* type, DETECT_FLOWBITS in this case */
uint8_t pad[2];
uint32_t idx; /* name idx */
GenericVar *next; /* right now just implement this as a list,
* in the long run we have think of something
Expand Down
5 changes: 3 additions & 2 deletions src/flow-var.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@ typedef struct FlowVarTypeInt_ {

/** Generic Flowvar Structure */
typedef struct FlowVar_ {
uint8_t type; /* type, DETECT_FLOWVAR in this case */
uint16_t type; /* type, DETECT_FLOWVAR in this case */
uint8_t datatype;
uint16_t keylen;
uint8_t pad;
uint32_t idx; /* name idx */
GenericVar *next; /* right now just implement this as a list,
* in the long run we have think of something
* faster. */
uint16_t keylen;
jlucovsky marked this conversation as resolved.
Show resolved Hide resolved
union {
FlowVarTypeStr fv_str;
FlowVarTypeInt fv_int;
Expand Down
9 changes: 4 additions & 5 deletions src/util-var.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,16 @@ enum VarTypes {
VAR_TYPE_IPPAIR_VAR,
};

/** \todo see ticket #6855. The type field should be 16 bits. */
typedef struct GenericVar_ {
uint8_t type; /**< variable type, uses detection sm_type */
uint8_t pad[3];
uint16_t type; /**< variable type, uses detection sm_type */
uint8_t pad[2];
uint32_t idx;
struct GenericVar_ *next;
} GenericVar;

typedef struct XBit_ {
uint8_t type; /* type, DETECT_XBITS in this case */
uint8_t pad[3];
uint16_t type; /* type, DETECT_XBITS in this case */
uint8_t pad[2];
uint32_t idx; /* name idx */
GenericVar *next;
uint32_t expire;
Expand Down
Loading