Summary: | strptime() conversion and validation issues | ||||||
---|---|---|---|---|---|---|---|
Product: | Base System | Reporter: | rlittle <rlittle> | ||||
Component: | bin | Assignee: | freebsd-bugs (Nobody) <bugs> | ||||
Status: | New --- | ||||||
Severity: | Affects Only Me | CC: | cem, yuripv | ||||
Priority: | --- | Keywords: | patch | ||||
Version: | CURRENT | ||||||
Hardware: | Any | ||||||
OS: | Any | ||||||
Attachments: |
|
We do have a unit test program that puts the function through its paces. I'm not aware if FreeBSD has a test suite but if required, I can put together something that can be submitted for inclusion. "00","%d" is fixed in base r339241 (bug #232072) "00","%I" and "00","%l" are fixed in base r339346. I'll take care of the remaining issues reported here, and sorry for missing this initially. Many thanks, Yuri. Ralph A commit references this bug: Author: yuripv Date: Sat Nov 3 23:37:14 UTC 2018 New revision: 340106 URL: https://svnweb.freebsd.org/changeset/base/340106 Log: strptime: make %k and %l specifiers match their description in strftime(3), and allow them to process space-padded input. PR: 230720 Submitted by: rlittle@inetco.com (original version) Approved by: kib (mentor, implicit) Differential Revision: https://reviews.freebsd.org/D17761 Changes: head/contrib/netbsd-tests/lib/libc/time/t_strptime.c head/lib/libc/stdtime/strptime.c |
Created attachment 196301 [details] Patch file for strptime.c I've been running the FreeBSD strptime() function through a few tests and a few of things came up. 1) Some compile warnings were silenced by changing the type of len from int to size_t. Also some compiler-reported possibly uninitialized use, which I don't think are really bugs but best to be safe. 2) %k and %l should allow preceding blanks. The current version requires all digits and throws an error. I have put in a little fix to permit this. 3) %I and %l should generate an error on 0. A small check added for that. 4) %d should generate an error on 0. A small check added for that. Patch attached.