diff --git a/miniupnpd/Changelog.txt b/miniupnpd/Changelog.txt index 6b2108a..256af19 100644 --- a/miniupnpd/Changelog.txt +++ b/miniupnpd/Changelog.txt @@ -1,7 +1,9 @@ -$Id: Changelog.txt,v 1.241 2011/11/18 11:10:08 nanard Exp $ +$Id: Changelog.txt,v 1.242 2011/11/18 11:21:20 nanard Exp $ 2011/11/18: avoid infinite loop in SendResp_upnphttp() in case of error + Replaced SendResp_upnphttp() + CloseSocket_upnphttp() by + SendRespAndClose_upnphttp() 2011/07/30: netfilter : Added a tiny_nf_nat.h file to compile with iptables diff --git a/miniupnpd/upnphttp.c b/miniupnpd/upnphttp.c index 92d50f0..3a20af1 100644 --- a/miniupnpd/upnphttp.c +++ b/miniupnpd/upnphttp.c @@ -1,4 +1,4 @@ -/* $Id: upnphttp.c,v 1.63 2011/11/18 11:10:09 nanard Exp $ */ +/* $Id: upnphttp.c,v 1.64 2011/11/18 11:21:17 nanard Exp $ */ /* Project : miniupnp * Website : http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * Author : Thomas Bernard @@ -179,8 +179,7 @@ Send404(struct upnphttp * h) h->respflags = FLAG_HTML; BuildResp2_upnphttp(h, 404, "Not Found", body404, sizeof(body404) - 1); - SendResp_upnphttp(h); - CloseSocket_upnphttp(h); + SendRespAndClose_upnphttp(h); } /* very minimalistic 501 error message */ @@ -209,8 +208,7 @@ Send501(struct upnphttp * h) h->respflags = FLAG_HTML; BuildResp2_upnphttp(h, 501, "Not Implemented", body501, sizeof(body501) - 1); - SendResp_upnphttp(h); - CloseSocket_upnphttp(h); + SendRespAndClose_upnphttp(h); } static const char * @@ -239,8 +237,7 @@ sendDummyDesc(struct upnphttp * h) " " "\r\n"; BuildResp_upnphttp(h, xml_desc, sizeof(xml_desc)-1); - SendResp_upnphttp(h); - CloseSocket_upnphttp(h); + SendRespAndClose_upnphttp(h); } #endif @@ -264,8 +261,7 @@ sendXMLdesc(struct upnphttp * h, char * (f)(int *)) { BuildResp_upnphttp(h, desc, len); } - SendResp_upnphttp(h); - CloseSocket_upnphttp(h); + SendRespAndClose_upnphttp(h); free(desc); } @@ -293,8 +289,7 @@ ProcessHTTPPOST_upnphttp(struct upnphttp * h) h->respflags = FLAG_HTML; BuildResp2_upnphttp(h, 400, "Bad Request", err400str, sizeof(err400str) - 1); - SendResp_upnphttp(h); - CloseSocket_upnphttp(h); + SendRespAndClose_upnphttp(h); } } else @@ -382,8 +377,7 @@ ProcessHTTPSubscribe_upnphttp(struct upnphttp * h, const char * path) * If CALLBACK header is missing or does not contain a valid HTTP URL, * the publisher must respond with HTTP error 412 Precondition Failed*/ BuildResp2_upnphttp(h, 412, "Precondition Failed", 0, 0); - SendResp_upnphttp(h); - CloseSocket_upnphttp(h); + SendRespAndClose_upnphttp(h); } else { /* - add to the subscriber list * - respond HTTP/x.x 200 OK @@ -421,8 +415,7 @@ with HTTP error 412 Precondition Failed. */ BuildResp_upnphttp(h, 0, 0); } } - SendResp_upnphttp(h); - CloseSocket_upnphttp(h); + SendRespAndClose_upnphttp(h); } } @@ -437,8 +430,7 @@ ProcessHTTPUnSubscribe_upnphttp(struct upnphttp * h, const char * path) } else { BuildResp_upnphttp(h, 0, 0); } - SendResp_upnphttp(h); - CloseSocket_upnphttp(h); + SendRespAndClose_upnphttp(h); } #endif @@ -718,7 +710,7 @@ BuildResp_upnphttp(struct upnphttp * h, } void -SendResp_upnphttp(struct upnphttp * h) +SendRespAndClose_upnphttp(struct upnphttp * h) { char * p; ssize_t n; @@ -746,5 +738,6 @@ SendResp_upnphttp(struct upnphttp * h) len -= n; } } + CloseSocket_upnphttp(h); } diff --git a/miniupnpd/upnphttp.h b/miniupnpd/upnphttp.h index 96b3260..c8462be 100644 --- a/miniupnpd/upnphttp.h +++ b/miniupnpd/upnphttp.h @@ -1,4 +1,4 @@ -/* $Id: upnphttp.h,v 1.24 2011/06/27 11:06:00 nanard Exp $ */ +/* $Id: upnphttp.h,v 1.25 2011/11/18 11:21:18 nanard Exp $ */ /* MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * (c) 2006-2011 Thomas Bernard @@ -110,9 +110,9 @@ BuildResp2_upnphttp(struct upnphttp * h, int respcode, const char * respmsg, const char * body, int bodylen); -/* SendResp_upnphttp() */ +/* SendRespAndClose_upnphttp() */ void -SendResp_upnphttp(struct upnphttp *); +SendRespAndClose_upnphttp(struct upnphttp *); #endif diff --git a/miniupnpd/upnpsoap.c b/miniupnpd/upnpsoap.c index 703d65b..7d6c387 100644 --- a/miniupnpd/upnpsoap.c +++ b/miniupnpd/upnpsoap.c @@ -1,4 +1,4 @@ -/* $Id: upnpsoap.c,v 1.87 2011/07/15 07:48:26 nanard Exp $ */ +/* $Id: upnpsoap.c,v 1.88 2011/11/18 11:21:18 nanard Exp $ */ /* MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * (c) 2006-2011 Thomas Bernard @@ -53,8 +53,7 @@ BuildSendAndCloseSoapResp(struct upnphttp * h, memcpy(h->res_buf + h->res_buflen, afterbody, sizeof(afterbody) - 1); h->res_buflen += sizeof(afterbody) - 1; - SendResp_upnphttp(h); - CloseSocket_upnphttp(h); + SendRespAndClose_upnphttp(h); } static void @@ -1864,7 +1863,6 @@ SoapError(struct upnphttp * h, int errCode, const char * errDesc) syslog(LOG_INFO, "Returning UPnPError %d: %s", errCode, errDesc); bodylen = snprintf(body, sizeof(body), resp, errCode, errDesc); BuildResp2_upnphttp(h, 500, "Internal Server Error", body, bodylen); - SendResp_upnphttp(h); - CloseSocket_upnphttp(h); + SendRespAndClose_upnphttp(h); }