[SBI] Crash occurs when ENUM in the MAP (#2103)

This commit is contained in:
Sukchan Lee 2023-03-01 17:50:25 +09:00
parent ce668c556c
commit 969c116e77
1097 changed files with 266728 additions and 42047 deletions

View file

@ -24,19 +24,30 @@ OpenAPI_tunnel_info_t *OpenAPI_tunnel_info_create(
void OpenAPI_tunnel_info_free(OpenAPI_tunnel_info_t *tunnel_info)
{
OpenAPI_lnode_t *node = NULL;
if (NULL == tunnel_info) {
return;
}
OpenAPI_lnode_t *node;
ogs_free(tunnel_info->ipv4_addr);
ogs_free(tunnel_info->ipv6_addr);
ogs_free(tunnel_info->gtp_teid);
if (tunnel_info->ipv4_addr) {
ogs_free(tunnel_info->ipv4_addr);
tunnel_info->ipv4_addr = NULL;
}
if (tunnel_info->ipv6_addr) {
ogs_free(tunnel_info->ipv6_addr);
tunnel_info->ipv6_addr = NULL;
}
if (tunnel_info->gtp_teid) {
ogs_free(tunnel_info->gtp_teid);
tunnel_info->gtp_teid = NULL;
}
ogs_free(tunnel_info);
}
cJSON *OpenAPI_tunnel_info_convertToJSON(OpenAPI_tunnel_info_t *tunnel_info)
{
cJSON *item = NULL;
OpenAPI_lnode_t *node = NULL;
if (tunnel_info == NULL) {
ogs_error("OpenAPI_tunnel_info_convertToJSON() failed [TunnelInfo]");
@ -58,12 +69,16 @@ cJSON *OpenAPI_tunnel_info_convertToJSON(OpenAPI_tunnel_info_t *tunnel_info)
}
}
if (!tunnel_info->gtp_teid) {
ogs_error("OpenAPI_tunnel_info_convertToJSON() failed [gtp_teid]");
return NULL;
}
if (cJSON_AddStringToObject(item, "gtpTeid", tunnel_info->gtp_teid) == NULL) {
ogs_error("OpenAPI_tunnel_info_convertToJSON() failed [gtp_teid]");
goto end;
}
if (tunnel_info->an_type) {
if (tunnel_info->an_type != OpenAPI_access_type_NULL) {
if (cJSON_AddStringToObject(item, "anType", OpenAPI_access_type_ToString(tunnel_info->an_type)) == NULL) {
ogs_error("OpenAPI_tunnel_info_convertToJSON() failed [an_type]");
goto end;
@ -77,38 +92,39 @@ end:
OpenAPI_tunnel_info_t *OpenAPI_tunnel_info_parseFromJSON(cJSON *tunnel_infoJSON)
{
OpenAPI_tunnel_info_t *tunnel_info_local_var = NULL;
cJSON *ipv4_addr = cJSON_GetObjectItemCaseSensitive(tunnel_infoJSON, "ipv4Addr");
OpenAPI_lnode_t *node = NULL;
cJSON *ipv4_addr = NULL;
cJSON *ipv6_addr = NULL;
cJSON *gtp_teid = NULL;
cJSON *an_type = NULL;
OpenAPI_access_type_e an_typeVariable = 0;
ipv4_addr = cJSON_GetObjectItemCaseSensitive(tunnel_infoJSON, "ipv4Addr");
if (ipv4_addr) {
if (!cJSON_IsString(ipv4_addr)) {
if (!cJSON_IsString(ipv4_addr) && !cJSON_IsNull(ipv4_addr)) {
ogs_error("OpenAPI_tunnel_info_parseFromJSON() failed [ipv4_addr]");
goto end;
}
}
cJSON *ipv6_addr = cJSON_GetObjectItemCaseSensitive(tunnel_infoJSON, "ipv6Addr");
ipv6_addr = cJSON_GetObjectItemCaseSensitive(tunnel_infoJSON, "ipv6Addr");
if (ipv6_addr) {
if (!cJSON_IsString(ipv6_addr)) {
if (!cJSON_IsString(ipv6_addr) && !cJSON_IsNull(ipv6_addr)) {
ogs_error("OpenAPI_tunnel_info_parseFromJSON() failed [ipv6_addr]");
goto end;
}
}
cJSON *gtp_teid = cJSON_GetObjectItemCaseSensitive(tunnel_infoJSON, "gtpTeid");
gtp_teid = cJSON_GetObjectItemCaseSensitive(tunnel_infoJSON, "gtpTeid");
if (!gtp_teid) {
ogs_error("OpenAPI_tunnel_info_parseFromJSON() failed [gtp_teid]");
goto end;
}
if (!cJSON_IsString(gtp_teid)) {
ogs_error("OpenAPI_tunnel_info_parseFromJSON() failed [gtp_teid]");
goto end;
}
cJSON *an_type = cJSON_GetObjectItemCaseSensitive(tunnel_infoJSON, "anType");
OpenAPI_access_type_e an_typeVariable;
an_type = cJSON_GetObjectItemCaseSensitive(tunnel_infoJSON, "anType");
if (an_type) {
if (!cJSON_IsString(an_type)) {
ogs_error("OpenAPI_tunnel_info_parseFromJSON() failed [an_type]");
@ -118,8 +134,8 @@ OpenAPI_tunnel_info_t *OpenAPI_tunnel_info_parseFromJSON(cJSON *tunnel_infoJSON)
}
tunnel_info_local_var = OpenAPI_tunnel_info_create (
ipv4_addr ? ogs_strdup(ipv4_addr->valuestring) : NULL,
ipv6_addr ? ogs_strdup(ipv6_addr->valuestring) : NULL,
ipv4_addr && !cJSON_IsNull(ipv4_addr) ? ogs_strdup(ipv4_addr->valuestring) : NULL,
ipv6_addr && !cJSON_IsNull(ipv6_addr) ? ogs_strdup(ipv6_addr->valuestring) : NULL,
ogs_strdup(gtp_teid->valuestring),
an_type ? an_typeVariable : 0
);