Commit Graph

2703 Commits

Author SHA1 Message Date
Simon Goldschmidt
347054b329 Fix C++ compatibility of newly added function lwip_memcmp_consttime() 2024-01-09 21:26:40 +01:00
Simon Goldschmidt
25de99d1c1 Introduce constant-time memcmp and use it for snmpv3_get_engine_boots
See #65118
2024-01-09 21:14:49 +01:00
Erik Ekman
5e3268cf3e src/core: Fix speling issues
Found by codespell
2023-10-14 18:16:49 +02:00
Simon Goldschmidt
1eeb70fbfa dhcp: fix memory corruption when LWIP_DHCP_MAX_DNS_SERVERS > DNS_MAX_SERVERS
see patch #10124
2023-10-12 22:08:14 +02:00
Simon Goldschmidt
b9ca1deba8 Fix building with ISO C90
This fixes the changes of commit 574bd6e5aa
2023-10-12 21:41:49 +02:00
Simon Goldschmidt
efe78e7e5b pbuf_cat: add a simple check to ensure we don't cat the same pbuf to itself 2023-10-12 21:34:11 +02:00
duckpowerMB
574bd6e5aa tcp_in : fix ooseq update error
if a pbuf received with the same seqno in ooseq ,
we then check  the size and replace the existing one
with the larger one,but if the existing one is the
last segment in ooseq ,it might has been trimed before.
the replacing action will overrun our receive windows

see patch #10106 and bug #56397
2023-10-12 21:00:21 +02:00
Thomas Kindler
de0b97861a Fix bug #60681: Initialize custom data in pbuf struct
Add a #define that users can use to initialize LWIP_PBUF_CUSTOM_DATA fields.

see patch #10072
idea by Thomas Kindler <mail_lwip@t-kindler.de>
2023-10-12 20:29:16 +02:00
Simon Goldschmidt
f5e7e8e576 pbuf: pbuf_get_contiguous: allow passing NULL for buffer to prevent copying
see bug #62832
2023-10-12 08:26:00 +02:00
Faidon Liambotis
4f88651247 Add MEM_CUSTOM_ALLOCATOR and make LIBC a subset of it
Allow one to provide a custom implementation of free/malloc/calloc
instead of the lwip internal allocator. The code to use the libc's
implementation already existed, so generalize the existing code and make
the libc variant a specialized case of this new capability, retaining
full backwards compatibility.
2023-10-11 21:45:55 +02:00
Simon Goldschmidt
c8f42025ce ipv6 reassembly: fix detecting holes in reassembled packets
Added unit test for reassembly.

See bug #64767
2023-10-10 16:31:16 +02:00
Simon Goldschmidt
16e8ef3145 ipv6: fix ip6_current_header() after reassembly
ip6_current_header() should point to the header before the reassembled data,
not to the first received pbuf (not necessarily the same).

