Skip to content

Commit

Permalink
Fix: illegal memory access in cmd_snapshot_record
Browse files Browse the repository at this point in the history
Found by Coverity:
CID 1243027 (#1 of 1): Buffer not null terminated
(BUFFER_SIZE_WARNING)20. buffer_size_warning: Calling strncpy with a
maximum size argument of 255 bytes on destination array tmp_output.name
of size 255 bytes might leave the destination string unterminated.

Signed-off-by: Mathieu Desnoyers <[email protected]>
Signed-off-by: Jérémie Galarneau <[email protected]>
  • Loading branch information
compudj authored and jgalar committed May 17, 2016
1 parent 35f3ec9 commit cf3e357
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/bin/lttng-sessiond/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3903,8 +3903,12 @@ int cmd_snapshot_record(struct ltt_session *session,

/* Use temporary name. */
if (*output->name != '\0') {
strncpy(tmp_output.name, output->name,
sizeof(tmp_output.name));
if (lttng_strncpy(tmp_output.name, output->name,
sizeof(tmp_output.name))) {
ret = LTTNG_ERR_INVALID;
rcu_read_unlock();
goto error;
}
}

tmp_output.nb_snapshot = session->snapshot.nb_snapshot;
Expand Down

0 comments on commit cf3e357

Please sign in to comment.