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
diff --git a/src/gsm/gsm23003.c b/src/gsm/gsm23003.c
index 004e20f..3c09aca 100644
--- a/src/gsm/gsm23003.c
+++ b/src/gsm/gsm23003.c
@@ -33,6 +33,8 @@
 	/* 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 682f162..a408b73 100644
--- a/tests/gsm23003/gsm23003_test.c
+++ b/tests/gsm23003/gsm23003_test.c
@@ -50,6 +50,7 @@
 	{ "1234567\n123456", false },
 	{ "123456\t123456", false },
 	{ "123456\r123456", false },
+	{ NULL, false },
 };
 
 bool test_valid_imsi()
@@ -92,6 +93,7 @@
 	{ "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 777451a..7d7ffd1 100644
--- a/tests/gsm23003/gsm23003_test.ok
+++ b/tests/gsm23003/gsm23003_test.ok
Binary files differ