From e08cd5d552a80a2d3166ee1be9d49179322a553c Mon Sep 17 00:00:00 2001 From: Guillaume Nault Date: Fri, 26 Apr 2013 10:22:18 +0200 Subject: l2tp: Fix PPP channel name Allocate space for the terminationg null byte, to avoid truncating PPP channel name. Signed-off-by: Guillaume Nault --- accel-pppd/ctrl/l2tp/l2tp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'accel-pppd') diff --git a/accel-pppd/ctrl/l2tp/l2tp.c b/accel-pppd/ctrl/l2tp/l2tp.c index 79d003ef..ffcbb8ac 100644 --- a/accel-pppd/ctrl/l2tp/l2tp.c +++ b/accel-pppd/ctrl/l2tp/l2tp.c @@ -1221,16 +1221,16 @@ static int l2tp_session_connect(struct l2tp_sess_t *sess) " snprintf() failed: %s\n", strerror(errno)); goto out_err; } - sess->ppp.ses.chan_name = _malloc(chan_sz); + sess->ppp.ses.chan_name = _malloc(chan_sz + 1); if (sess->ppp.ses.chan_name == NULL) { log_session(log_error, sess, "impossible to connect session:" " memory allocation failed\n"); goto out_err; } - if (snprintf(sess->ppp.ses.chan_name, chan_sz, "%s:%i session %i", + if (snprintf(sess->ppp.ses.chan_name, chan_sz + 1, "%s:%i session %i", addr, peer_port, sess->peer_sid) < 0) { log_session(log_error, sess, "impossible to connect session:" - " snprintf(%i) failed\n", chan_sz); + " snprintf(%i) failed\n", chan_sz + 1); goto out_err; } -- cgit v1.2.3