~mcepl/m2crypto#365: 
fix-ssl-timeout-for-t64

Description: Fix SSL timeout struct on 32-bit systems with 64-bit time_t
Author: Spyros Seimenis <spyros.seimenis@canonical.com>
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1072341
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/m2crypto/+bug/2059156
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/src/M2Crypto/SSL/timeout.py
+++ b/src/M2Crypto/SSL/timeout.py
@@ -9,6 +9,7 @@
 
 import sys
 import struct
+import platform
 
 from M2Crypto.util import is_32bit, is_libc_musl
 
@@ -43,7 +44,10 @@
         sec = int(millisec / 1000)
         microsec = (millisec % 1000) * 1000
     else:
-        (sec, microsec) = struct.unpack('ll', binstr)
+         if platform.machine() in ["i386", "i686"]:
+            (sec, microsec) = struct.unpack('ll', binstr)
+         else:
+            (sec, microsec) = struct.unpack('qq', binstr)
     return timeout(sec, microsec)
 
 
@@ -52,4 +56,7 @@
     if sys.platform == 'win32':
         return struct.calcsize('l')
     else:
-        return struct.calcsize('ll')
+        if platform.machine() in ["i386", "i686"]:
+            return struct.calcsize('ll')
+        else:
+            return struct.calcsize('qq')
Status
RESOLVED FIXED
Submitter
~mcepl
Assigned to
No-one
Submitted
a month ago
Updated
a month ago
Labels
distro_patches milestone-0.43

Paul Gevers a month ago · edit

This patch doesn't work on Debian armhf and armel, because it dropped a piece when importing version 0.42.0. I'm preparing a fix.

Paul

~mcepl a month ago

Thank you! Also, is it really platform.machine? Wouldn't somehow checking for 32bitness be better?

Paul Gevers a month ago · edit

Hi

On 21-10-2024 13:01, ~mcepl wrote:

Thank you! Also, is it really platform.machine? Wouldn't somehow checking for 32bitness be better?

Well, in Debian we decided to keep i386 on 32-bit time_t, while other 32-bit architectures got 64-bit time_t. So on Debian one really needs to single i386 out from the rest. In other (non-Debian derived) distributions it may be different.

I'm not claiming platform.machine is the best solution. This was cooked up by the people driving the 64-bit time_t transition in Debian (mostly Ubuntu people).

Paul

~mcepl a month ago

What’s wrong with adding somewhere to src/SWIG/lib.i something like?

#include <time.h>

int time_t_bits() {
    return sizeof(time_t) * 8;
}

Paul Gevers a month ago · edit

Hi

On 21-10-2024 23:00, ~mcepl wrote:

What’s wrong with adding somewhere to src/SWIG/lib.i something like?

From my very inexperienced c-code eyes, nothing.

Paul

~mcepl REPORTED FIXED a month ago

Matěj Cepl referenced this ticket in commit f390722.

~mcepl FIXED FIXED a month ago

Matěj Cepl referenced this ticket in commit 0949b6d.

~mcepl FIXED FIXED a month ago

Matěj Cepl referenced this ticket in commit 53c3b30.

~mcepl FIXED FIXED a month ago

Matěj Cepl referenced this ticket in commit f054091.

Register here or Log in to comment, or comment via email.