the format "%d" in the c function strptime(3) does not conform to what the documentation says (https://www.freebsd.org/cgi/man.cgi?query=strptime&sektion=3&manpath=freebsd-release-ports) It is supposed to allow numbers between "01" and "31" but it also allows "00". I am not sure if it is a bug or just the FreeBSD way of doing this function. To my knowledge GNU has the fore mentioned behaviour. Small c++ code to reproduce the error: ######################################################## #include<iostream> #include<ctime> int main() { struct tm tm; if(strptime("00", "%d", &tm)) { std::cout << "WRONG" << std::endl; } else { std::cout << "OK" << std::endl; } } ######################################################## just execute clang++ main.cpp && ./a.out EXPECTED: OK GOT: WRONG
Yes, both Linux and POSIX agree with your observation.
Created attachment 197918 [details] Disallow zero day of month from strptime("%d").
(In reply to Konstantin Belousov from comment #2) Thanks for the quick response :)
A commit references this bug: Author: kib Date: Mon Oct 8 18:45:41 UTC 2018 New revision: 339241 URL: https://svnweb.freebsd.org/changeset/base/339241 Log: Disallow zero day of month from strptime("%d"). It is required by POSIX, specified in our man page, and followed by Linux. PR: 232072 Reported by: miguel_tete17@hotmail.com Sponsored by: The FreeBSD Foundation Approved by: re (gjb) MFC after: 1 week Changes: head/lib/libc/stdtime/strptime.c
A commit references this bug: Author: kib Date: Mon Oct 15 10:50:05 UTC 2018 New revision: 339359 URL: https://svnweb.freebsd.org/changeset/base/339359 Log: MFC r339241: Disallow zero day of month from strptime("%d"). PR: 232072 Changes: _U stable/11/ stable/11/lib/libc/stdtime/strptime.c