[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 01/01: Fix nits in current_time() implementation.
From: |
G. Branden Robinson |
Subject: |
[groff] 01/01: Fix nits in current_time() implementation. |
Date: |
Sun, 19 Apr 2020 08:53:55 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit 5debf762ad3075418ed011aed51d21f8f794876a
Author: G. Branden Robinson <address@hidden>
AuthorDate: Sun Apr 19 22:50:07 2020 +1000
Fix nits in current_time() implementation.
* src/include/curtime.h: #include <time.h> if we're returning a time_t
from current_time().
* src/libs/libgroff/curtime.cpp (current_time): Quote
$SOURCE_DATE_EPOCH variable content since it's under user control and
could have all kinds of bogosity in it (like whitespace).
Tested with:
// from build directory:
// $ c++ -Wall -I ../src/include -I ../gnulib/lib -static thisfile.cc
// -L . -lgroff -L lib -lgnu
// $ SOURCE_DATE_EPOCH='aa ' ./a.out
// $ SOURCE_DATE_EPOCH=1aa ./a.out
int main(int argc, char *argv[]) {
program_name = "test-curtime";
long t = current_time(); // die here if $SOURCE_EPOCH_DATE is bogus
std::cout << "The time is " << t << ".\n";
}
---
ChangeLog | 10 ++++++++++
src/include/curtime.h | 4 ++++
src/libs/libgroff/curtime.cpp | 4 ++--
3 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 4b3d68f..c72dcef 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2020-04-19 G. Branden Robinson <address@hidden>
+ * src/include/curtime.h: #include <time.h> if we're returning
+ a time_t from current_time().
+
+ * src/libs/libgroff/curtime.cpp (current_time): Quote
+ $SOURCE_DATE_EPOCH variable content since it's under user
+ control and could have all kinds of bogosity in it (like
+ whitespace).
+
+2020-04-19 G. Branden Robinson <address@hidden>
+
* **/*.{man,tmac}: Save compatibility mode robustly.
Use new \n[.cp] register to save compatibilty mode.
diff --git a/src/include/curtime.h b/src/include/curtime.h
index 4d99fb0..54d9929 100644
--- a/src/include/curtime.h
+++ b/src/include/curtime.h
@@ -15,6 +15,10 @@ for more details.
The GNU General Public License version 2 (GPL2) is available in the
internet at <http://www.gnu.org/licenses/gpl-2.0.txt>. */
+#ifndef LONG_FOR_TIME_T
+#include <time.h>
+#endif
+
#ifdef LONG_FOR_TIME_T
long
#else
diff --git a/src/libs/libgroff/curtime.cpp b/src/libs/libgroff/curtime.cpp
index 72fe067..123bd71 100644
--- a/src/libs/libgroff/curtime.cpp
+++ b/src/libs/libgroff/curtime.cpp
@@ -42,9 +42,9 @@ current_time()
(errno != 0 && epoch == 0))
fatal("$SOURCE_DATE_EPOCH: strtol: %1", strerror(errno));
if (endptr == source_date_epoch)
- fatal("$SOURCE_DATE_EPOCH: no digits found: %1", endptr);
+ fatal("$SOURCE_DATE_EPOCH: no digits found: '%1'", endptr);
if (*endptr != '\0')
- fatal("$SOURCE_DATE_EPOCH: trailing garbage: %1", endptr);
+ fatal("$SOURCE_DATE_EPOCH: trailing garbage: '%1'", endptr);
return epoch;
} else
return time(0);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 01/01: Fix nits in current_time() implementation.,
G. Branden Robinson <=