aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Mraz <tmraz@fedoraproject.org>2016-08-15 12:02:06 +0200
committerMatt Caswell <matt@openssl.org>2016-08-15 23:30:45 +0100
commit40c60b0d7389aa479cf7474a080737e901944d0d (patch)
treeaa613a66660d83570050d26b0ec90b1b43bf146b
parente7e5d608fb6cef9929a2cf56d72fa7e236ca7573 (diff)
downloadopenssl-40c60b0d7389aa479cf7474a080737e901944d0d.tar.gz
Avoid truncating the pointer on x32 platform.
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>
-rw-r--r--engines/afalg/e_afalg.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/engines/afalg/e_afalg.c b/engines/afalg/e_afalg.c
index 1766230ce8..2ea5ba5232 100644
--- a/engines/afalg/e_afalg.c
+++ b/engines/afalg/e_afalg.c
@@ -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;