Bug 202832 - [PATCH] r391392 broke mail/sylpheed on platforms were time_t is 64 bit long
Summary: [PATCH] r391392 broke mail/sylpheed on platforms were time_t is 64 bit long
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Emanuel Haupt
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2015-09-02 11:21 UTC by yamagi
Modified: 2015-09-03 12:18 UTC (History)
2 users (show)

See Also:
bugzilla: maintainer-feedback? (ehaupt)


Attachments
Updated patch to fix breakage on platforms with a 64 bit time_t (608 bytes, patch)
2015-09-02 11:21 UTC, yamagi
no flags Details | Diff
fix (318 bytes, patch)
2015-09-02 12:29 UTC, Mikael Urankar
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description yamagi 2015-09-02 11:21:29 UTC
Created attachment 160630 [details]
Updated patch to fix breakage on platforms with a 64 bit time_t

Hello,
r391392 / PR 200053 added a patch to mail/sylpheed which fixes SIGBUS errors on ARM. That patch is wrong, it leads to data corruption on platforms where time_t is 64 bit long:
 
- The macro in procmsg.c:194 is called to read the date header of  a message: READ_CACHE_DATA_INT(msginfo->date_t);
- msginfo->date_t is a time_t.
- When time_t is 32 bit long everything's okay. But when it's a 64 bit value, the memcpy() copies only 32 bit from p to n aka  msginfo->date_t aka time_t leaving the upper or (on big endian) lower 32 bits undefined.
 
Attached is an updated patch developed by Christoph Mallon <christoph.mallon@gmx.de> that solves this issue.
Comment 1 Mikael Urankar freebsd_committer freebsd_triage 2015-09-02 12:29:08 UTC
Created attachment 160633 [details]
fix

Hi,

You are right, the patch I submitted is wrong, I was going to submit the attached patch (tested on amd64 and arm by Ulrich Grey and me).
Sorry for the breakage.

Mikaël
Comment 2 yamagi 2015-09-03 05:40:34 UTC
Im afraid that your new patch is still wrong. 'n' is 64 bit long and uninitialized, therefore filled with garbage. You copy 32 bits into it. So 32 bits are defined and the other 32 bits are still garbage. Christophs patch avoids this by an implicit type conversion. The 32 bit value is expanded to 64 bit and assigned. The expansion fills the unused 32 bit with zeros, resulting in a fully defined value.
Comment 3 Mikael Urankar freebsd_committer freebsd_triage 2015-09-03 05:54:28 UTC
I got it now, thanks for your explanation!
Comment 4 commit-hook freebsd_committer freebsd_triage 2015-09-03 12:14:54 UTC
A commit references this bug:

Author: ehaupt
Date: Thu Sep  3 12:14:27 UTC 2015
New revision: 395948
URL: https://svnweb.freebsd.org/changeset/ports/395948

Log:
  Updated patch to fix breakage on platforms with a 64 bit time_t. This fixes a
  regression that was introduced with r391392.

  PR:		202832
  Submitted by:	yamagi@yamagi.org

Changes:
  head/mail/sylpheed/Makefile
  head/mail/sylpheed/files/extra-patch-libsylph_ssl.c
  head/mail/sylpheed/files/patch-libsylph-defs.h
  head/mail/sylpheed/files/patch-libsylph_procmsg.c
  head/mail/sylpheed/files/patch-src-printing.c
Comment 5 Emanuel Haupt freebsd_committer freebsd_triage 2015-09-03 12:18:03 UTC
Committed, thanks!