buglwIP - A Lightweight TCP/IP stack - Bugs: bug #64685, snmp traps build failure (dangling...


You are not allowed to post comments on this tracker with your current authentication level.

bug #64685: snmp traps build failure (dangling pointer)

Submitter:  Erik Ekman <yarrick>
Submitted:  Sun 17 Sep 2023 09:42:22 AM UTC
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open Planned Release:  None
lwIP version:  2.1.3

Tue 10 Oct 2023 06:20:23 PM UTC, comment #1: 

You're right that it is storing the address of a variable on stack, but I don't think you're right that it is broken: as I see it the variable (although referenced by address) is only used during its lifetime, i.e. mainly for snmp_send_msg() and restored before the function is exited.

The code as it is should not have a real problem. I'm still open to change it to get rid of the warning you see, if you have any suggestion.

Simon Goldschmidt <goldsimon>
Group administrator
Sun 17 Sep 2023 09:42:22 AM UTC, original submission:  

When trying to build the fuzzer, I got this failure. Seems like it correctly detected where a pointer is given the address of a struct from the stack.

This has likely been broken since being added in patch #15072 in 2018.

../../src/apps/snmp/snmp_traps.c: In function ‘snmp_send_trap_or_notification_or_inform_generic’:
../../src/apps/snmp/snmp_traps.c:401:24: error: storing the address of local variable ‘snmp_v2_special_varbinds’ in ‘*varbinds.prev’ [-Werror=dangling-pointer=]
  401 |         varbinds->prev = &snmp_v2_special_varbinds[1];
      |         ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/apps/snmp/snmp_traps.c:356:23: note: ‘snmp_v2_special_varbinds’ declared here
  356 |   struct snmp_varbind snmp_v2_special_varbinds[] = {
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~
../../src/apps/snmp/snmp_traps.c:347:176: note: ‘varbinds’ declared here
  347 | snmp_send_trap_or_notification_or_inform_generic(struct snmp_msg_trap *trap_msg, const struct snmp_obj_id *eoid, s32_t generic_trap, s32_t specific_trap, struct snmp_varbind *varbinds)
      |                                                                                                                                                           ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
cc1: all warnings being treated as errors

Erik Ekman <yarrick>
Group Member


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by goldsimon (Posted a comment)
  • -email is unavailable- added by yarrick (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.


    No changes have been made to this item

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code