diff --git a/delta2/delta2.c b/delta2/delta2.c index f48d41e..c7274ad 100644 --- a/delta2/delta2.c +++ b/delta2/delta2.c @@ -127,6 +127,8 @@ delta2_encode(uchar_t *src, uint64_t srclen, uchar_t *dst, uint64_t *dstlen, int *((uint64_t *)dst) = LE64(srclen); dst += MAIN_HDR; rv = delta2_encode_real(src, srclen, dst, dstlen, rle_thresh, 1, &hdr_ovr); + if (rv == -1) + return (rv); *dstlen += MAIN_HDR; DEBUG_STAT_EN(fprintf(stderr, "DELTA2: srclen: %" PRIu64 ", dstlen: %" PRIu64 "\n", srclen, *dstlen)); DEBUG_STAT_EN(fprintf(stderr, "DELTA2: header overhead: %d\n", hdr_ovr)); @@ -288,7 +290,7 @@ delta2_encode_real(uchar_t *src, uint64_t srclen, uchar_t *dst, uint64_t *dstlen /* * No need to check for destination buffer overflow since - * dstlen == srclen always. + * dstlen >= srclen always. */ if ( gtot1 > (srclen - (DELTA_HDR + LIT_HDR + MAIN_HDR)) ) { if (srclen == DELTA2_CHUNK) { diff --git a/main.c b/main.c index 79535c0..eb7b02f 100644 --- a/main.c +++ b/main.c @@ -264,7 +264,6 @@ preproc_compress(compress_func_ptr cmp_func, void *src, uint64_t srclen, void *d if (type > 0) result = 0; } - return (result); } @@ -1489,8 +1488,12 @@ start_compress(const char *filename, uint64_t chunksize, int level) else flags |= FLAG_DEDUP_FIXED; /* Additional scratch space for dedup arrays. */ - compressed_chunksize += (dedupe_buf_extra(chunksize, 0, algo, - enable_delta_encode) - (compressed_chunksize - chunksize)); + if (chunksize + dedupe_buf_extra(chunksize, 0, algo, enable_delta_encode) + > compressed_chunksize) { + compressed_chunksize += (chunksize + + dedupe_buf_extra(chunksize, 0, algo, enable_delta_encode)) - + compressed_chunksize; + } } if (encrypt_type) { diff --git a/test/run_test.sh b/test/run_test.sh index 44c36d1..7c349c5 100644 --- a/test/run_test.sh +++ b/test/run_test.sh @@ -52,12 +52,9 @@ then [ $? -ne 0 ] && continue cd datafiles - (. ../${tf}) - if [ $? -ne 0 ] - then - echo "FATAL: Test ${tf} failed" - failures=$((failures + 1)) - fi + (. ../${tf}) 2>&1 | tee ${tf}.log + fails=`egrep "^FATAL:" ${tf}.log | wc -l` + failures=$((failures + fails)) cd $PDIR done else