Menu

#11 English names of Keychain constants not looked up on x86

Verify
open-fixed
Keychain (12)
5
2008-03-30
2008-01-13
Jens Alfke
No

English names of Keychain 4-char codes aren't looked up correctly on Intel systems. This is a minor issue, that only affects logging/debugging messages.

This happens because the related utility functions in SecurityUtils.m are converting the codes to strings in a way that only works on big-endian CPUs. I worked around this by adding a byte-swapping call to each function. Here's the patch:

Index: /Hack/Others/Keychain/Frameworks/Keychain/Utilities/SecurityUtils.m

--- /Hack/Others/Keychain/Frameworks/Keychain/Utilities/SecurityUtils.m (revision 449)
+++ /Hack/Others/Keychain/Frameworks/Keychain/Utilities/SecurityUtils.m (working copy)
@@ -60,30 +60,37 @@
}

NSString* nameOfAuthenticationTypeConstant(SecAuthenticationType type) {
+ type = EndianU32_NtoB(type);
return localizedStringWithFallback([NSString stringWithFormat:@"%-4.4s", (char*)(&type)], @"Authentication Type Constants");
}

NSString* nameOfAuthenticationType(SecAuthenticationType type) {
+ type = EndianU32_NtoB(type);
return localizedStringWithFallback([NSString stringWithFormat:@"%-4.4s", (char*)(&type)], @"Authentication Type Names");
}

NSString* nameOfProtocolConstant(SecProtocolType type) {
+ type = EndianU32_NtoB(type);
return localizedStringWithFallback([NSString stringWithFormat:@"%-4.4s", (char*)(&type)], @"Protocol Type Constants");
}

NSString* shortNameOfProtocol(SecProtocolType type) {
+ type = EndianU32_NtoB(type);
return localizedStringWithFallback([NSString stringWithFormat:@"%-4.4s", (char*)(&type)], @"Protocol Type Short Names");
}

NSString* longNameOfProtocol(SecProtocolType type) {
+ type = EndianU32_NtoB(type);
return localizedStringWithFallback([NSString stringWithFormat:@"%-4.4s", (char*)(&type)], @"Protocol Type Long Names");
}

NSString* nameOfKeychainAttributeConstant(SecKeychainAttrType type) {
+ type = EndianU32_NtoB(type);
return localizedStringWithFallback([NSString stringWithFormat:@"%-4.4s", (char*)(&type)], @"Keychain Attribute Type Constants");
}

NSString* nameOfKeychainAttribute(SecKeychainAttrType type) {
+ type = EndianU32_NtoB(type);
return localizedStringWithFallback([NSString stringWithFormat:@"%-4.4s", (char*)(&type)], @"Keychain Attribute Type Names");
}

Discussion

  • Wade Tregaskis

    Wade Tregaskis - 2008-03-30
    • milestone: --> Verify
    • status: open --> open-fixed
     
  • Wade Tregaskis

    Wade Tregaskis - 2008-03-30

    Logged In: YES
    user_id=735766
    Originator: NO

    Resolved in r453.

     

Log in to post a comment.