mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-03 07:33:50 +00:00
util: storage: Fix parsing of nbd:// URI without path
If a storage file would be backed with a NBD device without path (nbd://localhost) libvirt would crash when parsing the backing path for the disk as the URI structure's path element is NULL in such case but the NBD parser would access it shamelessly.
This commit is contained in:
parent
df04741cd3
commit
fdb80ed4f6
@ -2156,7 +2156,8 @@ virStorageSourceParseBackingURI(virStorageSourcePtr src,
|
||||
/* XXX We currently don't support auth, so don't bother parsing it */
|
||||
|
||||
/* possibly skip the leading slash */
|
||||
if (VIR_STRDUP(src->path,
|
||||
if (uri->path &&
|
||||
VIR_STRDUP(src->path,
|
||||
*uri->path == '/' ? uri->path + 1 : uri->path) < 0)
|
||||
goto cleanup;
|
||||
|
||||
|
@ -871,6 +871,20 @@ mymain(void)
|
||||
(&qcow2, &nbd2), EXP_PASS,
|
||||
(&qcow2, &nbd2), ALLOW_PROBE | EXP_PASS);
|
||||
|
||||
/* Rewrite qcow2 to use an nbd: protocol without path as backend */
|
||||
virCommandFree(cmd);
|
||||
cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2",
|
||||
"-F", "raw", "-b", "nbd://example.org",
|
||||
"qcow2", NULL);
|
||||
if (virCommandRun(cmd, NULL) < 0)
|
||||
ret = -1;
|
||||
qcow2.expBackingStoreRaw = "nbd://example.org";
|
||||
|
||||
nbd2.path = NULL;
|
||||
TEST_CHAIN(absqcow2, VIR_STORAGE_FILE_QCOW2,
|
||||
(&qcow2, &nbd2), EXP_PASS,
|
||||
(&qcow2, &nbd2), ALLOW_PROBE | EXP_PASS);
|
||||
|
||||
/* qed file */
|
||||
testFileData qed = {
|
||||
.expBackingStoreRaw = absraw,
|
||||
|
Loading…
x
Reference in New Issue
Block a user