From 23f8bd4fac40739de3233f2fb3278a41c68c3f14 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 12 Feb 2013 17:09:44 +0000 Subject: [PATCH] daemon: Fix RESOLVE_MOUNTABLE, internal_parse_mountable. - The mountable->volume field was not being initialized on the device path. - XDR string fields cannot be NULL. This fixes commit 7d976657e6f02ca0b61858f668ae792a70327309. --- daemon/daemon.h | 3 ++- daemon/mountable.c | 31 ++++++++++++++++++------------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/daemon/daemon.h b/daemon/daemon.h index 04f28bb85..1d3c65c9e 100644 --- a/daemon/daemon.h +++ b/daemon/daemon.h @@ -370,7 +370,7 @@ is_zero (const char *buffer, size_t size) */ #define RESOLVE_MOUNTABLE(string,mountable,cancel_stmt,fail_stmt) \ do { \ - if (STRPREFIX ((string), "btrfsvol:")) { \ + if (STRPREFIX ((string), "btrfsvol:")) { \ if (parse_btrfsvol ((string) + strlen ("btrfsvol:"), &(mountable)) == -1)\ { \ cancel_stmt; \ @@ -383,6 +383,7 @@ is_zero (const char *buffer, size_t size) else { \ (mountable).type = MOUNTABLE_DEVICE; \ (mountable).device = (string); \ + (mountable).volume = NULL; \ RESOLVE_DEVICE((string), cancel_stmt, fail_stmt); \ } \ } while (0) diff --git a/daemon/mountable.c b/daemon/mountable.c index 610633ee9..48c6c53f7 100644 --- a/daemon/mountable.c +++ b/daemon/mountable.c @@ -36,23 +36,28 @@ do_internal_parse_mountable (const mountable_t *mountable) } ret->im_type = mountable->type; - if (mountable->device) { + + if (mountable->device) ret->im_device = strdup (mountable->device); - if (!ret->im_device) { - reply_with_perror ("strdup"); - free (ret); - return NULL; - } + else + ret->im_device = strdup (""); + + if (!ret->im_device) { + reply_with_perror ("strdup"); + free (ret); + return NULL; } - if (mountable->volume) { + if (mountable->volume) ret->im_volume = strdup (mountable->volume); - if (!ret->im_volume) { - reply_with_perror ("strdup"); - free (ret->im_device); - free (ret); - return NULL; - } + else + ret->im_volume = strdup (""); + + if (!ret->im_volume) { + reply_with_perror ("strdup"); + free (ret->im_device); + free (ret); + return NULL; } return ret;