Re: strptime.c

2023-03-02 Thread Theo Buehler
On Sun, Jan 29, 2023 at 08:16:06AM -0700, Todd C. Miller wrote: > Unfortunately we cannot use strtonum(3) here since there may be > non-digit characters following the number. So, strtoll(3) > it is then. Since strptime's %s is supposed to be the inverse of strftime's %s, which is produced with mk

Re: strptime.c

2023-01-29 Thread Todd C . Miller
Unfortunately we cannot use strtonum(3) here since there may be non-digit characters following the number. So, strtoll(3) it is then. - todd Index: lib/libc/time/strptime.c === RCS file: /cvs/src/lib/libc/time/strptime.c,v

Re: strptime.c

2023-01-26 Thread enh
;t this need to be int64_t? > > > > int result = 0; > > Yes, it does, thanks. > > > https://github.com/openbsd/src/blob/master/lib/libc/time/strptime.c#L613 > > > > (i think the overflow checks are insufficient in both copies of the > > function too, espe

Re: strptime.c

2023-01-26 Thread Todd C . Miller
//github.com/openbsd/src/blob/master/lib/libc/time/strptime.c#L613 > > (i think the overflow checks are insufficient in both copies of the > function too, especially around the min and max values, but this seems like > the biggest problem with the code.) The checks for underflow/overflow

Re: strptime.c

2023-01-26 Thread enh
t64_t instead of > time_t though. > yeah, but that's the copy & paste-o, no? (apologies if it's just too early for me to be looking at code yet...) doesn't this need to be int64_t? int result = 0; https://github.com/openbsd/src/blob/master/lib/libc/time/strptime.c

Re: strptime.c

2023-01-26 Thread Todd C . Miller
On Thu, 26 Jan 2023 09:36:52 -0800, enh wrote: > it's quite possible that this could use _conv_num64(), but it wasn't > obvious to me that that function's correct? (i haven't thought too hard > about the overflow logic, but just the fact that result is an `int` seems > odd?) It just returns a boo

Re: strptime.c

2023-01-26 Thread enh
well, the + if (bp == old_bp || errno == ERANGE || +((long) t) != n) return NULL; bit is the "most active ingredient" here, deliberately failing (rather than wrapping) if out of 32-bit range. it's quite possible that this could use _conv_num64(), but it wasn't obvious to me that that functio

Re: strptime.c

2023-01-26 Thread Todd C . Miller
Is there a reason you didn't just change the gmtime_r() in the 's' case to localtime_r()? That seems like the simplest fix. Using strtol() for what may be a 64-bit value on an 32-bit system looks wrong. - todd

strptime.c

2023-01-23 Thread enh
i synced Android's strptime.c with openbsd's recently, getting rid of unnecessary/accidental differences. i'm left with the following, which i thought was interesting (the last one's probably the most interesting, so definitely stick around even if -- as is likely -- you don&#