Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1156)

Unified Diff: net/http/http_auth_gssapi_posix.cc

Issue 2646004: More robust handling of GSSAPI error strings... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Individual status message limit of 4K, total message of 8K-1 Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_auth_gssapi_posix.cc
===================================================================
--- net/http/http_auth_gssapi_posix.cc (revision 48997)
+++ net/http/http_auth_gssapi_posix.cc (working copy)
@@ -4,6 +4,8 @@
#include "net/http/http_auth_gssapi_posix.h"
+#include <limits>
+
#include "base/base64.h"
#include "base/file_path.h"
#include "base/logging.h"
@@ -208,20 +210,32 @@
gssapi::OM_uint32 status,
gssapi::OM_uint32 status_code_type) {
const int kMaxDisplayIterations = 8;
+ const size_t kMaxMsgLength = 4096;
// msg_ctx needs to be outside the loop because it is invoked multiple times.
gssapi::OM_uint32 msg_ctx = 0;
std::string rv = StringPrintf("(0x%08X)", status);
// This loop should continue iterating until msg_ctx is 0 after the first
// iteration. To be cautious and prevent an infinite loop, it stops after
- // a finite number of iterations as well.
- for (int i = 0; i < kMaxDisplayIterations; ++i) {
+ // a finite number of iterations as well. As an added sanity check, no
+ // individual message may exceed |kMaxMsgLength|, and the final result
+ // will not exceed |kMaxMsgLength|*2-1.
+ for (int i = 0; i < kMaxDisplayIterations && rv.size() < kMaxMsgLength;
+ ++i) {
gssapi::OM_uint32 min_stat;
wtc 2010/06/12 00:25:33 Andy, could you rename min_stat to minor_status an
gssapi::gss_buffer_desc_struct msg = GSS_C_EMPTY_BUFFER;
- gssapi_lib->display_status(&min_stat, status, status_code_type,
- GSS_C_NULL_OID,
- &msg_ctx, &msg);
- rv += StringPrintf(" %s", static_cast<char *>(msg.value));
+ gssapi::OM_uint32 maj_stat =
+ gssapi_lib->display_status(&min_stat, status, status_code_type,
+ GSS_C_NULL_OID, &msg_ctx, &msg);
+ if (maj_stat == GSS_S_COMPLETE) {
+ int msg_len = (msg.length > kMaxMsgLength) ?
+ static_cast<int>(kMaxMsgLength) :
+ static_cast<int>(msg.length);
+ if (msg_len > 0 && msg.value != NULL) {
+ rv += StringPrintf(" %.*s", msg_len,
+ static_cast<char *>(msg.value));
+ }
+ }
gssapi_lib->release_buffer(&min_stat, &msg);
if (!msg_ctx)
break;
Property changes on: net/http/http_auth_gssapi_posix.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698