mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
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:
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user