X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=daemon%2Frealpath.c;h=ff258beec9baffafc62f60864327aa10bf84f200;hb=e494a59921456d854a070612dad3e7c1e83f30a1;hp=e6c81efbe40ab9bb0fcee810a73fa577c59d8bf1;hpb=a86eb0e0d2c67e2153139c681632edc72162b8ed;p=libguestfs.git diff --git a/daemon/realpath.c b/daemon/realpath.c index e6c81ef..ff258be 100644 --- a/daemon/realpath.c +++ b/daemon/realpath.c @@ -56,7 +56,7 @@ do_realpath (const char *path) ret = realpath (path, NULL); CHROOT_OUT; if (ret == NULL) { - reply_with_perror ("realpath"); + reply_with_perror ("%s", path); return NULL; } @@ -98,11 +98,11 @@ do_case_sensitive_path (const char *path) if ((i == 1 && path[0] == '.') || (i == 2 && path[0] == '.' && path[1] == '.')) { - reply_with_error ("case_sensitive_path: path contained . or .. elements"); + reply_with_error ("path contained . or .. elements"); goto error; } if (i > NAME_MAX) { - reply_with_error ("case_sensitive_path: path element too long"); + reply_with_error ("path element too long"); goto error; } @@ -183,7 +183,8 @@ do_case_sensitive_path (const char *path) } } - close (fd_cwd); + if (fd_cwd >= 0) + close (fd_cwd); ret[next] = '\0'; char *retp = strdup (ret); @@ -194,6 +195,8 @@ do_case_sensitive_path (const char *path) return retp; /* caller frees */ error: - close (fd_cwd); + if (fd_cwd >= 0) + close (fd_cwd); + return NULL; }