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 7d976657e6.
This commit is contained in:
Richard W.M. Jones
2013-02-12 17:09:44 +00:00
parent db554cf271
commit 23f8bd4fac
2 changed files with 20 additions and 14 deletions

View File

@@ -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)

View File

@@ -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;