ofnet: Initialize structs in bootpath parser
PATCH v2 1/1 ofnet: Initialize structs in bootpath parser
Code later on checks if variables inside the struct are 0 to see if they have been set, like if there were addresses in the bootpath.
The variables were not initialized however, so the check might succeed with uninitialized data, and a new interface with random addresses and the same name is added. This causes $net_default_mac to point to the random one, so, for example, using that variable to load per-mac config files fails.
Bug-Ubuntu: https://bugs.launchpad.net/bugs/1785859
---
Notes:
v2: Rewrote commit message to address review comments and make it look nicer
grub-core/net/drivers/ieee1275/ofnet.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
grub-core/net/drivers/ieee1275/ofnet.c +2 -2
@@ -153,8 +153,8 @@ grub_ieee1275_parse_bootpath (const char *devpath, char *bootpath,char *comma_char =0 ;char *equal_char =0 ;grub_size_t field_counter =0 ; -grub_net_network_level_address_t client_addr, gateway_addr, subnet_mask; -grub_net_link_level_address_t hw_addr; +grub_net_network_level_address_t client_addr = {}, gateway_addr = {}, subnet_mask = {}; +grub_net_link_level_address_t hw_addr = {};grub_net_interface_flags_t flags =0 ;struct grub_net_network_level_interface *inter =NULL ;grub_uint16_t vlantag =0 ;
Signature · 1 line
2.17.1
Quoted 4 lines · Julian Andres Klode
Code later on checks if variables inside the struct are 0 to see if they have been set, like if there were addresses in the bootpath.
Quoted 8 lines
The variables were not initialized however, so the check might succeed with uninitialized data, and a new interface with random addresses and the same name is added. This causes $net_default_mac to point to the random one, so, for example, using that variable to load per-mac config files fails.
Bug-Ubuntu: https://bugs.launchpad.net/bugs/1785859
Signed-off-by Julian Andres Klode <[email protected]>
Daniel