From aa4fc60117a35a56735fdca533d0169c9c5f76d0 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 15 Dec 2014 11:38:56 -0500 Subject: Fix cast error An unsigned int cannot be cast to a size_t. On some architectures (like s390) they have different sizes resulting in both writing out of bounds and getting just a zero in the length field and causing the next operation to fail. Signed-off-by: Simo Sorce Reviewed-by: Nathaniel McCallum Reviewed-by: Roland Mainz --- proxy/src/gp_export.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/proxy/src/gp_export.c b/proxy/src/gp_export.c index b855c74..341ef0a 100644 --- a/proxy/src/gp_export.c +++ b/proxy/src/gp_export.c @@ -113,6 +113,7 @@ static int gp_encrypt_buffer(krb5_context context, krb5_keyblock *key, int ret; krb5_data data_in; krb5_enc_data enc_handle; + size_t cipherlen; data_in.length = len; data_in.data = buf; @@ -122,11 +123,12 @@ static int gp_encrypt_buffer(krb5_context context, krb5_keyblock *key, ret = krb5_c_encrypt_length(context, GP_CREDS_HANDLE_KEY_ENCTYPE, data_in.length, - (size_t *)&enc_handle.ciphertext.length); + &cipherlen); if (ret) { goto done; } + enc_handle.ciphertext.length = cipherlen; enc_handle.ciphertext.data = malloc(enc_handle.ciphertext.length); if (!enc_handle.ciphertext.data) { ret = ENOMEM; -- cgit