From 2b7637df366ae4ffb2157b12e52a0dcabe6326ba Mon Sep 17 00:00:00 2001 From: Philipp Hasper Date: Mon, 20 Jul 2015 09:00:24 +0200 Subject: [PATCH] Fixed buffer overflow in string handling pos should never exceed strlen, else the overflow check 'if (!len)' will wrongfully pass --- modules/core/include/opencv2/core/cvstd.inl.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/include/opencv2/core/cvstd.inl.hpp b/modules/core/include/opencv2/core/cvstd.inl.hpp index 03bac37..ad15406 100644 --- a/modules/core/include/opencv2/core/cvstd.inl.hpp +++ b/modules/core/include/opencv2/core/cvstd.inl.hpp @@ -87,7 +87,7 @@ String::String(const std::string& str, size_t pos, size_t len) : cstr_(0), len_(0) { size_t strlen = str.size(); - pos = max(pos, strlen); + pos = min(pos, strlen); len = min(strlen - pos, len); if (!len) return; memcpy(allocate(len), str.c_str() + pos, len); -- 2.7.4