svn commit: r327574 - in head: lib/libefivar usr.sbin/efidp
Warner Losh
imp at FreeBSD.org
Fri Jan 5 07:09:26 UTC 2018
Author: imp
Date: Fri Jan 5 07:09:24 2018
New Revision: 327574
URL: https://svnweb.freebsd.org/changeset/base/327574
Log:
Set dp to NULL when we free it, and tree a NULL dp as an error
condition. This should prevent a double free. In addition, prevent a
leak by freeing dp each loop and when we're done.
CID: 1383577
Sponsored by: Netflix
Modified:
head/lib/libefivar/efivar-dp-xlate.c
head/usr.sbin/efidp/efidp.c
Modified: head/lib/libefivar/efivar-dp-xlate.c
==============================================================================
--- head/lib/libefivar/efivar-dp-xlate.c Fri Jan 5 07:09:19 2018 (r327573)
+++ head/lib/libefivar/efivar-dp-xlate.c Fri Jan 5 07:09:24 2018 (r327574)
@@ -663,6 +663,7 @@ errout:
free(rp);
if (rv != 0) {
free(*dp);
+ *dp = NULL;
}
return (rv);
}
Modified: head/usr.sbin/efidp/efidp.c
==============================================================================
--- head/usr.sbin/efidp/efidp.c Fri Jan 5 07:09:19 2018 (r327573)
+++ head/usr.sbin/efidp/efidp.c Fri Jan 5 07:09:24 2018 (r327574)
@@ -143,10 +143,13 @@ unix_to_efi(void)
char *walker;
int rv;
+ dp = NULL;
while (fgets(buffer, sizeof(buffer), stdin)) {
walker= trim(buffer);
+ free(dp);
+ dp = NULL;
rv = efivar_unix_path_to_device_path(walker, &dp);
- if (rv != 0) {
+ if (rv != 0 || dp == NULL) {
errno = rv;
warn("Can't convert '%s' to efi", walker);
continue;
@@ -158,6 +161,7 @@ unix_to_efi(void)
}
printf("%s\n", efi);
}
+ free(dp);
}
static void
More information about the svn-src-head
mailing list