Commit aec38a2f authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

use free_wrapper instead of naked free

parent 3fea6ab9
......@@ -50,6 +50,10 @@
#include "comUt.hpp"
#include "sha256.hpp"
extern "C" {
#include "dynamic_memory_check.h"
}
using namespace nas;
using namespace amf_application;
using namespace config;
......@@ -820,7 +824,7 @@ bool amf_n1::authentication_vectors_generator_in_udm(std::shared_ptr<nas_context
generate_random(vector[0].rand, RAND_LENGTH);
mysql_push_rand_sqn(nc.get()->imsi, vector[0].rand, sqn);
mysql_increment_sqn(nc.get()->imsi);
free(sqn);
free_wrapper((void**) &sqn);
}
if (!get_mysql_auth_info(nc.get()->imsi, mysql_resp)) {
Logger::amf_n1().error("Cannot get data from MySQL");
......
......@@ -31,7 +31,6 @@
#include <curl/curl.h>
#include <nlohmann/json.hpp>
#include "dynamic_memory_check.h"
#include "amf_n1.hpp"
#include "itti.hpp"
#include "itti_msg_amf_app.hpp"
......@@ -46,20 +45,21 @@
#include "ApiClient.h"
#include "mime_parser.hpp"
extern "C" {
#include "dynamic_memory_check.h"
}
using namespace oai::smf::model;
using namespace oai::smf::api;
using namespace web;
// Common features like URIs.
using namespace web::http;
// Common HTTP functionality
using namespace web::http::client;
using namespace web::http; // Common features like URIs.
using namespace web::http::client; // Common HTTP functionality
using namespace config;
using namespace amf_application;
extern itti_mw *itti_inst;
extern amf_config amf_cfg;
extern amf_n11 *amf_n11_inst;
extern amf_n1 *amf_n1_inst;
extern void msg_str_2_msg_hex(std::string msg, bstring &b);
......@@ -219,8 +219,7 @@ void amf_n11::handle_itti_message(itti_smf_services_consumer &smf) {
if ((smf.dnn != nullptr) && (blength(smf.dnn) > 0)) {
char *tmp = bstring2charString(smf.dnn);
dnn = tmp;
free(tmp);
tmp = nullptr;
free_wrapper((void**) &tmp);
}
Logger::amf_n11().debug("Requested DNN: %s", dnn.c_str());
......@@ -431,11 +430,16 @@ void amf_n11::curl_http_client(std::string remoteUri, std::string jsonData, std:
std::string header_response = *httpHeaderData.get();
std::string CRLF = "\r\n";
std::size_t location_pos = header_response.find("Location");
if (location_pos != std::string::npos) {
std::size_t crlf_pos = header_response.find(CRLF, location_pos);
if (crlf_pos != std::string::npos) {
std::string location = header_response.substr(location_pos + 10, crlf_pos - (location_pos + 10));
Logger::amf_n11().info("Location of the SMF context created: %s", location.c_str());
Logger::amf_n11().info("Location of the created SMF context: %s", location.c_str());
psc.get()->smf_context_location = location;
}
}
}
nlohmann::json response_data = { };
bstring n1sm_hex;
......@@ -464,9 +468,5 @@ void amf_n11::curl_http_client(std::string remoteUri, std::string jsonData, std:
}
curl_global_cleanup();
if (body_data != nullptr) {
free(body_data);
body_data = NULL;
}
free_wrapper((void**) &body_data);
}
......@@ -62,17 +62,4 @@ class amf_n2 : public ngap::ngap_app{
}
#endif
......@@ -57,7 +57,7 @@ void statistics::display() {
Logger::amf_app().info("|----------------------------------------------------------------------------------------------------------------|");
Logger::amf_app().info("|----------------------------------------------------UEs' information--------------------------------------------|");
Logger::amf_app().info("| Index | Connection state | Registration state | IMSI | GUTI | RAN UE NGAP ID | AMF UE ID |");
Logger::amf_app().info("| Index | Connection state | Registration state | IMSI | GUTI |RAN UE NGAP ID|AMF UE ID|");
for (int i = 0; i < ues.size(); i++) {
//Logger::amf_app().info("[index %d][%s][%s][imsi %s][guti %s]", i + 1, ues[i].connStatus.c_str(), ues[i].registerStatus.c_str(), ues[i].imsi.c_str(), ues[i].guti.c_str());
Logger::amf_app().info("| %d | %s | %s | %s | %s | %d | %d | ", i + 1, ues[i].connStatus.c_str(), ues[i].registerStatus.c_str(), ues[i].imsi.c_str(), ues[i].guti.c_str(), ues[i].ranid, ues[i].amfid);
......
......@@ -4,6 +4,10 @@
#include "conversions.hpp"
extern "C" {
#include "dynamic_memory_check.h"
}
void convert_string_2_hex(std::string& input_str, std::string& output_str)
{
unsigned char *data = (unsigned char *) malloc (input_str.length() + 1);
......@@ -62,9 +66,7 @@ unsigned char * format_string_as_hex(std::string str){
}
printf("\n");
free(data);
data = nullptr;
free_wrapper((void**) &data);
return datavalue;
}
......@@ -74,8 +76,7 @@ char* bstring2charString(bstring b){
for(int i=0; i<blength(b); i++)
buf[i] = (char)value[i];
buf[blength(b)] = '\0';
free(value);
value = nullptr;
free_wrapper((void**) &value);
return buf;
}
......
......@@ -23,6 +23,10 @@
#include "logger.hpp"
#include "conversions.hpp"
extern "C" {
#include "dynamic_memory_check.h"
}
bool mime_parser::parse(const std::string &str) {
std::string CRLF = "\r\n";
Logger::amf_app().debug("Parsing the message with Simple Parser");
......@@ -91,10 +95,7 @@ unsigned char* mime_parser::format_string_as_hex(const std::string &str) {
printf("\n");
#endif
//free memory
//free_wrapper((void**) &data);
free(data);
data = NULL;
free_wrapper((void**) &data);
return data_hex;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment