Skip to content

Commit

Permalink
#402 fix potential overruns in all DLT plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
fklassen committed Jan 23, 2018
1 parent 746b10a commit d1c46a2
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 17 deletions.
11 changes: 8 additions & 3 deletions src/tcpedit/plugins/dlt_hdlc/hdlc_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,14 @@ extern "C" {
* Example: Ethernet VLAN tag info
*/
typedef struct {
int hdlc; /* set to 1 if values below are filled out */
u_int8_t address;
u_int8_t control;
union {
struct {
int hdlc; /* set to 1 if values below are filled out */
u_int8_t address;
u_int8_t control;
};
u_char packet[MAXPACKET];
};
} hdlc_extra_t;


Expand Down
2 changes: 1 addition & 1 deletion src/tcpedit/plugins/dlt_ieee80211/ieee80211.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ dlt_ieee80211_init(tcpeditdlt_t *ctx)
return TCPEDIT_ERROR;
}

/* allocate memory for our deocde extra data */
/* allocate memory for our decode extra data */
ctx->decoded_extra_size = sizeof(ieee80211_extra_t);
ctx->decoded_extra = safe_malloc(ctx->decoded_extra_size);

Expand Down
3 changes: 1 addition & 2 deletions src/tcpedit/plugins/dlt_ieee80211/ieee80211_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ typedef struct {
* Example: Ethernet VLAN tag info
*/
typedef struct {
/* dummy entry for SunPro compiler which doesn't like empty structs */
int dummy;
u_char packet[MAXPACKET];
} ieee80211_extra_t;

/*
Expand Down
2 changes: 1 addition & 1 deletion src/tcpedit/plugins/dlt_linuxsll/linuxsll.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ dlt_linuxsll_init(tcpeditdlt_t *ctx)
return TCPEDIT_ERROR;
}

/* allocate memory for our deocde extra data */
/* allocate memory for our decode extra data */
ctx->decoded_extra_size = sizeof(linuxsll_extra_t);
ctx->decoded_extra = safe_malloc(ctx->decoded_extra_size);

Expand Down
3 changes: 1 addition & 2 deletions src/tcpedit/plugins/dlt_linuxsll/linuxsll_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ extern "C" {
* Example: Ethernet VLAN tag info
*/
typedef struct {
/* dummy entry for SunPro compiler which doesn't like empty structs */
int dummy;
u_char packet[MAXPACKET];
} linuxsll_extra_t;


Expand Down
2 changes: 1 addition & 1 deletion src/tcpedit/plugins/dlt_radiotap/radiotap.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ dlt_radiotap_init(tcpeditdlt_t *ctx)
return TCPEDIT_ERROR;
}

/* allocate memory for our deocde extra data */
/* allocate memory for our decode extra data */
ctx->decoded_extra_size = sizeof(radiotap_extra_t);
ctx->decoded_extra = safe_malloc(ctx->decoded_extra_size);

Expand Down
2 changes: 1 addition & 1 deletion src/tcpedit/plugins/dlt_raw/raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ dlt_raw_init(tcpeditdlt_t *ctx)
return TCPEDIT_ERROR;
}

/* allocate memory for our deocde extra data */
/* allocate memory for our config data */
ctx->decoded_extra_size = sizeof(raw_extra_t);
ctx->decoded_extra = safe_malloc(ctx->decoded_extra_size);

Expand Down
4 changes: 1 addition & 3 deletions src/tcpedit/plugins/dlt_raw/raw.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,10 @@ u_char *dlt_raw_get_mac(tcpeditdlt_t *ctx, tcpeditdlt_mac_type_t mac, const u_ch
* Example: Ethernet VLAN tag info
*/
struct raw_extra_s {
/* dummy entry for SunPro compiler which doesn't like empty structs */
int dummy;
u_char packet[MAXPACKET];
};
typedef struct raw_extra_s raw_extra_t;


/*
* FIXME: structure to hold any data in the tcpeditdlt_plugin_t->config
* Things like:
Expand Down
2 changes: 1 addition & 1 deletion src/tcpedit/plugins/dlt_raw/raw_opts.def
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/* No options for DLT_RAW as it's an decoder only plugin */
/* No options for DLT_RAW as it's a decoder only plugin */
6 changes: 4 additions & 2 deletions src/tcpedit/plugins/dlt_user/user.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,10 @@ dlt_user_init(tcpeditdlt_t *ctx)
return TCPEDIT_ERROR;
}

/* allocate memory for our deocde extra data */
ctx->decoded_extra_size = sizeof(user_extra_t);
/* allocate memory for our decode extra data - plus some space for
* other DLT decodes
*/
ctx->decoded_extra_size = USER_L2MAXLEN;
ctx->decoded_extra = safe_malloc(ctx->decoded_extra_size);

/* allocate memory for our config data */
Expand Down

0 comments on commit d1c46a2

Please sign in to comment.