summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gsm/gsm23003.c2
-rw-r--r--tests/gsm23003/gsm23003_test.c2
-rw-r--r--tests/gsm23003/gsm23003_test.ok2
3 files changed, 6 insertions, 0 deletions
diff --git a/src/gsm/gsm23003.c b/src/gsm/gsm23003.c
index 004e20ff..3c09acac 100644
--- a/src/gsm/gsm23003.c
+++ b/src/gsm/gsm23003.c
@@ -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;
diff --git a/tests/gsm23003/gsm23003_test.c b/tests/gsm23003/gsm23003_test.c
index 682f1626..a408b73d 100644
--- a/tests/gsm23003/gsm23003_test.c
+++ b/tests/gsm23003/gsm23003_test.c
@@ -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()
diff --git a/tests/gsm23003/gsm23003_test.ok b/tests/gsm23003/gsm23003_test.ok
index 777451a8..7d7ffd1d 100644
--- a/tests/gsm23003/gsm23003_test.ok
+++ b/tests/gsm23003/gsm23003_test.ok
@@ -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)'