Skip to content

Commit aa4fc60

Browse files
committed
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 <[email protected]> Reviewed-by: Nathaniel McCallum <[email protected]> Reviewed-by: Roland Mainz <[email protected]>
1 parent 785889a commit aa4fc60

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

proxy/src/gp_export.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ static int gp_encrypt_buffer(krb5_context context, krb5_keyblock *key,
113113
int ret;
114114
krb5_data data_in;
115115
krb5_enc_data enc_handle;
116+
size_t cipherlen;
116117

117118
data_in.length = len;
118119
data_in.data = buf;
@@ -122,11 +123,12 @@ static int gp_encrypt_buffer(krb5_context context, krb5_keyblock *key,
122123
ret = krb5_c_encrypt_length(context,
123124
GP_CREDS_HANDLE_KEY_ENCTYPE,
124125
data_in.length,
125-
(size_t *)&enc_handle.ciphertext.length);
126+
&cipherlen);
126127
if (ret) {
127128
goto done;
128129
}
129130

131+
enc_handle.ciphertext.length = cipherlen;
130132
enc_handle.ciphertext.data = malloc(enc_handle.ciphertext.length);
131133
if (!enc_handle.ciphertext.data) {
132134
ret = ENOMEM;

0 commit comments

Comments
 (0)