Sanity check DES_enc_write buffer length
authorMatt Caswell <matt@openssl.org>
Mon, 27 Apr 2015 10:04:56 +0000 (11:04 +0100)
committerMatt Caswell <matt@openssl.org>
Thu, 30 Apr 2015 22:14:55 +0000 (23:14 +0100)
Add a sanity check to DES_enc_write to ensure the buffer length provided
is not negative. Thanks to Kevin Wojtysiak (Int3 Solutions) and Paramjot
Oberoi (Int3 Solutions) for reporting this issue.

Reviewed-by: Andy Polyakov <appro@openssl.org>
(cherry picked from commit 873fb39f20b6763daba226b74e83fb194924c7bf)

crypto/des/enc_writ.c

index 25041f2aab5e2465908a9c83c3c5c9118fe58ea5..bfaabde516ae5519c31d97b7eebb82a28e3d3346 100644 (file)
@@ -96,6 +96,9 @@ int DES_enc_write(int fd, const void *_buf, int len,
     const unsigned char *cp;
     static int start = 1;
 
+    if (len < 0)
+        return -1;
+
     if (outbuf == NULL) {
         outbuf = OPENSSL_malloc(BSIZE + HDRSIZE);
         if (outbuf == NULL)