]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Fix ippDateToTime when the timezone is not GMT/UTC (Issue #1208)
authorMichael R Sweet <msweet@msweet.org>
Sun, 30 Mar 2025 23:30:13 +0000 (19:30 -0400)
committerMichael R Sweet <msweet@msweet.org>
Sun, 30 Mar 2025 23:30:13 +0000 (19:30 -0400)
CHANGES.md
config-scripts/cups-common.m4
config.h.in
configure
cups/ipp.c
vcnet/config.h
xcode/config.h

index 5227c6f118ab5bab4291fee6444d89a054cd8745..2db76b3e9179cd33eb9988da74153095f3e1a695 100644 (file)
@@ -18,6 +18,7 @@ Changes in CUPS v2.4.12 (YYYY-MM-DD)
   (Issue #1201)
 - Fixed attributes returned by the Create-Xxx-Subscriptions requests
   (Issue #1204)
+- Fixed `ippDateToTime` when using a non GMT/UTC timezone (Issue #1208)
 
 
 Changes in CUPS v2.4.11 (2024-09-30)
index 613f01ddf50ef4f0d9db7deb26ffd5b70a6ea571..48602a8c30cb536e24f25ee338117442e32d817b 100644 (file)
@@ -1,7 +1,7 @@
 dnl
 dnl Common configuration stuff for CUPS.
 dnl
-dnl Copyright © 2020-2024 by OpenPrinting.
+dnl Copyright © 2020-2025 by OpenPrinting.
 dnl Copyright © 2007-2019 by Apple Inc.
 dnl Copyright © 1997-2007 by Easy Software Products, all rights reserved.
 dnl
@@ -207,6 +207,11 @@ AC_COMPILE_IFELSE([
     AC_MSG_RESULT([no])
 ])
 
+dnl See if we have the timegm function...
+AC_CHECK_FUNC([timegm], [
+    AC_DEFINE([HAVE_TIMEGM], [1], [Do we have the timegm function?])
+])
+
 dnl See if the stat structure has the st_gen member...
 AC_MSG_CHECKING([for st_gen member in stat structure])
 AC_COMPILE_IFELSE([
index 6940b96044580b00f5c49c308e9bcd20fb5bb7cd..7d655dd15c5a44537f622c1196b8a9b3d7e3e75e 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Configuration file for CUPS.
  *
- * Copyright © 2020-2023 by OpenPrinting
+ * Copyright © 2020-2025 by OpenPrinting
  * Copyright © 2007-2019 by Apple Inc.
  * Copyright © 1997-2007 by Easy Software Products.
  *
 #undef HAVE_TM_GMTOFF
 
 
+/*
+ * Do we have the timegm function?
+ */
+
+#undef HAVE_TIMEGM
+
+
 /*
  * Do we have rresvport_af()?
  */
index f9037fddbcd5db704171c3f6bb6aa39f03508e01..2fb1229526bf956b3123e0b6f77b6a87f6c89898 100755 (executable)
--- a/configure
+++ b/configure
@@ -4727,11 +4727,11 @@ if test x$ac_prog_cxx_stdcxx = xno
 then :
   { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++11 features" >&5
 printf %s "checking for $CXX option to enable C++11 features... " >&6; }
-if test ${ac_cv_prog_cxx_cxx11+y}
+if test ${ac_cv_prog_cxx_11+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  ac_cv_prog_cxx_cxx11=no
+  ac_cv_prog_cxx_11=no
 ac_save_CXX=$CXX
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
@@ -4773,11 +4773,11 @@ if test x$ac_prog_cxx_stdcxx = xno
 then :
   { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++98 features" >&5
 printf %s "checking for $CXX option to enable C++98 features... " >&6; }
-if test ${ac_cv_prog_cxx_cxx98+y}
+if test ${ac_cv_prog_cxx_98+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  ac_cv_prog_cxx_cxx98=no
+  ac_cv_prog_cxx_98=no
 ac_save_CXX=$CXX
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
@@ -6422,6 +6422,17 @@ printf "%s\n" "no" >&6; }
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 
+ac_fn_c_check_func "$LINENO" "timegm" "ac_cv_func_timegm"
+if test "x$ac_cv_func_timegm" = xyes
+then :
+
+
+printf "%s\n" "#define HAVE_TIMEGM 1" >>confdefs.h
+
+
+fi
+
+
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for st_gen member in stat structure" >&5
 printf %s "checking for st_gen member in stat structure... " >&6; }
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
index 8070785846268c01ba1c4b663908dbce8cb2979f..b9f6420a568a01cd2231e7108dad3118a57210c9 100644 (file)
@@ -1699,7 +1699,7 @@ ippDateToTime(const ipp_uchar_t *date)    /* I - RFC 2579 date info */
   *    6        Seconds (0 to 60, 60 = "leap second")
   *    7        Deciseconds (0 to 9)
   *    8        +/- UTC
-  *    9        UTC hours (0 to 11)
+  *    9        UTC hours (0 to 14)
   *    10       UTC minutes (0 to 59)
   */
 
@@ -1710,7 +1710,23 @@ ippDateToTime(const ipp_uchar_t *date)   /* I - RFC 2579 date info */
   unixdate.tm_min  = date[5];
   unixdate.tm_sec  = date[6];
 
-  t = mktime(&unixdate);
+#if _WIN32
+  if ((t = _mkgmtime(&unixdate)) < 0)
+    return (0);
+#elif defined(HAVE_TIMEGM)
+  if ((t = timegm(&unixdate)) < 0)
+    return (0);
+#else
+  if ((t = mktime(&unixdate)) < 0)
+    return (0);
+
+#  if defined(HAVE_TM_GMTOFF)
+  localtime_r(&t, &unixdate);
+  t -= unixdate.tm_gmtoff;
+#  else
+  t -= timezone;
+#  endif // HAVE_TM_GMTOFF
+#endif // _WIN32
 
   if (date[8] == '-')
     t += date[9] * 3600 + date[10] * 60;
index 7fc459217163a71ec50b77715b9e0545055b27ab..8d6322b664445ee9871dcc5f06c0d3132c156d69 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Configuration file for CUPS on Windows.
  *
- * Copyright © 2021-2024 by OpenPrinting
+ * Copyright © 2021-2025 by OpenPrinting
  * Copyright © 2007-2019 by Apple Inc.
  * Copyright © 1997-2007 by Easy Software Products.
  *
@@ -472,6 +472,13 @@ typedef unsigned long useconds_t;
 /* #undef HAVE_TM_GMTOFF */
 
 
+/*
+ * Do we have the timegm function?
+ */
+
+/* #undef HAVE_TIMEGM */
+
+
 /*
  * Do we have rresvport_af()?
  */
index c1aaa6b23d32748e4daf45fe5e902e9a53159352..0e4f3dae2772fd0b0af40b26be0857ae7c1adb13 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Configuration file for CUPS and Xcode.
  *
- * Copyright © 2021-2024 by OpenPrinting
+ * Copyright © 2021-2025 by OpenPrinting
  * Copyright © 2007-2019 by Apple Inc.
  * Copyright © 1997-2007 by Easy Software Products.
  *
 #define HAVE_TM_GMTOFF 1
 
 
+/*
+ * Do we have the timegm function?
+ */
+
+#define HAVE_TIMEGM 1
+
+
 /*
  * Do we have rresvport_af()?
  */