nuttx/include/nuttx/net
Justin Hammond cda33ae4fc libs/libc/netdb: Size an answer header by its header, not by its union.
dns_recv_response() checked for room using sizeof(struct dns_answer_s),
but that structure is the 10-byte header plus a union holding the largest
address it can carry.  With IPv6 built the union is 16 bytes, so the check
demanded 26 bytes where 10 were needed, and any answer sitting at the end
of a response was rejected as truncated.

An A record answer supplies 14 bytes, so whether a lookup worked depended
on how much padding the server happened to send after it:

  $ dig +noedns @10.1.1.2 github.com A      # ANSWER 1, AUTHORITY 0, ADDITIONAL 0
  -> answer is last in the packet, 14 bytes remain, rejected

  $ dig +noedns @10.11.5.254 github.com A   # ANSWER 1, AUTHORITY 13, ADDITIONAL 7
  -> 26+ bytes remain, accepted

On the board, before and after, against the first of those servers:

  nsh> nslookup apache.org
  [CPU1] dns_recv_response: DNS answer header truncated
  Host: apache.org Addr: 2a04:4e42::644                 <- A record lost

  nsh> nslookup apache.org
  Host: apache.org Addr: 2a04:4e42::644
  Host: apache.org Addr: 151.101.2.132                  <- both returned

The address that follows the header is already bounds checked separately,
where its real length is known, so only the header check was wrong.  The
size is now a named constant next to the structure, since the rest of this
function already used the literal 10 for the same quantity.

Only IPv4-only builds escaped it, where sizeof happens to equal 14 and an
A record fits exactly.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Justin Hammond <justin@dynam.ac>
2026-08-08 15:02:15 -03:00
..
netfilter include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
bluetooth.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
can.h net/can: can protocol uses a separate buffer to cache can data 2025-12-25 08:56:12 -03:00
dm90x0.h boards/mips: Add networking support to CI20 board 2026-07-17 16:14:14 -03:00
dns.h libs/libc/netdb: Size an answer header by its header, not by its union. 2026-08-08 15:02:15 -03:00
e1000.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
enc28j60.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
encx24j600.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
ethernet.h net/vlan: add some macro for vlan 2025-12-27 11:36:39 +08:00
ftmac100.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
gmii.h arm64/imx9: Support & configure RGMII-ID on RTL8211F 2025-06-05 08:58:24 +02:00
icmp.h net/icmp: check the checksum field when recieve icmp message 2025-12-25 18:09:03 +08:00
icmpv6.h style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
ieee802154.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
if_bridge.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
igb.h drivers/net: add IGB network card support 2025-07-08 10:02:15 +02:00
igc.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
igmp.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
ioctl.h netdev/ioctl: Add support for simple VLAN ioctl 2025-12-09 07:56:20 -03:00
ip.h nuttx/net: Expose the net_ipv6addr_maskcmp interface to user-mode calls 2025-12-25 22:13:43 +08:00
ipopt.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
ipv6ext.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
ksz9477.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
lan91c111.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
lan9250.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
loopback.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
mdio.h net/mdio: add mdio bus 2025-09-25 16:24:18 +08:00
mii.h h7: eth: add checks for PHYID in stm32_phyinit 2025-02-12 15:00:19 -03:00
mld.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
neighbor.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
net.h style: Fix "the the" typo across the codebase. 2026-03-23 11:07:49 +01:00
netconfig.h netconfig.h:add CONFIG_NET_USRSOCK & CONFIG_NET_IPv4 & CONFIG_NET_IPv6 to support communicating in slave core 2024-12-10 18:14:26 +08:00
netdev.h netdev: delete macro CONFIG_NETDEV_CHECKSUM with nuttx 2026-01-19 23:22:46 +08:00
netdev_lowerhalf.h netdev_upperhalf: add direct rx mode 2025-12-29 14:29:24 +08:00
netlink.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
netstats.h net/can/: add statistics for recv, sent and drop 2025-01-30 11:37:29 -03:00
oa_tc6.h drivers/net/oa_tc6: Add driver for the Microchip LAN865x SPI MAC-PHY 2025-09-03 00:53:03 +08:00
phy.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
pkt.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
radiodev.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
rfc6775.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
rpmsg.h drivers/net/rpmsgdrv.c: add bidirectional data netdev support, clien side 2026-01-16 09:42:01 +08:00
rpmsgdrv.h drivers/net/rpmsgdrv.c: add bidirectional data netdev support, server side 2026-01-16 09:42:01 +08:00
sixlowpan.h style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
slip.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
sms.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
snoop.h userspace: Exclude nuttx/arch.h 2024-11-01 16:59:37 +08:00
tcp.h net/tcp: add support for the CLOSE_WAIT state 2025-12-27 21:06:23 +08:00
telnet.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
tun.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
udp.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
usrsock.h net/usrsock: replace net_lock with usrsock_lock 2026-01-01 07:35:12 -03:00
vlan.h net/vlan: Allow setting default priority (PCP) 2025-12-09 07:56:20 -03:00
w5500.h include: migrate to SPDX identifier 2024-10-04 08:18:42 +08:00
wifi_sim.h wifi: Support the wifi operations based on the bss file. 2026-01-14 09:22:54 +08:00