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";
|
||||
|
||||
do {
|
||||
char try[50];
|
||||
|
||||
snprintf(try, sizeof(try), template, id);
|
||||
|
||||
if (!virNetworkBridgeInUse(nets, try, NULL)) {
|
||||
if (!(newname = strdup(try))) {
|
||||
virReportOOMError();
|
||||
return NULL;
|
||||
}
|
||||
if (virAsprintf(&newname, template, id) < 0) {
|
||||
virReportOOMError();
|
||||
return NULL;
|
||||
}
|
||||
if (!virNetworkBridgeInUse(nets, newname, NULL)) {
|
||||
return newname;
|
||||
}
|
||||
VIR_FREE(newname);
|
||||
|
||||
id++;
|
||||
} while (id <= MAX_BRIDGE_ID);
|
||||
|
Loading…
x
Reference in New Issue
Block a user