Merge pull request #1 from odiumuniverse/fix-dangling-pointer

Fix dangling pointer
This commit is contained in:
Azamat Ishbaev 2024-08-01 20:51:23 +03:00 committed by GitHub
commit 2c1b1e5588
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 7 deletions

View File

@ -7,6 +7,7 @@ with newer versions.
(git master) (git master)
* [Enter new changes just after this line - do not remove this line] * [Enter new changes just after this line - do not remove this line]
* Fixed bug with dangling pointer in snmp_traps.c
* The eth_addr_cmp and ip_addr_cmp set of functions have been renamed to eth_addr_eq, ip_addr_eq * The eth_addr_cmp and ip_addr_cmp set of functions have been renamed to eth_addr_eq, ip_addr_eq
and so on, since they return non-zero on equality. Macros for the old names exist. and so on, since they return non-zero on equality. Macros for the old names exist.
* The sio_write function used by PPP now takes the data argument as const. * The sio_write function used by PPP now takes the data argument as const.

View File

@ -343,6 +343,7 @@ snmp_send_msg(struct snmp_msg_trap *trap_msg, struct snmp_varbind *varbinds, u16
* and .iso.org.dod.internet.private.enterprises.yourenterprise * and .iso.org.dod.internet.private.enterprises.yourenterprise
* (sysObjectID) for specific traps. * (sysObjectID) for specific traps.
*/ */
struct snmp_varbind snmp_copy;
static err_t static err_t
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) 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)
{ {
@ -398,7 +399,8 @@ snmp_send_trap_or_notification_or_inform_generic(struct snmp_msg_trap *trap_msg,
snmp_v2_special_varbinds[1].value = snmp_trap_oid.id; snmp_v2_special_varbinds[1].value = snmp_trap_oid.id;
if (varbinds != NULL) { if (varbinds != NULL) {
original_prev = varbinds->prev; original_prev = varbinds->prev;
varbinds->prev = &snmp_v2_special_varbinds[1]; memcpy(&snmp_copy, &snmp_v2_special_varbinds[1], sizeof(snmp_v2_special_varbinds[1]));
varbinds->prev = &snmp_copy;
} }
varbinds = snmp_v2_special_varbinds; /* After inserting two varbinds at the beginning of the list, make sure that pointer is pointing to the first element */ varbinds = snmp_v2_special_varbinds; /* After inserting two varbinds at the beginning of the list, make sure that pointer is pointing to the first element */
} }