From 541839a11103a72d486edaab8a5c9e9499554511 Mon Sep 17 00:00:00 2001 From: Russell Brenner Date: Tue, 24 Jan 2012 10:05:57 -0800 Subject: Refine WebHistory log output Log output is more explicit upon failure, but otherwise quiet. Bug: 5143832 Change-Id: I8696c36277b0fac12698b4ace9cf4131344f6a0c --- Source/WebKit/android/jni/WebHistory.cpp | 41 ++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 10 deletions(-) (limited to 'Source/WebKit/android/jni/WebHistory.cpp') diff --git a/Source/WebKit/android/jni/WebHistory.cpp b/Source/WebKit/android/jni/WebHistory.cpp index e1ae28a..9bb29e3 100644 --- a/Source/WebKit/android/jni/WebHistory.cpp +++ b/Source/WebKit/android/jni/WebHistory.cpp @@ -488,7 +488,8 @@ bool readUnsigned(const char*& data, const char* end, unsigned& result, const ch { // Check if we have enough data left to continue. if ((end < data) || (static_cast(end - data) < sizeof(unsigned))) { - ALOGW("\tNot enough data to read unsigned; end=%p data=%p", end, data); + ALOGW("\tNot enough data to read unsigned; tag=\"%s\" end=%p data=%p", + dbgLabel ? dbgLabel : "", end, data); return false; } @@ -503,7 +504,8 @@ bool readInt(const char*& data, const char* end, int& result, const char* dbgLab { // Check if we have enough data left to continue. if ((end < data) || (static_cast(end - data) < sizeof(int))) { - ALOGW("\tNot enough data to read int; end=%p data=%p", end, data); + ALOGW("Not enough data to read int; tag=\"%s\" end=%p data=%p", + dbgLabel ? dbgLabel : "", end, data); return false; } @@ -518,7 +520,8 @@ bool readInt64(const char*& data, const char* end, int64_t& result, const char* { // Check if we have enough data left to continue. if ((end < data) || (static_cast(end - data) < sizeof(int64_t))) { - ALOGW("\tNot enough data to read int64_t; end=%p data=%p", end, data); + ALOGW("Not enough data to read int64_t; tag=\"%s\" end=%p data=%p", + dbgLabel ? dbgLabel : "", end, data); return false; } @@ -533,7 +536,8 @@ bool readFloat(const char*& data, const char* end, float& result, const char* db { // Check if we have enough data left to continue. if ((end < data) || (static_cast(end - data) < sizeof(float))) { - ALOGW("\tNot enough data to read float; end=%p data=%p", end, data); + ALOGW("Not enough data to read float; tag=\"%s\" end=%p data=%p", + dbgLabel ? dbgLabel : "", end, data); return false; } @@ -550,7 +554,8 @@ bool readBool(const char*& data, const char* end, bool& result, const char* dbgL { // Check if we have enough data left to continue. if ((end < data) || (static_cast(end - data) < sizeof(char))) { - ALOGW("\tNot enough data to read bool; end=%p data=%p", end, data); + ALOGW("Not enough data to read bool; tag=\"%s\" end=%p data=%p", + dbgLabel ? dbgLabel : "", end, data); return false; } @@ -563,7 +568,8 @@ bool readBool(const char*& data, const char* end, bool& result, const char* dbgL // Valid bool results are 0 or 1 if ((c != 0) && (c != 1)) { - ALOGW("\tInvalid value for bool; end=%p data=%p c=%u", end, data, c); + ALOGW("Invalid value for bool; tag=\"%s\" end=%p data=%p c=%u", + dbgLabel ? dbgLabel : "", end, data, c); return false; } @@ -574,7 +580,8 @@ bool readString(const char*& data, const char* end, String& result, const char* { unsigned stringLength; if (!readUnsigned(data, end, stringLength)) { - ALOGW("Not enough data to read string length; end=%p data=%p", end, data); + ALOGW("Not enough data to read string length; tag=\"%s\" end=%p data=%p", + dbgLabel ? dbgLabel : "", end, data); return false; } @@ -588,21 +595,35 @@ bool readString(const char*& data, const char* end, String& result, const char* } if ((end < data) || ((unsigned)(end - data) < stringLength)) { - ALOGW("\tNot enough data to read content; end=%p data=%p stringLength=%u", end, data, stringLength); + ALOGW("Not enough data to read content; tag=\"%s\" end=%p data=%p stringLength=%u", + dbgLabel ? dbgLabel : "", end, data, stringLength); return false; } + const unsigned MAX_REASONABLE_STRING_LENGTH = 10000; + if (stringLength > MAX_REASONABLE_STRING_LENGTH) { + ALOGW("String length is suspiciously large (>%d); tag=\"%s\" end=%p data=%p stringLength=%u", + MAX_REASONABLE_STRING_LENGTH, dbgLabel ? dbgLabel : "", + end, data, stringLength); + } + bool decodeFailed; static const WebCore::TextEncoding& encoding = WebCore::UTF8Encoding(); result = encoding.decode(data, stringLength, true, decodeFailed); if (decodeFailed) { - ALOGW("\tdecode failed, end=%p data=%p stringLength=%u content=\"%s\"", - end, data, stringLength, result.utf8().data()); + ALOGW("Decode failed, tag=\"%s\" end=%p data=%p stringLength=%u content=\"%s\"", + dbgLabel ? dbgLabel : "", end, data, stringLength, + result.utf8().data()); // Although an error was reported, the previous implementation did not // stop here, and debug output of the result, which looks correct, makes // it unclear just what the error was. } + if (stringLength > MAX_REASONABLE_STRING_LENGTH) { + ALOGW("\tdecodeFailed=%d (flag is ignored) content=\"%s\"", + decodeFailed, result.utf8().data()); + } + data += stringLength; return true; } -- cgit v1.1