[cpp-sp COMMIT] /branches/REL_2/isapi_shib/isapi_shib.cpp
noreply at shibboleth.net
noreply at shibboleth.net
Wed Nov 2 16:52:01 GMT 2011
Author: scantor
Date: Wed Nov 2 16:52:01 2011
New Revision: 3539
URL: http://svn.shibboleth.net/view/cpp-sp?rev=3539&view=rev
Log:
https://issues.shibboleth.net/jira/browse/SSPCPP-401
Modified:
branches/REL_2/isapi_shib/isapi_shib.cpp
Modified: branches/REL_2/isapi_shib/isapi_shib.cpp
URL: http://svn.shibboleth.net/view/cpp-sp/branches/REL_2/isapi_shib/isapi_shib.cpp?rev=3539&r1=3538&r2=3539&view=diff
==============================================================================
--- branches/REL_2/isapi_shib/isapi_shib.cpp (original)
+++ branches/REL_2/isapi_shib/isapi_shib.cpp Wed Nov 2 16:52:01 2011
@@ -321,61 +321,6 @@
return strcmp(bufptr,s)==0;
}
-void GetServerVariable(PHTTP_FILTER_CONTEXT pfc, LPSTR lpszVariable, dynabuf& s, DWORD size=80, bool bRequired=true)
-{
- s.reserve(size);
- s.erase();
- size=s.size();
-
- while (!pfc->GetServerVariable(pfc,lpszVariable,s,&size)) {
- // Grumble. Check the error.
- DWORD e=GetLastError();
- if (e==ERROR_INSUFFICIENT_BUFFER)
- s.reserve(size);
- else
- break;
- }
- if (bRequired && s.empty())
- throw ERROR_NO_DATA;
-}
-
-void GetServerVariable(LPEXTENSION_CONTROL_BLOCK lpECB, LPSTR lpszVariable, dynabuf& s, DWORD size=80, bool bRequired=true)
-{
- s.reserve(size);
- s.erase();
- size=s.size();
-
- while (!lpECB->GetServerVariable(lpECB->ConnID,lpszVariable,s,&size)) {
- // Grumble. Check the error.
- DWORD e=GetLastError();
- if (e==ERROR_INSUFFICIENT_BUFFER)
- s.reserve(size);
- else
- break;
- }
- if (bRequired && s.empty())
- throw ERROR_NO_DATA;
-}
-
-void GetHeader(PHTTP_FILTER_PREPROC_HEADERS pn, PHTTP_FILTER_CONTEXT pfc,
- LPSTR lpszName, dynabuf& s, DWORD size=80, bool bRequired=true)
-{
- s.reserve(size);
- s.erase();
- size=s.size();
-
- while (!pn->GetHeader(pfc,lpszName,s,&size)) {
- // Grumble. Check the error.
- DWORD e=GetLastError();
- if (e==ERROR_INSUFFICIENT_BUFFER)
- s.reserve(size);
- else
- break;
- }
- if (bRequired && s.empty())
- throw ERROR_NO_DATA;
-}
-
/****************************************************************************/
// ISAPI Filter
@@ -396,13 +341,18 @@
// URL path always come from IIS.
dynabuf var(256);
- GetHeader(pn,pfc,"url",var,256,false);
+ GetHeader("url",var,256,false);
setRequestURI(var);
// Port may come from IIS or from site def.
if (!g_bNormalizeRequest || (pfc->fIsSecurePort && site.m_sslport.empty()) || (!pfc->fIsSecurePort && site.m_port.empty())) {
- GetServerVariable(pfc,"SERVER_PORT",var,10);
- m_port = atoi(var);
+ GetServerVariable("SERVER_PORT",var,10);
+ if (var.empty()) {
+ m_port = pfc->fIsSecurePort ? 443 : 80;
+ }
+ else {
+ m_port = atoi(var);
+ }
}
else if (pfc->fIsSecurePort) {
m_port = atoi(site.m_sslport.c_str());
@@ -416,15 +366,20 @@
if (m_scheme.empty() || !g_bNormalizeRequest)
m_scheme=pfc->fIsSecurePort ? "https" : "http";
- GetServerVariable(pfc,"SERVER_NAME",var,32);
-
- // Make sure SERVER_NAME is "authorized" for use on this site. If not, set to canonical name.
- m_hostname = var;
- if (site.m_name!=m_hostname && site.m_aliases.find(m_hostname)==site.m_aliases.end())
- m_hostname=site.m_name;
+ GetServerVariable("SERVER_NAME",var,32);
+
+ // Make sure SERVER_NAME is "authorized" for use on this site. If not, or empty, set to canonical name.
+ if (var.empty()) {
+ m_hostname = site.m_name;
+ }
+ else {
+ m_hostname = var;
+ if (site.m_name!=m_hostname && site.m_aliases.find(m_hostname)==site.m_aliases.end())
+ m_hostname=site.m_name;
+ }
if (!g_spoofKey.empty()) {
- GetHeader(pn, pfc, "ShibSpoofCheck:", var, 32, false);
+ GetHeader("ShibSpoofCheck:", var, 32, false);
if (!var.empty() && g_spoofKey == (char*)var)
m_firsttime = false;
}
@@ -451,7 +406,7 @@
const char* getMethod() const {
if (m_method.empty()) {
dynabuf var(5);
- GetServerVariable(m_pfc,"HTTP_METHOD",var,5,false);
+ GetServerVariable("HTTP_METHOD",var,5,false);
if (!var.empty())
m_method = var;
}
@@ -460,7 +415,7 @@
string getContentType() const {
if (m_content_type.empty()) {
dynabuf var(32);
- GetServerVariable(m_pfc,"HTTP_CONTENT_TYPE",var,32,false);
+ GetServerVariable("HTTP_CONTENT_TYPE",var,32,false);
if (!var.empty())
m_content_type = var;
}
@@ -470,13 +425,13 @@
m_remote_addr = AbstractSPRequest::getRemoteAddr();
if (m_remote_addr.empty()) {
dynabuf var(16);
- GetServerVariable(m_pfc,"REMOTE_ADDR",var,16,false);
+ GetServerVariable("REMOTE_ADDR",var,16,false);
if (!var.empty())
m_remote_addr = var;
}
return m_remote_addr;
}
[... 317 lines stripped ...]
More information about the commits
mailing list