krb5_enc_data cipher;
krb5_data plain;
+ if (!mkey)
+ return KRB5_KDB_BADSTORED_MKEY;
ptr = key_data->key_data_contents[0];
if (ptr) {
krb5_kdb_decode_int16(ptr, tmplen);
ptr += 2;
+ if (tmplen < 0)
+ return EINVAL;
cipher.enctype = ENCTYPE_UNKNOWN;
cipher.ciphertext.length = key_data->key_data_length[0]-2;
- cipher.ciphertext.data = ptr;
+ cipher.ciphertext.data = (char *) ptr;
plain.length = key_data->key_data_length[0]-2;
- if ((plain.data = (krb5_octet *) malloc(plain.length)) == NULL)
+ if ((plain.data = malloc(plain.length)) == NULL)
return(ENOMEM);
if ((retval = krb5_c_decrypt(context, mkey, 0 /* XXX */, 0,
to make sure that there are enough bytes, but I can't do
any better than that. */
- if (tmplen > plain.length) {
+ if ((unsigned int) tmplen > plain.length) {
free(plain.data);
return(KRB5_CRYPTO_INTERNAL);
}
dbkey->magic = KV5M_KEYBLOCK;
dbkey->enctype = key_data->key_data_type[0];
dbkey->length = tmplen;
- dbkey->contents = plain.data;
+ dbkey->contents = (krb5_octet *) plain.data;
}
/* Decode salt data */
ptr += 2;
plain.length = dbkey->length;
- plain.data = dbkey->contents;
+ plain.data = (char *) dbkey->contents;
cipher.ciphertext.length = len;
- cipher.ciphertext.data = ptr;
+ cipher.ciphertext.data = (char *) ptr;
if ((retval = krb5_c_encrypt(context, mkey, /* XXX */ 0, 0,
&plain, &cipher))) {