Uh-oh. I'll fix those and try to test it without checks in isidriver...

--Pekka

2010/3/19 Denis Kenzior <[email protected]>:
> Hi Pekka,
>
>> -gboolean is_valid_pin(const char *pin)
>> +gboolean is_valid_pin(const char *pin, enum pin_type type)
>>  {
>>       unsigned int i;
>>
>> @@ -588,14 +588,30 @@ gboolean is_valid_pin(const char *pin)
>>       if (pin == NULL || pin[0] == '\0')
>>               return FALSE;
>>
>> -     for (i = 0; i < strlen(pin); i++)
>> -             if (pin[i] < '0' || pin[i] > '9')
>> -                     return FALSE;
>> -
>> -     if (i > 8)
>> +     i = strlen(pin);
>> +     if (i != strspn(pin, "012345679"))
>>               return FALSE;
>>
>> -     return TRUE;
>> +     switch (type)
>> +     {
>> +     case PIN_TYPE_PIN:
>> +             /* 11.11 Section 9.3 ("CHV"): 4..8 IA-5 digits */
>> +             if (4 <= i && i <= 8)
>> +                     return TRUE;
>
> This looks wrong, 'break' is missing.
>
>> +     case PIN_TYPE_PUK:
>> +             /* 11.11 Section 9.3 ("UNBLOCK CHV"), 8 IA-5 digits */
>> +             if (i == 8)
>> +                     return TRUE;
>
> Same here
>
>> +     case PIN_TYPE_NET:
>> +             /* 22.004 Section 5.2, 4 IA-5 digits */
>> +             if (i == 4)
>> +                     return TRUE;
>
> And here
>
>> +     case PIN_TYPE_NONE:
>> +             if (i < 8)
>> +                     return TRUE;
>> +     }
>
> and here
>
>> +
>> +     return FALSE;
>>  }
>
>>
>> -gboolean is_valid_pin(const char *pin);
>> +
>> +
>> +gboolean is_valid_pin(const char *pin, enum pin_type type);
>
> Why the extra lines?
>
> Regards,
> -Denis
> _______________________________________________
> ofono mailing list
> [email protected]
> http://lists.ofono.org/listinfo/ofono
>



-- 
Pekka.Pessi mail at nokia.com
_______________________________________________
ofono mailing list
[email protected]
http://lists.ofono.org/listinfo/ofono

Reply via email to