miniupnpd/upnpevents.c: Better error checking after connect()

This commit is contained in:
Thomas Bernard 2012-10-05 00:32:04 +02:00
parent 5de71bc396
commit 38939ac2d9
2 changed files with 16 additions and 1 deletions

View File

@ -4,6 +4,7 @@ $Id: Changelog.txt,v 1.318 2012/10/04 22:11:55 nanard Exp $
updated DEFAULTCONNECTIONSERVICE_MAGICALVALUE for IGDv2
increased default buffer size for HTTP response
More argument check for SOAP actions in UPNP_STRICT mode
Better error checking after connect() in upnpevent
2012/10/03:
Fix atoi() on null pointer in upnpsoap.c

View File

@ -426,9 +426,23 @@ static void upnp_event_recv(struct upnp_event_notify * obj)
static void
upnp_event_process_notify(struct upnp_event_notify * obj)
{
int err;
socklen_t len;
switch(obj->state) {
case EConnecting:
/* now connected or failed to connect */
len = sizeof(err);
if(getsockopt(obj->s, SOL_SOCKET, SO_ERROR, &err, &len) < 0) {
syslog(LOG_ERR, "%s: getsockopt: %m", "upnp_event_process_notify");
obj->state = EError;
break;
}
if(err != 0) {
errno = err;
syslog(LOG_WARNING, "%s: connect failed: %m", "upnp_event_process_notify");
obj->state = EError;
break;
}
upnp_event_prepare(obj);
if(obj->state == ESending)
upnp_event_send(obj);
@ -444,7 +458,7 @@ upnp_event_process_notify(struct upnp_event_notify * obj)
obj->s = -1;
break;
default:
syslog(LOG_ERR, "upnp_event_process_notify: unknown state");
syslog(LOG_ERR, "%s: unknown state", "upnp_event_process_notify");
}
}