Fix: out of bound strcpy
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 18 Jun 2013 19:51:37 +0000 (15:51 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Wed, 19 Jun 2013 18:47:22 +0000 (14:47 -0400)
1019904 Copy into fixed size buffer
In add_context: A source buffer of statically unknown size is copied
into a fixed-size destination buffer (CWE-120)

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
src/bin/lttng/commands/add_context.c

index 45357598362ac9c0fb1c2f031609c0c79fd4ea2b..4904d2772b5181bb835d928595671b456b38f562 100644 (file)
@@ -383,7 +383,9 @@ static int add_context(char *session_name)
                if (context.ctx == LTTNG_EVENT_CONTEXT_PERF_COUNTER) {
                        context.u.perf_counter.type = type->opt->u.perf.type;
                        context.u.perf_counter.config = type->opt->u.perf.config;
-                       strcpy(context.u.perf_counter.name, type->opt->symbol);
+                       strncpy(context.u.perf_counter.name, type->opt->symbol,
+                               LTTNG_SYMBOL_NAME_LEN);
+                       context.u.perf_counter.name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
                        /* Replace : and - by _ */
                        while ((ptr = strchr(context.u.perf_counter.name, '-')) != NULL) {
                                *ptr = '_';
This page took 0.025144 seconds and 4 git commands to generate.