File: 31-cpp-Ensure-correct-expiration-time-on-32-bit-arch-wi.patch

package info (click to toggle)
gpgme1.0 1.24.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 13,264 kB
  • sloc: ansic: 51,655; cpp: 27,213; sh: 12,776; python: 6,020; javascript: 3,773; makefile: 1,792; lisp: 1,652; sed: 37
file content (37 lines) | stat: -rw-r--r-- 1,281 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
From f23cef6f66a44c5c1cc8717f74b658d14fde04e5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ingo=20Kl=C3=B6cker?= <dev@ingo-kloecker.de>
Date: Mon, 5 May 2025 16:14:55 +0200
Subject: [PATCH 4/4] cpp: Ensure correct expiration time on 32-bit arch with
 64-bit time_t

* lang/cpp/src/key.cpp (Subkey::expirationTime): Cast away the
signedness of _gpgme_subkey.expires before casting to time_t.
--

_gpgme_subkey.expires stores the expiration as `long int` although the
expiration is always an unsigned value. Casting the value to unsigned
long int before casting it to time_t ensures that we get the correct
expiration value for 64-bit time_t even on 32-bit systems. With signed
32-bit time_t we still get a negative value as before.

GnuPG-bug-id: 7627
---
 lang/cpp/src/key.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lang/cpp/src/key.cpp b/lang/cpp/src/key.cpp
index 42046aa0..2b14d901 100644
--- a/lang/cpp/src/key.cpp
+++ b/lang/cpp/src/key.cpp
@@ -633,7 +633,7 @@ time_t Subkey::creationTime() const
 
 time_t Subkey::expirationTime() const
 {
-    return static_cast<time_t>(subkey ? subkey->expires : 0);
+    return static_cast<time_t>(static_cast<unsigned long int>(subkey ? subkey->expires : 0));
 }
 
 bool Subkey::neverExpires() const
-- 
2.47.2