mirror of
https://github.com/status-im/miniupnp.git
synced 2025-01-30 16:15:40 +00:00
miniupnpd/upnpevents.c: Better error checking after connect()
This commit is contained in:
parent
5de71bc396
commit
38939ac2d9
@ -4,6 +4,7 @@ $Id: Changelog.txt,v 1.318 2012/10/04 22:11:55 nanard Exp $
|
|||||||
updated DEFAULTCONNECTIONSERVICE_MAGICALVALUE for IGDv2
|
updated DEFAULTCONNECTIONSERVICE_MAGICALVALUE for IGDv2
|
||||||
increased default buffer size for HTTP response
|
increased default buffer size for HTTP response
|
||||||
More argument check for SOAP actions in UPNP_STRICT mode
|
More argument check for SOAP actions in UPNP_STRICT mode
|
||||||
|
Better error checking after connect() in upnpevent
|
||||||
|
|
||||||
2012/10/03:
|
2012/10/03:
|
||||||
Fix atoi() on null pointer in upnpsoap.c
|
Fix atoi() on null pointer in upnpsoap.c
|
||||||
|
@ -426,9 +426,23 @@ static void upnp_event_recv(struct upnp_event_notify * obj)
|
|||||||
static void
|
static void
|
||||||
upnp_event_process_notify(struct upnp_event_notify * obj)
|
upnp_event_process_notify(struct upnp_event_notify * obj)
|
||||||
{
|
{
|
||||||
|
int err;
|
||||||
|
socklen_t len;
|
||||||
switch(obj->state) {
|
switch(obj->state) {
|
||||||
case EConnecting:
|
case EConnecting:
|
||||||
/* now connected or failed to connect */
|
/* 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);
|
upnp_event_prepare(obj);
|
||||||
if(obj->state == ESending)
|
if(obj->state == ESending)
|
||||||
upnp_event_send(obj);
|
upnp_event_send(obj);
|
||||||
@ -444,7 +458,7 @@ upnp_event_process_notify(struct upnp_event_notify * obj)
|
|||||||
obj->s = -1;
|
obj->s = -1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
syslog(LOG_ERR, "upnp_event_process_notify: unknown state");
|
syslog(LOG_ERR, "%s: unknown state", "upnp_event_process_notify");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user