Skip to content

Commit

Permalink
Fix a crash when one of application support or tilde expanding fails …
Browse files Browse the repository at this point in the history
…when getting paths to ssh config files
  • Loading branch information
gnachman committed Jun 23, 2016
1 parent e73a84b commit bc6888d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions sources/SCPFile.m
Expand Up @@ -190,12 +190,16 @@ - (BOOL)privateKeyIsEncrypted:(NSString *)filename {
- (NSArray *)configs {
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *appSupport = [fileManager applicationSupportDirectory];
NSArray *paths = @[ [appSupport stringByAppendingPathExtension:@"iTerm/ssh_config"],
[@"~/.ssh/config" stringByExpandingTildeInPath],
NSArray *paths = @[ [appSupport stringByAppendingPathExtension:@"iTerm/ssh_config"] ?: @"",
[@"~/.ssh/config" stringByExpandingTildeInPath] ?: @"",
@"/etc/ssh/ssh_config",
@"/etc/ssh_config" ];
NSMutableArray *configs = [NSMutableArray array];
for (NSString *path in paths) {
if (path.length == 0) {
DLog(@"Zero length path in configs paths %@", paths);
continue;
}
if ([fileManager fileExistsAtPath:path]) {
NMSSHConfig *config = [NMSSHConfig configFromFile:path];
if (config) {
Expand Down

0 comments on commit bc6888d

Please sign in to comment.