summaryrefslogtreecommitdiffstats
path: root/testsuite
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xtestsuite/check.sh11
-rw-r--r--testsuite/unzcrash.cc31
2 files changed, 21 insertions, 21 deletions
diff --git a/testsuite/check.sh b/testsuite/check.sh
index 92dcfdd..bd77f02 100755
--- a/testsuite/check.sh
+++ b/testsuite/check.sh
@@ -1,6 +1,6 @@
#! /bin/sh
# check script for Lziprecover - Data recovery tool for lzipped files
-# Copyright (C) 2009, 2010, 2011, 2012 Antonio Diaz Diaz.
+# Copyright (C) 2009, 2010, 2011, 2012, 2013 Antonio Diaz Diaz.
#
# This script is free software: you have unlimited permission
# to copy, distribute and modify it.
@@ -53,6 +53,15 @@ printf .
cmp ${in} copy || fail=1
printf .
+"${LZIPRECOVER}" -lq
+if [ $? != 1 ] ; then fail=1 ; printf - ; else printf . ; fi
+"${LZIPRECOVER}" -mq ${bad1_lz}
+if [ $? != 1 ] ; then fail=1 ; printf - ; else printf . ; fi
+"${LZIPRECOVER}" -Rq
+if [ $? != 1 ] ; then fail=1 ; printf - ; else printf . ; fi
+"${LZIPRECOVER}" -sq
+if [ $? != 1 ] ; then fail=1 ; printf - ; else printf . ; fi
+
"${LZIPRECOVER}" -D 921-1921 -fo copy ${in_lz} || fail=1
cmp ${inD} copy || fail=1
printf .
diff --git a/testsuite/unzcrash.cc b/testsuite/unzcrash.cc
index 4c49035..abf61bb 100644
--- a/testsuite/unzcrash.cc
+++ b/testsuite/unzcrash.cc
@@ -1,7 +1,7 @@
/* Unzcrash - A test program written to test robustness to
decompression of corrupted data.
Inspired by unzcrash.c from Julian Seward's bzip2.
- Copyright (C) 2008, 2009, 2010, 2011, 2012 Antonio Diaz Diaz.
+ Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013 Antonio Diaz Diaz.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -34,22 +34,12 @@
#error "Environments where CHAR_BIT != 8 are not supported."
#endif
-#ifndef LLONG_MAX
-#define LLONG_MAX 0x7FFFFFFFFFFFFFFFLL
-#endif
-#ifndef LLONG_MIN
-#define LLONG_MIN (-LLONG_MAX - 1LL)
-#endif
-#ifndef ULLONG_MAX
-#define ULLONG_MAX 0xFFFFFFFFFFFFFFFFULL
-#endif
-
namespace {
const char * const Program_name = "Unzcrash";
const char * const program_name = "unzcrash";
-const char * const program_year = "2012";
+const char * const program_year = "2013";
const char * invocation_name = 0;
int verbosity = 0;
@@ -67,11 +57,12 @@ void show_help()
"\nOptions:\n"
" -h, --help display this help and exit\n"
" -V, --version output version information and exit\n"
- " -b, --bits=<n>[,<n>]... test <n>-bit errors instead of full byte\n"
+ " -b, --bits=<range> test N-bit errors instead of full byte\n"
" -p, --position=<bytes> first byte position to test\n"
" -q, --quiet suppress all messages\n"
" -s, --size=<bytes> number of byte positions to test\n"
" -v, --verbose be verbose (a 2nd -v gives more)\n"
+ "Examples of <range>: 1 1,2,3 1-4 1,3-5,8\n"
"\nReport bugs to lzip-bug@nongnu.org\n"
"Lzip home page: http://www.nongnu.org/lzip/lzip.html\n" );
}
@@ -99,7 +90,7 @@ void show_error( const char * const msg, const int errcode = 0,
std::fprintf( stderr, ": %s", std::strerror( errcode ) );
std::fprintf( stderr, "\n" );
}
- if( help && invocation_name && invocation_name[0] )
+ if( help )
std::fprintf( stderr, "Try '%s --help' for more information.\n",
invocation_name );
}
@@ -114,13 +105,13 @@ void internal_error( const char * const msg )
}
-long long getnum( const char * const ptr,
- const long long llimit = LLONG_MIN + 1,
- const long long ulimit = LLONG_MAX )
+unsigned long long getnum( const char * const ptr,
+ const unsigned long long llimit,
+ const unsigned long long ulimit )
{
errno = 0;
- char *tail;
- long long result = strtoll( ptr, &tail, 0 );
+ char * tail;
+ unsigned long long result = strtoull( ptr, &tail, 0 );
if( tail == ptr )
{
show_error( "Bad or missing numerical argument.", 0, true );
@@ -155,7 +146,7 @@ long long getnum( const char * const ptr,
}
for( int i = 0; i < exponent; ++i )
{
- if( LLONG_MAX / factor >= llabs( result ) ) result *= factor;
+ if( ulimit / factor >= result ) result *= factor;
else { errno = ERANGE; break; }
}
}