提交 a3510e33 编写于 作者: P Peter Krempa

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
b3d06987.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1325120
上级 f06ca25d
......@@ -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;
......@@ -1445,7 +1445,7 @@ int virNetDevSetIPAddress(const char *ifname,
if (!(addrstr = virSocketAddrFormat(addr)))
goto cleanup;
if (VIR_SOCKET_ADDR_VALID(peer) && !(peerstr = virSocketAddrFormat(peer)))
if (peer && VIR_SOCKET_ADDR_VALID(peer) && !(peerstr = virSocketAddrFormat(peer)))
goto cleanup;
/* format up a broadcast address if this is IPv4 */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册