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.10.2~32 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=bbf3690b8cc0bf63812b6671a752e769d8d5cb8a;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];