Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 2 Jul 2019 20:32:35 +0000 (UTC)
From:      Toomas Soome <tsoome@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r349613 - head/stand/efi/libefi
Message-ID:  <201907022032.x62KWZQD040671@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: tsoome
Date: Tue Jul  2 20:32:35 2019
New Revision: 349613
URL: https://svnweb.freebsd.org/changeset/base/349613

Log:
  efihttp: mac and err can be used uninitialized
  
  While there, also check if mac != NULL, and use pointer compare for ipv4
  and dns.

Modified:
  head/stand/efi/libefi/efihttp.c

Modified: head/stand/efi/libefi/efihttp.c
==============================================================================
--- head/stand/efi/libefi/efihttp.c	Tue Jul  2 19:51:40 2019	(r349612)
+++ head/stand/efi/libefi/efihttp.c	Tue Jul  2 20:32:35 2019	(r349613)
@@ -127,9 +127,11 @@ setup_ipv4_config2(EFI_HANDLE handle, MAC_ADDR_DEVICE_
 	    (void **)&ip4config2, IH, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
 	if (EFI_ERROR(status))
 		return (efi_status_to_errno(status));
-	if (ipv4) {
-		setenv("boot.netif.hwaddr",
-		    ether_sprintf((u_char *)mac->MacAddress.Addr), 1);
+	if (ipv4 != NULL) {
+		if (mac != NULL) {
+			setenv("boot.netif.hwaddr",
+			    ether_sprintf((u_char *)mac->MacAddress.Addr), 1);
+		}
 		setenv("boot.netif.ip",
 		    inet_ntoa(*(struct in_addr *)ipv4->LocalIpAddress.Addr), 1);
 		setenv("boot.netif.netmask",
@@ -160,7 +162,7 @@ setup_ipv4_config2(EFI_HANDLE handle, MAC_ADDR_DEVICE_
 				return (efi_status_to_errno(status));
 		}
 
-		if (dns) {
+		if (dns != NULL) {
 			status = ip4config2->SetData(ip4config2,
 			    Ip4Config2DataTypeDnsServer,
 			    sizeof(EFI_IPv4_ADDRESS), &dns->DnsServerIp);
@@ -252,6 +254,7 @@ efihttp_dev_open(struct open_file *f, ...)
 	status = BS->LocateDevicePath(&httpsb_guid, &devpath, &handle);
 	if (EFI_ERROR(status))
 		return (efi_status_to_errno(status));
+	mac = NULL;
 	ipv4 = NULL;
 	dns = NULL;
 	uri = NULL;
@@ -662,7 +665,7 @@ static int
 efihttp_fs_read(struct open_file *f, void *buf, size_t size, size_t *resid)
 {
 	size_t res;
-	int err;
+	int err = 0;
 
 	while (size > 0) {
 		err = _efihttp_fs_read(f, buf, size, &res);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201907022032.x62KWZQD040671>