Avoid truncating the pointer on x32 platform.
authorTomas Mraz <tmraz@fedoraproject.org>
Mon, 15 Aug 2016 10:02:06 +0000 (12:02 +0200)
committerMatt Caswell <matt@openssl.org>
Mon, 15 Aug 2016 22:30:45 +0000 (23:30 +0100)
The 64 bit pointer must not be cast to 32bit unsigned long on
x32 platform.

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
engines/afalg/e_afalg.c

index 1766230ce8f664be13920dae1f54c379e25e5f23..2ea5ba5232a1996ba09e1ee7c3ba773cde543264 100644 (file)
@@ -230,11 +230,15 @@ int afalg_fin_cipher_aio(afalg_aio *aio, int sfd, unsigned char *buf,
     memset(cb, '\0', sizeof(*cb));
     cb->aio_fildes = sfd;
     cb->aio_lio_opcode = IOCB_CMD_PREAD;
-    /*
-     * The pointer has to be converted to unsigned value first to avoid
-     * sign extension on cast to 64 bit value
-     */
-    cb->aio_buf = (uint64_t)(unsigned long)buf;
+    if (sizeof(buf) != sizeof(cb->aio_buf)) {
+        /*
+         * The pointer has to be converted to 32 bit unsigned value first
+         * to avoid sign extension on cast to 64 bit value
+         */
+        cb->aio_buf = (uint64_t)(unsigned long)buf;
+    } else {
+        cb->aio_buf = (uint64_t)buf;
+    }
     cb->aio_offset = 0;
     cb->aio_data = 0;
     cb->aio_nbytes = len;