-//
-//
-//
-//
-
-
+/*
+ * Copyright (c) 2003-2007,2009-2010,2013-2014 Apple Inc. All Rights Reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ *
+ * keychain_find.c
+ */
#include <CoreFoundation/CoreFoundation.h>
CFArrayAppendValue(context, key);
}
+static bool isPrintableString(CFStringRef theString){
+ bool result = false;
+ CFCharacterSetRef controlSet = CFCharacterSetGetPredefined(kCFCharacterSetControl);
+ CFCharacterSetRef newlineSet = CFCharacterSetGetPredefined(kCFCharacterSetNewline);
+ CFCharacterSetRef illegalSet = CFCharacterSetGetPredefined(kCFCharacterSetIllegal);
+
+ CFMutableCharacterSetRef unacceptable = CFCharacterSetCreateMutableCopy(kCFAllocatorDefault, controlSet);
+ CFCharacterSetUnion(unacceptable, newlineSet);
+ CFCharacterSetUnion(unacceptable, illegalSet);
+ result = CFStringFindCharacterFromSet(theString, unacceptable, CFRangeMake(0, CFStringGetLength(theString)), 0, NULL);
+ CFReleaseNull(unacceptable);
+ return result;
+}
+
static void display_item(const void *v_item, void *context) {
CFDictionaryRef item = (CFDictionaryRef)v_item;
CFIndex dict_count, key_ix, key_count;
CFDataRef v_d = (CFDataRef)value;
CFStringRef v_s = CFStringCreateFromExternalRepresentation(
kCFAllocatorDefault, v_d, kCFStringEncodingUTF8);
+
if (v_s) {
- CFStringAppend(line, CFSTR("/"));
- CFStringAppend(line, v_s);
- CFStringAppend(line, CFSTR("/ "));
- CFRelease(v_s);
+ if(!isPrintableString(v_s))
+ CFStringAppend(line, CFSTR("not printable "));
+ else{
+ CFStringAppend(line, CFSTR("/"));
+ CFStringAppend(line, v_s);
+ CFStringAppend(line, CFSTR("/ "));
+ }
}
+ CFReleaseNull(v_s);
+
const uint8_t *bytes = CFDataGetBytePtr(v_d);
CFIndex len = CFDataGetLength(v_d);
for (jx = 0; jx < len; ++jx) {
result = 1;
}
} else {
+ if (!do_delete && CFDictionaryGetValue(query, kSecUseAuthenticationUI) == NULL)
+ CFDictionarySetValue(query, kSecUseAuthenticationUI, kSecUseAuthenticationUISkip);
do_find_or_delete(query, do_delete);
}