[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Odd krb5_free_cred_contents problem (Heimdal 1.0.2, Solaris 9)
On Sun, 24 Feb 2008 12:37:33 -0000
"Markus Moeller" <huaraz@moeller.plus.com> wrote:
> Russ,
>
> I think you need to set the whole structure to 0 after calloc.
>
> memset(*creds, 0, sizeof(krb5_creds));
>
> otherwise pointers like creds->client, creds->server could be undefined and
> then used in free calls later on in krb5_free_creds_contents (e.g.
> krb5_free_principal(context, creds->client);
No, calloc zeros the memory. That's the difference between calloc and
malloc. Calloc zeros out the allocated memory whereas malloc does not.
Mike
> "Russ Allbery" <rra@stanford.edu> wrote in message
> 877igvo4d2.fsf@windlord.stanford.edu">news:877igvo4d2.fsf@windlord.stanford.edu...
> > Alf ran into an odd problem with my pam-krb5 module built statically with
> > Heimdal 1.0.2 on Solaris 9 with the Sun Studio C version 11 compiler.
> >
> > pam-krb5, when authentication failed, was dying with:
> >
> > 23484: Incurred fault #5, FLTACCESS %pc = 0x001E1668
> > 23484: siginfo: SIGBUS BUS_ADRALN addr=0xAACA6001
> > 23484: Received signal #10, SIGBUS [default]
> > 23484: siginfo: SIGBUS BUS_ADRALN addr=0xAACA6001
> >
> > Inside the module, it does:
> >
> > int
> > pamk5_password_auth(struct pam_args *args, const char *service,
> > krb5_creds **creds)
> > {
> > /* ... */
> > *creds = calloc(1, sizeof(krb5_creds));
> > /* ... */
> > retval = krb5_get_init_creds_password(ctx->context, *creds,
> > ctx->princ, pass, pamk5_prompter_krb5, args, 0,
> > (char *) service, opts);
> > success = (retval == 0) ? PAM_SUCCESS : PAM_AUTH_ERR;
> > /* ... */
> > if (*creds != NULL) {
> > krb5_free_cred_contents(ctx->context, *creds);
> > free(*creds);
> > *creds = NULL;
> > }
> >
> > The krb5_free_cred_contents here appears to be the culprit, even though
> > the structure is initialized all-zeros. If I apply this patch, the crash
> > goes away:
--
Michael B Allen
PHP Active Directory SPNEGO SSO
http://www.ioplex.com/