mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-07-04 04:59:28 +03:00
util: netdev: Don't crash in virNetDevSetIPAddress if @peer is NULL
VIR_SOCKET_ADDR_VALID dereferences the pointer, thus if we pass NULL
into virNetDevSetIPAddress it crashes. Regression introduced by
b3d069872c
.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1325120
This commit is contained in:
@ -1129,7 +1129,7 @@ int virNetDevSetIPAddress(const char *ifname,
|
|||||||
unsigned int recvbuflen;
|
unsigned int recvbuflen;
|
||||||
|
|
||||||
/* The caller needs to provide a correct address */
|
/* The caller needs to provide a correct address */
|
||||||
if (VIR_SOCKET_ADDR_FAMILY(addr) == AF_INET && !VIR_SOCKET_ADDR_VALID(peer)) {
|
if (VIR_SOCKET_ADDR_FAMILY(addr) == AF_INET && peer && !VIR_SOCKET_ADDR_VALID(peer)) {
|
||||||
/* compute a broadcast address if this is IPv4 */
|
/* compute a broadcast address if this is IPv4 */
|
||||||
if (VIR_ALLOC(broadcast) < 0)
|
if (VIR_ALLOC(broadcast) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -1445,7 +1445,7 @@ int virNetDevSetIPAddress(const char *ifname,
|
|||||||
if (!(addrstr = virSocketAddrFormat(addr)))
|
if (!(addrstr = virSocketAddrFormat(addr)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (VIR_SOCKET_ADDR_VALID(peer) && !(peerstr = virSocketAddrFormat(peer)))
|
if (peer && VIR_SOCKET_ADDR_VALID(peer) && !(peerstr = virSocketAddrFormat(peer)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
/* format up a broadcast address if this is IPv4 */
|
/* format up a broadcast address if this is IPv4 */
|
||||||
|
Reference in New Issue
Block a user