Skip to content

Commit dfb2f39

Browse files
committed
Fix ippDateToTime when the timezone is not GMT/UTC (Issue #1208)
1 parent 98edd72 commit dfb2f39

7 files changed

Lines changed: 64 additions & 10 deletions

File tree

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Changes in CUPS v2.4.12 (YYYY-MM-DD)
1818
(Issue #1201)
1919
- Fixed attributes returned by the Create-Xxx-Subscriptions requests
2020
(Issue #1204)
21+
- Fixed `ippDateToTime` when using a non GMT/UTC timezone (Issue #1208)
2122

2223

2324
Changes in CUPS v2.4.11 (2024-09-30)

config-scripts/cups-common.m4

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
dnl
22
dnl Common configuration stuff for CUPS.
33
dnl
4-
dnl Copyright © 2020-2024 by OpenPrinting.
4+
dnl Copyright © 2020-2025 by OpenPrinting.
55
dnl Copyright © 2007-2019 by Apple Inc.
66
dnl Copyright © 1997-2007 by Easy Software Products, all rights reserved.
77
dnl
@@ -207,6 +207,11 @@ AC_COMPILE_IFELSE([
207207
AC_MSG_RESULT([no])
208208
])
209209

210+
dnl See if we have the timegm function...
211+
AC_CHECK_FUNC([timegm], [
212+
AC_DEFINE([HAVE_TIMEGM], [1], [Do we have the timegm function?])
213+
])
214+
210215
dnl See if the stat structure has the st_gen member...
211216
AC_MSG_CHECKING([for st_gen member in stat structure])
212217
AC_COMPILE_IFELSE([

config.h.in

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* Configuration file for CUPS.
33
*
4-
* Copyright © 2020-2023 by OpenPrinting
4+
* Copyright © 2020-2025 by OpenPrinting
55
* Copyright © 2007-2019 by Apple Inc.
66
* Copyright © 1997-2007 by Easy Software Products.
77
*
@@ -380,6 +380,13 @@
380380
#undef HAVE_TM_GMTOFF
381381

382382

383+
/*
384+
* Do we have the timegm function?
385+
*/
386+
387+
#undef HAVE_TIMEGM
388+
389+
383390
/*
384391
* Do we have rresvport_af()?
385392
*/

configure

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4727,11 +4727,11 @@ if test x$ac_prog_cxx_stdcxx = xno
47274727
then :
47284728
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++11 features" >&5
47294729
printf %s "checking for $CXX option to enable C++11 features... " >&6; }
4730-
if test ${ac_cv_prog_cxx_cxx11+y}
4730+
if test ${ac_cv_prog_cxx_11+y}
47314731
then :
47324732
printf %s "(cached) " >&6
47334733
else $as_nop
4734-
ac_cv_prog_cxx_cxx11=no
4734+
ac_cv_prog_cxx_11=no
47354735
ac_save_CXX=$CXX
47364736
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
47374737
/* end confdefs.h. */
@@ -4773,11 +4773,11 @@ if test x$ac_prog_cxx_stdcxx = xno
47734773
then :
47744774
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++98 features" >&5
47754775
printf %s "checking for $CXX option to enable C++98 features... " >&6; }
4776-
if test ${ac_cv_prog_cxx_cxx98+y}
4776+
if test ${ac_cv_prog_cxx_98+y}
47774777
then :
47784778
printf %s "(cached) " >&6
47794779
else $as_nop
4780-
ac_cv_prog_cxx_cxx98=no
4780+
ac_cv_prog_cxx_98=no
47814781
ac_save_CXX=$CXX
47824782
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
47834783
/* end confdefs.h. */
@@ -6422,6 +6422,17 @@ printf "%s\n" "no" >&6; }
64226422
fi
64236423
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
64246424

6425+
ac_fn_c_check_func "$LINENO" "timegm" "ac_cv_func_timegm"
6426+
if test "x$ac_cv_func_timegm" = xyes
6427+
then :
6428+
6429+
6430+
printf "%s\n" "#define HAVE_TIMEGM 1" >>confdefs.h
6431+
6432+
6433+
fi
6434+
6435+
64256436
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for st_gen member in stat structure" >&5
64266437
printf %s "checking for st_gen member in stat structure... " >&6; }
64276438
cat confdefs.h - <<_ACEOF >conftest.$ac_ext

cups/ipp.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1699,7 +1699,7 @@ ippDateToTime(const ipp_uchar_t *date) /* I - RFC 2579 date info */
16991699
* 6 Seconds (0 to 60, 60 = "leap second")
17001700
* 7 Deciseconds (0 to 9)
17011701
* 8 +/- UTC
1702-
* 9 UTC hours (0 to 11)
1702+
* 9 UTC hours (0 to 14)
17031703
* 10 UTC minutes (0 to 59)
17041704
*/
17051705

@@ -1710,7 +1710,23 @@ ippDateToTime(const ipp_uchar_t *date) /* I - RFC 2579 date info */
17101710
unixdate.tm_min = date[5];
17111711
unixdate.tm_sec = date[6];
17121712

1713-
t = mktime(&unixdate);
1713+
#if _WIN32
1714+
if ((t = _mkgmtime(&unixdate)) < 0)
1715+
return (0);
1716+
#elif defined(HAVE_TIMEGM)
1717+
if ((t = timegm(&unixdate)) < 0)
1718+
return (0);
1719+
#else
1720+
if ((t = mktime(&unixdate)) < 0)
1721+
return (0);
1722+
1723+
# if defined(HAVE_TM_GMTOFF)
1724+
localtime_r(&t, &unixdate);
1725+
t -= unixdate.tm_gmtoff;
1726+
# else
1727+
t -= timezone;
1728+
# endif // HAVE_TM_GMTOFF
1729+
#endif // _WIN32
17141730

17151731
if (date[8] == '-')
17161732
t += date[9] * 3600 + date[10] * 60;

vcnet/config.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* Configuration file for CUPS on Windows.
33
*
4-
* Copyright © 2021-2024 by OpenPrinting
4+
* Copyright © 2021-2025 by OpenPrinting
55
* Copyright © 2007-2019 by Apple Inc.
66
* Copyright © 1997-2007 by Easy Software Products.
77
*
@@ -472,6 +472,13 @@ typedef unsigned long useconds_t;
472472
/* #undef HAVE_TM_GMTOFF */
473473

474474

475+
/*
476+
* Do we have the timegm function?
477+
*/
478+
479+
/* #undef HAVE_TIMEGM */
480+
481+
475482
/*
476483
* Do we have rresvport_af()?
477484
*/

xcode/config.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* Configuration file for CUPS and Xcode.
33
*
4-
* Copyright © 2021-2024 by OpenPrinting
4+
* Copyright © 2021-2025 by OpenPrinting
55
* Copyright © 2007-2019 by Apple Inc.
66
* Copyright © 1997-2007 by Easy Software Products.
77
*
@@ -398,6 +398,13 @@
398398
#define HAVE_TM_GMTOFF 1
399399

400400

401+
/*
402+
* Do we have the timegm function?
403+
*/
404+
405+
#define HAVE_TIMEGM 1
406+
407+
401408
/*
402409
* Do we have rresvport_af()?
403410
*/

0 commit comments

Comments
 (0)