[1558] in Kerberos_V5_Development

home help back first fref pref prev next nref lref last post

kadmin/cli/getdate.y

daemon@ATHENA.MIT.EDU (Ezra Peisach)
Tue Aug 13 15:27:45 1996

Date: Tue, 13 Aug 1996 15:27:23 -0400
From: Ezra Peisach <epeisach@MIT.EDU>
To: krbcore@MIT.EDU


I can reliably cause kadmin to crash on a sun compiling with the suncc
compiler. (use modent -maxlife.....).

The problem is in the system header file /usr/include/sys/timeb.h:


#if defined(__STDC__)
#pragma	pack(2)
#endif

/*
 * Structure returned by ftime system call
 */
struct timeb {
	time_t	time;		/* time, seconds since the epoch */
	unsigned short millitm;	/* 1000 msec of additional accuracy */
	short	timezone;	/* timezone, minutes west of GMT */
	short	dstflag;	/* daylight savings when appropriate? */
};

#if defined(__STDC__)
#pragma	pack()
#endif


Problem: You get an unaligned bus error when pass a field of the struct
timeb to time or assign to it... Sample program shows failure... I
believe the pragmas are doing us in!!! In fact compiling with "
-misalign2" will solve the problem.... 

#include <sys/time.h>
#include <sys/timeb.h>

main() 
{
  time_t t;
  struct timeb foo;

  /*  time(&foo.time);*/
  t = time((time_t *)0);
  foo.time = t;

printf("Time %d\n", t);
}

Proposed solution:
a) Use our own builtin struct timeb on this platform (if not using gcc
which of course works). 
b) Don't use timeb at all... We are using get_date throughout the code -
 but never do we care about the return value. I propose modifying
get_date to take only one argument - the input string and not return
this timeb.....


I prefer (b).

	ezra


home help back first fref pref prev next nref lref last post