Skip to content

Commit e34e8d4

Browse files
compudjjgalar
authored andcommitted
Fix: illegal memory access in _cmd_enable_event
Found by Coverity: CID 1321742 (#1 of 2): Buffer not null terminated (BUFFER_SIZE_WARNING)21. buffer_size_warning: Calling strncpy with a maximum size argument of 256 bytes on destination array attr->name of size 256 bytes might leave the destination string unterminated. CID 1321742 (#2 of 2): Buffer not null terminated (BUFFER_SIZE_WARNING)22. buffer_size_warning: Calling strncpy with a maximum size argument of 256 bytes on destination array attr->name of size 256 bytes might leave the destination string unterminated. Signed-off-by: Mathieu Desnoyers <[email protected]> Signed-off-by: Jérémie Galarneau <[email protected]>
1 parent dfbb327 commit e34e8d4

File tree

1 file changed

+12
-2
lines changed
  • src/bin/lttng-sessiond

1 file changed

+12
-2
lines changed

src/bin/lttng-sessiond/cmd.c

+12-2
Original file line numberDiff line numberDiff line change
@@ -1853,7 +1853,12 @@ static int _cmd_enable_event(struct ltt_session *session,
18531853
ret = LTTNG_ERR_FATAL;
18541854
goto error;
18551855
}
1856-
strncpy(attr->name, channel_name, sizeof(attr->name));
1856+
if (lttng_strncpy(attr->name, channel_name,
1857+
sizeof(attr->name))) {
1858+
ret = LTTNG_ERR_INVALID;
1859+
free(attr);
1860+
goto error;
1861+
}
18571862

18581863
ret = cmd_enable_channel(session, domain, attr, wpipe);
18591864
if (ret != LTTNG_OK) {
@@ -1990,7 +1995,12 @@ static int _cmd_enable_event(struct ltt_session *session,
19901995
ret = LTTNG_ERR_FATAL;
19911996
goto error;
19921997
}
1993-
strncpy(attr->name, channel_name, sizeof(attr->name));
1998+
if (lttng_strncpy(attr->name, channel_name,
1999+
sizeof(attr->name))) {
2000+
ret = LTTNG_ERR_INVALID;
2001+
free(attr);
2002+
goto error;
2003+
}
19942004

19952005
ret = cmd_enable_channel(session, domain, attr, wpipe);
19962006
if (ret != LTTNG_OK) {

0 commit comments

Comments
 (0)