[tip:tools/kvm] kvm tools: Fix realpath() error checking

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit-ID:  20082f5fd70db549a659a8874ea0cb73ab42984c
Gitweb:     http://git.kernel.org/tip/20082f5fd70db549a659a8874ea0cb73ab42984c
Author:     Pekka Enberg <penberg@xxxxxxxxxx>
AuthorDate: Fri, 9 Mar 2012 09:52:15 +0200
Committer:  Pekka Enberg <penberg@xxxxxxxxxx>
CommitDate: Fri, 9 Mar 2012 09:52:15 +0200

kvm tools: Fix realpath() error checking

The realpath() function can fail, so check for errors to fix up compilation
with "-Werror".

Reported-by: Sasha Levin <levinsasha928@xxxxxxxxx>
Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxx>
---
 tools/kvm/builtin-run.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/tools/kvm/builtin-run.c b/tools/kvm/builtin-run.c
index c8ae2f5..33be3bd 100644
--- a/tools/kvm/builtin-run.c
+++ b/tools/kvm/builtin-run.c
@@ -857,7 +857,8 @@ static void resolve_program(const char *src, char *dst, size_t len)
 	if (!err && S_ISREG(st.st_mode)) {
 		char resolved_path[PATH_MAX];
 
-		realpath(src, resolved_path);
+		if (!realpath(src, resolved_path))
+			die("Unable to resolve program %s: %s\n", src, strerror(errno));
 
 		snprintf(dst, len, "/host%s", resolved_path);
 	} else
--
To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux