Skip to content

Commit ce1308c

Browse files
committed
libvncclient: fix ARD auth CI regressions
1 parent f0ca173 commit ce1308c

4 files changed

Lines changed: 26 additions & 25 deletions

File tree

include/rfb/rfbclient.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -407,11 +407,6 @@ typedef struct _rfbClient {
407407
* Set by function SetClientAuthSchemes() */
408408
uint32_t *clientAuthSchemes;
409409

410-
/** Optional configuration for ARD Kerberos auth. */
411-
char *ardAuthRealm;
412-
char *ardAuthClientPrincipal;
413-
char *ardAuthServicePrincipal;
414-
415410
/** When the server is a repeater, this specifies the final destination */
416411
char *destHost;
417412
int destPort;
@@ -506,10 +501,16 @@ typedef struct _rfbClient {
506501
*/
507502
GotXCutTextUTF8Proc GotXCutTextUTF8;
508503

509-
/* flag to indicate wheter updateRect is managed by lib or user */
510-
rfbBool isUpdateRectManagedByLib;
504+
/* flag to indicate wheter updateRect is managed by lib or user */
505+
rfbBool isUpdateRectManagedByLib;
511506

512-
GetX509CertFingerprintMismatchDecisionProc GetX509CertFingerprintMismatchDecision;
507+
GetX509CertFingerprintMismatchDecisionProc GetX509CertFingerprintMismatchDecision;
508+
509+
/** Optional configuration for ARD Kerberos auth.
510+
* Appended here to preserve offsets of pre-existing public struct fields. */
511+
char *ardAuthRealm;
512+
char *ardAuthClientPrincipal;
513+
char *ardAuthServicePrincipal;
513514
} rfbClient;
514515

515516
/* cursor.c */

src/libvncclient/ardauth.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <GSS/GSS.h>
1111
#endif
1212

13-
#if defined(__has_include)
13+
#if defined(__APPLE__) && defined(LIBVNCSERVER_HAVE_LIBSSL) && defined(__has_include)
1414
#if __has_include(<openssl/bn.h>)
1515
#include <openssl/bn.h>
1616
#define LIBVNCCLIENT_APPLE_HAS_OPENSSL_BN 1
@@ -148,11 +148,19 @@ static rfbBool ConsumeRSASRPServerFinalIfPresent(rfbClient *client) {
148148
int wm = WaitForMessage(client, 1500000);
149149
ssize_t r;
150150

151-
if (wm <= 0)
152-
return TRUE;
153-
r = recv(client->sock, (char *)hdr, sizeof(hdr), MSG_PEEK);
154-
if (r < 4)
151+
if (wm < 0)
152+
return FALSE;
153+
if (wm == 0)
155154
return TRUE;
155+
if (client->buffered >= sizeof(hdr)) {
156+
memcpy(hdr, client->bufoutptr, sizeof(hdr));
157+
} else {
158+
if (client->buffered > 0 || client->tlsSession || client->saslconn)
159+
return TRUE;
160+
r = recv(client->sock, (char *)hdr, sizeof(hdr), MSG_PEEK);
161+
if (r < (ssize_t)sizeof(hdr))
162+
return TRUE;
163+
}
156164
n = ReadBEU32(hdr);
157165
if (n < 16 || n > 4096)
158166
return TRUE;
@@ -1059,15 +1067,9 @@ static rfbBool HandleARDAuthDirectSRP(rfbClient *client) {
10591067
return ok;
10601068
}
10611069

1070+
#if defined(__APPLE__)
10621071
static rfbBool ImportKerberosName(const char *value, gss_const_OID oid,
10631072
gss_name_t *out_name, const char *what) {
1064-
#if !defined(__APPLE__)
1065-
(void)value;
1066-
(void)oid;
1067-
(void)out_name;
1068-
(void)what;
1069-
return FALSE;
1070-
#else
10711073
OM_uint32 major = 0;
10721074
OM_uint32 minor = 0;
10731075
gss_buffer_desc buf = GSS_C_EMPTY_BUFFER;
@@ -1086,8 +1088,8 @@ static rfbBool ImportKerberosName(const char *value, gss_const_OID oid,
10861088
return FALSE;
10871089
}
10881090
return TRUE;
1089-
#endif
10901091
}
1092+
#endif
10911093

10921094
static rfbBool WriteLengthPrefixedBlob(rfbClient *client, const uint8_t *buf,
10931095
size_t len, const char *what) {

src/libvncclient/rfbclient.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,11 @@ SupportsARDAuthScheme(uint8_t authScheme)
131131
#if defined(__APPLE__)
132132
case rfbARDAuthKerberosGSSAPI:
133133
return TRUE;
134-
#if defined(__has_include)
135-
#if __has_include(<openssl/bn.h>)
134+
#if defined(LIBVNCSERVER_HAVE_LIBSSL)
136135
case rfbARDAuthRSASRP:
137136
case rfbARDAuthDirectSRP:
138137
return TRUE;
139138
#endif
140-
#endif
141139
#endif
142140
default:
143141
return FALSE;

test/ardauthprobe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ int main(int argc, char **argv) {
111111
int init_argc = 2;
112112
char *init_argv[3] = {NULL, NULL, NULL};
113113

114-
if (argc < 3 || strcmp(argv[1], "-auth") != 0 ||
114+
if (argc < 4 || strcmp(argv[1], "-auth") != 0 ||
115115
!ParseAuthType(argv[2], &auth_types[0])) {
116116
fprintf(stderr, "usage: %s -auth <security-type> <host[:port]>\n",
117117
argv[0]);

0 commit comments

Comments
 (0)