1
0
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:
Eric Blake 2010-08-31 14:25:49 -06:00
parent ff578973c7
commit ff82941604

View File

@ -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);