Merge pull request #26354 from ksooo/pvr-fix-listitem-titleextrainfo
[xbmc.git] / lib / libUPnP / patches / 0032-platinum-improve-logging-on-bad-HTTP-requests.patch
blobd8715c0398b19757f00ae31d8bd3d1a3bc044a78
1 From bf8934a1f074c14b21359978821957520ed66eb4 Mon Sep 17 00:00:00 2001
2 From: montellese <montellese@xbmc.org>
3 Date: Thu, 7 Aug 2014 21:28:38 +0200
4 Subject: [PATCH] platinum: improve logging on bad HTTP requests
6 ---
7 lib/libUPnP/Platinum/Source/Core/PltDeviceHost.cpp | 77 ++++++++++++++++++----
8 1 file changed, 63 insertions(+), 14 deletions(-)
10 diff --git a/lib/libUPnP/Platinum/Source/Core/PltDeviceHost.cpp b/lib/libUPnP/Platinum/Source/Core/PltDeviceHost.cpp
11 index 4d9524b..6fbe7a7 100644
12 --- a/lib/libUPnP/Platinum/Source/Core/PltDeviceHost.cpp
13 +++ b/lib/libUPnP/Platinum/Source/Core/PltDeviceHost.cpp
14 @@ -510,10 +510,10 @@ PLT_DeviceHost::ProcessHttpPostRequest(NPT_HttpRequest& request,
15 #endif
17 if (NPT_FAILED(FindServiceByControlURL(url, service, true)))
18 - goto bad_request;
19 + goto bad_request_find_service;
21 if (!request.GetHeaders().GetHeaderValue("SOAPAction"))
22 - goto bad_request;
23 + goto bad_request_soap_header_value;
25 // extract the soap action name from the header
26 soap_action_header = *request.GetHeaders().GetHeaderValue("SOAPAction");
27 @@ -522,45 +522,45 @@ PLT_DeviceHost::ProcessHttpPostRequest(NPT_HttpRequest& request,
29 components = soap_action_header.Split("#");
30 if (components.GetItemCount() != 2)
31 - goto bad_request;
32 + goto bad_request_soap_action_header;
34 soap_action_name = *components.GetItem(1);
37 // read the xml body and parse it
38 if (NPT_FAILED(PLT_HttpHelper::ParseBody(request, xml)))
39 - goto bad_request;
40 + goto bad_request_body_parse_error;
42 // check envelope
43 if (xml->GetTag().Compare("Envelope", true))
44 - goto bad_request;
45 + goto bad_request_no_envelope;
47 #if defined(PLATINUM_UPNP_SPECS_STRICT)
48 // check namespace
49 if (!xml->GetNamespace() || xml->GetNamespace()->Compare("http://schemas.xmlsoap.org/soap/envelope/"))
50 - goto bad_request;
51 + goto bad_request_upnp_not_strict;
53 // check encoding
54 attr = xml->GetAttribute("encodingStyle", "http://schemas.xmlsoap.org/soap/envelope/");
55 if (!attr || attr->Compare("http://schemas.xmlsoap.org/soap/encoding/"))
56 - goto bad_request;
57 + goto bad_request_bad_encoding;
58 #endif
60 // read action
61 soap_body = PLT_XmlHelper::GetChild(xml, "Body");
62 if (soap_body == NULL)
63 - goto bad_request;
64 + goto bad_request_soap_body;
66 PLT_XmlHelper::GetChild(soap_body, soap_action);
67 if (soap_action == NULL)
68 - goto bad_request;
69 + goto bad_request_soap_action_body;
71 // verify action name is identical to SOAPACTION header*/
72 if (soap_action->GetTag().Compare(soap_action_name, true))
73 - goto bad_request;
74 + goto bad_request_action_mismatch;
76 // verify namespace
77 if (!soap_action->GetNamespace() || soap_action->GetNamespace()->Compare(service->GetServiceType()))
78 - goto bad_request;
79 + goto bad_request_bad_namespace;
81 // create a buffer for our response body and call the service
82 if ((action_desc = service->FindActionDesc(soap_action_name)) == NULL) {
83 @@ -646,8 +646,58 @@ done:
84 return NPT_SUCCESS;
86 bad_request:
87 - delete xml;
88 + // generic 500 now unused
89 response.SetStatus(500, "Bad Request");
90 + goto bad_request_end;
92 +bad_request_find_service:
93 + response.SetStatus(500, "Bad Request: Service by URL");
94 + goto bad_request_end;
96 +bad_request_soap_header_value:
97 + response.SetStatus(500, "Bad Request: SOAP Header");
98 + goto bad_request_end;
100 +bad_request_soap_action_header:
101 + response.SetStatus(500, "Bad Request: SOAP Action in Header");
102 + goto bad_request_end;
104 +bad_request_body_parse_error:
105 + response.SetStatus(500, "Bad Request: Error Parsing XML Body");
106 + goto bad_request_end;
108 +bad_request_no_envelope:
109 + response.SetStatus(500, "Bad Request: SOAP Envelope");
110 + goto bad_request_end;
112 +#if defined(PLATINUM_UPNP_SPECS_STRICT)
113 +bad_request_upnp_not_strict:
114 + response.SetStatus(500, "Bad Request: SOAP not Strict");
115 + goto bad_request_end;
117 +bad_request_bad_encoding:
118 + response.SetStatus(500, "Bad Request: SOAP Encoding");
119 + goto bad_request_end;
120 +#endif
122 +bad_request_soap_body:
123 + response.SetStatus(500, "Bad Request: SOAP Body");
124 + goto bad_request_end;
126 +bad_request_soap_action_body:
127 + response.SetStatus(500, "Bad Request: SOAP Action in Body");
128 + goto bad_request_end;
130 +bad_request_action_mismatch:
131 + response.SetStatus(500, "Bad Request: SOAP Action Mismatch");
132 + goto bad_request_end;
134 +bad_request_bad_namespace:
135 + response.SetStatus(500, "Bad Request: Bad Namespace");
136 + goto bad_request_end;
138 +bad_request_end:
139 + delete xml;
140 return NPT_SUCCESS;
143 @@ -901,4 +951,3 @@ PLT_DeviceHost::OnAction(PLT_ActionReference& action,
144 action->SetError(401, "Invalid Action");
145 return NPT_FAILURE;
149 1.7.11.msysgit.0