minor checks on PCPSendUnsolicitedAnnounce()
/* $Id: pcpserver.c,v 1.51 2019/05/21 08:39:44 nanard Exp $ */
/* vim: tabstop=4 shiftwidth=4 noexpandtab
* MiniUPnP project
- * Website : http://miniupnp.free.fr/
+ * Website : http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
* Author : Peter Tatrai
Copyright (c) 2013 by Cisco Systems, Inc.
@@ -1682,9 +1682,12 @@ void PCPSendUnsolicitedAnnounce(int * sockets, int n_sockets)
addr.sin_addr.s_addr = inet_addr("224.0.0.1");
addr.sin_port = htons(5350);
for(i = 0; i < n_sockets; i++) {
+ if (sockets[i] < 0) {
+ continue;
+ }
len = sendto_or_schedule(sockets[i], buff, PCP_MIN_LEN, 0, (struct sockaddr *)&addr, sizeof(struct sockaddr_in));
if( len < 0 ) {
- syslog(LOG_ERR, "PCPSendUnsolicitedAnnounce() sendto(): %m");
+ syslog(LOG_ERR, "PCPSendUnsolicitedAnnounce(sockets[%d]) sendto(): %m", i);
}
}
#ifdef ENABLE_IPV6
