I think this issue might be a bug, so I filed a bug report already
4550961. Maybe this was a bit too early, so let me ask some folks
here on the list, maybe someone knows the issue. Here is the text of
the bug report:
17-May-2006 10:28 AM Markus Hanauska:
Please find attached a C file that compiles using
gcc -framework Security -o test test.c
When you run it, it creates a KeychainItem (a generic password),
filling all generic password attributes with data. Keychain Access
shows the item correctly, all data has been set as the code demands.
Now I try to retrieve attributes again of the item I just created and
it does not work. Even worse, I get this:
test(726) malloc: *** Deallocation of a pointer not malloced:
0x5228c0; This could be a double free(), or free() called with the
middle of an allocated block; Try setting environment variable
MallocHelp to see tools to help debug
And that multiple times. Now on top of the C file, you see
#define GETLABEL
put comments in front of the line ("//"), remove the Keychain Item
named "theLabel" manually from your Keychain and then compile and
start the app again. This time it works(!!!), it gets all attributes
and displays their value correctly.
So the alloc problem only happens if you request "kSecLabelItemAttr"
of a generic password item. All other attributes can be requested
just fine. And not only that I get malloc issues, the result code of
the operation when trying to retrieve kSecLabelItemAttr is -25303,
which means "Invalid Attribute". Now how can kSecLabelItemAttr be an
invalid attribute if I just set it above in the code, it is displayed
correctly in Keychain Access and thus it still was a valid one
before? (leaving aside that even if it was invalid, no malloc errors
should take place)
Only tested on Intel Mac, might be an Intel related problem (endian
i.e.)
Now let me show you the C file here in its full beauty:
err = SecKeychainItemCopyAttributesAndData(
item,
&attr2,
NULL,
&l,
NULL,
NULL
);
printf("Error %d\n", err);
int i;
for (i = 0; i < 4; i++) {
printf("Attribute %d of size %d: %.*s\n",
l->attr[i].tag,
l->attr[i].length,
l->attr[i].length,
l->attr[i].data);
}
return 0;
}
Okay, now is that really me who's doing something wrong or has Apple
a serious bug in their Keychain Service API?
--
Markus Hanauska
-----------------------------------------------
equinux Aktiengesellschaft
Informationstechnologien
Kirschstr. 35
80999 München - Germany
Tel. +49(0)89 520465-323
Fax. +49(0)89 520465-299
mailto:email@hiddenhttp://www.equinux.de
equinux USA Inc., San Mateo (CA)
Toll free: 1-888-equinux (1-888-3784689)
http://www.equinux.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Apple-cdsa mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/apple-cdsa/email@hidden