From 25bbc76e372f945e1d39611f716e04ae83584d78 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sun, 14 Dec 2014 04:16:53 -0800 Subject: [PATCH] This is so far the best tradeoff for no passwords. --- Tweak.mm | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Tweak.mm b/Tweak.mm index 1c5f343..b401d1d 100644 --- a/Tweak.mm +++ b/Tweak.mm @@ -429,13 +429,14 @@ static void VNCSettings() { return; [(NSString *) screen_->authPasswdData release]; - screen_->authPasswdData = NULL; if (CFStringRef password = (CFStringRef) CFPreferencesCopyAppValue(CFSTR("Password"), CFSTR("com.saurik.Veency"))) - if (CFStringGetLength(password) == 0) - CFRelease(password); - else + if (CFStringGetLength(password) != 0) screen_->authPasswdData = (void *) password; + else { + CFRelease(password); + screen_->authPasswdData = [@"" retain]; + } Boolean valid; cursor_ = CFPreferencesGetAppBooleanValue(CFSTR("ShowCursor"), CFSTR("com.saurik.Veency"), &valid); @@ -461,6 +462,8 @@ static void VNCNotifySettings( static rfbBool VNCCheck(rfbClientPtr client, const char *data, int size) { @synchronized (condition_) { if (NSString *password = reinterpret_cast(screen_->authPasswdData)) { + if ([password length] == 0) + return TRUE; NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]); rfbEncryptBytes(client->authChallenge, const_cast([password UTF8String])); bool good(memcmp(client->authChallenge, data, size) == 0); @@ -840,7 +843,7 @@ static rfbNewClientAction VNCClient(rfbClientPtr client) { [condition_ lock]; rfbNewClientAction action; - if (screen_->authPasswdData != NULL) + if (screen_->authPasswdData != NULL && [(NSString *) screen_->authPasswdData length] != 0) action = RFB_CLIENT_ACCEPT; else { client_ = client; -- 2.45.2