This repository was archived by the owner on Nov 9, 2017. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +47
-4
lines changed Expand file tree Collapse file tree 5 files changed +47
-4
lines changed Original file line number Diff line number Diff line change @@ -342,6 +342,9 @@ all::
342
342
# Define DEFAULT_HELP_FORMAT to "man", "info" or "html"
343
343
# (defaults to "man") if you want to have a different default when
344
344
# "git help" is called without a parameter specifying the format.
345
+ #
346
+ # Define GMTIME_UNRELIABLE_ERRORS if your gmtime() function does not
347
+ # return NULL when it receives a bogus time_t.
345
348
346
349
GIT-VERSION-FILE : FORCE
347
350
@$(SHELL_PATH ) ./GIT-VERSION-GEN
@@ -1494,6 +1497,11 @@ ifneq (,$(XDL_FAST_HASH))
1494
1497
BASIC_CFLAGS += -DXDL_FAST_HASH
1495
1498
endif
1496
1499
1500
+ ifdef GMTIME_UNRELIABLE_ERRORS
1501
+ COMPAT_OBJS += compat/gmtime.o
1502
+ BASIC_CFLAGS += -DGMTIME_UNRELIABLE_ERRORS
1503
+ endif
1504
+
1497
1505
ifeq ($(TCLTK_PATH ) ,)
1498
1506
NO_TCLTK = NoThanks
1499
1507
endif
Original file line number Diff line number Diff line change
1
+ #include "../git-compat-util.h"
2
+ #undef gmtime
3
+ #undef gmtime_r
4
+
5
+ struct tm * git_gmtime (const time_t * timep )
6
+ {
7
+ static struct tm result ;
8
+ return git_gmtime_r (timep , & result );
9
+ }
10
+
11
+ struct tm * git_gmtime_r (const time_t * timep , struct tm * result )
12
+ {
13
+ struct tm * ret ;
14
+
15
+ memset (result , 0 , sizeof (* result ));
16
+ ret = gmtime_r (timep , result );
17
+
18
+ /*
19
+ * Rather than NULL, FreeBSD gmtime simply leaves the "struct tm"
20
+ * untouched when it encounters overflow. Since "mday" cannot otherwise
21
+ * be zero, we can test this very quickly.
22
+ */
23
+ if (ret && !ret -> tm_mday ) {
24
+ ret = NULL ;
25
+ errno = EOVERFLOW ;
26
+ }
27
+
28
+ return ret ;
29
+ }
Original file line number Diff line number Diff line change @@ -188,6 +188,7 @@ ifeq ($(uname_S),FreeBSD)
188
188
endif
189
189
PYTHON_PATH = /usr/local/bin/python
190
190
HAVE_PATHS_H = YesPlease
191
+ GMTIME_UNRELIABLE_ERRORS = UnfortunatelyYes
191
192
endif
192
193
ifeq ($(uname_S),OpenBSD)
193
194
NO_STRCASESTR = YesPlease
Original file line number Diff line number Diff line change @@ -721,4 +721,11 @@ void warn_on_inaccessible(const char *path);
721
721
/* Get the passwd entry for the UID of the current process. */
722
722
struct passwd * xgetpwuid_self (void );
723
723
724
+ #ifdef GMTIME_UNRELIABLE_ERRORS
725
+ struct tm * git_gmtime (const time_t * );
726
+ struct tm * git_gmtime_r (const time_t * , struct tm * );
727
+ #define gmtime git_gmtime
728
+ #define gmtime_r git_gmtime_r
729
+ #endif
730
+
724
731
#endif
Original file line number Diff line number Diff line change @@ -82,11 +82,9 @@ test_expect_success 'date parser recognizes time_t overflow' '
82
82
'
83
83
84
84
# date is within 2^63-1, but enough to choke glibc's gmtime
85
- test_expect_success ' absurdly far-in-future dates produce sentinel ' '
85
+ test_expect_success ' absurdly far-in-future date ' '
86
86
commit=$(munge_author_date HEAD 999999999999999999) &&
87
- echo "Thu Jan 1 00:00:00 1970 +0000" >expect &&
88
- git log -1 --format=%ad $commit >actual &&
89
- test_cmp expect actual
87
+ git log -1 --format=%ad $commit
90
88
'
91
89
92
90
test_done
You can’t perform that action at this time.
0 commit comments