Informal date format: wrong time shown

Bug #1881363 reported by Stefan Pöschel
This bug affects 1 person
Affects Status Importance Assigned to Milestone
caja (Ubuntu)

Bug Description

System: Ubuntu MATE 18.04.4
Package version: 1.20.2-4ubuntu1

This issue is only present when the "informal" date format is set. This format is the last entry in the format dropdown i.e. the "today at 14:23:45" format - the two other date formats are not affected. You also have to switch the view to "list" mode, in order to see the "modified date" column.

The issue affects all files that were last modified neither today nor yesterday. For these files, the correct date is shown. But instead of the time of the file itself, the current wall clock time is displayed! So whenever an update of the shown timestamp is triggered, the time is replaced by the current time (as time goes by).

See the attached screenshot for an example. As one can see, many files have the very same time, though having different dates. Exceptions are, as said, files that were modified today ("heute") or yesterday ("gestern") - they have the expected time.

I had a look at the code and it seems that the bug is located in "libcaja-private/caja-file.c" in the function "caja_file_fit_date_as_string". While for the two other date formats everything is fine, the retrieval of the "informal" format is a bit more complex. It involes a call to localtime which returns a pointer to struct tm. This pointer is cached for later use. However, the manpage for ctime warns: "The return value points to a statically allocated struct which might be overwritten by subsequent calls to any of the date and time functions." This seems to happen here, due to later date/time operations.

I'm not sure whether this has already been fixed in later versions, as the Git history shows later refactoring. At least as a quick fix for this version, here localtime_r instead of localtime could be used.

Tags: bionic patch
Revision history for this message
Stefan Pöschel (stefan-poeschel) wrote :
Revision history for this message
Stefan Pöschel (stefan-poeschel) wrote :

I haven't been able so far to test the patch myself; at least it compiles without errors.

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "Patch suggestion" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Revision history for this message
Stefan Pöschel (stefan-poeschel) wrote :

OK, I was now able to compile a patched version and can confirm the patch solves the issue.

Norbert (nrbrtx)
tags: added: bionic
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.