diff options
authorPau Espin Pedrol <pespin@sysmocom.de>2018-01-25 18:20:51 +0100
committerPau Espin Pedrol <pespin@sysmocom.de>2018-01-25 18:20:55 +0100
commit282d4e3dda5c3a1eabb76da601c5a680a1ccbd15 (patch)
parent42d3250d1790dffc30fc0ce02bd520c2e8445637 (diff)
gtp.c: gtp_gpdu_ind: Early return to avoid use of uninitialized var
If the version received is not known, pdp is then uninitalized so we should not be using it. Let's return an error to inform the caller. Change-Id: Ib3e23b61a3521bd3c9002d3165ca8eff4361a35e
1 files changed, 2 insertions, 1 deletions
diff --git a/gtp/gtp.c b/gtp/gtp.c
index a2526a3..9dabcd2 100644
--- a/gtp/gtp.c
+++ b/gtp/gtp.c
@@ -2696,7 +2696,7 @@ int gtp_gpdu_ind(struct gsn_t *gsn, int version,
struct sockaddr_in *peer, int fd, void *pack, unsigned len)
- int hlen = GTP1_HEADER_SIZE_SHORT;
+ int hlen;
/* Need to include code to verify packet src and dest addresses */
struct pdp_t *pdp;
@@ -2732,6 +2732,7 @@ int gtp_gpdu_ind(struct gsn_t *gsn, int version,
GTP_LOGPKG(LOGL_ERROR, peer, pack, len,
"Unknown version: %d\n", version);
+ return EOF;
/* If the GPDU was not from the peer GSN tell him to delete context */