Linux cryptographic layer development
 help / color / mirror / Atom feed
From: "Aseem Rastogi" <arastogi@cs.sunysb.edu>
To: herbert@gondor.apana.org.au, davem@davemloft.net,
	linux-crypto@vger.kernel.org
Cc: vtaras@cs.sunysb.edu
Subject: PATCH crypto/zlib: Allow Z_OK return value from zlib_deflate
Date: Sun, 20 Dec 2009 14:34:09 -0500	[thread overview]
Message-ID: <20091220192122.M17448@cs.sunysb.edu> (raw)

From: Aseem Rastogi

crypto/zlib: When zlib_deflate is called with Z_FINISH flag, it should be
considered valid if it returns Z_OK instead of Z_STREAM_END.

zlib_defalte allows callers to call it with Z_FINISH flag multiple times. This
is useful if output buffer did not have enough space first time zlib_deflate
was called with Z_FINISH set. zlib_deflate returns Z_OK in that case and
expects that caller will invoke it again with Z_FINISH set to collect
remaining data. So, return value from zlib_deflate can be Z_OK OR
Z_STREAM_END. zlib_compress_final is modified to allow return value of Z_OK.

Signed-off-by: Aseem Rastogi <arastogi@cs.sunysb.edu>
Tested-by: Aseem Rastogi <arastogi@cs.sunysb.edu>
Reviewed-by: Vasily Tarasov <vtaras@cs.sunysb.edu>

diff --git a/crypto/zlib.c b/crypto/zlib.c
index c301573..c63c520 100644
--- a/crypto/zlib.c
+++ b/crypto/zlib.c
@@ -190,7 +190,7 @@ static int zlib_compress_final(struct crypto_pcomp *tfm,
 	stream->avail_out = req->avail_out;
 
 	ret = zlib_deflate(stream, Z_FINISH);
-	if (ret != Z_STREAM_END) {
+	if ((ret != Z_STREAM_END) && (ret != Z_OK)) {
 		pr_debug("zlib_deflate failed %d\n", ret);
 		return -EINVAL;
 	}

             reply	other threads:[~2009-12-20 20:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-20 19:34 Aseem Rastogi [this message]
2009-12-23 12:01 ` PATCH crypto/zlib: Allow Z_OK return value from zlib_deflate Herbert Xu
2010-01-13  9:45   ` Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091220192122.M17448@cs.sunysb.edu \
    --to=arastogi@cs.sunysb.edu \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=vtaras@cs.sunysb.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox