hrev43855 adds 1 changeset to branch 'master' old head: 08de244f9c3347109ca6d3c054eac7bec522e9fe new head: 395167071d38f02b7d476a7f60d441417ab502e4 ---------------------------------------------------------------------------- 3951670: * Fix a bug where a string longer than INT_MAX can cause IsValid() to falsely report a valid mimetype because strlen() returns a result than when stored in an int is treated as a negative number. * Style fixes in the same method [ John Scipione <jscipione@xxxxxxxxx> ] ---------------------------------------------------------------------------- Revision: hrev43855 Commit: 395167071d38f02b7d476a7f60d441417ab502e4 URL: http://cgit.haiku-os.org/haiku/commit/?id=3951670 Author: John Scipione <jscipione@xxxxxxxxx> Date: Wed Mar 14 22:56:54 2012 UTC ---------------------------------------------------------------------------- 1 files changed, 8 insertions(+), 8 deletions(-) src/kits/storage/MimeType.cpp | 16 ++++++++-------- ---------------------------------------------------------------------------- diff --git a/src/kits/storage/MimeType.cpp b/src/kits/storage/MimeType.cpp index f8e35d6..d5bf993 100644 --- a/src/kits/storage/MimeType.cpp +++ b/src/kits/storage/MimeType.cpp @@ -1152,25 +1152,25 @@ BMimeType::GetWildcardApps(BMessage *wild_ones) bool BMimeType::IsValid(const char *string) { - if (!string) + if (string == NULL) return false; - - bool foundSlash = false; - int len = strlen(string); + + bool foundSlash = false; + size_t len = strlen(string); if (len >= B_MIME_TYPE_LENGTH || len == 0) return false; - - for (int i = 0; i < len; i++) { + + for (size_t i = 0; i < len; i++) { char ch = string[i]; if (ch == '/') { - if (foundSlash || i == 0 || i == len-1) + if (foundSlash || i == 0 || i == len - 1) return false; else foundSlash = true; } else if (!isValidMimeChar(ch)) { return false; } - } + } return true; }