Runtime Error in qstrdup: Null Pointer Returned from strdup Leading to Unexpected Behavior #17171
Open
2 tasks done
Labels
triage
Needs further investigation
Description
When running the bgpd daemon, a runtime error is observed in lib/memory.c related to a null pointer being returned from a function that is expected to always return a valid pointer.
Version
How to reproduce
export LDFLAGS="-L/root/protocols/rip/frr/libyang/build"
make -j$(nproc)
frr/zebra/zebra --limit-fds 100000 -d
frr/bgpd/bgpd --limit-fds 100000 -p 179 -f /etc/bgpd.conf -i /var/run/frr/bgpd_1.pid --log stdout
Expected behavior
The qstrdup function should allocate memory for the input string using strdup and handle any errors gracefully, ensuring that mt_checkalloc only receives valid pointers.
Actual behavior
A runtime error is observed when qstrdup tries to duplicate a string:
lib/memory.c:118:63: runtime error: null pointer returned from function declared to never return null
Additional context
The issue seems to arise because qstrdup does not check if strdup returns NULL.
Checklist
The text was updated successfully, but these errors were encountered: