From e00aae4be2b5f126eb67ff3cdfd1b8e09e99fc0b Mon Sep 17 00:00:00 2001 From: наб Date: Tue, 25 May 2021 21:03:56 +0200 Subject: libefi: efi_get_devname: don't allocate procfs path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Brian Behlendorf Reviewed-by: Matthew Ahrens Reviewed-by: John Kennedy Signed-off-by: Ahelenia Ziemiańska Closes #12048 --- lib/libefi/rdwr_efi.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'lib') diff --git a/lib/libefi/rdwr_efi.c b/lib/libefi/rdwr_efi.c index ca7a760b6..1e022cc8e 100644 --- a/lib/libefi/rdwr_efi.c +++ b/lib/libefi/rdwr_efi.c @@ -218,22 +218,15 @@ read_disk_info(int fd, diskaddr_t *capacity, uint_t *lbsize) static char * efi_get_devname(int fd) { - char *path; - char *dev_name; - - path = calloc(1, PATH_MAX); - if (path == NULL) - return (NULL); + char path[32]; /* * The libefi API only provides the open fd and not the file path. * To handle this realpath(3) is used to resolve the block device * name from /proc/self/fd/. */ - (void) sprintf(path, "/proc/self/fd/%d", fd); - dev_name = realpath(path, NULL); - free(path); - return (dev_name); + (void) snprintf(path, sizeof (path), "/proc/self/fd/%d", fd); + return (realpath(path, NULL)); } static int -- cgit v1.2.3