From 056bfef996a0e33932a96ff4e0131a13817ff409 Mon Sep 17 00:00:00 2001 From: Joseph Giovatto Date: Tue, 25 Sep 2018 16:20:10 -0400 Subject: [PATCH] use inet_pton to vefify ip address validity --- srsepc/src/hss/hss.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/srsepc/src/hss/hss.cc b/srsepc/src/hss/hss.cc index 3ce32f342..3baa741fe 100644 --- a/srsepc/src/hss/hss.cc +++ b/srsepc/src/hss/hss.cc @@ -170,9 +170,9 @@ bool hss::read_db_file(std::string db_filename) if (split[9] == std::string("dynamic")) { ue_ctx->static_ip_addr = "0.0.0.0"; } else { - char buf[128]; - if (inet_ntop(AF_INET, split[9].c_str(), buf, sizeof(buf))) { - if (m_ip_to_imsi.insert(std::make_pair(split[8], ue_ctx->imsi)).second) { + char buf[128] = {0}; + if (inet_pton(AF_INET, split[9].c_str(), buf)) { + if (m_ip_to_imsi.insert(std::make_pair(split[9], ue_ctx->imsi)).second) { ue_ctx->static_ip_addr = split[9]; m_hss_log->info("static ip addr %s\n", ue_ctx->static_ip_addr.c_str()); } else {