From eb890eb98477fde872daa27cc56e89c0b3e31f6a Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Fri, 19 May 2023 12:06:28 +0100 Subject: [PATCH] Fix time_t handling in parsing F5 session timeout We can't assume that time_t is 'long'. When building for win64 we get: ../f5.c: In function 'f5_configure': ../f5.c:690:63: warning: format '%ld' expects argument of type 'long int *', but argument 6 has type 'time_t *' {aka 'long long int *'} [-Wformat=] 690 | if (sscanf(cookie->value, "%dz%dz%dz%ldz%ld%c", &junk, &junk, &junk, &start, &dur, &c) >= 5 | ~~^ ~~~~~~ | | | | long int * time_t * {aka long long int *} | %lld ../f5.c:690:67: warning: format '%ld' expects argument of type 'long int *', but argument 7 has type 'time_t *' {aka 'long long int *'} [-Wformat=] 690 | if (sscanf(cookie->value, "%dz%dz%dz%ldz%ld%c", &junk, &junk, &junk, &start, &dur, &c) >= 5 | ~~^ ~~~~ | | | | long int * time_t * {aka long long int *} | %lld Make it explicitly 'unsigned long long' instead. Signed-off-by: David Woodhouse --- f5.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/f5.c b/f5.c index 9fdf209b..634a95f0 100644 --- a/f5.c +++ b/f5.c @@ -685,9 +685,9 @@ static int f5_configure(struct openconnect_info *vpninfo) for (cookie = vpninfo->cookies; cookie; cookie = cookie->next) { if (!strcmp(cookie->option, "F5_ST")) { int junk; - time_t start, dur; + unsigned long long start, dur; char c = 0; - if (sscanf(cookie->value, "%dz%dz%dz%ldz%ld%c", &junk, &junk, &junk, &start, &dur, &c) >= 5 + if (sscanf(cookie->value, "%dz%dz%dz%lldz%lld%c", &junk, &junk, &junk, &start, &dur, &c) >= 5 && (c == 0 || c == 'z')) vpninfo->auth_expiration = start + dur; break; -- 2.50.1