yes, the code in engine_pkcs11.c to parse the slot string
is horrible, we tried to allow far too many formats old and new,
and the result is a big mess.

if anyone could clean it up (and properly test it), that would
be very welcome.

hmm the safenet changes look bogus.
the line 339 says:
        if (slot_id[i + 5] >= 0) {


that test was meant to be "does the string end with "slot_DIGITS"
or does it continue with something (e.g. "-id_HEXDIGITS")?

every u8 char is >= 0, so the condition now is aways true...

hmm, ok slot_id is const char, but we are not concerned with
chars 0..127 opposed to 128..255 (or -127 .. -1 in char notation).

the next tests are for "-" and "id_" which should follow any
"slot_" plus DIGITS. and then of course the rest of the string
should be HEXDIGITS and a zero char to terminate the string.

the old code looks good to me: if "slot_" followed by a 0
char, we put the number we scanf()ed from the DIGITS into slot,
and set id_len to 0, since there was no ID information and
we return 1 (parsed ok).

the code for slot_ seems to be ok to me too, it puts the
number n into slot as well, and uses hex_to_bin for putting
the slot into into the id and id_len.

what seems to be missing is the label_ branch, which doesn't
store n into slot as far as I can see, maybe that was the
reason for the old "bugfix" change?

akroehnert, your email is in the comment, so I put you on CC:
maybe you can re-read your changes and the previous posters
email and help us out?

is there some regular expression library that is available on
all unix'es and mac OS X and mingw windows environment (in
standards environments, so we don't need another new dependency)?
writing pattern matching yourself is sooo ugly.

Regards, Andreas
p.s. not sure if akroehnert is on opensc-devel. thus I keep the
whole original email included here.
Am Montag 01 Juni 2009 10:13:17 schrieb Ubi - opensc:
> Dear all, I'm a happy user of OpenSC stuff since some time.
> Recently, by testing my SW with the latest release of smart card
> software, I stumbled on a problem that I never had.
>
> Using a common smart card (InCrypto 34v2) I had this *CUSTOMized* log in
> my application:
>
> Ubi: id string too long (slot_NN-id_NN slot_00-id_65725359524e796c)
>
> this, after I changed line 364 of engine_pkcs11.c that simply stated "id
> string too long" (I wanted to tell it apart from similar messages).
>
> As you see, it seems that the identifier "slot_00-id_65725359524e796c"
> is rejected by the parser.
>
> In my humble opinion the problem is in line 340 where I read
>
> *id_len = 0;
>
> That will trigger the condition in line 363
>
> (strlen(slot_id) - i - 3 + 1) / 2 > *id_len)
>
> I had to comment line 340 to make things work again.
> Can anybody confirm this?
> Which is the most logical fix?
>
> I don't dare to go beyond because
> 1) I'm really busy
> 2) I don't know the project sufficiently
>
>
> Some more info:
>
> SW compiled on a Slackware 12.2 for IA 32 bit
> engine_pkcs11-0.1.5
> opensc-0.11.8
> nothing special in compilation options

_______________________________________________
opensc-devel mailing list
[email protected]
http://www.opensc-project.org/mailman/listinfo/opensc-devel

Reply via email to