efi_loader: fix ipv4 device path node conversion
PATCH 1/1 efi_loader: fix ipv4 device path node conversion
When converting an IPv4 device path node to text, the EFI_DEVICE_PATH_TO_TEXT_PROTOCOL will produce the following string:
IPv4(5.6.7.8,TCP,UDP,0x6,DHCP,1.2.3.4,9.10.11.12,255.255.255.0)
This string erroneously contains multiple protocols: TCP, UDP and 0x6.
Add the missing `break' statements in the dp_msging() function to fix this and obtain the following expected string instead:
IPv4(5.6.7.8,TCP,DHCP,1.2.3.4,9.10.11.12,255.255.255.0)
--- lib/efi_loader/efi_device_path_to_text.c | 3 +++ 1 file changed, 3 insertions(+)
lib/efi_loader/efi_device_path_to_text.c +3 -0
@@ -181,10 +181,13 @@ static char *dp_msging(char *s, struct efi_device_path *dp)switch (idp->protocol) {case IPPROTO_TCP : s +=sprintf (s,"TCP," ); +break ;case IPPROTO_UDP : s +=sprintf (s,"UDP," ); +break ;default : s +=sprintf (s,"0x%x," , idp->protocol); +break ; } s +=sprintf (s, idp->static_ip_address ?"Static" :"DHCP" ); s +=sprintf (s,",%pI4" , &idp->local_ip_address);
Signature · 1 line
2.47.2
On Mon, 24 Mar 2025 09:34:43 +0100
Vincent Stehlé <[email protected]> wrote:
Hi,
Tom: I think this is v2025.04 material, as this code was introduced in this cycle.
Quoted 11 lines
When converting an IPv4 device path node to text, the
EFI_DEVICE_PATH_TO_TEXT_PROTOCOLwill produce the following string:
IPv4(5.6.7.8,TCP,UDP,0x6,DHCP,1.2.3.4,9.10.11.12,255.255.255.0)This string erroneously contains multiple protocols: TCP, UDP and
0x6.Add the missing `break' statements in the
dp_msging()function to fix this and obtain the following expected string instead:
IPv4(5.6.7.8,TCP,DHCP,1.2.3.4,9.10.11.12,255.255.255.0)
Nice catch! Being spoiled by the picky kernel, I wondered how this could slip through, only to realise that we don't use -Wimplicit-fallthrough.
So I enabled that, and somewhat expectedly found some issues, and fixed them for the one build that I tried for now. Will send a series later.
Quoted 2 lines
Fixes aaf63429a112 ("efi_loader: add IPv4() to device path to text protocol")Signed-off-by Vincent Stehlé <[email protected]>
Cheers,
Andre
Quoted 26 lines
Cc Heinrich Schuchardt <[email protected]>Cc Ilias Apalodimas <[email protected]>Cc Adriano Cordova <[email protected]>Cc Tom Rini <[email protected]>--- lib/efi_loader/efi_device_path_to_text.c | 3 +++ 1 file changed, 3 insertions(+)lib/efi_loader/efi_device_path_to_text.c +3
-0@@ -181,10 +181,13 @@ static char *dp_msging(char *s, struct efi_device_path *dp)switch (idp->protocol) {case IPPROTO_TCP : s +=sprintf (s,"TCP," ); +break ;case IPPROTO_UDP : s +=sprintf (s,"UDP," ); +break ;default : s +=sprintf (s,"0x%x," , idp->protocol); +break ; } s +=sprintf (s, idp->static_ip_address ?"Static" :"DHCP" ); s +=sprintf (s,",%pI4" , &idp->local_ip_address);
Quoted 10 lines · Vincent Stehlé
When converting an IPv4 device path node to text, the
EFI_DEVICE_PATH_TO_TEXT_PROTOCOLwill produce the following string:IPv4(5.6.7.8,TCP,UDP,0x6,DHCP,1.2.3.4,9.10.11.12,255.255.255.0)This string erroneously contains multiple protocols: TCP, UDP and
0x6.Add the missing `break' statements in the
dp_msging()function to fix this and obtain the following expected string instead:
Quoted 8 lines
IPv4(5.6.7.8,TCP,DHCP,1.2.3.4,9.10.11.12,255.255.255.0)Fixes aaf63429a112 ("efi_loader: add IPv4() to device path to text protocol")Signed-off-by Vincent Stehlé <[email protected]>Cc Heinrich Schuchardt <[email protected]>Cc Ilias Apalodimas <[email protected]>Cc Adriano Cordova <[email protected]>Cc Tom Rini <[email protected]>
Quoted 22 lines
--- lib/efi_loader/efi_device_path_to_text.c | 3 +++ 1 file changed, 3 insertions(+)lib/efi_loader/efi_device_path_to_text.c +3
-0@@ -181,10 +181,13 @@ static char *dp_msging(char *s, struct efi_device_path *dp)switch (idp->protocol) {case IPPROTO_TCP : s +=sprintf (s,"TCP," ); +break ;case IPPROTO_UDP : s +=sprintf (s,"UDP," ); +break ;default : s +=sprintf (s,"0x%x," , idp->protocol); +break ; } s +=sprintf (s, idp->static_ip_address ?"Static" :"DHCP" ); s +=sprintf (s,",%pI4" , &idp->local_ip_address);
Thanks Vincent!
Quoted 11 lines · Vincent Stehlé
When converting an IPv4 device path node to text, the
EFI_DEVICE_PATH_TO_TEXT_PROTOCOLwill produce the following string:
IPv4(5.6.7.8,TCP,UDP,0x6,DHCP,1.2.3.4,9.10.11.12,255.255.255.0)This string erroneously contains multiple protocols: TCP, UDP and
0x6.Add the missing `break' statements in the
dp_msging()function to fix this and obtain the following expected string instead:
Quoted 8 lines
IPv4(5.6.7.8,TCP,DHCP,1.2.3.4,9.10.11.12,255.255.255.0)Fixes aaf63429a112 ("efi_loader: add IPv4() to device path to text protocol")Signed-off-by Vincent Stehlé <[email protected]>Cc Heinrich Schuchardt <[email protected]>Cc Ilias Apalodimas <[email protected]>Cc Adriano Cordova <[email protected]>Cc Tom Rini <[email protected]>
Quoted 25 lines
--- lib/efi_loader/efi_device_path_to_text.c | 3 +++ 1 file changed, 3 insertions(+)lib/efi_loader/efi_device_path_to_text.c +3
-1@@ -181,10 +181,13 @@ static char *dp_msging(char *s, struct efi_device_path *dp)switch (idp->protocol) {case IPPROTO_TCP : s +=sprintf (s,"TCP," ); +break ;case IPPROTO_UDP : s +=sprintf (s,"UDP," ); +break ;default : s +=sprintf (s,"0x%x," , idp->protocol); +break ; } s +=sprintf (s, idp->static_ip_address ?"Static" :"DHCP" ); s +=sprintf (s,",%pI4" , &idp->local_ip_address); --2.47.2