pullup from trunk
authorTom Yu <tlyu@mit.edu>
Wed, 23 Mar 2005 04:38:46 +0000 (04:38 +0000)
committerTom Yu <tlyu@mit.edu>
Wed, 23 Mar 2005 04:38:46 +0000 (04:38 +0000)
ticket: 2953
version_fixed: 1.4.1

git-svn-id: svn://anonsvn.mit.edu/krb5/branches/krb5-1-4@17151 dc483132-0cff-0310-8789-dd5450dbe970

src/include/ChangeLog
src/include/configure.in
src/lib/krb5/asn.1/ChangeLog
src/lib/krb5/asn.1/asn1_encode.c

index 33d4ceaace2cd7dd9cbeb03071e1de73b7803d85..29358cafd638d2d773914dece6d4656227096799 100644 (file)
@@ -1,3 +1,9 @@
+2005-03-04  Ken Raeburn  <raeburn@mit.edu>
+
+       * configure.in: Check return type of gmtime_r, and define
+       GMTIME_R_RETURNS_INT if it returns int.  If the return type can't
+       be determined, pretend the function isn't there.
+
 2005-02-08  Ken Raeburn  <raeburn@mit.edu>
 
        * k5-platform.h (PROGRAM_EXITING) [__GNUC__ && !_WIN32 &&
index 071ff55ac6f385a45f768d31d7ec35ae1852b6e1..450eea556bd664dc6457187fd7678f2aa37a45d6 100644 (file)
@@ -98,6 +98,29 @@ if test "$ac_cv_func_getpwuid_r" = yes; then
   fi
 fi
 
+if test "$ac_cv_func_gmtime_r" = yes; then
+  AC_MSG_CHECKING([whether gmtime_r returns int])
+  AC_CACHE_VAL(krb5_cv_gmtime_r_returns_int,
+  [AC_TRY_COMPILE([#include <time.h>
+   extern int gmtime_r ();], [1;], return_int=yes, return_int=no)
+   AC_TRY_COMPILE([#include <time.h>
+   extern struct tm *gmtime_r ();], [1;], return_ptr=yes, return_ptr=no)
+   case $return_int/$return_ptr in
+     yes/no) krb5_cv_gmtime_r_returns_int=yes ;;
+     no/yes) krb5_cv_gmtime_r_returns_int=no ;;
+     *)      # Can't figure it out, punt the function.
+             ac_cv_func_gmtime_r=no ;;
+   esac])
+  if test "$ac_cv_func_gmtime_r" = no; then
+    AC_MSG_RESULT(unknown -- ignoring gmtime_r)
+  else
+    AC_MSG_RESULT($krb5_cv_gmtime_r_returns_int)
+    if test "$krb5_cv_gmtime_r_returns_int" = yes; then
+      AC_DEFINE(GMTIME_R_RETURNS_INT,1,[Define if gmtime_r returns int instead of struct tm pointer, as on old HP-UX systems.])
+    fi
+  fi
+fi
+
 AC_CHECK_FUNC(getservbyname_r,[
 ac_cv_func_getservbyname_r=yes
 if test "$ac_cv_func_getservbyname_r" = yes; then
index 4baf064f23225164e6b75a0aa09581f9001914c5..9d9d2bbc29c88958ffa4e5e5faa1ac91942c75ca 100644 (file)
@@ -1,3 +1,8 @@
+2005-03-04  Ken Raeburn  <raeburn@mit.edu>
+
+       * asn1_encode.c (asn1_encode_generaltime): If gmtime_r returns int
+       instead of pointer, do the appropriate error checking.
+
 2004-12-28  Ezra Peisach  <epeisach@mit.edu>
 
        * asn1_decode.c (asn1_decode_generaltime): Fix memory leak when
index 4f9e6949b53370830807d11934ffd7741e3e38f6..c5e3452b8575d4ab9349fbbbf0f87e2a872012b8 100644 (file)
@@ -242,8 +242,13 @@ asn1_error_code asn1_encode_generaltime(asn1buf *buf, time_t val,
        * and some bogus implementations might overrun on the sprintf.
        */
 #ifdef HAVE_GMTIME_R
+# ifdef GMTIME_R_RETURNS_INT
+      if (gmtime_r(&gmt_time, &gtimebuf) != 0)
+         return ASN1_BAD_GMTIME;
+# else
       if (gmtime_r(&gmt_time, &gtimebuf) == NULL)
          return ASN1_BAD_GMTIME;
+# endif
 #else
       gtime = gmtime(&gmt_time);
       if (gtime == NULL)