Fix all strncpy() usage: need to set a final \0 character at the end
[lttng-tools.git] / ltt-sessiond / trace.c
index 1509edacdf048e92fef749cad90ac8c30e09af7a..94d3c4946619c8429614b9f091f4000a91dd5ccc 100644 (file)
@@ -138,6 +138,7 @@ struct ltt_kernel_channel *trace_create_kernel_channel(struct lttng_channel *cha
 
        lkc->fd = 0;
        lkc->stream_count = 0;
+       lkc->event_count = 0;
        lkc->enabled = 1;
        lkc->ctx = NULL;
        /* Init linked list */
@@ -182,11 +183,22 @@ struct ltt_kernel_event *trace_create_kernel_event(struct lttng_event *ev)
                attr->u.kprobe.offset = ev->attr.probe.offset;
                strncpy(attr->u.kprobe.symbol_name,
                                ev->attr.probe.symbol_name, LTTNG_SYM_NAME_LEN);
+               attr->u.kprobe.symbol_name[LTTNG_SYM_NAME_LEN - 1] = '\0';
                break;
        case LTTNG_EVENT_FUNCTION:
+               attr->instrumentation = LTTNG_KERNEL_KRETPROBE;
+               attr->u.kretprobe.addr = ev->attr.probe.addr;
+               attr->u.kretprobe.offset = ev->attr.probe.offset;
+               attr->u.kretprobe.offset = ev->attr.probe.offset;
+               strncpy(attr->u.kretprobe.symbol_name,
+                               ev->attr.probe.symbol_name, LTTNG_SYM_NAME_LEN);
+               attr->u.kretprobe.symbol_name[LTTNG_SYM_NAME_LEN - 1] = '\0';
+               break;
+       case LTTNG_EVENT_FUNCTION_ENTRY:
                attr->instrumentation = LTTNG_KERNEL_FUNCTION;
                strncpy(attr->u.ftrace.symbol_name,
                                ev->attr.ftrace.symbol_name, LTTNG_SYM_NAME_LEN);
+               attr->u.ftrace.symbol_name[LTTNG_SYM_NAME_LEN - 1] = '\0';
                break;
        case LTTNG_EVENT_TRACEPOINT:
                attr->instrumentation = LTTNG_KERNEL_TRACEPOINT;
@@ -198,6 +210,7 @@ struct ltt_kernel_event *trace_create_kernel_event(struct lttng_event *ev)
 
        /* Copy event name */
        strncpy(attr->name, ev->name, LTTNG_SYM_NAME_LEN);
+       attr->name[LTTNG_SYM_NAME_LEN - 1] = '\0';
 
        /* Setting up a kernel event */
        lke->fd = 0;
This page took 0.024391 seconds and 4 git commands to generate.