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')
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
Thank you! Also, is it really
platform.machine
? Wouldn't somehow checking for 32bitness be better?
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
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; }
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
Matěj Cepl referenced this ticket in commit f390722.
Matěj Cepl referenced this ticket in commit 0949b6d.
Matěj Cepl referenced this ticket in commit 53c3b30.
Matěj Cepl referenced this ticket in commit f054091.