Fix: buffer overflow warning in python bindings
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 12 Nov 2017 16:41:47 +0000 (11:41 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 12 Nov 2017 16:45:25 +0000 (11:45 -0500)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
extras/bindings/swig/python/lttng.i.in

index e48bf6d8e57a6e229d4ed76d62ad7f340916e586..d74e08478268f6ea23ed68728753d734d1eb76b0 100644 (file)
@@ -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];
This page took 0.026662 seconds and 4 git commands to generate.