Skip to content

Commit f35aa95

Browse files
committed
Fix SSPI GSS credential lifetime units
1 parent d897f31 commit f35aa95

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

contrib/win32/win32compat/gss-sspi.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,26 @@ ssh_gss_time_to_lifetime(TimeStamp expiry, OM_uint32 *time_rec)
131131
{
132132
SYSTEMTIME current_time_system;
133133
FILETIME current_time;
134+
LONGLONG lifetime;
134135

136+
*time_rec = 0;
135137
GetSystemTime(&current_time_system);
136138
if (SystemTimeToFileTime(&current_time_system, &current_time) == 0) {
137139
error("SystemTimeToFileTime failed with %d", GetLastError());
138140
return 0;
139141
}
140142

141-
*time_rec = (OM_uint32)(expiry.QuadPart -
142-
((PLARGE_INTEGER)&current_time)->QuadPart) / 10000;
143+
if (expiry.QuadPart <= ((PLARGE_INTEGER)&current_time)->QuadPart)
144+
return 1;
145+
146+
lifetime = (expiry.QuadPart - ((PLARGE_INTEGER)&current_time)->QuadPart) /
147+
10000000;
148+
if (lifetime > GSS_C_INDEFINITE) {
149+
*time_rec = GSS_C_INDEFINITE;
150+
return 1;
151+
}
152+
153+
*time_rec = (OM_uint32)lifetime;
143154
return 1;
144155
}
145156

0 commit comments

Comments
 (0)