Re: [hackers] [quark][PATCH] fix for NOT_MODIFIED being sent in non-GMT timezone

From: Jeremy <jer_AT_jer.cx>
Date: Tue, 21 Jul 2020 10:43:25 -0700

Hey Hiltjo,

I appreciate your feedback. That suggestion works well and is nicer.
I've submitted the modified patch.

Thanks!
Jeremy

On 07/19/20 10:33PM, Hiltjo Posthuma wrote:
> On Sun, Jul 19, 2020 at 09:37:31AM -0700, Jeremy wrote:
> > From: Jeremy Bobbin <jer_AT_jer.cx>
> >
> > stat(3)'s mtime is in local time while REQ_MOD is in GMT.
> > This patch translates mtime to GMT before comparing to REQ_MOD.
> > ---
> > http.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/http.c b/http.c
> > index 249c168..0c707be 100644
> > --- a/http.c
> > +++ b/http.c
> > _AT_@ -531,7 +531,8 @@ http_send_response(int fd, struct request *r)
> > }
> >
> > /* compare with last modification date of the file */
> > - if (difftime(st.st_mtim.tv_sec, mktime(&tm)) <= 0) {
> > + time_t mtime = mktime(gmtime(&st.st_mtim.tv_sec));
> > + if (difftime(mtime, mktime(&tm)) <= 0) {
> > if (dprintf(fd,
> > "HTTP/1.1 %d %s\r\n"
> > "Date: %s\r\n"
> > --
> > 2.27.0
> >
> >
>
> It looks incorrect to me, but I have not tested the patch.
>
> Maybe it should be instead:
>
> if (difftime(st.st_mtim.tv_sec, timegm(&tm)) <= 0) {
>
> Note that strptime also assumes GMT and doesn't for example parse %Z (which is
> an extension). That's probably OK generally.
>
> --
> Kind regards,
> Hiltjo
>
Received on Tue Jul 21 2020 - 19:43:25 CEST

This archive was generated by hypermail 2.3.0 : Tue Jul 21 2020 - 19:48:32 CEST