{"action":"closed","issue":{"url":"https://api.github.com/repos/hioa-cs/IncludeOS/issues/1721","repository_url":"https://api.github.com/repos/hioa-cs/IncludeOS","labels_url":"https://api.github.com/repos/hioa-cs/IncludeOS/issues/1721/labels{/name}","comments_url":"https://api.github.com/repos/hioa-cs/IncludeOS/issues/1721/comments","events_url":"https://api.github.com/repos/hioa-cs/IncludeOS/issues/1721/events","html_url":"https://github.com/hioa-cs/IncludeOS/issues/1721","id":306932363,"number":1721,"title":"possible deca-millennium bug in isotime::to_datetime_string","user":{"login":"ingve","id":62911,"avatar_url":"https://avatars3.githubusercontent.com/u/62911?v=4","gravatar_id":"","url":"https://api.github.com/users/ingve","html_url":"https://github.com/ingve","followers_url":"https://api.github.com/users/ingve/followers","following_url":"https://api.github.com/users/ingve/following{/other_user}","gists_url":"https://api.github.com/users/ingve/gists{/gist_id}","starred_url":"https://api.github.com/users/ingve/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ingve/subscriptions","organizations_url":"https://api.github.com/users/ingve/orgs","repos_url":"https://api.github.com/users/ingve/repos","events_url":"https://api.github.com/users/ingve/events{/privacy}","received_events_url":"https://api.github.com/users/ingve/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-03-20T16:05:48Z","updated_at":"2018-04-20T13:43:08Z","closed_at":"2018-04-20T13:43:08Z","author_association":"CONTRIBUTOR","body":"If I run the following code:\r\n\r\n```\r\ntime_t add_hour(time_t t) {\r\n\treturn t + (60*60);\r\n}\r\n\r\nint main(int argc, char *argv[]) {\r\n\ttime_t t0 = 0L;\r\n\ttime_t t1 = add_hour(t0);\r\n\ttime_t t2 = 253402297200L;\r\n\ttime_t t3 = add_hour(t2);\r\n\tprintf(\"%s\\n\", isotime::to_datetime_string(t0).c_str());\r\n\tprintf(\"%s\\n\", isotime::to_datetime_string(t1).c_str());\r\n\tprintf(\"%s\\n\", isotime::to_datetime_string(t2).c_str());\r\n\tprintf(\"%s\\n\", isotime::to_datetime_string(t3).c_str());\t\r\n}\r\n```\r\n\r\nin IncludeOS (v0.12.0-rc.3-271-g25f83a3d-dirty), I get the following output:\r\n\r\n```\r\n1970-01-01T00:00:00Z\r\n1970-01-01T01:00:00Z\r\n9999-12-31T23:00:00Z\r\n+10000-01-01T00:00:0\r\n```\r\n\r\nThis seems to be caused by not checking the return value from `strftime` inside `isotime::to_datetime_string`\r\n\r\n> The number of bytes written into the character array pointed to by str not including the terminating '\\0' on success. If count was reached before the entire string could be stored, ​0​ is returned and the contents are undefined.\r\n\r\n— [strftime@cppreference.com](http://www.cplusplus.com/reference/ctime/strftime/)\r\n\r\n0 is indeed returned in the last case above. Checking the return value would be easy enough, but I don't know what would be a reasonable string to return from `to_datetime_string` in this case (truncated string? empty string? \"invalid date\" error message? throwing an exception?) [¯\\\\\\_(ツ)_/¯](https://rachelbythebay.com/w/2013/03/17/time/)."}}
{"actor":{"display_login":"fwsGonzo"}}