Skip Menu |
 

To: krb5-bugs@MIT.EDU
Subject: strptime() doesn't like being touched that way by krb5_ldap_get_time
From: Tom Yu <tlyu@MIT.EDU>
Date: Wed, 19 Aug 2009 18:56:27 -0400
I noticed this problem on Mac OS X, but we probably want to fix it in
the general case for portability reasons.

getepochtime(), called by krb5_ldap_get_time(), passes a format string
of "%Y%m%d%H%M%SZ" to strptime(), causing a a return of EINVAL on Mac
OS X when any KDC programs attempt to fetch the master key list when
using an LDAP back end. According to POSIX / SUS, the application
must provide nonalphanumeric separators between format specifiers in
the format string of strptime().

Experimentation with a test program implies that the "%Y" format
specifier to strptime() tries to eat as many digits as it can, which
is about ten. This happens to be the number of decimal digits
required to represent a 32-bit integer...
From: Ken Raeburn <raeburn@MIT.EDU>
To: rt-comment@krbdev.mit.edu
Subject: Re: [krbdev.mit.edu #6548] strptime() doesn't like being touched that way by krb5_ldap_get_time
Date: Wed, 19 Aug 2009 23:08:23 -0400
RT-Send-Cc:
On Aug 19, 2009, at 18:56, Tom Yu via RT wrote:
Show quoted text
> I noticed this problem on Mac OS X, but we probably want to fix it in
> the general case for portability reasons.
>
> getepochtime(), called by krb5_ldap_get_time(), passes a format string
> of "%Y%m%d%H%M%SZ" to strptime(), causing a a return of EINVAL on Mac
> OS X when any KDC programs attempt to fetch the master key list when
> using an LDAP back end. According to POSIX / SUS, the application
> must provide nonalphanumeric separators between format specifiers in
> the format string of strptime().

I think we might see similar problems in krb5_string_to_timestamp,
too. Currently it ignores conversion errors (assumes that the pattern
tried wasn't applicable so the next pattern should be tried). The
t_kerb test program can exercise krb5_string_to_timestamp, but we
don't currently have it do so.

Ken