From: Ezra Peisach Date: Tue, 17 Oct 2000 23:00:56 +0000 (+0000) Subject: * bld_pr_ext.c, bld_princ.c (krb5_build_principal_ext, X-Git-Tag: krb5-1.3-alpha1~1821 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=773b682dfda7919d3e2cdfb7bddd54d831e4dc1d;p=krb5.git * bld_pr_ext.c, bld_princ.c (krb5_build_principal_ext, krb5_build_principal_va, krb5_build_principal): Take an unsigned int realm length. * get_in_tkt.c (krb5_get_init_creds): Use SALT_TYPE_AFS_LENGTH instead of -1. * gic_pwd.c (krb5_get_as_key_password): Use SALT_TYPE_AFS_LENGTH instead of -1. * in_tkt_pwd.c (pwd_keyproc): Argument to krb5_read_password is unsigned int. * pr_to_salt.c (krb5_principal2salt_internal): Declare as static. Unsigned int fix. * preauth.c (krb5_obtain_padata): Use SALT_TYPE_AFS_LENGTH instead of -1. * preauth2.c (pa_salt): Use SALT_TYPE_AFS_LENGTH instead of -1. * conv_princ.c, copy_auth.c, copy_princ.c, gc_frm_kdc.c, parse.c, send_tgs.c, srv_rcache.c: Unsigned/signed int cleanup. * unparse.c (krb5_unparse_name_ext): size parameter changed to unsigned int *. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@12782 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5/krb/ChangeLog b/src/lib/krb5/krb/ChangeLog index 4221c736a..9c6724128 100644 --- a/src/lib/krb5/krb/ChangeLog +++ b/src/lib/krb5/krb/ChangeLog @@ -1,3 +1,32 @@ +2000-10-17 Ezra Peisach + + * bld_pr_ext.c, bld_princ.c (krb5_build_principal_ext, + krb5_build_principal_va, krb5_build_principal): Take an unsigned + int realm length. + + * get_in_tkt.c (krb5_get_init_creds): Use SALT_TYPE_AFS_LENGTH + instead of -1. + + * gic_pwd.c (krb5_get_as_key_password): Use SALT_TYPE_AFS_LENGTH + instead of -1. + + * in_tkt_pwd.c (pwd_keyproc): Argument to krb5_read_password is + unsigned int. + + * pr_to_salt.c (krb5_principal2salt_internal): Declare as + static. Unsigned int fix. + + * preauth.c (krb5_obtain_padata): Use SALT_TYPE_AFS_LENGTH instead + of -1. + + * preauth2.c (pa_salt): Use SALT_TYPE_AFS_LENGTH instead of -1. + + * conv_princ.c, copy_auth.c, copy_princ.c, gc_frm_kdc.c, parse.c, + send_tgs.c, srv_rcache.c: Unsigned/signed int cleanup. + + * unparse.c (krb5_unparse_name_ext): size parameter changed to + unsigned int *. + 2000-10-04 Ezra Peisach * rd_req_dec.c (krb5_rd_req_decrypt_tkt_part): Fix memory leak if @@ -5,6 +34,12 @@ 2000-10-03 Ezra Peisach + * srv_rcache.c (krb5_get_server_rcache): Signed vs unsigned int + warning fix. + + * pr_to_salt.c (krb5_principal2salt_internal): Add prototype for + internal function, and declare static. + * copy_addrs.c (krb5_copy_addresses): Cleanup unsigned vs signed warnings as arguments to malloc(). diff --git a/src/lib/krb5/krb/bld_pr_ext.c b/src/lib/krb5/krb/bld_pr_ext.c index f2c450f59..ef95405ca 100644 --- a/src/lib/krb5/krb/bld_pr_ext.c +++ b/src/lib/krb5/krb/bld_pr_ext.c @@ -37,18 +37,19 @@ KRB5_DLLIMP krb5_error_code KRB5_CALLCONV_C #ifdef HAVE_STDARG_H -krb5_build_principal_ext(krb5_context context, krb5_principal FAR * princ, int rlen, krb5_const char FAR * realm, ...) +krb5_build_principal_ext(krb5_context context, krb5_principal FAR * princ, unsigned int rlen, krb5_const char FAR * realm, ...) #else krb5_build_principal_ext(context, princ, rlen, realm, va_alist) krb5_context context; krb5_principal FAR *princ; - int rlen; + unsigned int rlen; krb5_const char FAR *realm; va_dcl #endif { va_list ap; - register int i, count = 0, size; + register int i, count = 0; + register unsigned int size; register char *next; char *tmpdata; krb5_data *princ_data; @@ -97,7 +98,7 @@ krb5_build_principal_ext(context, princ, rlen, realm, va_alist) va_start(ap); #endif for (i = 0; i < count; i++) { - size = va_arg(ap, int); + size = va_arg(ap, unsigned int); next = va_arg(ap, char *); princ_data[i].length = size; princ_data[i].data = malloc(size+1); diff --git a/src/lib/krb5/krb/bld_princ.c b/src/lib/krb5/krb/bld_princ.c index bf4910510..6ddef9d45 100644 --- a/src/lib/krb5/krb/bld_princ.c +++ b/src/lib/krb5/krb/bld_princ.c @@ -40,7 +40,7 @@ krb5_error_code krb5_build_principal_va(context, princ, rlen, realm, ap) krb5_context context; krb5_principal princ; - int rlen; + unsigned int rlen; krb5_const char *realm; va_list ap; { @@ -101,13 +101,14 @@ krb5_build_principal_va(context, princ, rlen, realm, ap) KRB5_DLLIMP krb5_error_code KRB5_CALLCONV_C #ifdef HAVE_STDARG_H -krb5_build_principal(krb5_context context, krb5_principal * princ, int rlen, - krb5_const char FAR * realm, ...) +krb5_build_principal(krb5_context context, krb5_principal * princ, + unsigned int rlen, + krb5_const char FAR * realm, ...) #else krb5_build_principal(context, princ, rlen, realm, va_alist) krb5_context context; krb5_principal *princ; - int rlen; + unsigned int rlen; krb5_const char FAR *realm; va_dcl #endif diff --git a/src/lib/krb5/krb/conv_princ.c b/src/lib/krb5/krb/conv_princ.c index c880de3eb..8805fe0d5 100644 --- a/src/lib/krb5/krb/conv_princ.c +++ b/src/lib/krb5/krb/conv_princ.c @@ -138,7 +138,8 @@ krb5_524_conv_principal(context, princ, name, inst, realm) const struct krb_convert *p; krb5_data *compo; char *c, *tmp_realm, *tmp_prealm; - int tmp_realm_len, retval; + unsigned int tmp_realm_len; + int retval; *name = *inst = '\0'; switch (krb5_princ_size(context, princ)) { diff --git a/src/lib/krb5/krb/copy_auth.c b/src/lib/krb5/krb/copy_auth.c index 331c350fe..75af4aac6 100644 --- a/src/lib/krb5/krb/copy_auth.c +++ b/src/lib/krb5/krb/copy_auth.c @@ -64,7 +64,7 @@ krb5_copy_authdata(context, inauthdat, outauthdat) { krb5_error_code retval; krb5_authdata ** tempauthdat; - register int nelems = 0; + register unsigned int nelems = 0; if (!inauthdat) { *outauthdat = 0; diff --git a/src/lib/krb5/krb/copy_princ.c b/src/lib/krb5/krb/copy_princ.c index 7e8ad6e09..aa98ba9cf 100644 --- a/src/lib/krb5/krb/copy_princ.c +++ b/src/lib/krb5/krb/copy_princ.c @@ -61,7 +61,7 @@ krb5_copy_principal(context, inprinc, outprinc) } for (i = 0; i < nelems; i++) { - int len = krb5_princ_component(context, inprinc, i)->length; + unsigned int len = krb5_princ_component(context, inprinc, i)->length; krb5_princ_component(context, tempprinc, i)->length = len; if (((krb5_princ_component(context, tempprinc, i)->data = malloc(len)) == 0) && len) { diff --git a/src/lib/krb5/krb/gc_frm_kdc.c b/src/lib/krb5/krb/gc_frm_kdc.c index 1e315febd..25ae0a601 100644 --- a/src/lib/krb5/krb/gc_frm_kdc.c +++ b/src/lib/krb5/krb/gc_frm_kdc.c @@ -81,7 +81,7 @@ krb5_get_cred_from_kdc_opt(context, ccache, in_cred, out_cred, tgts, kdcopt) krb5_principal *tgs_list = NULL; krb5_principal *top_server = NULL; krb5_principal *next_server = NULL; - int nservers = 0; + unsigned int nservers = 0; /* in case we never get a TGT, zero the return */ diff --git a/src/lib/krb5/krb/get_in_tkt.c b/src/lib/krb5/krb/get_in_tkt.c index a75f90a48..9bd469c2e 100644 --- a/src/lib/krb5/krb/get_in_tkt.c +++ b/src/lib/krb5/krb/get_in_tkt.c @@ -918,7 +918,7 @@ krb5_get_init_creds(context, creds, client, prompter, prompter_data, if (options && (options->flags & KRB5_GET_INIT_CREDS_OPT_SALT)) { salt = *options->salt; } else { - salt.length = -1; + salt.length = SALT_TYPE_AFS_LENGTH; salt.data = NULL; } diff --git a/src/lib/krb5/krb/gic_pwd.c b/src/lib/krb5/krb/gic_pwd.c index 76594e953..5e8c2127f 100644 --- a/src/lib/krb5/krb/gic_pwd.c +++ b/src/lib/krb5/krb/gic_pwd.c @@ -66,7 +66,7 @@ krb5_get_as_key_password(context, client, etype, prompter, prompter_data, krb5int_set_prompt_types(context, 0); } - if ((salt->length == -1) && (salt->data == NULL)) { + if ((salt->length == -1 || salt->length == SALT_TYPE_AFS_LENGTH) && (salt->data == NULL)) { if ((ret = krb5_principal2salt(context, client, &defsalt))) return(ret); @@ -270,9 +270,9 @@ krb5_get_init_creds_password(context, creds, client, password, prompter, data, result_string.length = sizeof(banner)-100; sprintf(banner, "%.*s%s%.*s. Please try again.\n", - code_string.length, code_string.data, + (int) code_string.length, code_string.data, result_string.length?": ":"", - result_string.length, result_string.data); + (int) result_string.length, result_string.data); krb5_xfree(code_string.data); krb5_xfree(result_string.data); diff --git a/src/lib/krb5/krb/in_tkt_pwd.c b/src/lib/krb5/krb/in_tkt_pwd.c index 6e435f28e..6e747652d 100644 --- a/src/lib/krb5/krb/in_tkt_pwd.c +++ b/src/lib/krb5/krb/in_tkt_pwd.c @@ -51,7 +51,7 @@ pwd_keyproc(context, type, salt, keyseed, key) { krb5_error_code retval; krb5_data * password; - int pwsize; + unsigned int pwsize; password = (krb5_data *)keyseed; diff --git a/src/lib/krb5/krb/parse.c b/src/lib/krb5/krb/parse.c index 85fa069ea..366f75447 100644 --- a/src/lib/krb5/krb/parse.c +++ b/src/lib/krb5/krb/parse.c @@ -75,7 +75,7 @@ krb5_parse_name(context, name, nprincipal) int components = 0; const char *parsed_realm = NULL; int fcompsize[FCOMPNUM]; - int realmsize = 0; + unsigned int realmsize = 0; static char *default_realm = NULL; static int default_realm_size = 0; char *tmpdata; diff --git a/src/lib/krb5/krb/pr_to_salt.c b/src/lib/krb5/krb/pr_to_salt.c index 9ccc3b4ce..9efe1b7cd 100644 --- a/src/lib/krb5/krb/pr_to_salt.c +++ b/src/lib/krb5/krb/pr_to_salt.c @@ -29,17 +29,20 @@ #include "k5-int.h" +static krb5_error_code krb5_principal2salt_internal + PROTOTYPE((krb5_context, krb5_const_principal, krb5_data *ret, int)); + /* * Convert a krb5_principal into the default salt for that principal. */ -krb5_error_code +static krb5_error_code krb5_principal2salt_internal(context, pr, ret, use_realm) krb5_context context; register krb5_const_principal pr; krb5_data *ret; int use_realm; { - int size = 0, offset = 0; + unsigned int size = 0, offset=0; krb5_int32 nelem; register int i; diff --git a/src/lib/krb5/krb/preauth.c b/src/lib/krb5/krb/preauth.c index 9f301dafd..d51e57ff7 100644 --- a/src/lib/krb5/krb/preauth.c +++ b/src/lib/krb5/krb/preauth.c @@ -183,13 +183,19 @@ krb5_error_code krb5_obtain_padata(context, preauth_to_use, key_proc, enctype = request->ktype[0]; salt.data = 0; - salt.length = -1; + salt.length = SALT_TYPE_NO_LENGTH; if (etype_info) { enctype = etype_info[0]->etype; salt.data = (char *) etype_info[0]->salt; - salt.length = etype_info[0]->length; + if(etype_info[0]->length == KRB5_ETYPE_NO_SALT) + salt.length = SALT_TYPE_NO_LENGTH; /* XXX */ + else + salt.length = etype_info[0]->length; } - if (salt.length == -1) { + if (salt.length == SALT_TYPE_NO_LENGTH) { + /* + * This will set the salt length + */ if ((retval = krb5_principal2salt(context, request->client, &salt))) return(retval); f_salt = 1; @@ -373,7 +379,7 @@ process_pw_salt(context, padata, request, as_reply, salt.data = (char *) padata->contents; salt.length = - (padata->pa_type == KRB5_PADATA_AFS3_SALT)?(-1):(padata->length); + (padata->pa_type == KRB5_PADATA_AFS3_SALT)?(SALT_TYPE_AFS_LENGTH):(padata->length); if ((retval = (*key_proc)(context, as_reply->enc_part.enctype, &salt, keyseed, decrypt_key))) { @@ -438,11 +444,11 @@ char *handle_sam_labels(sc) krb5_sam_challenge *sc; { char *label = sc->sam_challenge_label.data; - int label_len = sc->sam_challenge_label.length; + unsigned int label_len = sc->sam_challenge_label.length; char *prompt = sc->sam_response_prompt.data; - int prompt_len = sc->sam_response_prompt.length; + unsigned int prompt_len = sc->sam_response_prompt.length; char *challenge = sc->sam_challenge.data; - int challenge_len = sc->sam_challenge.length; + unsigned int challenge_len = sc->sam_challenge.length; char *prompt1, *p; char *sep1 = ": ["; char *sep2 = "]\n"; @@ -549,7 +555,7 @@ obtain_sam_padata(context, in_padata, etype_info, def_enc_key, return retval; if (sam_challenge->sam_flags & KRB5_SAM_SEND_ENCRYPTED_SAD) { /* encrypt passcode in key by stuffing it here */ - int pcsize = 256; + unsigned int pcsize = 256; char *passcode = malloc(pcsize+1); if (passcode == NULL) return ENOMEM; diff --git a/src/lib/krb5/krb/preauth2.c b/src/lib/krb5/krb/preauth2.c index 2327f1eec..d3841988e 100644 --- a/src/lib/krb5/krb/preauth2.c +++ b/src/lib/krb5/krb/preauth2.c @@ -83,7 +83,7 @@ krb5_error_code pa_salt(krb5_context context, /* assume that no other salt was allocated */ if (in_padata->pa_type == KRB5_PADATA_AFS3_SALT) - salt->length = -1; + salt->length = SALT_TYPE_AFS_LENGTH; return(0); } @@ -322,7 +322,7 @@ krb5_error_code pa_sam(krb5_context context, /* generate a salt using the requested principal */ - if ((salt->length == -1) && (salt->data == NULL)) { + if ((salt->length == -1 || salt->length == SALT_TYPE_AFS_LENGTH) && (salt->data == NULL)) { if ((ret = krb5_principal2salt(context, request->client, &defsalt))) { krb5_xfree(sam_challenge); @@ -360,7 +360,7 @@ krb5_error_code pa_sam(krb5_context context, } #if 0 - if ((salt->length == -1) && (salt->data == NULL)) { + if ((salt->length == SALT_TYPE_AFS_LENGTH) && (salt->data == NULL)) { if (ret = krb5_principal2salt(context, request->client, &defsalt)) { krb5_xfree(sam_challenge); @@ -538,7 +538,7 @@ krb5_do_preauth(krb5_context context, krb5_etype_info_entry *e = etype_info[j]; fprintf (stderr, "etype info %d: etype %d salt len=%d", j, e->etype, e->length); - if (e->length > 0) + if (e->length > 0 && e->length != KRB5_ETYPE_NO_SALT) fprintf (stderr, " '%*s'", e->length, e->salt); fprintf (stderr, "\n"); } diff --git a/src/lib/krb5/krb/send_tgs.c b/src/lib/krb5/krb/send_tgs.c index 3d65eb61d..452600201 100644 --- a/src/lib/krb5/krb/send_tgs.c +++ b/src/lib/krb5/krb/send_tgs.c @@ -236,7 +236,7 @@ krb5_send_tgs(context, kdcoptions, timestruct, ktypes, sname, addrs, /* combine in any other supplied padata */ if (padata) { krb5_pa_data * const * counter; - register int i = 0; + register unsigned int i = 0; for (counter = padata; *counter; counter++, i++); combined_padata = (krb5_pa_data **)malloc(i+2); if (!combined_padata) { diff --git a/src/lib/krb5/krb/srv_rcache.c b/src/lib/krb5/krb/srv_rcache.c index c94201bad..33e76842e 100644 --- a/src/lib/krb5/krb/srv_rcache.c +++ b/src/lib/krb5/krb/srv_rcache.c @@ -41,7 +41,8 @@ krb5_get_server_rcache(context, piece, rcptr) char *cachename = 0; char tmp[4]; krb5_error_code retval; - int len, p, i; + int p, i; + unsigned int len; #ifdef HAVE_GETEUID unsigned long tens; diff --git a/src/lib/krb5/krb/unparse.c b/src/lib/krb5/krb/unparse.c index f7df6ab7d..2c971aff7 100644 --- a/src/lib/krb5/krb/unparse.c +++ b/src/lib/krb5/krb/unparse.c @@ -62,13 +62,13 @@ krb5_unparse_name_ext(context, principal, name, size) krb5_context context; krb5_const_principal principal; register char FAR * FAR *name; - int FAR *size; + unsigned int FAR *size; { register char *cp, *q; register int i,j; int length; krb5_int32 nelem; - register int totalsize = 0; + register unsigned int totalsize = 0; cp = krb5_princ_realm(context, principal)->data; length = krb5_princ_realm(context, principal)->length;