X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=saml%2Fsaml2%2Fbinding%2Fimpl%2FSAML2Redirect.cpp;h=f55cae8731752806b9ad8d6800c6b7933a1fd97b;hb=e9554c255ad3c91c7c4976e7a1a54905903e66a2;hp=3c264c06f88016797e984ca512fcfab546b57281;hpb=e2951afb4bafd4c6f6de677e73651ef11c9253af;p=shibboleth%2Fcpp-opensaml.git diff --git a/saml/saml2/binding/impl/SAML2Redirect.cpp b/saml/saml2/binding/impl/SAML2Redirect.cpp index 3c264c0..f55cae8 100644 --- a/saml/saml2/binding/impl/SAML2Redirect.cpp +++ b/saml/saml2/binding/impl/SAML2Redirect.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2006 Internet2 + * Copyright 2001-2010 Internet2 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,17 +17,17 @@ /** * @file saml/saml2/binding/SAML2Redirect.h * - * SAML 2.0 HTTP Redirect compression functionality + * SAML 2.0 HTTP Redirect compression functionality. */ #include "internal.h" #include "saml2/binding/SAML2Redirect.h" -#include -#include +#include +#include #include -using namespace log4cpp; +using namespace xmltooling::logging; using namespace std; namespace { @@ -56,7 +56,7 @@ char* opensaml::saml2p::deflate(char* in, unsigned int in_len, unsigned int* out z.zalloc = saml_zalloc; z.zfree = saml_zfree; - z.opaque = NULL; + z.opaque = nullptr; z.next_in = (Bytef*)in; z.avail_in = in_len; *out_len = 0; @@ -64,7 +64,7 @@ char* opensaml::saml2p::deflate(char* in, unsigned int in_len, unsigned int* out int ret = deflateInit2(&z, 9, Z_DEFLATED, -15, 9, Z_DEFAULT_STRATEGY); if (ret != Z_OK) { log.error("zlib deflateInit2 failed with error code (%d)", ret); - return NULL; + return nullptr; } int dlen = in_len + (in_len >> 8) + 12; /* orig_size * 1.001 + 12 */ @@ -96,7 +96,7 @@ unsigned int opensaml::saml2p::inflate(char* in, unsigned int in_len, ostream& o z.zalloc = saml_zalloc; z.zfree = saml_zfree; - z.opaque = NULL; + z.opaque = nullptr; z.next_in = (Bytef*)in; z.avail_in = in_len; @@ -113,21 +113,22 @@ unsigned int opensaml::saml2p::inflate(char* in, unsigned int in_len, ostream& o return 0; } + size_t diff; int iter = 30; while (--iter) { /* Make sure we can never be caught in infinite loop */ ret = inflate(&z, Z_SYNC_FLUSH); switch (ret) { case Z_STREAM_END: - ret = z.next_out - buf; + diff = z.next_out - buf; z.next_out = buf; - while (ret--) + while (diff--) out << *(z.next_out++); goto done; case Z_OK: /* avail_out should be 0 now. Time to dump the buffer. */ - ret = z.next_out - buf; + diff = z.next_out - buf; z.next_out = buf; - while (ret--) + while (diff--) out << *(z.next_out++); memset(buf, 0, dlen); z.next_out = buf;