diff --git a/lib/libefi/rdwr_efi.c b/lib/libefi/rdwr_efi.c index 7c0f5b4787..d3bc8d84ad 100644 --- a/lib/libefi/rdwr_efi.c +++ b/lib/libefi/rdwr_efi.c @@ -149,10 +149,16 @@ static int efi_get_info(int fd, struct dk_cinfo *dki_info) { #if defined(__linux__) - char path[PATH_MAX]; + char *path; char *dev_path; int rval = 0; + memset(dki_info, 0, sizeof(*dki_info)); + + path = calloc(PATH_MAX, 1); + if (path == NULL) + goto error; + /* * The simplest way to get the partition number under linux is * to parse it out of the /dev/ block device name. @@ -166,9 +172,11 @@ efi_get_info(int fd, struct dk_cinfo *dki_info) * /proc/self/fd/. Aside from the partition number we collect * some additional device info. */ - memset(dki_info, 0, sizeof(*dki_info)); (void) sprintf(path, "/proc/self/fd/%d", fd); - if ((dev_path = realpath(path, NULL)) == NULL) + dev_path = realpath(path, NULL); + free(path); + + if (dev_path == NULL) goto error; if ((strncmp(dev_path, "/dev/sd", 7) == 0)) {