Skip to content

Commit 5b34dc7

Browse files
philljjdanielinux
authored andcommitted
esp: detect multiple subsequent seq overflows.
1 parent a568dda commit 5b34dc7

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

src/test/unit/unit_esp.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -540,13 +540,15 @@ START_TEST(test_replay_overflow)
540540
ck_assert_int_eq(ret, 0);
541541
}
542542

543-
/* oseq overflow is detected, and is rejected. */
544-
frame_len = build_ip_packet(buf, sizeof(buf), WI_IPPROTO_UDP,
545-
ref, sizeof(ref));
546-
ip_len = (uint16_t)(frame_len - ETH_HEADER_LEN);
543+
/* all of these should be rejected, oseq overflow is detected. */
544+
for (i = 0; i < 10; ++i) {
545+
frame_len = build_ip_packet(buf, sizeof(buf), WI_IPPROTO_UDP,
546+
ref, sizeof(ref));
547+
ip_len = (uint16_t)(frame_len - ETH_HEADER_LEN);
547548

548-
ret = esp_transport_wrap(ip, &ip_len);
549-
ck_assert_int_eq(ret, -1);
549+
ret = esp_transport_wrap(ip, &ip_len);
550+
ck_assert_int_eq(ret, -1);
551+
}
550552
}
551553
END_TEST
552554

src/wolfesp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,6 +1491,7 @@ esp_transport_wrap(struct wolfIP_ip_packet *ip, uint16_t * ip_len)
14911491

14921492
esp_sa->replay.oseq++;
14931493
if (esp_sa->replay.oseq == 0) {
1494+
esp_sa->replay.oseq--;
14941495
ESP_LOG("error: oseq overflow\n");
14951496
return -1;
14961497
}

0 commit comments

Comments
 (0)