[2016] in Kerberos-V5-bugs
Re: problem in krb5_string_to_timestamp()
daemon@ATHENA.MIT.EDU (epeisach@MIT.EDU)
Mon Jun 17 20:31:11 1996
From: epeisach@MIT.EDU
Date: Mon, 17 Jun 1996 20:30:37 -0400
To: Paul Pomes <p-pomes@Qualcomm.com>
Cc: krb5-bugs@MIT.EDU
You described a problem in which timestamps of the for HH:MM would give
you weird values... You did not specify the platform, but I saw the same
failure under OSF/1 (oops DU 3.2b).
From the strptime man page, it explictly indicates that fields that are
not specified by the format description are not set/changed... Hence, if
you send in a zeroed structure, you lose...
Try this fix out for size....
Ezra
Index: str_conv.c
===================================================================
RCS file: /mit/krb5/.cvsroot/src/lib/krb5/krb/str_conv.c,v
retrieving revision 5.6
diff -c -r5.6 str_conv.c
*** str_conv.c 1996/05/15 00:57:15 5.6
--- str_conv.c 1996/06/18 00:23:42
***************
*** 432,442 ****
int i;
int found;
struct tm timebuf;
char *s;
found = 0;
! memset(&timebuf, 0, sizeof(timebuf));
for (i=0; i<atime_format_table_nents; i++) {
if ((s = strptime(string, atime_format_table[i], &timebuf))
&& (s != string)) {
found = 1;
--- 432,448 ----
int i;
int found;
struct tm timebuf;
+ time_t now;
char *s;
found = 0;
! now = time((time_t *) NULL);
for (i=0; i<atime_format_table_nents; i++) {
+ /* We reset every time throughout the loop as the manual page
+ * indicated that no guarantees are made as to preserving timebuf
+ * when parsing fails
+ */
+ memcpy(&timebuf, localtime(&now), sizeof(timebuf));
if ((s = strptime(string, atime_format_table[i], &timebuf))
&& (s != string)) {
found = 1;