mirror of https://gerrit.osmocom.org/libosmocore
gsm: make osmo_imsi_str_valid() NULL-safe
No callers that would pass NULL exist, but let's check against NULL from the start. Fixup for recent change I1e94f5b0717b947d2a7a7d36bacdf04a75cb3522. Change-Id: I111fbf29228929f2cd6ffa06bcb1f69da223224e
This commit is contained in:
parent
f624546ed1
commit
4b7c791e15
|
@ -33,6 +33,8 @@ static bool is_n_digits(const char *str, int min_digits, int max_digits)
|
|||
/* Use unsigned char * to avoid a compiler warning of
|
||||
* "error: array subscript has type 'char' [-Werror=char-subscripts]" */
|
||||
const unsigned char *pos = (const unsigned char *)str;
|
||||
if (!pos)
|
||||
return min_digits < 1;
|
||||
for (len = 0; *pos && len < max_digits; len++, pos++)
|
||||
if (!isdigit(*pos))
|
||||
return false;
|
||||
|
|
|
@ -50,6 +50,7 @@ static struct {
|
|||
{ "1234567\n123456", false },
|
||||
{ "123456\t123456", false },
|
||||
{ "123456\r123456", false },
|
||||
{ NULL, false },
|
||||
};
|
||||
|
||||
bool test_valid_imsi()
|
||||
|
@ -92,6 +93,7 @@ static struct {
|
|||
{ "1234567\n123456", false },
|
||||
{ "123456\t123456", false },
|
||||
{ "123456\r123456", false },
|
||||
{ NULL, false },
|
||||
};
|
||||
|
||||
bool test_valid_msisdn()
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
123456'
|
||||
17: expect=false result=false imsi='123456 123456'
|
||||
18: expect=false result=false imsi='123456
123456'
|
||||
19: expect=false result=false imsi='(null)'
|
||||
----- test_valid_msisdn
|
||||
0: expect=false result=false msisdn=''
|
||||
1: expect=false result=false msisdn=' '
|
||||
|
@ -40,3 +41,4 @@
|
|||
123456'
|
||||
17: expect=false result=false msisdn='123456 123456'
|
||||
18: expect=false result=false msisdn='123456
123456'
|
||||
19: expect=false result=false msisdn='(null)'
|
||||
|
|
Loading…
Reference in New Issue