Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion vhd/lib/vhd-util-scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include <sys/stat.h>
#include <sys/types.h>

#include "debug.h"
#include "list.h"
#include "libvhd.h"
#include "lvm-util.h"
Expand Down Expand Up @@ -482,6 +483,14 @@ copy_name(char *dst, const char *src)
static int
vhd_util_scan_extract_volume_name(char *dst, const char *src, size_t size)
{
ASSERT(dst);
ASSERT(src);

if (!*src) {
EPRINTF("parent name is empty\n");
return -EINVAL;
}

char copy[VHD_MAX_NAME_LEN], *name, *s, *c;

name = strrchr(src, '/');
Expand Down Expand Up @@ -509,6 +518,7 @@ vhd_util_scan_extract_volume_name(char *dst, const char *src, size_t size)
return -EINVAL;
}

ASSERT(c && *c == '/');
safe_strncpy(dst, ++c, size);
return 0;
}
Expand Down Expand Up @@ -542,7 +552,7 @@ vhd_util_scan_get_volume_parent(vhd_context_t *vhd, struct vhd_image *image)
if (!err)
return copy_name(image->parent, name);

return 0;
return err;
}

static int
Expand Down