mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
xenxs: Remove PATH_MAX sized stack allocation in XM script parsing
This commit is contained in:
parent
0e27b8a856
commit
1901d091f1
@ -211,6 +211,7 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
|
|||||||
const char *defaultArch, *defaultMachine;
|
const char *defaultArch, *defaultMachine;
|
||||||
int vmlocaltime = 0;
|
int vmlocaltime = 0;
|
||||||
unsigned long count;
|
unsigned long count;
|
||||||
|
char *script = NULL;
|
||||||
|
|
||||||
if (VIR_ALLOC(def) < 0) {
|
if (VIR_ALLOC(def) < 0) {
|
||||||
virReportOOMError();
|
virReportOOMError();
|
||||||
@ -556,7 +557,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
|
|||||||
if (list && list->type == VIR_CONF_LIST) {
|
if (list && list->type == VIR_CONF_LIST) {
|
||||||
list = list->list;
|
list = list->list;
|
||||||
while (list) {
|
while (list) {
|
||||||
char script[PATH_MAX];
|
|
||||||
char model[10];
|
char model[10];
|
||||||
char type[10];
|
char type[10];
|
||||||
char ip[16];
|
char ip[16];
|
||||||
@ -567,7 +567,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
|
|||||||
|
|
||||||
bridge[0] = '\0';
|
bridge[0] = '\0';
|
||||||
mac[0] = '\0';
|
mac[0] = '\0';
|
||||||
script[0] = '\0';
|
|
||||||
ip[0] = '\0';
|
ip[0] = '\0';
|
||||||
model[0] = '\0';
|
model[0] = '\0';
|
||||||
type[0] = '\0';
|
type[0] = '\0';
|
||||||
@ -602,12 +601,10 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
|
|||||||
goto skipnic;
|
goto skipnic;
|
||||||
}
|
}
|
||||||
} else if (STRPREFIX(key, "script=")) {
|
} else if (STRPREFIX(key, "script=")) {
|
||||||
int len = nextkey ? (nextkey - data) : sizeof(script) - 1;
|
int len = nextkey ? (nextkey - data) : strlen(data);
|
||||||
if (virStrncpy(script, data, len, sizeof(script)) == NULL) {
|
VIR_FREE(script);
|
||||||
XENXS_ERROR(VIR_ERR_INTERNAL_ERROR,
|
if (!(script = strndup(data, len))) {
|
||||||
_("Script %s too big for destination"),
|
goto no_memory;
|
||||||
data);
|
|
||||||
goto skipnic;
|
|
||||||
}
|
}
|
||||||
} else if (STRPREFIX(key, "model=")) {
|
} else if (STRPREFIX(key, "model=")) {
|
||||||
int len = nextkey ? (nextkey - data) : sizeof(model) - 1;
|
int len = nextkey ? (nextkey - data) : sizeof(model) - 1;
|
||||||
@ -1043,6 +1040,7 @@ cleanup:
|
|||||||
virDomainNetDefFree(net);
|
virDomainNetDefFree(net);
|
||||||
virDomainDiskDefFree(disk);
|
virDomainDiskDefFree(disk);
|
||||||
virDomainDefFree(def);
|
virDomainDefFree(def);
|
||||||
|
VIR_FREE(script);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user