Skip to content

Commit 378227b

Browse files
authored
Merge pull request #91 from danielinux/fixes-20260330
Fixes 20260330
2 parents b9d0ac3 + a77fe9d commit 378227b

6 files changed

Lines changed: 1126 additions & 75 deletions

File tree

src/test/unit/unit.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ Suite *wolf_suite(void)
107107
tcase_add_test(tc_utils, test_wolfip_getdev_ex_api);
108108
tcase_add_test(tc_utils, test_wolfip_ll_frame_mtu_enforces_minimum);
109109
tcase_add_test(tc_utils, test_transport_capacity_helpers_cover_guard_paths);
110+
tcase_add_test(tc_utils, test_tx_has_writable_space_icmp_accepts_minimal_packet);
110111
tcase_add_test(tc_utils, test_wolfip_if_for_local_ip_single_interface_falls_back_to_zero);
111112
tcase_add_test(tc_utils, test_wolfip_mtu_set_get_api);
112113
tcase_add_test(tc_utils, test_wolfip_ll_at_and_ipconf_at_invalid);
@@ -209,6 +210,7 @@ Suite *wolf_suite(void)
209210
tcase_add_test(tc_utils, test_sock_sendto_error_paths);
210211
tcase_add_test(tc_utils, test_sock_sendto_null_buf_or_len_zero);
211212
tcase_add_test(tc_utils, test_sock_sendto_tcp_not_established);
213+
tcase_add_test(tc_utils, test_sock_sendto_tcp_close_wait_allowed);
212214
tcase_add_test(tc_utils, test_sock_recvfrom_tcp_states);
213215
tcase_add_test(tc_utils, test_sock_recvfrom_tcp_close_wait_empty_returns_zero);
214216
tcase_add_test(tc_utils, test_sock_recvfrom_tcp_close_wait_with_data);
@@ -319,6 +321,7 @@ Suite *wolf_suite(void)
319321
tcase_add_test(tc_utils, test_dhcp_send_request_rebinding_broadcasts_to_lease_expiry);
320322
tcase_add_test(tc_utils, test_dhcp_send_request_send_failure_retries_next_tick);
321323
tcase_add_test(tc_utils, test_dhcp_send_discover_send_failure_retries_next_tick);
324+
tcase_add_test(tc_utils, test_dhcp_messages_set_secs_from_process_start);
322325
tcase_add_test(tc_utils, test_dhcp_poll_offer_and_ack);
323326
tcase_add_test(tc_utils, test_dhcp_poll_renewing_ack_binds_client);
324327
tcase_add_test(tc_utils, test_dhcp_poll_rebinding_ack_binds_client);
@@ -333,6 +336,7 @@ Suite *wolf_suite(void)
333336
tcase_add_test(tc_utils, test_udp_try_recv_unmatched_port_sends_icmp_unreachable);
334337
tcase_add_test(tc_utils, test_udp_try_recv_unmatched_nonlocal_dst_does_not_send_icmp);
335338
tcase_add_test(tc_utils, test_dns_callback_bad_flags);
339+
tcase_add_test(tc_utils, test_dns_callback_truncated_response_aborts_query);
336340
tcase_add_test(tc_utils, test_dns_callback_bad_name);
337341
tcase_add_test(tc_utils, test_dns_callback_short_header_ignored);
338342
tcase_add_test(tc_utils, test_dns_callback_wrong_id_ignored);
@@ -348,16 +352,20 @@ Suite *wolf_suite(void)
348352
tcase_add_test(tc_utils, test_dhcp_parse_offer_len_lt_four_rejected);
349353
tcase_add_test(tc_utils, test_dhcp_parse_offer_ignores_short_unknown_option);
350354
tcase_add_test(tc_utils, test_dhcp_parse_offer_ignores_zero_len_unknown_option);
355+
tcase_add_test(tc_utils, test_dhcp_parse_offer_missing_server_id_rejected);
351356
tcase_add_test(tc_utils, test_dhcp_parse_offer_missing_end_rejected);
352357
tcase_add_test(tc_utils, test_dhcp_parse_offer_msg_type_len_ne_1_rejected);
353358
tcase_add_test(tc_utils, test_dhcp_parse_ack_truncated_option_rejected);
354359
tcase_add_test(tc_utils, test_dhcp_parse_ack_ignores_short_unknown_option);
355360
tcase_add_test(tc_utils, test_dhcp_parse_ack_msg_type_len_ne_1_rejected);
356361
tcase_add_test(tc_utils, test_dhcp_parse_ack_len_lt_four_rejected);
357362
tcase_add_test(tc_utils, test_dhcp_parse_ack_ignores_zero_len_unknown_option);
363+
tcase_add_test(tc_utils, test_dhcp_parse_ack_missing_server_id_rejected);
358364
tcase_add_test(tc_utils, test_dhcp_parse_ack_missing_end_rejected);
359365
tcase_add_test(tc_utils, test_dhcp_parse_offer_bad_magic_rejected);
360366
tcase_add_test(tc_utils, test_dhcp_parse_ack_bad_magic_rejected);
367+
tcase_add_test(tc_utils, test_dhcp_parse_offer_rejects_boot_request_op);
368+
tcase_add_test(tc_utils, test_dhcp_parse_ack_rejects_boot_request_op);
361369
tcase_add_test(tc_utils, test_dhcp_parse_offer_zero_len_option_rejected);
362370
tcase_add_test(tc_utils, test_dhcp_parse_ack_zero_len_option_rejected);
363371
tcase_add_test(tc_utils, test_dhcp_poll_no_data_and_wrong_state);
@@ -410,7 +418,7 @@ Suite *wolf_suite(void)
410418
tcase_add_test(tc_utils, test_tcp_ctrl_state_needs_rto_fin_wait_1_waits_for_payload_drain);
411419
tcase_add_test(tc_utils, test_tcp_rto_cb_fin_wait_1_with_data_uses_data_recovery);
412420
tcase_add_test(tc_utils, test_tcp_rto_cb_fin_wait_1_no_data_requeues_finack);
413-
tcase_add_test(tc_utils, test_tcp_ack_fin_wait_1_ack_of_fin_moves_to_fin_wait_2_and_stops_timer);
421+
tcase_add_test(tc_utils, test_tcp_ack_fin_wait_1_ack_of_fin_moves_to_fin_wait_2_and_arms_timeout);
414422
tcase_add_test(tc_utils, test_tcp_ack_closing_ack_of_fin_moves_to_time_wait_and_stops_timer);
415423
tcase_add_test(tc_utils, test_tcp_rto_cb_control_retry_cap_closes_socket);
416424
tcase_add_test(tc_utils, test_tcp_rto_cb_cancels_existing_timer);
@@ -688,6 +696,10 @@ Suite *wolf_suite(void)
688696
tcase_add_test(tc_proto, test_icmp_input_echo_request_ip_filter_drop);
689697
tcase_add_test(tc_proto, test_icmp_input_echo_request_eth_filter_drop);
690698
tcase_add_test(tc_proto, test_icmp_input_filter_drop_receiving);
699+
tcase_add_test(tc_proto, test_icmp_input_dest_unreach_port_unreachable_keeps_established_tcp_socket);
700+
tcase_add_test(tc_proto, test_icmp_input_dest_unreach_frag_needed_reduces_tcp_peer_mss);
701+
tcase_add_test(tc_proto, test_icmp_input_dest_unreach_port_unreachable_closes_syn_sent_tcp_socket);
702+
tcase_add_test(tc_proto, test_icmp_input_dest_unreach_port_unreachable_quoted_ip_options_keep_established_tcp_socket);
691703
tcase_add_test(tc_proto, test_udp_sendto_and_recvfrom);
692704
tcase_add_test(tc_proto, test_udp_sendto_respects_mtu_api);
693705
tcase_add_test(tc_proto, test_udp_recvfrom_sets_remote_ip);
@@ -696,6 +708,7 @@ Suite *wolf_suite(void)
696708
tcase_add_test(tc_proto, test_udp_recvfrom_null_addrlen);
697709
tcase_add_test(tc_proto, test_udp_recvfrom_src_equals_local_ip_does_not_persist_remote);
698710
tcase_add_test(tc_proto, test_dns_query_and_callback_a);
711+
tcase_add_test(tc_proto, test_dhcp_option_u32_macros_round_trip_wire_order);
699712
tcase_add_test(tc_proto, test_dhcp_parse_offer_and_ack);
700713
tcase_add_test(tc_proto, test_dhcp_schedule_lease_timer_defaults_t1_t2);
701714
tcase_add_test(tc_proto, test_dhcp_schedule_lease_timer_small_lease_clamps_t1_t2);
@@ -717,7 +730,9 @@ Suite *wolf_suite(void)
717730
tcase_add_test(tc_proto, test_regression_syn_on_last_ack_not_silently_processed);
718731
tcase_add_test(tc_proto, test_regression_fast_recovery_cwnd_ssthresh_rfc5681);
719732
tcase_add_test(tc_proto, test_regression_paws_rejects_stale_timestamp);
733+
tcase_add_test(tc_proto, test_regression_paws_accepts_wrapped_newer_timestamp);
720734
tcase_add_test(tc_proto, test_regression_dhcp_nak_restarts_configuration);
735+
tcase_add_test(tc_proto, test_regression_dhcp_boot_request_nak_ignored);
721736
tcase_add_test(tc_proto, test_regression_dns_rcode_error_aborts_query);
722737
tcase_add_test(tc_proto, test_regression_udp_checksum_zero_substituted_with_ffff);
723738
tcase_add_test(tc_proto, test_regression_last_ack_rejects_out_of_window_segment);

