From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH] Checking PIN length based on its type (PIN / PUK / NET).
Date: Fri, 19 Mar 2010 10:25:32 -0500 [thread overview]
Message-ID: <201003191025.32736.denkenz@gmail.com> (raw)
In-Reply-To: <1269010831-21798-1-git-send-email-ppessi@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1241 bytes --]
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
next prev parent reply other threads:[~2010-03-19 15:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-19 15:00 [PATCH] Checking PIN length based on its type (PIN / PUK / NET) ppessi
2010-03-19 15:25 ` Denis Kenzior [this message]
2010-03-19 17:50 ` Pekka Pessi
-- strict thread matches above, loose matches on Subject: below --
2010-03-19 17:49 ppessi
2010-03-19 18:53 ` Denis Kenzior
2010-03-19 14:35 ppessi
2010-03-19 15:01 ` Pekka Pessi
2010-03-19 15:03 ` Denis Kenzior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201003191025.32736.denkenz@gmail.com \
--to=denkenz@gmail.com \
--cc=ofono@ofono.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox