_("cannot read tagged data type and length"));
return EINVAL;
}
+ if (i1 < INT16_MIN || i1 > INT16_MAX || u1 > UINT16_MAX) {
+ load_err(fname, lineno, _("data type or length overflowed"));
+ return EINVAL;
+ }
tl->tl_data_type = i1;
tl->tl_data_length = u1;
if (read_octets_or_minus1(filep, tl->tl_data_length,
goto fail;
/* Get memory for and form tagged data linked list */
+ if (u3 > UINT16_MAX) {
+ load_err(fname, *linenop, _("cannot allocate tl_data (too large)"));
+ goto fail;
+ }
if (alloc_tl_data(u3, &dbentry->tl_data))
goto fail;
dbentry->n_tl_data = u3;
load_err(fname, *linenop, _("cannot read key size and version"));
goto fail;
}
+ if (t1 > KRB5_KDB_V1_KEY_DATA_ARRAY) {
+ load_err(fname, *linenop, _("unsupported key_data_ver version"));
+ goto fail;
+ }
kd->key_data_ver = t1;
kd->key_data_kvno = t2;
for (j = 0; j < t1; j++) {
nread = fscanf(filep, "%d\t%d\t", &t3, &t4);
- if (nread != 2) {
+ if (nread != 2 || t4 < 0) {
load_err(fname, *linenop,
_("cannot read key type and length"));
goto fail;
krb5_data plain;
krb5_enc_data cipher;
size_t ec_max;
+ size_t encrypt_size;
/* 300: Adds some slop. */
if (SIZE_MAX - 300 < message->length)
return err;
/* Get size of ciphertext. */
- bufsize = 16 + krb5_encrypt_size (plain.length, key->keyblock.enctype);
+ encrypt_size = krb5_encrypt_size(plain.length, key->keyblock.enctype);
+ if (encrypt_size > SIZE_MAX / 2) {
+ err = ENOMEM;
+ goto error;
+ }
+ bufsize = 16 + encrypt_size;
/* Allocate space for header plus encrypted data. */
outbuf = gssalloc_malloc(bufsize);
if (outbuf == NULL) {