From 93d56af0ae5cf68cfcfdd97b2eca827981522816 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Thu, 5 Jun 2003 23:09:13 +0000 Subject: [PATCH] (sub_wrap_size): gss_wrap_size_limit() has req_output_size and max_input_size around the wrong way -- it returns the output token size for a given input size, rather than the maximum input size for a given output token size. From: Luke Howard git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@12352 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/gssapi/krb5/wrap.c | 20 ++++++++++++++------ lib/gssapi/wrap.c | 20 ++++++++++++++------ 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/lib/gssapi/krb5/wrap.c b/lib/gssapi/krb5/wrap.c index 8c4087b18..9ce0a1240 100644 --- a/lib/gssapi/krb5/wrap.c +++ b/lib/gssapi/krb5/wrap.c @@ -68,12 +68,20 @@ sub_wrap_size ( int extrasize ) { - size_t len, total_len, padlength; - padlength = blocksize - (req_output_size % blocksize); - len = req_output_size + 8 + padlength + extrasize; - gssapi_krb5_encap_length(len, &len, &total_len); - *max_input_size = (OM_uint32)total_len; - return GSS_S_COMPLETE; + size_t len, total_len; + + len = 8 + req_output_size + blocksize + extrasize; + + gssapi_krb5_encap_length(len, &len, &total_len); + + total_len -= req_output_size; /* token length */ + if (total_len < req_output_size) { + *max_input_size = (req_output_size - total_len); + (*max_input_size) &= (~(OM_uint32)(blocksize - 1)); + } else { + *max_input_size = 0; + } + return GSS_S_COMPLETE; } OM_uint32 diff --git a/lib/gssapi/wrap.c b/lib/gssapi/wrap.c index 8c4087b18..9ce0a1240 100644 --- a/lib/gssapi/wrap.c +++ b/lib/gssapi/wrap.c @@ -68,12 +68,20 @@ sub_wrap_size ( int extrasize ) { - size_t len, total_len, padlength; - padlength = blocksize - (req_output_size % blocksize); - len = req_output_size + 8 + padlength + extrasize; - gssapi_krb5_encap_length(len, &len, &total_len); - *max_input_size = (OM_uint32)total_len; - return GSS_S_COMPLETE; + size_t len, total_len; + + len = 8 + req_output_size + blocksize + extrasize; + + gssapi_krb5_encap_length(len, &len, &total_len); + + total_len -= req_output_size; /* token length */ + if (total_len < req_output_size) { + *max_input_size = (req_output_size - total_len); + (*max_input_size) &= (~(OM_uint32)(blocksize - 1)); + } else { + *max_input_size = 0; + } + return GSS_S_COMPLETE; } OM_uint32