From 51127ea9621a4863ad7efe8c9f500fd2b2ffc907 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Mon, 6 Nov 2017 02:42:22 +0900 Subject: sgsnemu: Don't leak FILE handle in proc_read() Change-Id: Ie22e6a9bc172427e867e7a4001b6c710477a232b Fixes: Coverity CID#178660 --- ggsn/gtp-kernel.c | 44 ++++++++++---------------------------------- 1 file changed, 10 insertions(+), 34 deletions(-) (limited to 'ggsn') diff --git a/ggsn/gtp-kernel.c b/ggsn/gtp-kernel.c index f98586d..916b92f 100644 --- a/ggsn/gtp-kernel.c +++ b/ggsn/gtp-kernel.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -36,37 +37,15 @@ static void pdp_debug(struct pdp_t *pdp) { - int i; - uint64_t teid; + struct in46_addr ia46; + struct in_addr ia; - if (!debug) - return; - - printf("version %u\n", pdp->version); - if (pdp->version == 0) { - teid = pdp_gettid(pdp->imsi, pdp->nsapi); - printf("flowid %u\n", pdp->flru); - } else { - teid = pdp->teid_gn; /* GTPIE_TEI_DI */ - } - - printf("teid %llx\n", teid); - printf("address (%u)\n", pdp->eua.l); + in46a_from_eua(&pdp->eua, &ia46); + gsna2in_addr(&ia, &pdp->gsnrc); - /* Byte 0: 0xf1 == IETF */ - /* Byte 1: 0x21 == IPv4 */ - /* Byte 2-6: IPv4 address */ - - for (i = 0; i < 6; i++) - printf("%x ", pdp->eua.v[i] & 0xff); /* GTPIE_EUA */ - - printf("\n"); - printf("sgsn-addr (%u)\n", pdp->gsnrc.l); - - for (i = 0; i < 4; i++) - printf("%x ", pdp->gsnrc.v[i] & 0xff); /* GTPIE_GSN_ADDR */ - - printf("\n"); + LOGPDPX(DGGSN, LOGL_DEBUG, pdp, "v%u TEID %"PRIu64"x EUA=%s SGSN=%s\n", pdp->version, + pdp->version == 0 ? pdp_gettid(pdp->imsi, pdp->nsapi) : pdp->teid_gn, + in46a_ntoa(&ia46), inet_ntoa(ia)); } static struct { @@ -101,11 +80,8 @@ int gtp_kernel_init(struct gsn_t *gsn, struct in_addr *net, "cannot lookup GTP genetlink ID\n"); return -1; } - if (debug) { - SYS_ERR(DGGSN, LOGL_NOTICE, 0, - "Using the GTP kernel mode (genl ID is %d)\n", - gtp_nl.genl_id); - } + SYS_ERR(DGGSN, LOGL_DEBUG, 0, + "Using the GTP kernel mode (genl ID is %d)\n", gtp_nl.genl_id); DEBUGP(DGGSN, "Setting route to reach %s via %s\n", net_arg, GTP_DEVNAME); -- cgit v1.2.3