Fix calculation of extra scratch space for Dedupe.

Add missing return value check in small buffer Delta2.
Update test failure detection in test driver.
This commit is contained in:
Moinak Ghosh 2013-01-03 22:25:14 +05:30
parent d9eb82e0e8
commit 47ebd5b752
3 changed files with 12 additions and 10 deletions

View file

@ -127,6 +127,8 @@ delta2_encode(uchar_t *src, uint64_t srclen, uchar_t *dst, uint64_t *dstlen, int
*((uint64_t *)dst) = LE64(srclen); *((uint64_t *)dst) = LE64(srclen);
dst += MAIN_HDR; dst += MAIN_HDR;
rv = delta2_encode_real(src, srclen, dst, dstlen, rle_thresh, 1, &hdr_ovr); rv = delta2_encode_real(src, srclen, dst, dstlen, rle_thresh, 1, &hdr_ovr);
if (rv == -1)
return (rv);
*dstlen += MAIN_HDR; *dstlen += MAIN_HDR;
DEBUG_STAT_EN(fprintf(stderr, "DELTA2: srclen: %" PRIu64 ", dstlen: %" PRIu64 "\n", srclen, *dstlen)); 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)); 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 * 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 ( gtot1 > (srclen - (DELTA_HDR + LIT_HDR + MAIN_HDR)) ) {
if (srclen == DELTA2_CHUNK) { if (srclen == DELTA2_CHUNK) {

9
main.c
View file

@ -264,7 +264,6 @@ preproc_compress(compress_func_ptr cmp_func, void *src, uint64_t srclen, void *d
if (type > 0) if (type > 0)
result = 0; result = 0;
} }
return (result); return (result);
} }
@ -1489,8 +1488,12 @@ start_compress(const char *filename, uint64_t chunksize, int level)
else else
flags |= FLAG_DEDUP_FIXED; flags |= FLAG_DEDUP_FIXED;
/* Additional scratch space for dedup arrays. */ /* Additional scratch space for dedup arrays. */
compressed_chunksize += (dedupe_buf_extra(chunksize, 0, algo, if (chunksize + dedupe_buf_extra(chunksize, 0, algo, enable_delta_encode)
enable_delta_encode) - (compressed_chunksize - chunksize)); > compressed_chunksize) {
compressed_chunksize += (chunksize +
dedupe_buf_extra(chunksize, 0, algo, enable_delta_encode)) -
compressed_chunksize;
}
} }
if (encrypt_type) { if (encrypt_type) {

View file

@ -52,12 +52,9 @@ then
[ $? -ne 0 ] && continue [ $? -ne 0 ] && continue
cd datafiles cd datafiles
(. ../${tf}) (. ../${tf}) 2>&1 | tee ${tf}.log
if [ $? -ne 0 ] fails=`egrep "^FATAL:" ${tf}.log | wc -l`
then failures=$((failures + fails))
echo "FATAL: Test ${tf} failed"
failures=$((failures + 1))
fi
cd $PDIR cd $PDIR
done done
else else