提交 fef3a810 编写于 作者: P Peter Krempa

qemu: command: escape smbios entry strings

We pass free-form strings from the users to qemu, thus we need escape
commas since they are passed to qemu monitor.

Partially resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1373535
上级 ec454395
...@@ -5621,17 +5621,25 @@ qemuBuildSmbiosBiosStr(virSysinfoBIOSDefPtr def) ...@@ -5621,17 +5621,25 @@ qemuBuildSmbiosBiosStr(virSysinfoBIOSDefPtr def)
virBufferAddLit(&buf, "type=0"); virBufferAddLit(&buf, "type=0");
/* 0:Vendor */ /* 0:Vendor */
if (def->vendor) if (def->vendor) {
virBufferAsprintf(&buf, ",vendor=%s", def->vendor); virBufferAddLit(&buf, ",vendor=");
virQEMUBuildBufferEscapeComma(&buf, def->vendor);
}
/* 0:BIOS Version */ /* 0:BIOS Version */
if (def->version) if (def->version) {
virBufferAsprintf(&buf, ",version=%s", def->version); virBufferAddLit(&buf, ",version=");
virQEMUBuildBufferEscapeComma(&buf, def->version);
}
/* 0:BIOS Release Date */ /* 0:BIOS Release Date */
if (def->date) if (def->date) {
virBufferAsprintf(&buf, ",date=%s", def->date); virBufferAddLit(&buf, ",date=");
virQEMUBuildBufferEscapeComma(&buf, def->date);
}
/* 0:System BIOS Major Release and 0:System BIOS Minor Release */ /* 0:System BIOS Major Release and 0:System BIOS Minor Release */
if (def->release) if (def->release) {
virBufferAsprintf(&buf, ",release=%s", def->release); virBufferAddLit(&buf, ",release=");
virQEMUBuildBufferEscapeComma(&buf, def->release);
}
return virBufferContentAndReset(&buf); return virBufferContentAndReset(&buf);
} }
...@@ -5652,27 +5660,40 @@ qemuBuildSmbiosSystemStr(virSysinfoSystemDefPtr def, ...@@ -5652,27 +5660,40 @@ qemuBuildSmbiosSystemStr(virSysinfoSystemDefPtr def,
virBufferAddLit(&buf, "type=1"); virBufferAddLit(&buf, "type=1");
/* 1:Manufacturer */ /* 1:Manufacturer */
if (def->manufacturer) if (def->manufacturer) {
virBufferAsprintf(&buf, ",manufacturer=%s", virBufferAddLit(&buf, ",manufacturer=");
def->manufacturer); virQEMUBuildBufferEscapeComma(&buf, def->manufacturer);
}
/* 1:Product Name */ /* 1:Product Name */
if (def->product) if (def->product) {
virBufferAsprintf(&buf, ",product=%s", def->product); virBufferAddLit(&buf, ",product=");
virQEMUBuildBufferEscapeComma(&buf, def->product);
}
/* 1:Version */ /* 1:Version */
if (def->version) if (def->version) {
virBufferAsprintf(&buf, ",version=%s", def->version); virBufferAddLit(&buf, ",version=");
virQEMUBuildBufferEscapeComma(&buf, def->version);
}
/* 1:Serial Number */ /* 1:Serial Number */
if (def->serial) if (def->serial) {
virBufferAsprintf(&buf, ",serial=%s", def->serial); virBufferAddLit(&buf, ",serial=");
virQEMUBuildBufferEscapeComma(&buf, def->serial);
}
/* 1:UUID */ /* 1:UUID */
if (def->uuid && !skip_uuid) if (def->uuid && !skip_uuid) {
virBufferAsprintf(&buf, ",uuid=%s", def->uuid); virBufferAddLit(&buf, ",uuid=");
virQEMUBuildBufferEscapeComma(&buf, def->uuid);
}
/* 1:SKU Number */ /* 1:SKU Number */
if (def->sku) if (def->sku) {
virBufferAsprintf(&buf, ",sku=%s", def->sku); virBufferAddLit(&buf, ",sku=");
virQEMUBuildBufferEscapeComma(&buf, def->sku);
}
/* 1:Family */ /* 1:Family */
if (def->family) if (def->family) {
virBufferAsprintf(&buf, ",family=%s", def->family); virBufferAddLit(&buf, ",family=");
virQEMUBuildBufferEscapeComma(&buf, def->family);
}
return virBufferContentAndReset(&buf); return virBufferContentAndReset(&buf);
} }
...@@ -5689,24 +5710,33 @@ qemuBuildSmbiosBaseBoardStr(virSysinfoBaseBoardDefPtr def) ...@@ -5689,24 +5710,33 @@ qemuBuildSmbiosBaseBoardStr(virSysinfoBaseBoardDefPtr def)
virBufferAddLit(&buf, "type=2"); virBufferAddLit(&buf, "type=2");
/* 2:Manufacturer */ /* 2:Manufacturer */
if (def->manufacturer) virBufferAddLit(&buf, ",manufacturer=");
virBufferAsprintf(&buf, ",manufacturer=%s", virQEMUBuildBufferEscapeComma(&buf, def->manufacturer);
def->manufacturer);
/* 2:Product Name */ /* 2:Product Name */
if (def->product) if (def->product) {
virBufferAsprintf(&buf, ",product=%s", def->product); virBufferAddLit(&buf, ",product=");
virQEMUBuildBufferEscapeComma(&buf, def->product);
}
/* 2:Version */ /* 2:Version */
if (def->version) if (def->version) {
virBufferAsprintf(&buf, ",version=%s", def->version); virBufferAddLit(&buf, ",version=");
virQEMUBuildBufferEscapeComma(&buf, def->version);
}
/* 2:Serial Number */ /* 2:Serial Number */
if (def->serial) if (def->serial) {
virBufferAsprintf(&buf, ",serial=%s", def->serial); virBufferAddLit(&buf, ",serial=");
virQEMUBuildBufferEscapeComma(&buf, def->serial);
}
/* 2:Asset Tag */ /* 2:Asset Tag */
if (def->asset) if (def->asset) {
virBufferAsprintf(&buf, ",asset=%s", def->asset); virBufferAddLit(&buf, ",asset=");
virQEMUBuildBufferEscapeComma(&buf, def->asset);
}
/* 2:Location */ /* 2:Location */
if (def->location) if (def->location) {
virBufferAsprintf(&buf, ",location=%s", def->location); virBufferAddLit(&buf, ",location=");
virQEMUBuildBufferEscapeComma(&buf, def->location);
}
if (virBufferCheckError(&buf) < 0) if (virBufferCheckError(&buf) < 0)
goto error; goto error;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册