[lvm-devel] master - tests: don't crash if checked string is shorter

Zdenek Kabelac zkabelac at fedoraproject.org
Thu Feb 12 14:42:13 UTC 2015


Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=739b751046c17ba8e6225821446951e6742c16eb
Commit:        739b751046c17ba8e6225821446951e6742c16eb
Parent:        b1002e98e020e0a9e35bcf75eac5a991550fc0b2
Author:        Zdenek Kabelac <zkabelac at redhat.com>
AuthorDate:    Thu Feb 12 10:39:37 2015 +0100
Committer:     Zdenek Kabelac <zkabelac at redhat.com>
CommitterDate: Thu Feb 12 15:38:51 2015 +0100

tests: don't crash if checked string is shorter

Not really sure what is this testing - just avoid coredump if
the test cannot happen since the index would too high.
---
 test/lib/brick-shelltest.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/test/lib/brick-shelltest.h b/test/lib/brick-shelltest.h
index 335ef85..d67b164 100644
--- a/test/lib/brick-shelltest.h
+++ b/test/lib/brick-shelltest.h
@@ -958,7 +958,7 @@ struct Main {
               flav != options.flavours.end(); ++flav ) {
 
             for ( Listing::iterator i = l.begin(); i != l.end(); ++i ) {
-                if ( i->substr( i->length() - 3, i->length() ) != ".sh" )
+                if ( ( i->length() < 3 ) || ( i->substr( i->length() - 3, i->length() ) != ".sh" ) )
                     continue;
                 if ( i->substr( 0, 4 ) == "lib/" )
                     continue;




More information about the lvm-devel mailing list