Package: libesmtp
Severity: normal
Tags: patch
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu noble ubuntu-patch
X-Debbugs-Cc: michael.hud...@ubuntu.com

Dear Maintainer,

Apologies for submitting this as only one report. libesmtp was failing
on Ubuntu on armhf only because although strlcpy is now in glibc, the
declaration is only found if _DEFAULT_SOURCE or _BSD_SOURCE is defined.

While looking at this I saw some scary warnings about the date handling
in headers.c which I fixed the easy bits of.

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

  * d/patches/time64: cast time_t values to long long before passing to
    *printf functions (code storing time_t values in void* variables will
    still break in 2038).
  * d/patches/default-source: define _DEFAULT_SOURCE to get access to
    prototype of strlcpy.


Thanks for considering the patch.

Cheers,
mwh


-- 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/16 CPU threads; PREEMPT)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_NZ.UTF-8:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
diff -Nru libesmtp-1.1.0/debian/patches/default-source 
libesmtp-1.1.0/debian/patches/default-source
--- libesmtp-1.1.0/debian/patches/default-source        1970-01-01 
12:00:00.000000000 +1200
+++ libesmtp-1.1.0/debian/patches/default-source        2024-04-11 
11:37:59.000000000 +1200
@@ -0,0 +1,10 @@
+--- a/meson.build
++++ b/meson.build
+@@ -30,6 +30,7 @@
+ 
################################################################################
+ cflags = [
+   '-D_POSIX_C_SOURCE=200809L',
++  '-D_DEFAULT_SOURCE',
+ ]
+ 
+ cflags_warnings = [
diff -Nru libesmtp-1.1.0/debian/patches/series 
libesmtp-1.1.0/debian/patches/series
--- libesmtp-1.1.0/debian/patches/series        2023-08-19 22:04:32.000000000 
+1200
+++ libesmtp-1.1.0/debian/patches/series        2024-04-11 11:37:24.000000000 
+1200
@@ -1 +1,3 @@
 meson-build-soname
+time64
+default-source
diff -Nru libesmtp-1.1.0/debian/patches/time64 
libesmtp-1.1.0/debian/patches/time64
--- libesmtp-1.1.0/debian/patches/time64        1970-01-01 12:00:00.000000000 
+1200
+++ libesmtp-1.1.0/debian/patches/time64        2024-04-11 11:37:18.000000000 
+1200
@@ -0,0 +1,16 @@
+--- a/headers.c
++++ b/headers.c
+@@ -170,11 +170,11 @@
+     {
+ #ifdef HAVE_GETTIMEOFDAY
+       if (gettimeofday (&tv, NULL) != -1) /* This shouldn't fail ... */
+-      snprintf (buf, sizeof buf, "%ld.%ld.%d@%s", tv.tv_sec, tv.tv_usec,
++            snprintf (buf, sizeof buf, "%lld.%lld.%d@%s", (long 
long)tv.tv_sec, (long long)tv.tv_usec,
+                 getpid (), message->session->localhost);
+       else /* ... but if it does fall back to using time() */
+ #endif
+-      snprintf (buf, sizeof buf, "%ld.%d@%s", time (NULL),
++      snprintf (buf, sizeof buf, "%lld.%d@%s", (long long)time (NULL),
+               getpid (), message->session->localhost);
+       message_id = buf;
+     }

Reply via email to