In case the compression result is the same size as the orignal version,

the compression was useless as well.  Make sure to not update the data
and return, else we would waste resources when decompressing.

This also avoids the copyback() changing data other consumers like
xform_ipcomp.c would have ignored because of no win and sent out without
noting that compression was used, resulting in invalid packets at the
receiver.

MFC after:	5 days
This commit is contained in:
Bjoern A. Zeeb 2009-11-29 17:53:57 +00:00
parent 10229cd109
commit df4dece102
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=199906

View File

@ -552,7 +552,7 @@ swcr_compdec(struct cryptodesc *crd, struct swcr_data *sw,
sw->sw_size = result;
/* Check the compressed size when doing compression */
if (crd->crd_flags & CRD_F_COMP) {
if (result > crd->crd_len) {
if (result >= crd->crd_len) {
/* Compression was useless, we lost time */
free(out, M_CRYPTO_DATA);
return 0;