See bug #64031
2023-10-10 16:31:09 +02:00
Simon Goldschmidt
f85ed72bac ipv6: frag: fix bogus icmp6 response on reassembly timeout
See bug #63929
2023-10-03 17:50:28 +02:00
Simon Goldschmidt
1ef6189287 pbuf: fix "returns" documentation on pbuf_get_contiguous()
See bug #64049
2023-10-03 17:34:53 +02:00
Simon Goldschmidt
ae5a5b99eb tcp: fix compiling with LWIP_NOASSERT
See bug #64734
2023-10-03 17:31:19 +02:00
Erik Ekman
339372919a mem: Include stdio.h
Memory overflow checks uses snprintf. Reported in bug #63904.
2023-09-28 23:04:37 +02:00
Erik Ekman
6f700a157d nd6: Fix RA link-local address option length check
Length field is in units of 8 bytes.
2023-09-28 22:39:14 +02:00
Erik Ekman
7807f706f3 nd6: Update RA link-local addr option length check
lwIP might support different hardware address lengths (when using
Ethernet and 6LoWPAN for instance). Match provided lladdr length
from Router Advertisement to the current network interface instead
of comparing against longest that can be stored.
2023-09-28 22:23:25 +02:00
Simon Goldschmidt
d8b97bfc5d icmp: fix bug #64211 (ICMP reply error when using bridge)
when reusing an rx pbuf for tx, its if_idx has to be reset or else bridgeif_send_to_port() might drop it
2023-09-27 21:49:24 +02:00
Simon Goldschmidt
3eeda139bc minor coding style/spelling fixes 2023-09-22 09:54:36 +02:00
Simon Goldschmidt
b92faffaaa LWIP_VLAN_PCP==1: initialize tci correctly (disabled); add pcb_tci_*() functions to access the tci 2023-09-22 09:53:13 +02:00
Simon Goldschmidt
657c9735a7 doxygen: dhcp: fix doxygen stumbling over nonexisting define 2023-06-29 21:59:05 +02:00
Shawn Silverman
f84076b112 Add missing terminating newlines to LWIP_DEBUGF statements 2023-05-11 22:13:51 +02:00
Mingjie Shen
e3a20b3bc2 mdns: Add null check for pbuf_skip 2023-05-11 21:26:22 +02:00
David Cermak
3aa82745c1 dhcp: Add macro for appending extra client's request options
Co-Authored-By: Liu Han <liuhan@espressif.com>
Co-Authored-By: Simon Goldschmidt <goldsimon@gmx.de>
2023-05-11 21:03:11 +02:00
Logan Gunthorpe
90b2a6b4c4 dhcp: Set hostname for DISCOVER packets
If the hostname is not set in the DISCOVER packet, then some servers might
issue an OFFER with hostname configured and consequently reject the REQUEST
with any other hostname.

Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Co-Authored-By: Simon Goldschmidt <goldsimon@gmx.de>
2023-05-11 20:59:15 +02:00
xueyunfei
5231c8da23 dhcp: Enable custom config for timeouts, thresholds, backoff time
Enables to configure:
* DHCP_COARSE_TIMER_SECS
* if DHCP_DEFINE_CUSTOM_TIMEOUTS defined these addtional options are
available:
  - DHCP_CALC_TIMEOUT_FROM_OFFERED_T0_LEASE to adjust the t0 lease timeout from the offered value
  - DHCP_CALC_TIMEOUT_FROM_OFFERED_T1_RENEW same for t1 renew
  - DHCP_CALC_TIMEOUT_FROM_OFFERED_T2_REBIND same for t2 rebind
  - DHCP_NEXT_TIMEOUT_THRESHOLD to adjust the period of the next timeout
  - DHCP_REQUEST_BACKOFF_SEQUENCE to adjust back-off times based on DHCP
request attempts
Also updates timeout type from u16 to u32 - eps useful when DHCP_COARSE_TIMER_SECS is a smaller number
2023-05-11 20:49:14 +02:00
David Cermak
00f5e179b5 dhcp: Move in-place timeout/threshold calculations to macros 2023-05-11 20:44:21 +02:00
Jonathan Neuschäfer
d8d1e4a015 altcp: Fix NULL pointer dereference found by fuzzing
Reproducer (in bash):

base64 -d <<< "H4sIAP/9L2QCA+3WoQ2AMBSE4QoCTFHBBJfgSRF4RDfpRmgmYBpGQRBCk4ZiSfk/+fJMK+5dZRVpzSQzSs6oPierDV4y87WxLQLwE42SfNCdDyHJB9/xZwAARPbMJbUq4JJmu4JVT1cAAACfbGIqoqcMzy90eu+aBw2+N28WFgAA" | gunzip | test/fuzz/lwip_fuzz2

Crash log:

../../src/core/altcp_tcp.c:178:13: runtime error: member access within null pointer of type 'struct tcp_pcb'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../../src/core/altcp_tcp.c:178:13 in
AddressSanitizer:DEADLYSIGNAL
=================================================================
==192415==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000048 (pc 0x557065081703 bp 0x0aae0cb71204 sp 0x7ffd034dabc0 T0)
==192415==The signal is caused by a READ memory access.
==192415==Hint: address points to the zero page.
    #0 0x557065081703 in altcp_tcp_setup_callbacks /.../lwip/test/fuzz/../../src/core/altcp_tcp.c:178:19
    #1 0x55706508206f in altcp_tcp_setup /.../lwip/test/fuzz/../../src/core/altcp_tcp.c:189:3
    #2 0x55706508206f in altcp_tcp_accept /.../lwip/test/fuzz/../../src/core/altcp_tcp.c:84:5
    #3 0x557065095592 in tcp_input /.../lwip/test/fuzz/../../src/core/tcp_in.c:380:9
    #4 0x5570650e752f in ip4_input /.../lwip/test/fuzz/../../src/core/ipv4/ip4.c:743:9
    #5 0x55706513d4de in ethernet_input /.../lwip/test/fuzz/../../src/netif/ethernet.c:186:9
    #6 0x557064fe0959 in input_pkt /.../lwip/test/fuzz/fuzz_common.c:209:9
    #7 0x557064fdeb6a in input_pkts /.../lwip/test/fuzz/fuzz_common.c:257:9
    #8 0x557064fdeb6a in lwip_fuzztest /.../lwip/test/fuzz/fuzz_common.c:669:3
    #9 0x7ff4f578e189 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    #10 0x7ff4f578e244 in __libc_start_main csu/../csu/libc-start.c:381:3
    #11 0x557064f20420 in _start (/.../lwip/test/fuzz/lwip_fuzz2+0x81420) (BuildId: 8680a96430d5749c90111fe9c3a3d4f881a5dbcd)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /.../lwip/test/fuzz/../../src/core/altcp_tcp.c:178:19 in altcp_tcp_setup_callbacks
