Skip to content

Commit

Permalink
Merge pull request #234 from flaviojs/fix-null-dereference-eth_switch
Browse files Browse the repository at this point in the history
Fix null dereference in eth_switch.
  • Loading branch information
grossmj authored Apr 12, 2024
2 parents 951f1f4 + 26ba748 commit f736133
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions common/eth_switch.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ static void ethsw_iv_access(ethsw_table_t *t,ethsw_packet_t *sp,
netio_send(op,sp->pkt,sp->pkt_len);
} else {
pkt = malloc(sp->pkt_len+4);
memset(pkt, 0, sp->pkt_len+4);
if (pkt == NULL) {
perror("ethsw_iv_access: dot1q");
break;
}
memset(pkt, 0, sp->pkt_len+4);
dot1q_push_tag(pkt,sp,op->vlan_id,sp->input_port->ethertype);
netio_send(op,pkt,sp->pkt_len+4);
free(pkt);
Expand Down Expand Up @@ -150,11 +150,11 @@ static void ethsw_iv_dot1q(ethsw_table_t *t,ethsw_packet_t *sp,
/* 802.1Q -> Access: pop tag */
case ETHSW_PORT_TYPE_ACCESS:
pkt = malloc(sp->pkt_len-4);
memset(pkt, 0, sp->pkt_len-4);
if (pkt == NULL) {
perror("ethsw_iv_dot1q: access");
break;
}
memset(pkt, 0, sp->pkt_len-4);
dot1q_pop_tag(pkt,sp);
netio_send(op,pkt,sp->pkt_len-4);
free(pkt);
Expand All @@ -164,11 +164,11 @@ static void ethsw_iv_dot1q(ethsw_table_t *t,ethsw_packet_t *sp,
case ETHSW_PORT_TYPE_DOT1Q:
if (op->vlan_id == sp->input_vlan) {
pkt = malloc(sp->pkt_len-4);
memset(pkt, 0, sp->pkt_len-4);
if (pkt == NULL) {
perror("ethsw_iv_dot1q: dot1q");
break;
}
memset(pkt, 0, sp->pkt_len-4);
dot1q_pop_tag(pkt,sp);
netio_send(op,pkt,sp->pkt_len-4);
free(pkt);
Expand All @@ -184,11 +184,11 @@ static void ethsw_iv_dot1q(ethsw_table_t *t,ethsw_packet_t *sp,
case ETHSW_PORT_TYPE_QINQ:
if (op->vlan_id == sp->input_vlan) {
pkt = malloc(sp->pkt_len-4);
memset(pkt, 0, sp->pkt_len-4);
if (pkt == NULL) {
perror("ethsw_iv_dot1q: qinq");
break;
}
memset(pkt, 0, sp->pkt_len-4);
dot1q_pop_tag(pkt,sp);
netio_send(op,pkt,sp->pkt_len-4);
free(pkt);
Expand All @@ -211,11 +211,11 @@ static void ethsw_iv_qinq(ethsw_table_t *t,ethsw_packet_t *sp,
/* QinQ -> 802.1Q: push outer tag */
case ETHSW_PORT_TYPE_DOT1Q:
pkt = malloc(sp->pkt_len+4);
memset(pkt, 0, sp->pkt_len+4);
if (pkt == NULL) {
perror("ethsw_iv_qinq: dot1q");
break;
}
memset(pkt, 0, sp->pkt_len+4);
dot1q_push_tag(pkt,sp,sp->input_port->vlan_id,sp->input_port->ethertype);
netio_send(op,pkt,sp->pkt_len+4);
free(pkt);
Expand All @@ -228,11 +228,11 @@ static void ethsw_iv_qinq(ethsw_table_t *t,ethsw_packet_t *sp,
case ETHSW_PORT_TYPE_QINQ:
if (sp->input_port->vlan_id == op->vlan_id) {
pkt = malloc(sp->pkt_len-4);
memset(pkt, 0, sp->pkt_len-4);
if (pkt == NULL) {
perror("ethsw_iv_qinq: qinq");
break;
}
memset(pkt, 0, sp->pkt_len-4);
dot1q_pop_tag(pkt,sp);
netio_send(op,pkt,sp->pkt_len-4);
free(pkt);
Expand Down

0 comments on commit f736133

Please sign in to comment.