obgm / libcoap

A CoAP (RFC 7252) implementation in C

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Segmentation fault in coap_new_client_session

torres98 opened this issue · comments

Environment

  • Build System: Make 4.3 | CMake 3.27.4
  • Operating System: Ubuntu 22.04.03 LTS
  • Hosted Environment: None

libcoap Configuration Summary

configure_output.txt

Problem Description

Whenever i call the coap_new_client_session i get a segmentation fault with the 4.3.2 and 4.3.3 tagged versions (while using 4.3.1 doesn't raise this problem).

Expected Behavior

No segfault during the call.

Actual Behavior

I get a segmentation fault during the coap_new_client_session function call. With debugging enabled, i end up with the following sequence of calls before the segfault:

  1. coap_new_client_session
  2. coap_session_create_client
  3. coap_netif_dgrm_connect (at coap_session.c:1189)
  4. coap_socket_connect_udp (at coap_netif.c:55)
  5. coap_is_mcast (at coap_io.c:222)
  6. coap_is_bcast (at coap_address.c:118)

segfault at coap_address.c:217

Local variables at segfault time:

ifa = 0x5555555b8830
ife = 0x5555555b88e8
ipv4 = {s_addr = 16777343}
i = 32767
now = 39161

Steps to reproduce

After installing libcoap with the tagged versions 4.3.2 or 4.3.3, compile the client source code with the following command:

gcc client.c -l coap-3 -o client
./client

Code to reproduce this issue

client_code.txt

Debug Logs

Only a (not meaningful) debug line is printed with the minimum debug level.

I noticed that on develop this has been fixed, closing it.

Yes, develop branch fixes a NULL ptr issue when getifaddrs() returns a struct ifaddrs that does not have ifa_addr set.