Commit Graph

6850 Commits

Author SHA1 Message Date
Sylvain Rochet
49bbc2d4bf PPP, PPPoE: prevent integer overflows when computing packets length
Check that service_name and concentrator_name strings length will not
trigger integer overflows when computing packets length.
2020-10-16 19:27:46 +02:00
Sylvain Rochet
678a7a4044 PPP, PPPoE: remove casts from unsigned (strlen return value) to signed
Those casts do not serve any purpose and can be safely removed.
2020-10-16 17:17:40 +02:00
Erik Ekman
c385f31076 Remove @ref to fix doxygen build
Generating docs for file src/incl/home/travis/build/lwip-tcpip/lwip/src/include/lwip/ip4_addr.h:151:s
error: unable to resolve reference to `ip4_addr_eq' for \ref command (warning treated as error, aborting now)
2020-07-07 18:59:50 +02:00
Erik Ekman
264a5a3e97 Rename IP and Ethernet equality checkers from _cmp to _eq
Functions ending in cmp are expected to return 0 on equality but these
return non-zero.

eth_addr_cmp -> eth_addr_eq

ip_addr_cmp -> ip_addr_eq
ip4_addr_cmp -> ip4_addr_eq
ip6_addr_cmp -> ip6_addr_eq

ip_addr_netcmp -> ip_addr_net_eq
ip4_addr_netcmp -> ip4_addr_net_eq
ip6_addr_netcmp -> ip6_addr_net_eq

ip_addr_cmp_zoneless -> ip_addr_zoneless_eq
ip6_addr_cmp_zoneless -> ip6_addr_zoneless_eq

ip6_addr_cmp_zone -> ip6_addr_zone_eq
ip6_addr_netcmp_zoneless -> ip6_addr_net_zoneless_eq
ip6_addr_nethostcmp -> ip6_addr_nethost_eq
ip6_addr_cmp_packed -> ip6_addr_packed_eq
ip6_addr_cmp_solicitednode -> ip6_addr_solicitednode_eq

All call sites have been changed, and fallback macros have been added to not
break external users.
2020-07-07 18:51:45 +02:00
Erik Ekman
047f3b3306 dns: Verify setting/getting servers in unit test 2020-07-04 18:57:41 +02:00
Erik Ekman
5b7524e10e unit: Enable DNS
Avoid allocating in dns_init by enabling random source port.
2020-07-04 14:24:40 +02:00
Erik Ekman
8363c24e45 zepif: Copy possibly chained output pbuf properly
Fixes bug #58554
2020-07-03 18:55:08 +02:00
Erik Ekman
2bf8fcd7c2 pbuf: Add pbuf_copy_partial_pbuf library function
Like pbuf_copy, but can copy part of a pbuf to an offset in another.
pbuf_copy now uses this function internally.

Replace pbuf_take_at loop in icmp6 with pbuf_copy_partial_pbuf().
2020-07-03 18:55:02 +02:00
Erik Ekman
942ca825d0 ip4: Fix missing END_TEST in ip4 test case 2020-07-01 21:09:49 +02:00
Erik Ekman
776e612872 Remove extra newlines in LWIP_ASSERT messages 2020-07-01 20:52:12 +02:00
Erik Ekman
ec5f3a1563 ip6: Add ipv6 fragmentation test
Seems to work the same as ipv4, and that I was just confused by all the
loops when reading the code.
2020-07-01 20:17:29 +02:00
Erik Ekman
0bda621d3d ip4: Verify ipv4 fragmentation sends all chunks right away
Ahead of investigation how ipv6 code behaves.
2020-07-01 20:16:24 +02:00
Erik Ekman
2faa2d7009 ip6: Rename pbuf in unit test
../../../../src/../test/unit/ip6/test_ip6.c: In function ‘test_ip6_dest_unreachable_chained_pbuf’:
../../../../src/../test/unit/ip6/test_ip6.c:314:16: error: ‘main’ is usually a function [-Werror=main]
   struct pbuf *main = pbuf_alloc(PBUF_RAW, sizeof(udp_hdr), PBUF_ROM);
                ^~~~
cc1: all warnings being treated as errors
2020-07-01 10:46:33 +02:00
Erik Ekman
8fe567b86f ip6: Fix incorrect assert in ip6_frag()
New test case now passes.

Fixes bug #57374 (Found by Hiromasa Ito).
2020-06-30 01:27:37 +02:00
Erik Ekman
e2ae25d158 ip6: Add test for fragmenting special packet
Reproduces bug #57374 (Found by Hiromasa Ito).
2020-06-30 01:27:32 +02:00
Erik Ekman
90b3e45c31 pbuf: Add pbuf_copy test operating on chained pbufs
With the payload lengths not matching between source and destination.

Also remove redundant allocation check in other test, it is now done
in the test setup code.
2020-06-29 19:45:18 +02:00
Erik Ekman
a49c347b7e pbuf: Update documentation for pbuf_copy
Remove detail from when the method was called pbuf_take
which worked on packet queues.
2020-06-25 10:04:43 +02:00
Erik Ekman
488d4ad246 icmp6: Don't copy too much data
Fix of the fix for bug #58553
2020-06-24 01:09:37 +02:00
Erik Ekman
bc1da0bddb pbuf: Remove redundant tests that pbufs are freed
Already checked by lwip_check_ensure_no_alloc() in teardown function.
2020-06-24 01:00:12 +02:00
Erik Ekman
489405839a icmp6: Fix copying of chained pbuf in reply
Fixes bug #58553, and the newly added unit test.

The pbuf_take_at loop should probably be made into a pbuf library
function, which would avoid this mistake in the future and provide
a simpler implementation of pbuf_copy.
2020-06-24 01:00:12 +02:00
Erik Ekman
dd913250a9 icmp6: add test case for returning copy of chained pbufs
Currently fails due to bug #58553
2020-06-24 01:00:12 +02:00
Erik Ekman
b58e0061e0 unit: Improve message when the mem heap has usage
Show "mem heap still has 216 bytes allocated"
instead of "Assertion 'lwip_stats.mem.used == 0' failed"
2020-06-24 01:00:02 +02:00
Erik Ekman
ff67ce6e07 unit: Improve message when a memp pool has entries
Show "memp pool 'PBUF_REF/ROM' still has 2 entries allocated"
instead of "Assertion 'lwip_stats.memp[i]->used == 0' failed"
2020-06-22 00:51:09 +02:00
Daniel Pauli
0b370fbade add API function mdns_resp_netif_active() that can be used to test if an MDNS responder is active for a given network interface.
Signed-off-by: Erik Ekman <erik@kryo.se>
2020-06-19 16:23:34 +02:00
Erik Ekman
e80d4ff2cc tcp: Fix double free in tcp_split_unsent_seg()
Fixes bug #57377 (found by Hiromasa Ito).
2020-06-19 15:39:15 +02:00
Erik Ekman
ea111c511e unit: Support check v0.13.0 and later
Function name no longer needs to be fed separately when adding tests.

Also fix collision of non-static net_test variables in dhcp and netif
tests.
2020-06-19 15:39:15 +02:00
Erik Ekman
9b1056ef0e fuzz: Fix compile error in simulated glibc rand
When using LWIP_RAND_FOR_FUZZ_SIMULATE_GLIBC:

fuzz_common.c: In function ‘lwip_fuzz_rand’:
fuzz_common.c:683:11: error: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Werror=sign-compare]
  683 |   if (idx >= sizeof(rand_nrs)/sizeof((rand_nrs)[0])) {
      |           ^~
cc1: all warnings being treated as errors
2020-06-19 13:26:58 +02:00
Erik Ekman
0ed8f754c5 Restore travis-ci link in README 2020-06-07 13:59:31 +02:00
Erik Ekman
897bcb7d4e Update README
Remove text about contrib as separate git repo
Remove link to old travis-ci setup
Update links to https
2020-06-06 18:49:08 +02:00
Sylvain Rochet
3f47b04f16 PPP: add FIXME about removing netif_set_up() call later
User application code should be responsible to call netif_set_up() but
let's not break compatibility for now.

Signed-off-by: Sylvain Rochet <gradator@gradator.net>
2020-04-09 03:52:47 +02:00
Sylvain Rochet
c8fda8d46c PPP: use netif_set_up() instead of setting NETIF_FLAG_UP flag
NETIF_FLAG_UP flag is not supposed to be set by netif init callback
anymore, call netif_set_up() instead.

Sure it would be better to let user application code call netif_set_up()
by itself as it is now meant to be but let's not break compatibility for
now and add a FIXME for next release with allowed behavior break.

Signed-off-by: Sylvain Rochet <gradator@gradator.net>
2020-04-09 03:45:44 +02:00
Sylvain Rochet
cfe5ce9d49 init: raise an error if PPP CCP_SUPPORT==1 but MPPE_SUPPORT==0
Building PPP CCP support without adding any compressor support serve
no real use case. Forbid doing so instead of bloating the code with
more ifdef.

Signed-off-by: Sylvain Rochet <gradator@gradator.net>
2020-04-09 03:17:30 +02:00
Sylvain Rochet
cd140b1105 Revert "ppp: fix compiling with CCP_SUPPORT=1 but MPPE_SUPPORT=0"
This reverts commit 6e7ea92d56.

We better forbid building configurations that does not make sense instead
of bloating the code with more ifdef. Here building CCP support without
adding any compressor support serve no real use case.
2020-04-09 03:05:30 +02:00
Hannes Gredler
f36e51e9c9 tcp_out: fix tcp_output_fill_options() arguments
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-04-02 20:15:58 +02:00
Simon Goldschmidt
003d34eebd tcp: fix sequence number comparison
This fixes both undefined behavior (see bug #51447) as well as a possible bug
where sequence numbers in 31 bit distance may come through.
2020-03-27 22:59:05 +01:00
Simon Goldschmidt
e30d50710d fuzz: allow overriding LWIP_RAND for fuzz tests
Fuzz tests need reproducible code, so we need an "unsafe" version of
LWIP_RAND() in this case...

Also, to reproduce fuzz tests cases from Linux on Windows,
LWIP_RAND_FOR_FUZZ_SIMULATE_GLIBC provides the first 20 random numbers that
glibc would have...
2020-03-27 22:42:06 +01:00
Simon Goldschmidt
003f5cc12d fuzz: whitespace fixes 2020-03-09 21:50:50 +01:00
Simon Goldschmidt
b795784832 fuzz: make CC overridable from 'afl-gcc'
e.g. for debugging crashes
2020-03-09 21:40:30 +01:00
Simon Goldschmidt
412c8d1902 fuzz: fix compiler error "missing prototype" 2020-03-08 20:41:53 +01:00
Simon Goldschmidt
34352e9649 altcp: mbedtls: no need for SYS_ARCH locking 2020-03-05 21:48:08 +01:00
Simon Goldschmidt
33f2b313c7 altcp: mbedtls: coding style fixes 2020-03-05 21:45:20 +01:00
Simon Goldschmidt
87618e2f2a Revert "altcp_tls_mbedtls: ensure configuration is properly freed"
This reverts commit d84a84e5ca.

This commit seemed to be merged in an invalid order
2020-03-05 21:40:23 +01:00
Simon Goldschmidt
21cde5dc9e altcp: mbedtls: fix compiling altcp_mbedtls_lower_sent() 2020-03-05 21:36:59 +01:00
Simon Goldschmidt
74cd9a8644 ip4: add unit test for ip4addr_aton 2020-03-05 21:28:52 +01:00
Karol Domagalski
2e175a23cb ip4: ip4addr_aton: fix parsing of the octal IP representation 2020-03-05 21:27:59 +01:00
Simon Goldschmidt
adbc5b5f71 tcp: tighten up checks for received SYN
Any malicous segment could contain a SYN up to now (no check).
A SYN in the wrong segment could break OOSEQ queueing.
Fix this by allowing SYN only in states where it is required.

See bug #56397: Assert "tcp_receive: ooseq tcplen > rcv_wnd"

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-03-05 21:20:35 +01:00
Simon Goldschmidt
a02f34a193 fuzz: add pcap output to help debugging fuzz crashes 2020-03-05 21:00:00 +01:00
Simon Goldschmidt
a9052caf10 fuzz: add debug output to help debugging fuzz crashes 2020-03-05 20:49:41 +01:00
Harrold Spier
0192fe773e Fix allowing negative offset for snmp_pbuf_stream_seek()
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-02-21 17:28:33 +01:00
Simon Goldschmidt
349c077feb Fix last commit for all netif loopback traffic 2020-02-21 17:25:51 +01:00