From 2e840a3cb9d14ee40cb836f934d66d562d805d3e Mon Sep 17 00:00:00 2001 From: jjako Date: Tue, 28 Jan 2003 16:05:18 +0000 Subject: [PATCH] Paranoid buffer overflow checking improvements. --- gtp/gtp.c | 15 +++++++++++++-- gtp/gtp.h | 2 ++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/gtp/gtp.c b/gtp/gtp.c index e00168c..d1b8cca 100644 --- a/gtp/gtp.c +++ b/gtp/gtp.c @@ -193,6 +193,7 @@ char* snprint_packet(struct gsn_t *gsn, struct sockaddr_in *peer, inet_ntoa(peer->sin_addr), ntohs(peer->sin_port), len); + buf[size-1] = 0; pos = strlen(buf); for(n=0; nsin_addr), ntohs(peer->sin_port), len); + buf2[ERRMSG_SIZE-1] = 0; pos = strlen(buf2); for(n=0; ngsnlc, &gsn->gsnc); in_addr2gsna(&pdp->gsnlu, &gsn->gsnu); + if (GTP_DEBUG) printf("gtp_create_pdp_ind: Before pdp_tidget\n"); + if (!pdp_tidget(&pdp_old, ((union gtp_packet*)pack)->gtp0.h.tid)) { /* Found old pdp with same tid. Now the voodoo begins! */ /* We check that the APN, selection mode and MSISDN is the same */ + if (GTP_DEBUG) printf("gtp_create_pdp_ind: Old context found\n"); if ( (pdp->apn_req.l == pdp_old->apn_req.l) && (!memcmp(pdp->apn_req.v, pdp_old->apn_req.v, pdp->apn_req.l)) && (pdp->selmode == pdp_old->selmode) @@ -1058,6 +1064,8 @@ int gtp_create_pdp_ind(struct gsn_t *gsn, int version, * QoS: MS will get originally negotiated QoS. * End user address (EUA). MS will get old EUA anyway. * Protocol configuration option (PCO): Only application can verify */ + + if (GTP_DEBUG) printf("gtp_create_pdp_ind: Old context found\n"); /* Copy remote flow label */ pdp_old->flru = pdp->flru; @@ -1077,10 +1085,13 @@ int gtp_create_pdp_ind(struct gsn_t *gsn, int version, GTPCAUSE_ACC_REQ); } else { /* This is not the same PDP context. Delete the old one. */ + + if (GTP_DEBUG) printf("gtp_create_pdp_ind: Deleting old context\n"); if (gsn->cb_delete_context) gsn->cb_delete_context(pdp_old); pdp_freepdp(pdp_old); - + + if (GTP_DEBUG) printf("gtp_create_pdp_ind: Deleted...\n"); } } diff --git a/gtp/gtp.h b/gtp/gtp.h index 2a4e57a..191eef1 100644 --- a/gtp/gtp.h +++ b/gtp/gtp.h @@ -17,6 +17,8 @@ #ifndef _GTP_H #define _GTP_H +#define GTP_DEBUG 1 /* Print debug information */ + #define GTP0_PORT 3386 #define GTP1C_PORT 2123 #define GTP1U_PORT 2152