src/test/unit/unit_tests_api.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,7 @@ START_TEST(test_dns_skip_and_copy_name)
853853
{
854854
uint8_t buf[64];
855855
int pos = 0;
856+
int ptr_pos;
856857
int ret;
857858
char out[64];
858859

@@ -875,6 +876,15 @@ START_TEST(test_dns_skip_and_copy_name)
875876
ret = dns_copy_name(buf, sizeof(buf), pos - 2, out, sizeof(out));
876877
ck_assert_int_eq(ret, 0);
877878
ck_assert_str_eq(out, "www.example.com");
879+
880+
/* forward pointer must be rejected */
881+
ptr_pos = pos;
882+
buf[pos++] = 0xC0;
883+
buf[pos++] = (uint8_t)(ptr_pos + 2);
884+
buf[pos++] = 3; memcpy(&buf[pos], "bad", 3); pos += 3;
885+
buf[pos++] = 0;
886+
ret = dns_copy_name(buf, pos, ptr_pos, out, sizeof(out));
887+
ck_assert_int_eq(ret, -1);
878888
}
879889
END_TEST
880890

@@ -2628,6 +2638,35 @@ START_TEST(test_sock_sendto_tcp_not_established)
26282638
}
26292639
END_TEST
26302640

2641+
START_TEST(test_sock_sendto_tcp_close_wait_allowed)
2642+
{
2643+
struct wolfIP s;
2644+
int tcp_sd;
2645+
struct tsocket *ts;
2646+
struct pkt_desc *desc;
2647+
uint8_t buf[4] = {1, 2, 3, 4};
2648+
2649+
wolfIP_init(&s);
2650+
mock_link_init(&s);
2651+
2652+
tcp_sd = wolfIP_sock_socket(&s, AF_INET, IPSTACK_SOCK_STREAM, WI_IPPROTO_TCP);
2653+
ck_assert_int_gt(tcp_sd, 0);
2654+
ts = &s.tcpsockets[SOCKET_UNMARK(tcp_sd)];
2655+
ts->sock.tcp.state = TCP_CLOSE_WAIT;
2656+
ts->sock.tcp.peer_mss = TCP_MSS;
2657+
ts->src_port = 1234;
2658+
ts->dst_port = 4321;
2659+
ts->local_ip = 0x0A000001U;
2660+
ts->remote_ip = 0x0A000002U;
2661+
fifo_init(&ts->sock.tcp.txbuf, ts->txmem, TXBUF_SIZE);
2662+
2663+
ck_assert_int_eq(wolfIP_sock_sendto(&s, tcp_sd, buf, sizeof(buf), 0, NULL, 0),
2664+
(int)sizeof(buf));
2665+
desc = fifo_peek(&ts->sock.tcp.txbuf);
2666+
ck_assert_ptr_nonnull(desc);
2667+
}
2668+
END_TEST
2669+
26312670
START_TEST(test_sock_sendto_udp_sets_dest_and_assigns)
26322671
{
26332672
struct wolfIP s;

0 commit comments

Comments
 (0)