Skip to content

Commit 1618d76

Browse files
dineshsuryaprakashdahlerlend
authored andcommitted
Revert "Bug#29291533 BASESTRING::SUBSTR() LACKS VALIDATION AND LEADS TO HEAP-OVERFLOW"
This reverts commit 50ea3a2cb8e54bdb5c1f309f991996464b3e81e6. 32bit build breaks with this commit. So, reverting the changes Change-Id: I1c9681709e37cd83bf13fd560f48d305fedf11f4
1 parent 7fb0ae5 commit 1618d76

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

storage/ndb/include/util/BaseString.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ class BaseString {
167167
*
168168
* @param start index of first character
169169
* @param stop index of last character
170-
* @return a new string on success or a null string on failure
170+
* @return a new string
171171
*/
172172
BaseString substr(ssize_t start, ssize_t stop = -1) const;
173173

storage/ndb/src/common/util/BaseString.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ BaseString::substr(ssize_t start, ssize_t stop) const
341341
if(stop < 0)
342342
stop = length();
343343
ssize_t len = stop-start;
344-
if(len <= 0 || stop > m_len)
344+
if(len <= 0)
345345
return BaseString("");
346346
BaseString s;
347347
s.assign(m_chr+start, len);
@@ -681,10 +681,6 @@ TAPTEST(BaseString)
681681
OK(BaseString("hamburger").substr(3) == "burger");
682682
OK(BaseString("hamburger").substr(4,8) == "urge");
683683
OK(BaseString("smiles").substr(1,5) == "mile");
684-
OK(BaseString("smiles").substr(1,10) == "");
685-
OK(BaseString("smiles").substr(10, 1) == "");
686-
OK(BaseString("smiles").substr(1,1) == "");
687-
OK(BaseString("smiles").substr(11, 15) == "");
688684
OK(BaseString("012345").indexOf('2') == 2);
689685
OK(BaseString("hej").indexOf('X') == -1);
690686
}

0 commit comments

Comments
 (0)