From: Jérémie Galarneau Date: Sun, 12 Nov 2017 16:41:47 +0000 (-0500) Subject: Fix: buffer overflow warning in python bindings X-Git-Tag: v2.11.0-rc1~449 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=25986cde0913d96be75b0d5fdf4dc2959f1e7e11;p=lttng-tools.git Fix: buffer overflow warning in python bindings Signed-off-by: Jérémie Galarneau --- 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];