Bug 230720

Summary: strptime() conversion and validation issues
Product: Base System Reporter: rlittle <rlittle>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: New ---    
Severity: Affects Only Me CC: cem, yuripv
Priority: --- Keywords: patch
Version: CURRENT   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
Patch file for strptime.c none

Description rlittle@inetco.com 2018-08-17 22:19:07 UTC
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.
Comment 1 rlittle@inetco.com 2018-08-20 16:02:32 UTC
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.
Comment 2 Yuri Pankov 2018-10-13 21:54:05 UTC
"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.
Comment 3 rlittle@inetco.com 2018-10-14 00:49:15 UTC
Many thanks, Yuri.

Ralph
Comment 4 commit-hook freebsd_committer freebsd_triage 2018-11-03 23:37:19 UTC
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