Fixed #392. Wrongfully cleared internal data on failed password input.

Signed-off-by: michael starke <michael.starke@hicknhack-software.com>
This commit is contained in:
michael starke
2015-12-04 12:31:32 +01:00
parent 366d6f9734
commit 569d8a700d
3 changed files with 9 additions and 8 deletions

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9059" systemVersion="15B42" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9060" systemVersion="15B42" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9059"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9060"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="MPDatabaseSettingsWindowController">
@@ -37,7 +37,7 @@
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="196" y="240" width="547" height="335"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/>
<view key="contentView" id="2">
<rect key="frame" x="0.0" y="0.0" width="547" height="335"/>
<autoresizingMask key="autoresizingMask"/>

View File

@@ -287,11 +287,12 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey
- (BOOL)unlockWithPassword:(NSString *)password keyFileURL:(NSURL *)keyFileURL error:(NSError *__autoreleasing*)error{
self.compositeKey = [[KPKCompositeKey alloc] initWithPassword:password key:keyFileURL];
self.tree = [[KPKTree alloc] initWithData:self.encryptedData password:self.compositeKey error:error];
/* clear out the encrypted data as we do not need it for now */
self.encryptedData = nil;
BOOL isUnlocked = (nil != self.tree);
if(isUnlocked) {
/* only clear the data if we actually do not need it anymore */
self.encryptedData = nil;
self.unlockCount += 1;
[[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentDidUnlockDatabaseNotification object:self];
/* Make sure to only store */

View File

@@ -87,13 +87,13 @@
#pragma mark -
#pragma mark Private
- (IBAction)_decrypt:(id)sender {
MPDocument *document = [[self windowController] document];
MPDocument *document = self.windowController.document;
if(document) {
NSError *error = nil;
/* No password is different than an empty password */
NSString *password = self.enablePassword ? [self.passwordTextField stringValue] : nil;
NSString *password = self.enablePassword ? self.passwordTextField.stringValue : nil;
if(![document unlockWithPassword:password
keyFileURL:[self.keyPathControl URL]
keyFileURL:self.keyPathControl.URL
error:&error]) {
[self _showError:error];
[[[self view] window] shakeWindow:nil];