[Libguestfs] [PATCH] launch: direct: check for null paths in make_uri

Pino Toscano ptoscano at redhat.com
Mon Jul 28 17:53:21 UTC 2014


Some protocols may pass a null path to make_uri, so make sure to handle
that gracefully.
---
 src/launch-direct.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/launch-direct.c b/src/launch-direct.c
index 104809d..9654e04 100644
--- a/src/launch-direct.c
+++ b/src/launch-direct.c
@@ -1218,7 +1218,7 @@ make_uri (guestfs_h *g, const char *scheme, const char *user,
   CLEANUP_FREE char *userauth = NULL;
 
   /* Need to add a leading '/' to URI paths since xmlSaveUri doesn't. */
-  if (path[0] != '/') {
+  if (path != NULL && path[0] != '/') {
     pathslash = safe_asprintf (g, "/%s", path);
     uri.path = pathslash;
   }
-- 
1.9.3




More information about the Libguestfs mailing list