Ticket #1527: version-privacy.patch

File version-privacy.patch, 2.8 KB (added by shadowofged, 3 years ago)

Patch to limit information sent with CTCP VERSION replies.

  • Chat

     
    21272127 
    21282128    if( request ) { 
    21292129        if( [command isCaseInsensitiveEqualToString:@"VERSION"] ) { 
    2130             NSDictionary *systemVersion = [[NSDictionary allocWithZone:nil] initWithContentsOfFile:@"/System/Library/CoreServices/ServerVersion.plist"]; 
    2131             if( ! [systemVersion count] ) systemVersion = [[NSDictionary allocWithZone:nil] initWithContentsOfFile:@"/System/Library/CoreServices/SystemVersion.plist"]; 
     2130            NSUserDefaults * userDefaults = [NSUserDefaults standardUserDefaults]; 
     2131            BOOL hideSystemName = [userDefaults boolForKey:@"MVChatHideSystemName"]; 
     2132            BOOL hideSystemVersion = [userDefaults boolForKey:@"MVChatHideSystemVersion"]; 
     2133            BOOL hideSystemArch = [userDefaults boolForKey:@"MVChatHideSystemArch"]; 
     2134             
    21322135            NSDictionary *clientVersion = [[NSBundle mainBundle] infoDictionary]; 
    2133  
     2136            NSDictionary *systemVersion = nil; 
     2137             
     2138            systemVersion = [[NSDictionary allocWithZone:nil] initWithContentsOfFile:@"/System/Library/CoreServices/ServerVersion.plist"]; 
     2139            if ( ! [systemVersion count] ) 
     2140            { 
     2141                [systemVersion release]; 
     2142                systemVersion = [[NSDictionary allocWithZone:nil] initWithContentsOfFile:@"/System/Library/CoreServices/SystemVersion.plist"]; 
     2143            } 
     2144             
    21342145#if __ppc__ 
    21352146            NSString *processor = @"PowerPC"; 
    21362147#elif __i386__ 
     
    21412152            NSString *processor = @"Unknown Architecture"; 
    21422153#endif 
    21432154 
    2144             NSString *reply = [[NSString allocWithZone:nil] initWithFormat:@"%@ %@ (%@) - %@ %@ (%@) - %@", [clientVersion objectForKey:@"CFBundleName"], [clientVersion objectForKey:@"CFBundleShortVersionString"], [clientVersion objectForKey:@"CFBundleVersion"], [systemVersion objectForKey:@"ProductName"], [systemVersion objectForKey:@"ProductVersion"], processor, [clientVersion objectForKey:@"MVChatCoreCTCPVersionReplyInfo"]]; 
     2155            NSMutableString *reply = [[NSMutableString allocWithZone:nil] init]; 
     2156            [reply appendFormat:@"%@ %@ (%@)", 
     2157                [clientVersion objectForKey:@"CFBundleName"], 
     2158                [clientVersion objectForKey:@"CFBundleShortVersionString"], 
     2159                [clientVersion objectForKey:@"CFBundleVersion"]]; 
     2160             
     2161            if (!hideSystemName || !hideSystemVersion || !hideSystemArch) 
     2162                [reply appendString:@" -"]; 
     2163             
     2164            if (!hideSystemName) 
     2165                [reply appendFormat:@" %@", [systemVersion objectForKey:@"ProductName"]]; 
     2166            if (!hideSystemVersion) 
     2167                [reply appendFormat:@" %@", [systemVersion objectForKey:@"ProductVersion"]]; 
     2168            if (!hideSystemArch) 
     2169                [reply appendFormat:@" (%@)", processor]; 
     2170             
     2171            [reply appendFormat:@" - %@", [clientVersion objectForKey:@"MVChatCoreCTCPVersionReplyInfo"]]; 
     2172                 
    21452173            [sender sendSubcodeReply:command withArguments:reply]; 
    21462174 
    21472175            [reply release];