You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Cliff Skolnick <cl...@organic.com> on 1995/08/08 10:48:36 UTC

mod_cookie.c broken for solaris

>From the man page...

NAME
     ftime - get date and time

...

DESCRIPTION
     This interface is obsoleted by gettimeofday(2).
...

---

hmm....I wonder if the cookies should be in hex,
10, 111  is the same as 101, 11 for the sec, msec pairs.
I dunno, guess it would be a long time before digits are
added. Seems strang.

Here is the fix, I think....


------- mod_cookies.c -------
*** /tmp/da00680	Wed Dec 31 16:00:00 1969
--- mod_cookies.c	Tue Aug  8 01:43:33 1995
***************
*** 86,102 ****
  
  void make_cookie(request_rec *r)
  {
!     struct timeb tp;
      char new_cookie[100];	/* blurgh */
      char *dot;
      char *rname = pstrdup(r->pool,r->connection->remote_name);
  
      if ((dot = strchr(rname,'.'))) *dot='\0';	/* First bit of hostname */
!     ftime(&tp);
      sprintf(new_cookie,"s=%s%d%ld%d; path=/",
          rname,
          (int)getpid(),  
!         (long)tp.time, (int)tp.millitm );
  
      table_set(r->headers_out,"Set-Cookie",new_cookie);
      return;
--- 86,103 ----
  
  void make_cookie(request_rec *r)
  {
!     struct timeval tv;
      char new_cookie[100];	/* blurgh */
      char *dot;
      char *rname = pstrdup(r->pool,r->connection->remote_name);
+     struct timezone tz = { 0 , 0 };
  
      if ((dot = strchr(rname,'.'))) *dot='\0';	/* First bit of hostname */
!     gettimeofday(&tv, &tz);
      sprintf(new_cookie,"s=%s%d%ld%d; path=/",
          rname,
          (int)getpid(),  
!         (long)tv.tv_sec, (int)tv.tv_usec/1000 );
  
      table_set(r->headers_out,"Set-Cookie",new_cookie);
      return;