summaryrefslogtreecommitdiff
path: root/src/mount
diff options
context:
space:
mode:
authorSage Weil <sage.weil@dreamhost.com>2011-08-21 13:50:45 -0700
committerSage Weil <sage.weil@dreamhost.com>2011-08-21 13:50:45 -0700
commit3ff9068ed3894381b0af17cd83644c4831a6f122 (patch)
tree6e4035c66be8c771af9b12bd36aeaa6e2a9c2377 /src/mount
parentb920fac493a32854c7d0ab8578b918605edcab81 (diff)
downloadceph-3ff9068ed3894381b0af17cd83644c4831a6f122.tar.gz
mount: avoid big stack item
Coverity cid 54 Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
Diffstat (limited to 'src/mount')
-rw-r--r--src/mount/canonicalize.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/mount/canonicalize.c b/src/mount/canonicalize.c
index 8ff602e807e..b0df632b20c 100644
--- a/src/mount/canonicalize.c
+++ b/src/mount/canonicalize.c
@@ -37,7 +37,7 @@ static char *
myrealpath(const char *path, char *resolved_path, int maxreslth) {
int readlinks = 0;
char *npath;
- char link_path[PATH_MAX+1];
+ char *link_path;
int n;
char *buf = NULL;
@@ -56,6 +56,7 @@ myrealpath(const char *path, char *resolved_path, int maxreslth) {
}
/* Expand each slash-separated pathname component. */
+ link_path = malloc(PATH_MAX+1);
while (*path != '\0') {
/* Ignore stray "/" */
if (*path == '/') {
@@ -93,6 +94,7 @@ myrealpath(const char *path, char *resolved_path, int maxreslth) {
/* See if last pathname component is a symlink. */
*npath = '\0';
+
n = readlink(resolved_path, link_path, PATH_MAX);
if (n < 0) {
/* EINVAL means the file exists but isn't a symlink. */
@@ -130,10 +132,12 @@ myrealpath(const char *path, char *resolved_path, int maxreslth) {
/* Make sure it's null terminated. */
*npath = '\0';
+ free(link_path);
free(buf);
return resolved_path;
err:
+ free(link_path);
free(buf);
return NULL;
}