From 25986cde0913d96be75b0d5fdf4dc2959f1e7e11 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Sun, 12 Nov 2017 11:41:47 -0500 Subject: [PATCH] Fix: buffer overflow warning in python bindings MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- extras/bindings/swig/python/lttng.i.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extras/bindings/swig/python/lttng.i.in b/extras/bindings/swig/python/lttng.i.in index e48bf6d8e..d74e08478 100644 --- a/extras/bindings/swig/python/lttng.i.in +++ b/extras/bindings/swig/python/lttng.i.in @@ -979,7 +979,7 @@ struct lttng_channel { %extend { char *__repr__() { static char temp[512]; - sprintf(temp, "lttng.Channel; name('%s'), enabled(%s)", + snprintf(temp, sizeof(temp), "lttng.Channel; name('%s'), enabled(%s)", $self->name, $self->enabled ? "True" : "False"); return &temp[0]; } @@ -994,8 +994,8 @@ struct lttng_session { %extend { char *__repr__() { - static char temp[512]; - sprintf(temp, "lttng.Session; name('%s'), path('%s'), enabled(%s)", + static char temp[PATH_MAX + NAME_MAX + 512]; + snprintf(temp, sizeof(temp), "lttng.Session; name('%s'), path('%s'), enabled(%s)", $self->name, $self->path, $self->enabled ? "True" : "False"); return &temp[0]; -- 2.34.1