Date: | Wed, 6 Aug 2003 13:08:58 -0400 |
From: | Cesar Garcia <Cesar.Garcia@morganstanley.com> |
To: | krb5-bugs@mit.edu |
Subject: | starttime marshalling bug on 64bit platforms in krb524d |
krb524d uses krb524int_krb_create_ticket(), which when it populates
the K4 ticket starttime in the tkt->dat, is using memcpy to copy 4
from an 8 byte long (8 bytes on 64bit platforms).
The result is a starttime of zero, rather than the actual start time
which is held in the lower order bytes (assuming big endian).
marshalling the 64bit starttime is implemented in krb_create_ticket
(src/lib/krb4/cr_tkt.c), but appears to have been overlooked in
krb524int_krb_create_ticket (src/krb524/cnv_tkt_skey.c).
Attached is a patch to 1.3.1 for your review. I've tested this on:
* 64bit solaris 8 (big endian)
* 32bit solaris 8 (big endian)
* 32bit red hat linux AS 2.1 (little endian)
However the krb_create_ticket code assumes big endian, so this patch
is an adaptation of the changes made to krb_create_ticket. I'm not
aware of any predefined macros that can be used to determine
endianness, but the intent of this patch should be clear.
Regards,
Cesar
the K4 ticket starttime in the tkt->dat, is using memcpy to copy 4
from an 8 byte long (8 bytes on 64bit platforms).
The result is a starttime of zero, rather than the actual start time
which is held in the lower order bytes (assuming big endian).
marshalling the 64bit starttime is implemented in krb_create_ticket
(src/lib/krb4/cr_tkt.c), but appears to have been overlooked in
krb524int_krb_create_ticket (src/krb524/cnv_tkt_skey.c).
Attached is a patch to 1.3.1 for your review. I've tested this on:
* 64bit solaris 8 (big endian)
* 32bit solaris 8 (big endian)
* 32bit red hat linux AS 2.1 (little endian)
However the krb_create_ticket code assumes big endian, so this patch
is an adaptation of the changes made to krb_create_ticket. I'm not
aware of any predefined macros that can be used to determine
endianness, but the intent of this patch should be clear.
Regards,
Cesar
*** cnv_tkt_skey.c.orig Tue Aug 5 19:23:21 2003
--- cnv_tkt_skey.c Wed Aug 6 12:25:14 2003
***************
*** 33,38 ****
--- 33,40 ----
#include <krb.h>
#include "krb524d.h"
+ #define KRB524_LITTLE_ENDIAN (1 != htonl(1))
+
static int krb524d_debug = 0;
static int
***************
*** 359,366 ****
data += 8;
*(data++) = (char) life;
/* issue time */
! memcpy(data, (char *) &time_sec, 4);
! data += 4;
(void) strcpy(data, sname);
data += 1 + strlen(sname);
(void) strcpy(data, sinstance);
--- 361,368 ----
data += 8;
*(data++) = (char) life;
/* issue time */
! KRB4_PUT32(data, time_sec, (KRB524_LITTLE_ENDIAN));
!
(void) strcpy(data, sname);
data += 1 + strlen(sname);
(void) strcpy(data, sinstance);
--- cnv_tkt_skey.c Wed Aug 6 12:25:14 2003
***************
*** 33,38 ****
--- 33,40 ----
#include <krb.h>
#include "krb524d.h"
+ #define KRB524_LITTLE_ENDIAN (1 != htonl(1))
+
static int krb524d_debug = 0;
static int
***************
*** 359,366 ****
data += 8;
*(data++) = (char) life;
/* issue time */
! memcpy(data, (char *) &time_sec, 4);
! data += 4;
(void) strcpy(data, sname);
data += 1 + strlen(sname);
(void) strcpy(data, sinstance);
--- 361,368 ----
data += 8;
*(data++) = (char) life;
/* issue time */
! KRB4_PUT32(data, time_sec, (KRB524_LITTLE_ENDIAN));
!
(void) strcpy(data, sname);
data += 1 + strlen(sname);
(void) strcpy(data, sinstance);