gprs: Add testcases for the APN string/octet conversion and fix it

Create a testcase for the gprs_str_to_apn and gprs_apn_to_str
routines. While writing the testcase we noticed it is possible to
write more bytes than should have been allowed. This is fixed by
checking that the max_len is at least 1 (needed to write the first
length octet) and to do the size check before writing to the output.

Modify the signature of gprs_str_to_apn to put the length/size next
to the parameter that requires a size.

Done with Jacob
diff --git a/openbsc/src/gprs/gb_proxy_vty.c b/openbsc/src/gprs/gb_proxy_vty.c
index 29494c6..d40d9b3 100644
--- a/openbsc/src/gprs/gb_proxy_vty.c
+++ b/openbsc/src/gprs/gb_proxy_vty.c
@@ -230,7 +230,7 @@
 		g_cfg->core_apn =
 			talloc_realloc_size(NULL, g_cfg->core_apn, apn_len + 1);
 		g_cfg->core_apn_size =
-			gprs_str_to_apn(g_cfg->core_apn, apn, apn_len + 1);
+			gprs_str_to_apn(g_cfg->core_apn, apn_len + 1, apn);
 	}
 
 	return CMD_SUCCESS;