Ludovic Rousseau wrote:
> On Fri, Aug 15, 2008 at 12:28 AM, Huie-Ying Lee <[EMAIL PROTECTED]> wrote:
>
>> Hello,
>>
>
> Hello,
>
>
>> The "strndup()" function is a Gnu extension which is not supported on
>> Solaris OS or standard C library.
>> To resolve a related compilation error, we made a small change to the
>> src/tools/pkcs11_setup.c file for the Solaris port.
>> Please accept the change, so that it will be more portable for the future
>> releases.
>>
>> Attached is the patch file. Let me know if you have any comments.
>>
>> Thanks,
>> Huie-Ying
>>
>> Index: src/tools/pkcs11_setup.c
>> ===================================================================
>> --- src/tools/pkcs11_setup.c (revision 325)
>> +++ src/tools/pkcs11_setup.c (working copy)
>> @@ -69,7 +69,8 @@
>>
>> while (value != NULL) {
>> if ((next=strchr(value, ',')) != NULL) {
>> - lstitem = strndup(value, next-value);
>> + lstitem = strdup(value);
>> + lstitem[next-value]='\0';
>> next++;
>> }
>> else {
>>
>
> You changed the semantic (a bit) because you assume value is a
> NUL-terminated string when you use strdup(value);
>
>
"value" is indeed a NULL-terminated string, because it is passed from
set_card_insert_action(params[INS_ACTION]) or
set_card_remove_action(params[RM_ACTION]) and both param[INS_ACTION] and
param[RM_ACTION] are constant strings.
Please note that strdup() is also used in the original code, line 76.
If value is not a NULL-teminated string, then line76 needs to be updated
as well.
Thanks,
Huie-Ying
> I would prefer to add an implementation of strndup() on platform without it.
> I found many free implementation like the one from tar [1].
>
>
> Bye
>
> [1]
> http://www.google.fr/codesearch?hl=fr&q=show:qpSs4ioSpog:LamQPxhK_CA:qSDv38YtxWw&sa=N&ct=rd&cs_p=http://ftp.gnu.org/gnu/tar/tar-1.16.tar.bz2&cs_f=tar-1.16/lib/strndup.c&start=1
>
>
_______________________________________________
opensc-devel mailing list
[email protected]
http://www.opensc-project.org/mailman/listinfo/opensc-devel