(fcc_get_first): check return value from malloc, memset the structure,
make sure cursor doesn't point to freed memory on failure. From: Wynn Wilkes <wwilkes@vintela.com> git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@15164 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -566,11 +566,17 @@ fcc_get_first (krb5_context context,
|
||||
krb5_principal principal;
|
||||
|
||||
*cursor = malloc(sizeof(struct fcc_cursor));
|
||||
if (*cursor == NULL) {
|
||||
krb5_set_error_string (context, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
memset(*cursor, 0, sizeof(struct fcc_cursor));
|
||||
|
||||
ret = init_fcc (context, id, &FCC_CURSOR(*cursor)->sp,
|
||||
&FCC_CURSOR(*cursor)->fd);
|
||||
if (ret) {
|
||||
free(*cursor);
|
||||
*cursor = NULL;
|
||||
return ret;
|
||||
}
|
||||
ret = krb5_ret_principal (FCC_CURSOR(*cursor)->sp, &principal);
|
||||
|
Reference in New Issue
Block a user