dbentry->n_tl_data = t3;
/* Get memory for key list */
- if (t4 && (kp = malloc(t4*sizeof(krb5_key_data))) == NULL)
+ if (t4 && (kp = calloc(t4, sizeof(krb5_key_data))) == NULL)
goto cleanup;
/* Get memory for extra data */
dbentry->e_length = t5;
if (kp != NULL) {
- memset(kp, 0, t4*sizeof(krb5_key_data));
dbentry->key_data = kp;
kp = NULL;
}
krb5_key_data *entry_key;
int i, k;
- keys = malloc(sizeof(krb5_keyblock) * (request->nktypes + 1));
+ keys = calloc(request->nktypes + 1, sizeof(krb5_keyblock));
if (keys == NULL)
return ENOMEM;
- memset(keys, 0, sizeof(krb5_keyblock) * (request->nktypes + 1));
k = 0;
for (i = 0; i < request->nktypes; i++) {
entry_key = NULL;
/* return length and data */
astream++;
savelen = *astream;
- if ((data->length = asn1length(&astream)) < 0) {
+ if ((length = asn1length(&astream)) < 0) {
return(-1);
}
+ data->length = length;
/* if the field length is indefinite, we will have to subtract two
(terminating octets) from the length returned since we don't want
to pass any info from the "wrapper" back. asn1length will always return
{
unsigned char *buf = *buf_in;
unsigned char *endptr = buf + cur_size;
- unsigned int seqsize;
+ int seqsize;
int ret = 0;
unsigned int bytes;
/*
* Make sure we have the entire buffer as described
*/
- if (buf + seqsize > endptr)
+ if (seqsize > endptr - buf)
return (G_BAD_TOK_HEADER);
} else {
return (G_BAD_TOK_HEADER);
/*
* Make sure we have the entire buffer as described
*/
- if (buf + bytes > endptr)
+ if (seqsize > endptr - buf)
return (G_BAD_TOK_HEADER);
} else {
return (G_BAD_TOK_HEADER);
static krb5_error_code
add_string_to_array(krb5_context context, char ***array, const char *addition)
{
- char **out = NULL;
-
- if (*array == NULL) {
- out = malloc(2 * sizeof(char *));
- if (out == NULL)
- return ENOMEM;
- out[1] = NULL;
- out[0] = strdup(addition);
- if (out[0] == NULL) {
- free(out);
- return ENOMEM;
- }
- } else {
- int i;
- char **a = *array;
- for (i = 0; a[i] != NULL; i++);
- out = malloc( (i + 2) * sizeof(char *));
- if (out == NULL)
- return ENOMEM;
- for (i = 0; a[i] != NULL; i++) {
- out[i] = a[i];
- }
- out[i++] = strdup(addition);
- if (out == NULL) {
- free(out);
- return ENOMEM;
- }
- out[i] = NULL;
- free(*array);
- }
- *array = out;
+ char **a = *array;
+ size_t len;
+ for (len = 0; a != NULL && a[len] != NULL; len++);
+ a = realloc(a, (len + 2) * sizeof(char *));
+ if (a == NULL)
+ return ENOMEM;
+ *array = a;
+ a[len] = strdup(addition);
+ if (a[len] == NULL)
+ return ENOMEM;
+ a[len + 1] = NULL;
return 0;
}
+
static krb5_error_code
handle_gic_opt(krb5_context context,
pkinit_context plgctx,