diff options
Diffstat (limited to 'extensions/app_diameap')
| -rw-r--r-- | extensions/app_diameap/CMakeLists.txt | 15 | ||||
| -rw-r--r-- | extensions/app_diameap/diameap_eap.c | 4 | ||||
| -rw-r--r-- | extensions/app_diameap/diameap_init.c | 5 | ||||
| -rw-r--r-- | extensions/app_diameap/diameap_server.c | 21 |
4 files changed, 30 insertions, 15 deletions
diff --git a/extensions/app_diameap/CMakeLists.txt b/extensions/app_diameap/CMakeLists.txt index f463022..8844286 100644 --- a/extensions/app_diameap/CMakeLists.txt +++ b/extensions/app_diameap/CMakeLists.txt @@ -1,11 +1,26 @@ # The Diameter EAP Application extension PROJECT("Diameter EAP Application extension" C) +INCLUDE (CheckCSourceCompiles) + # Find MySQL FIND_PACKAGE(MySQL REQUIRED) FIND_PACKAGE(Gcrypt REQUIRED) INCLUDE_DIRECTORIES(${MySQL_INCLUDE_DIR}) +# Check for my_bool, deprecated in MySQL 8.0 +SET(CHECK_MYSQL_MY_BOOL " +#include <mysql.h> +int main() { +my_bool f; +}") +SET(CMAKE_REQUIRED_INCLUDES ${MySQL_INCLUDE_DIR}) +SET(CMAKE_REQUIRED_LIBRARIES ${MySQL_LIBRARY}) +CHECK_C_SOURCE_COMPILES("${CHECK_MYSQL_MY_BOOL}" HAVE_MYSQL_MY_BOOL) +IF (HAVE_MYSQL_MY_BOOL) + ADD_DEFINITIONS(-DHAVE_MYSQL_MY_BOOL) +ENDIF() + # Parse plugins ADD_SUBDIRECTORY(plugins) diff --git a/extensions/app_diameap/diameap_eap.c b/extensions/app_diameap/diameap_eap.c index 72885ea..d7b235c 100644 --- a/extensions/app_diameap/diameap_eap.c +++ b/extensions/app_diameap/diameap_eap.c @@ -59,7 +59,7 @@ static void diameap_ba_policyupdate(struct eap_state_machine * eap_sm, struct eap_packet *eapPacket) { TRACE_ENTRY("%p %p",eap_sm, eapPacket); - if ((eap_sm->respMethod == TYPE_NAK)) + if (eap_sm->respMethod == TYPE_NAK) { int id; eap_sm->user.pmethods = 0; @@ -100,7 +100,7 @@ static int diameap_ba_policygetnextmethod(struct eap_state_machine * eap_sm, if (eap_sm->user.userid == NULL) { - if ((eap_sm->currentMethod == TYPE_NONE)) + if (eap_sm->currentMethod == TYPE_NONE) { *vendor = VENDOR_IETF; *eaptype = TYPE_IDENTITY; diff --git a/extensions/app_diameap/diameap_init.c b/extensions/app_diameap/diameap_init.c index e3b8cc9..59a0bbb 100644 --- a/extensions/app_diameap/diameap_init.c +++ b/extensions/app_diameap/diameap_init.c @@ -38,6 +38,11 @@ #include "diameap_common.h" +#ifndef HAVE_MYSQL_MY_BOOL +#include <stdbool.h> +typedef bool my_bool; +#endif /* HAVE_MYSQL_MY_BOOL */ + /* Dictionary Object templates */ struct dict_object * dataobj_diameap_cmd = NULL; /* Diameter-EAP-Request Command Code */ struct dict_object * dataobj_diameap_app = NULL; /* Diameter EAP Application object */ diff --git a/extensions/app_diameap/diameap_server.c b/extensions/app_diameap/diameap_server.c index b93f6bb..329d6a2 100644 --- a/extensions/app_diameap/diameap_server.c +++ b/extensions/app_diameap/diameap_server.c @@ -1674,6 +1674,7 @@ union avp_value diameap_get_num(char * num, enum dict_avp_basetype datatype) break; default: TRACE_DEBUG(INFO, "%sUnknown AVP Base Type.",DIAMEAP_EXTENSION) + memset(&val, 0, sizeof(val)); ; } return val; @@ -1959,22 +1960,16 @@ char * diameap_attribute_operator(char * op, int * toadd, boolean *isrule) switch (*toadd) { case 1: - attribute_op = malloc(strlen(op)); - memset(attribute_op, 0, strlen(op)); - strncpy(attribute_op, op + 1, strlen(op) - 1); - attribute_op[strlen(op)] = '\0'; + attribute_op = calloc(strlen(op), sizeof(char *)); + memcpy(attribute_op, op + 1, strlen(op) - 1); break; case 2: - attribute_op = malloc(strlen(op)); - memset(attribute_op, 0, strlen(op)); - strncpy(attribute_op, op, strlen(op) - 1); - attribute_op[strlen(op)] = '\0'; + attribute_op = calloc(strlen(op), sizeof(char *)); + memcpy(attribute_op, op, strlen(op) - 1); break; default: - attribute_op = malloc(strlen(op) + 1); - memset(attribute_op, 0, strlen(op) + 1); - strcpy(attribute_op, op); - attribute_op[strlen(op) + 1] = '\0'; + attribute_op = calloc(strlen(op) + 1, sizeof(char *)); + memcpy(attribute_op, op, strlen(op)); } if (strcmp(attribute_op, "=") == 0) { @@ -3064,7 +3059,7 @@ static int diameap_server_callback(struct msg ** rmsg, struct avp * ravp, struct sess_state * diameap_sess_data = NULL; struct diameap_state_machine * diameap_sm = NULL; struct diameap_eap_interface eap_i; - struct msg *req, *ans; + struct msg *req, *ans = NULL; boolean non_fatal_error = FALSE; if (rmsg == NULL) |
