From c0932825ea9faa18f34dce6f258c7fe530dd46e7 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Thu, 22 Jul 2010 13:16:33 -0700 Subject: [PATCH] Reduce stack move path local to heap To use the -fstack-check gcc option each stack frame must be keep reasonably small. In this case the path local is moved from the stack to the heap to keep us under the limit. warning: frame size too large for reliable stack checking warning: try reducing the number of local variables --- lib/libefi/rdwr_efi.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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)) {