Package: iraf-fitsutil
Severity: important
Tags: patch
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu noble ubuntu-patch

Dear Maintainer,

 The package autopkgtests fail on armhf[1] due to 'long' passed to functions
taking 'time_t' as an argument.

fgwrite crashes with the following stacktrace:
---
Program received signal SIGSEGV, Segmentation fault.
0x0040284e in sprintf (__fmt=0x405160 "%d-%2.2d-%2.2dT%2.2d:%2.2d:%2.2d",
__s=0xfffef18c "2024-04-10T23:34:55")
    at /usr/include/arm-linux-gnueabihf/bits/stdio2.h:30
warning: Source file is more recent than executable.
30 return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
(gdb) where
#0 0x0040284e in sprintf (__fmt=0x405160 "%d-%2.2d-%2.2dT%2.2d:%2.2d:%2.2d",
__s=0xfffef18c "2024-04-10T23:34:55")
    at /usr/include/arm-linux-gnueabihf/bits/stdio2.h:30
#1 fgfileout (fname=fname@entry=0xfffef77d "pix.fits", out=1, ftype=6,
path=path@entry=0x405318 "", level=level@entry=1)
    at fgwrite.c:695
#2 0x00400f7e in main (argc=<optimized out>, argv=<optimized out>) at
fgwrite.c:360
(gdb) down
Bottom (innermost) frame selected; you cannot go down.
(gdb) up
#1 fgfileout (fname=fname@entry=0xfffef77d "pix.fits", out=1, ftype=6,
path=path@entry=0x405318 "", level=level@entry=1)
    at fgwrite.c:695
warning: 695 fgwrite.c: No such file or directory
(gdb) print tm
$1 = (struct tm *) 0x0
---
Structure fheader uses long to represent timestamps causing a failure to obtain
the proper timestamp.

In Ubuntu, the attached patch was applied to achieve the following:

  * d/p/use-time-t.patch: use time_t instead of long for
    timestamps (LP: #2058985).


Thanks for considering the patch.

[1]
https://objectstorage.prodstack5.canonical.com/swift/v1/AUTH_0f9aae918d5b4744bf7b827671c86842/autopkgtest-
noble/noble/armhf/i/iraf-fitsutil/20240408_131637_f974b@/log.gz


-- System Information:
Debian Release: trixie/sid
  APT prefers mantic-updates
  APT policy: (500, 'mantic-updates'), (500, 'mantic-security'), (500, 
'mantic'), (100, 'mantic-backports')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 6.5.0-27-generic (SMP w/32 CPU threads; PREEMPT)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
diff -Nru iraf-fitsutil-2018.07.06/debian/patches/series 
iraf-fitsutil-2018.07.06/debian/patches/series
--- iraf-fitsutil-2018.07.06/debian/patches/series      2024-03-26 
10:57:36.000000000 +1300
+++ iraf-fitsutil-2018.07.06/debian/patches/series      2024-04-11 
11:54:47.000000000 +1200
@@ -5,3 +5,4 @@
 Add-missing-tm_isdst-initialization.patch
 Don-t-try-to-install-cfitsio.patch
 ANSI-C-clean-Wall.patch
+Use-time-t.patch
diff -Nru iraf-fitsutil-2018.07.06/debian/patches/Use-time-t.patch 
iraf-fitsutil-2018.07.06/debian/patches/Use-time-t.patch
--- iraf-fitsutil-2018.07.06/debian/patches/Use-time-t.patch    1970-01-01 
12:00:00.000000000 +1200
+++ iraf-fitsutil-2018.07.06/debian/patches/Use-time-t.patch    2024-04-11 
11:54:47.000000000 +1200
@@ -0,0 +1,35 @@
+Description: use time_t to represent timestamps
+ Due to time_t migration, sizeof(time_t) != sizeof(long) on armhf.
+ Use time_t type to represent timestamps in fgwrite/fgread.
+ This is safe to do, because the timestamps are stored in the string
+ format in the input/output file.
+Author: Vladimir Petko <vladimir.pe...@canonical.com>
+Origin: https://github.com/iraf-community/iraf-fitsutil/pull/17
+Bug: https://github.com/iraf-community/iraf-fitsutil/issues/16
+Bug-Ubuntu: 
https://bugs.launchpad.net/ubuntu/+source/iraf-fitsutil/+bug/2058985
+Last-Update: 2024-04-11
+
+--- a/src/fgwrite.c
++++ b/src/fgwrite.c
+@@ -71,8 +71,8 @@
+       int     gid;
+       int     isdir;
+       long    size;
+-      long    mtime;
+-      long    ctime;
++      time_t  mtime;
++      time_t  ctime;
+       long    chksum;
+       int     linkflag;
+       char    linkname[NAMSIZ];
+--- a/src/fgread.c
++++ b/src/fgread.c
+@@ -85,7 +85,7 @@
+       int     dirlevel;
+       long    size;
+       long    hsize;
+-      long    mtime;
++      time_t  mtime;
+       long    chksum;
+       int     linkflag;
+       char    linkname[NAMSIZ];

Reply via email to