Eli Schwartz wrote in <20191113-060928.sv131778.1...@savannah.gnu.org>: |Follow-up Comment #1, bug #57218 (project groff): | |It was pointed out by another reproducible-builds.org member that Debian's |man-db package produces reproducible .ps files, so I dug around a little, \ |and |it turns out debian's groff package has a downstream patch to work \ |around this |issue! | |https://salsa.debian.org/debian/groff/blob/master/debian/patches/display\ |-utc-times.patch | |This patch should be incorporated upstream if possible. Was it ever \ |proposed |here? Is it suitable for inclusion as-is?
I'd say no since no error checking is done on gmtime(3) result. Also it changes localtime to gmtime, which is something different. Continuing the use of asctime is also no good since that has a buffer overflow builtin if time fields are too large. One better uses something like this (i do not say it is perfect as such yet, stack buffers etc.). I say ciao already here. P.S.: it seems that salsa.debian.org does not like lynx(1), the buttons are all Javascript?? char const n_weekday_names[7 + 1][4] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "" }; char const n_month_names[12 + 1][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "" }; char * n_time_ctime(s64 secsepoch, struct tm const *localtime_or_nil){/* TODO err*/ /* Problem is that secsepoch may be invalid for representation of ctime(3), * which indeed is asctime(localtime(t)); musl libc says for asctime(3): * ISO C requires us to use the above format string, * even if it will not fit in the buffer. Thus asctime_r * is _supposed_ to crash if the fields in tm are too large. * We follow this behavior and crash "gracefully" to warn * application developers that they may not be so lucky * on other implementations (e.g. stack smashing..). * So we need to do it on our own or the libc may kill us */ static char buf[32]; /* TODO static buffer (-> datetime_to_format()) */ s32 y, md, th, tm, ts; char const *wdn, *mn; struct tm const *tmp; if((tmp = localtime_or_nil) == NULL){ time_t t; t = (time_t)secsepoch; jredo: if((tmp = localtime(&t)) == NULL){ /* TODO error log */ t = 0; goto jredo; } } if(UNLIKELY((y = tmp->tm_year) < 0 || y >= 9999/*S32_MAX*/ - 1900)){ y = 1970; wdn = n_weekday_names[4]; mn = n_month_names[0]; md = 1; th = tm = ts = 0; }else{ y += 1900; wdn = (tmp->tm_wday >= 0 && tmp->tm_wday <= 6) ? n_weekday_names[tmp->tm_wday] : n_qm; mn = (tmp->tm_mon >= 0 && tmp->tm_mon <= 11) ? n_month_names[tmp->tm_mon] : n_qm; if((md = tmp->tm_mday) < 1 || md > 31) md = 1; if((th = tmp->tm_hour) < 0 || th > 23) th = 0; if((tm = tmp->tm_min) < 0 || tm > 59) tm = 0; if((ts = tmp->tm_sec) < 0 || ts > 60) ts = 0; } (void)snprintf(buf, sizeof buf, "%3s %3s%3d %.2d:%.2d:%.2d %d", wdn, mn, md, th, tm, ts, y); } --steffen | |Der Kragenbaer, The moon bear, |der holt sich munter he cheerfully and one by one |einen nach dem anderen runter wa.ks himself off |(By Robert Gernhardt)