==192415==ABORTING
Aborted
2023-04-07 22:32:18 +02:00
Simon Goldschmidt
790b914fea pbuf_copy_partial_pbuf: fix warning about assigning to smaller type when using '-=' operator
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2022-12-22 20:43:18 +01:00
yuanjm
239918ccc1 tcp: Make retransmission timeout (RTO) configurable 2022-05-09 21:24:57 +02:00
Florian La Roche
62ac0faad8 redefine many vars as "static"
See patch #10156
2021-12-30 22:13:01 +01:00
Florian La Roche
089697bb1c Use NULL instead of 0 as a pointer
Recommended by 'sparse' tool
2021-11-27 15:49:20 +01:00
Florian La Roche
53c09fe921 tcp_out: move debug output to after checking pcb 2021-11-24 23:17:16 +01:00
Simon Goldschmidt
39a9c5a3c5 netif: fix removing ext-callback while callback is called
When a registered netif ext-callback unregisters itself when being
called (e.g. because some state is reached by this event), the invoke
iteration might access uninitialized memory or at least stop the
iteration (because next is set to null).

Fix his by caching the next pointer during iteration before calling
callbacks.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2021-10-01 19:44:07 +02:00
Simon Goldschmidt
a8e8ce4108 dhcp: don't set a default gateway if dhcp server doesn't give one
see bug #60578
2021-05-14 10:32:57 +02:00
Axel Lin
919dc2019a acd: Fix updating prev pointer in acd_remove
Fixes: 3a788b6e8b ("dhcp: remove acd handle when stopping dhcp")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2021-05-14 13:48:43 +08:00
Eric Koldeweij
b538bff383 ip6: Fix crash in ip6_output with debug enabled
It turns out the crash only occurs if LWIP_DEBUG is enabled. If the
parameter dest is NULL the function tries to find a route using the
destination address of the packet instead. If this fails as well a
debug message is printed but it is still using dest causing a NULL
pointer dereference and crash at src/core/ipv6/ip6.c line 1312.

[erik@kryo.se: Apply fix to ip6_output_hinted as well]
2021-05-13 13:40:33 +02:00
Erik Ekman
b9056e148e acd: Fix LWIP_ASSERT argument order 2021-05-13 13:28:02 +02:00
Simon Goldschmidt
3a788b6e8b dhcp: remove acd handle when stopping dhcp
see bug #57706
2021-05-12 21:05:17 +02:00
Simon Goldschmidt
fa5ca55c9d pbuf_realloc: check that mem_trim does not move the memory
Our own implementation does not do this, but overridden implementations
calling 'realloc()' might invalidly do this
2021-05-12 21:05:17 +02:00
Erik Ekman
b0e347158d dhcp: Add missing newline to debug message 2021-03-25 20:56:21 +01:00
Simon Goldschmidt
3ff267fbed dhcp: prevent dhcp_cleanup passing external data to heap 2021-03-04 22:20:17 +01:00
Simon Goldschmidt
c7e1b35899 dhcp: convert 'subnet_mask_given' to 'flags'
Don't waste 7 bits (in preparation for more flags)
2021-03-04 22:16:19 +01:00
Oliver Hitz
b5176936c7 tcp: make tcp_listen() inherit the netbuf_idx of the original pcb
This simple patch causes tcp_listen() to inherit the netbuf_idx setting
of the original pcb. Without this, it is not possible to restrict a
socket to a specific interface using SO_BINDTODEVICE before listening.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2021-03-04 21:15:25 +01:00
Simon Goldschmidt
3666dcc66c tcp: send RST to input netif when no pcb is available
If we know there's no matchin pcb (e.g. for routing), don't even
try to pass NULL but instead send the RST to the input netif.

See also patch #9988.
2021-03-04 21:10:28 +01:00
Christoffer Lind
600e248f06 dhcp: generate new xid for DHCP release 2021-03-02 22:49:57 +01:00
Simon Goldschmidt
9aae444f49 pbuf_free: remove outdated comment about packet queues
See bug #59875
2021-01-30 22:08:36 +01:00
Simon Goldschmidt
3e098f90df pbuf: fix allocating large PBUF_RAM
See bug #59974
2021-01-30 22:06:46 +01:00
Erik Ekman
35550eeab3 icmp: Fix copied length in response packets
Fixes bug #59364, reported by Yi Guai
2021-01-13 20:31:55 +01:00