Huie-Ying Lee wrote:
> 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].
>>
>>
Thought it a little bit more on this ...
Although my changes work fine, it use more memory than it needs.
Adding an implementation of strndup() on a platform without it is a
better solution.
Can we add this into the source code with "#ifdef " ?
Thanks,
Huie-Ying
_______________________________________________
opensc-devel mailing list
[email protected]
http://www.opensc-project.org/mailman/listinfo/opensc-devel