Discussion:
[LIBREPORT PATCH] Fix problem_item_format() to work properly after 2038 on x32. #691
Denys Vlasenko
2013-09-03 14:29:32 UTC
Permalink
Signed-off-by: Denys Vlasenko <dvlasenk-H+wXaHxf7aLQT0dZR+***@public.gmane.org>
---
src/lib/problem_data.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/lib/problem_data.c b/src/lib/problem_data.c
index c3da1e7..ea2c94e 100644
--- a/src/lib/problem_data.c
+++ b/src/lib/problem_data.c
@@ -37,9 +37,12 @@ char *problem_item_format(struct problem_item *item)
{
errno = 0;
char *end;
- time_t time = strtol(item->content, &end, 10);
- if (!errno && !*end && end != item->content)
- {
+ /* On x32 arch, time_t is wider than long. Must use strtoll */
+ long long ll = strtoll(item->content, &end, 10);
+ time_t time = ll;
+ if (!errno && *end == '\0' && end != item->content
+ && ll == time /* there was no truncation in long long -> time_t conv */
+ ) {
char timeloc[256];
int success = strftime(timeloc, sizeof(timeloc), "%c", localtime(&time));
if (success)
--
1.8.1.4
Jakub Filak
2013-09-11 09:47:05 UTC
Permalink
Pushed. Thank you!

Please, try to use correct ticket ids.
#691 issue comes from ABRT's repository therefore you must write
abrt/abrt#691

Please, read this articles. It will save much work for all of us :)
https://help.github.com/articles/closing-issues-via-commit-messages
Loading...