summaryrefslogtreecommitdiffstats
path: root/testsuite/unzcrash.cc
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 11:42:32 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 11:42:32 +0000
commitbcbac5cac5f6194d9fa5fbc16e0a4490e7e23520 (patch)
tree87adc0b5058585d2c7529c151321af22097e2fd2 /testsuite/unzcrash.cc
parentAdding upstream version 1.15~pre1. (diff)
downloadlziprecover-bcbac5cac5f6194d9fa5fbc16e0a4490e7e23520.tar.xz
lziprecover-bcbac5cac5f6194d9fa5fbc16e0a4490e7e23520.zip
Adding upstream version 1.15~rc1.upstream/1.15_rc1
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to '')
-rw-r--r--testsuite/unzcrash.cc28
1 files changed, 18 insertions, 10 deletions
diff --git a/testsuite/unzcrash.cc b/testsuite/unzcrash.cc
index 24defa6..b2cdc4e 100644
--- a/testsuite/unzcrash.cc
+++ b/testsuite/unzcrash.cc
@@ -1,5 +1,4 @@
-/* Unzcrash - A test program written to test robustness to
- decompression of corrupted data.
+/* Unzcrash - Tests robustness of decompressors to corrupted data.
Inspired by unzcrash.c from Julian Seward's bzip2.
Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013 Antonio Diaz Diaz.
@@ -16,6 +15,12 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/*
+ Exit status: 0 for a normal exit, 1 for environmental problems
+ (file not found, invalid flags, I/O errors, etc), 2 to indicate a
+ corrupt or invalid input file, 3 for an internal consistency error
+ (eg, bug) which caused unzcrash to panic.
+*/
#include <cerrno>
#include <climits>
@@ -47,9 +52,8 @@ int verbosity = 0;
void show_help()
{
- std::printf( "%s - A test program written to test robustness to\n", Program_name );
- std::printf( "decompression of corrupted data.\n"
- "\nUsage: %s [options] \"lzip -tv\" filename.lz\n", invocation_name );
+ std::printf( "%s - Tests robustness of decompressors to corrupted data.\n", Program_name );
+ std::printf( "\nUsage: %s [options] \"lzip -tv\" filename.lz\n", invocation_name );
std::printf( "\nThis program reads the specified file and then repeatedly decompresses\n"
"it, increasing 256 times each byte of the compressed data, so as to test\n"
"all possible one-byte errors. This should not cause any invalid memory\n"
@@ -63,8 +67,12 @@ void show_help()
" -s, --size=<bytes> number of byte positions to test [all]\n"
" -v, --verbose be verbose (a 2nd -v gives more)\n"
"Examples of <range>: 1 1,2,3 1-4 1,3-5,8 1-3,5-8\n"
+ "\nExit status: 0 for a normal exit, 1 for environmental problems (file\n"
+ "not found, invalid flags, I/O errors, etc), 2 to indicate a corrupt or\n"
+ "invalid input file, 3 for an internal consistency error (eg, bug) which\n"
+ "caused unzcrash to panic.\n"
"\nReport bugs to lzip-bug@nongnu.org\n"
- "Lzip home page: http://www.nongnu.org/lzip/lzip.html\n" );
+ "Lziprecover home page: http://www.nongnu.org/lzip/lziprecover.html\n" );
}
@@ -160,7 +168,7 @@ unsigned long long getnum( const char * const ptr,
}
-class Bitset8 // 8 value bitset (1..8)
+class Bitset8 // 8 value bitset (1 to 8)
{
bool data[8];
static bool valid_digit( const unsigned char ch )
@@ -195,7 +203,7 @@ public:
return false;
}
- // number of n-bit errors per byte (n=0..8): 1 8 28 56 70 56 28 8 1
+ // number of N-bit errors per byte (N=0 to 8): 1 8 28 56 70 56 28 8 1
void print() const
{
std::fflush( stderr );
@@ -295,9 +303,9 @@ int main( const int argc, const char * const argv[] )
if( size >= buffer_size )
{
if( verbosity >= 0 )
- std::fprintf( stderr, "input file '%s' is too big.\n",
+ std::fprintf( stderr, "input file '%s' is too large.\n",
parser.argument( argind + 1 ).c_str() );
- return 1;
+ return 2;
}
std::fclose( f );