mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
network: use virAsprintf when appropriate
* src/conf/network_conf.c (virNetworkAllocateBridge): Avoid limited buffer from snprintf.
This commit is contained in:
parent
ff578973c7
commit
ff82941604
@ -891,17 +891,14 @@ char *virNetworkAllocateBridge(const virNetworkObjListPtr nets,
|
|||||||
template = "virbr%d";
|
template = "virbr%d";
|
||||||
|
|
||||||
do {
|
do {
|
||||||
char try[50];
|
if (virAsprintf(&newname, template, id) < 0) {
|
||||||
|
virReportOOMError();
|
||||||
snprintf(try, sizeof(try), template, id);
|
return NULL;
|
||||||
|
}
|
||||||
if (!virNetworkBridgeInUse(nets, try, NULL)) {
|
if (!virNetworkBridgeInUse(nets, newname, NULL)) {
|
||||||
if (!(newname = strdup(try))) {
|
|
||||||
virReportOOMError();
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return newname;
|
return newname;
|
||||||
}
|
}
|
||||||
|
VIR_FREE(newname);
|
||||||
|
|
||||||
id++;
|
id++;
|
||||||
} while (id <= MAX_BRIDGE_ID);
|
} while (id <= MAX_BRIDGE_ID);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user