Path: csiph.com!tncsrv06.tnetconsulting.net!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail From: Steffen Nurpmeso Newsgroups: gnu.groff.bug Subject: Re: [bug #57218] Reproducible builds support is broken and embeds timezone Date: Wed, 13 Nov 2019 17:39:56 +0100 Lines: 101 Approved: bug-groff@gnu.org Message-ID: References: <20191113-055806.sv131778.86634@savannah.gnu.org> <20191113-060928.sv131778.1661@savannah.gnu.org> <20191113163956.z1m6q%steffen@sdaoden.eu> NNTP-Posting-Host: lists.gnu.org X-Trace: usenet.stanford.edu 1573663211 2166 209.51.188.17 (13 Nov 2019 16:40:11 GMT) X-Complaints-To: action@cs.stanford.edu To: Eli Schwartz , bug-groff@gnu.org Envelope-to: bug-groff@gnu.org In-Reply-To: <20191113-060928.sv131778.1661@savannah.gnu.org> Mail-Followup-To: Eli Schwartz , bug-groff@gnu.org User-Agent: s-nail v14.9.15-213-geb83b092 OpenPGP: id=EE19E1C1F2F7054F8D3954D8308964B51883A0DD; url=https://ftp.sdaoden.eu/steffen.asc; preference=signencrypt BlahBlahBlah: Any stupid boy can crush a beetle. But all the professors in the world can make no bugs. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 217.144.132.164 X-BeenThere: bug-groff@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Bug reports for the GNU version of nroff, troff et al" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <20191113163956.z1m6q%steffen@sdaoden.eu> X-Mailman-Original-References: <20191113-055806.sv131778.86634@savannah.gnu.org> <20191113-060928.sv131778.1661@savannah.gnu.org> Xref: csiph.com gnu.groff.bug:1566 Eli Schwartz wrote in <20191113-060928.sv131778.1661@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)