[PATCH] util: netdev: Don't crash in virNetDevSetIPAddress if @peer is NULL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



VIR_SOCKET_ADDR_VALID dereferences the pointer, thus if we pass NULL
into virNetDevSetIPAddress it crashes. Regression introduced by
b3d069872ce53eb.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1325120
---
 src/util/virnetdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index 712c3bc..0d030a3 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -1129,7 +1129,7 @@ int virNetDevSetIPAddress(const char *ifname,
     unsigned int recvbuflen;

     /* 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 */
         if (VIR_ALLOC(broadcast) < 0)
             return -1;
-- 
2.8.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]