Skip to contentSkip to conversation

VirtFS update

GIT PULL New Aneesh Kumar K.V 2 participants 4 messages Jun 16, 2015 – Jun 17, 2015

lore
Share & tools
lore
#2 lore raw

PATCH 2/2 virtfs-proxy-helper: fail gracefully if socket path is too long

In reply to Aneesh Kumar K.V

From: Stefan Hajnoczi <[email protected]>

Replace the assertion check with graceful failure when the socket path is too long. Programs should not crash on invalid input. Print an error message and exit properly.

---
 fsdev/virtfs-proxy-helper.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
fsdev/virtfs-proxy-helper.c +6 -1
index 91e8b9b7f1cf..9097d15c989c 100644
@@ -739,7 +739,12 @@ static int proxy_socket(const char *path, uid_t uid, gid_t gid)
         return -1;
     }
 
-    g_assert(strlen(path) < sizeof(proxy.sun_path));
+    if (strlen(path) >= sizeof(proxy.sun_path)) {
+        do_log(LOG_CRIT, "UNIX domain socket path exceeds %zu characters\n",
+               sizeof(proxy.sun_path));
+        return -1;
+    }
+
     sock = socket(AF_UNIX, SOCK_STREAM, 0);
     if (sock < 0) {
         do_perror("socket");
Signature · 1 line
2.1.4
#0 lore raw

The following changes since commit 93f6d1c16036aaf34055d16f54ea770fb8d6d280:

Merge remote-tracking branch 'remotes/kraxel/tags/pull-vga-20150615-1' into staging (2015-06-16 10:35:43 +0100)

are available in the git repository at:

https://github.com/kvaneesh/qemu.git tags/for-upstream-signed

for you to fetch changes up to f8d30a4f96d6c3a12e692d2e69b8fe4734b916c6:

virtfs-proxy-helper: fail gracefully if socket path is too long (2015-06-16 20:32:29 +0530)

----------------------------------------------------------------
VirtFS update:

* Fix for virtfs-proxy-helper crash
* Gracefully handle the error condition on input validation in virtfs-proxy-helper

----------------------------------------------------------------
Stefan Hajnoczi (2):
virtfs-proxy-helper: add missing long option terminator
virtfs-proxy-helper: fail gracefully if socket path is too long

 fsdev/virtfs-proxy-helper.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
Signature · 1 line
2.1.4
#1 lore raw

PATCH 1/2 virtfs-proxy-helper: add missing long option terminator

From: Stefan Hajnoczi <[email protected]>

The getopt_long(3) long options array must have a zeroed terminator.

This patch solves a segmentation fault when an unknown command-line option is encountered:

  $ fsdev/virtfs-proxy-helper --help
  Segmentation fault (core dumped)
---
 fsdev/virtfs-proxy-helper.c | 1 +
 1 file changed, 1 insertion(+)
fsdev/virtfs-proxy-helper.c +1 -0
index a698e2dbb37b..91e8b9b7f1cf 100644
@@ -49,6 +49,7 @@ static struct option helper_opts[] = {
     {"socket", required_argument, NULL, 's'},
     {"uid", required_argument, NULL, 'u'},
     {"gid", required_argument, NULL, 'g'},
+    {},
 };
 
 static bool is_daemon;
Signature · 1 line
2.1.4
#3 lore raw
In reply to Aneesh Kumar K.V
Quoted 12 lines · Aneesh Kumar K.V

The following changes since commit 93f6d1c16036aaf34055d16f54ea770fb8d6d280:

Merge remote-tracking branch 'remotes/kraxel/tags/pull-vga-20150615-1' into staging (2015-06-16 10:35:43 +0100)

are available in the git repository at:

https://github.com/kvaneesh/qemu.git tags/for-upstream-signed

for you to fetch changes up to f8d30a4f96d6c3a12e692d2e69b8fe4734b916c6:

virtfs-proxy-helper: fail gracefully if socket path is too long (2015-06-16 20:32:29 +0530)

Quoted 7 lines

----------------------------------------------------------------
VirtFS update:

* Fix for virtfs-proxy-helper crash
* Gracefully handle the error condition on input validation in virtfs-proxy-helper

----------------------------------------------------------------

Applied, thanks.

-- PMM