Branch: Tag:

2002-10-03

2002-10-03 15:22:11 by Martin Stjernholm <mast@lysator.liu.se>

Fixed missing checks for NULL from gmtime(2) and localtime(2) which could
cause segfaults. E.g. on NT they don't handle negative time stamps.

Rev: src/builtin_functions.c:1.362

5:   \*/   /**/   #include "global.h" - RCSID("$Id: builtin_functions.c,v 1.361 2002/07/22 17:56:03 grubba Exp $"); + RCSID("$Id: builtin_functions.c,v 1.362 2002/10/03 15:22:11 mast Exp $");   #include "interpret.h"   #include "svalue.h"   #include "pike_macros.h"
3994: Inside #if defined(HAVE_GMTIME)
   t = tt;    tm = gmtime(&t);    pop_n_elems(args); +  +  if (!tm) { +  push_int (0); +  return; +  }    encode_struct_tm(tm);       push_string(make_shared_string("timezone"));
4032: Inside #if defined(HAVE_LOCALTIME)
   *! Offset from UTC.    *! @endmapping    *! +  *! Zero is returned if the localtime(2) call failed on the system. +  *! It's platform dependent what time ranges that function can handle, +  *! e.g. Windows doesn't handle a negative @[timestamp]. +  *!    *! @note    *! The field @tt{"timezone"@} may not be available on all platforms.    *!
4049: Inside #if defined(HAVE_LOCALTIME)
   t = tt;    tm = localtime(&t);    pop_n_elems(args); +  +  if (!tm) { +  push_int (0); +  return; +  }    encode_struct_tm(tm);      #ifdef STRUCT_TM_HAS_GMTOFF