The server application encountered a runtime error detected by UndefinedBehaviorSanitizer (UBSan) during the execution of routine tasks. UBSan identified a null pointer being passed as the second argument to the memcpy function, which is explicitly declared to never accept a null pointer according to the annotations in string.h. The specific error was reported within the server_handle_regular function of test_coap_server.c.
Crash report
log of server:
Info : Received confirmable request from address 127.0.0.1 and port 58854
Info : Request URI path requires a piggy-backed response to address 127.0.0.1 and port 58854
Info : Responding to address 127.0.0.1 and port 58854
Notice : handle regular
Received:
ver: 0x01
type: 0x00
token_len: 4
code_class: 0
code_detail: 1
msg_id: 0x26c4
token: 0x88 0x18 0x8c 0x3d
op[0].num: 11
op[0].len: 7
op[0].val: 0x72 0x65 0x67 0x75 0x6c 0x61 0x72
payload:
payload_len: 0
Sent:
ver: 0x01
type: 0x00
token_len: 0
code_class: 2
code_detail: 5
msg_id: 0x0000
token:
payload: qwertyuiopasdfgh
payload_len: 16
Here is the UBSan report:
test_coap_server.c:361:29: runtime error: null pointer passed as argument 2, which is declared to never be null
/usr/include/string.h:44:28: note: nonnull attribute specified here
#0 0x4cb239 in server_handle_regular FreeCoAP/test/test_coap_server/test_coap_server.c:361:9
#1 0x4c8e1b in server_handle FreeCoAP/test/test_coap_server/test_coap_server.c:616:15
#2 0x4db596 in coap_server_exchange FreeCoAP/lib/src/coap_server.c:2440:15
#3 0x4d7c1f in coap_server_run FreeCoAP/lib/src/coap_server.c:2559:15
#4 0x4c8b95 in main FreeCoAP/test/test_coap_server/test_coap_server.c:747:11
#5 0x7fa12859d0b2 in __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16
#6 0x41c36d in _start (FreeCoAP/test/test_coap_server/test_coap_server+0x41c36d)
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior test_coap_server.c:361:29 in
Reproduce Info
Version:v0.7
Build Environment Update
The
Makefile
within thetest_coap_server
directory have been updated to utilizeclang
with sanitizers.Building test_coap_server
Run Instructions
Starting the CoAP Server
The CoAP server was started using the
test_coap_server
executable:Sending a Packet
The packet was sent to the server using the following command:
The packet's structure is as follows:
The hex representation of the datagram sent to the server is as follows:
Description
The server application encountered a runtime error detected by UndefinedBehaviorSanitizer (UBSan) during the execution of routine tasks. UBSan identified a null pointer being passed as the second argument to the
memcpy
function, which is explicitly declared to never accept a null pointer according to the annotations instring.h
. The specific error was reported within theserver_handle_regular
function oftest_coap_server.c
.Crash report
log of server:
Here is the UBSan report: