summaryrefslogtreecommitdiff
path: root/stand
diff options
context:
space:
mode:
authorAndrew Turner <andrew@FreeBSD.org>2020-06-10 09:31:37 +0000
committerAndrew Turner <andrew@FreeBSD.org>2020-06-10 09:31:37 +0000
commit0e281c4f0d164e703547e692e6773cb0d62f6d4a (patch)
treec3fb29cd4b7ea61c960c426a37aa7aeb4a2d43ac /stand
parenta287a973e36063119b9bfacc46dfcb01ea1ff09d (diff)
downloadsrc-test2-0e281c4f0d164e703547e692e6773cb0d62f6d4a.tar.gz
src-test2-0e281c4f0d164e703547e692e6773cb0d62f6d4a.zip
Notes
Diffstat (limited to 'stand')
-rw-r--r--stand/efi/loader/efiserialio.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/stand/efi/loader/efiserialio.c b/stand/efi/loader/efiserialio.c
index c881e23680d2..8b3f8e83e0b3 100644
--- a/stand/efi/loader/efiserialio.c
+++ b/stand/efi/loader/efiserialio.c
@@ -216,8 +216,9 @@ comc_get_con_serial_handle(const char *name)
status = efi_global_getenv(name, buf, &sz);
if (status == EFI_BUFFER_TOO_SMALL) {
buf = malloc(sz);
- if (buf != NULL)
- status = efi_global_getenv(name, buf, &sz);
+ if (buf == NULL)
+ return (NULL);
+ status = efi_global_getenv(name, buf, &sz);
}
if (status != EFI_SUCCESS) {
free(buf);
@@ -232,17 +233,13 @@ comc_get_con_serial_handle(const char *name)
free(buf);
return (handle);
}
- if (IsDevicePathEndType(node) &&
- DevicePathSubType(node) ==
- END_INSTANCE_DEVICE_PATH_SUBTYPE) {
- /*
- * Start of next device path in list.
- */
- node = NextDevicePathNode(node);
- continue;
- }
- if (IsDevicePathEnd(node))
+
+ /* Sanity check the node before moving to the next node. */
+ if (DevicePathNodeLength(node) < sizeof(*node))
break;
+
+ /* Start of next device path in list. */
+ node = NextDevicePathNode(node);
}
free(buf);
return (NULL);