Skip to content

Commit f998008

Browse files
jerome-pouillerJuha Heiskanen
authored andcommitted
Fix use-after-free in mac_helper_coordinator_address_set()
Currently, the scope of the variable "short_addr" ends with the end of the "if" body. However, "short_addr" is passed to mlme_req() a bit though the variable "set_req". Signed-off-by: Jérôme Pouiller <[email protected]>
1 parent 4d04541 commit f998008

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

source/6LoWPAN/MAC/mac_helper.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,13 +476,14 @@ void mac_helper_security_key_clean(protocol_interface_info_entry_t *interface)
476476

477477
void mac_helper_coordinator_address_set(protocol_interface_info_entry_t *interface, addrtype_t adr_type, uint8_t *adr_ptr)
478478
{
479+
uint16_t short_addr;
479480
mlme_set_t set_req;
480481
set_req.attr_index = 0;
481482

482483
if (adr_type == ADDR_802_15_4_SHORT) {
483484
memcpy(interface->mac_parameters->mac_cordinator_info.mac_mlme_coord_address, adr_ptr, 2);
484485
interface->mac_parameters->mac_cordinator_info.cord_adr_mode = MAC_ADDR_MODE_16_BIT;
485-
uint16_t short_addr = common_read_16_bit(interface->mac_parameters->mac_cordinator_info.mac_mlme_coord_address);
486+
short_addr = common_read_16_bit(interface->mac_parameters->mac_cordinator_info.mac_mlme_coord_address);
486487
set_req.attr = macCoordShortAddress;
487488
set_req.value_pointer = &short_addr;
488489
set_req.value_size = 2;

0 commit comments

Comments
 (0)