From: Jérémie Galarneau Date: Mon, 4 Jun 2018 15:27:37 +0000 (-0400) Subject: Replace strncpy by lttng_strncpy in lttngctl session configuration API X-Git-Tag: v2.11.0-rc1~190 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=3716477e44a520ac4a0c65b15c63a1bb56c37ec3;p=lttng-tools.git Replace strncpy by lttng_strncpy in lttngctl session configuration API Signed-off-by: Jérémie Galarneau --- diff --git a/src/lib/lttng-ctl/load.c b/src/lib/lttng-ctl/load.c index e70a87d92..0f9ccfa0e 100644 --- a/src/lib/lttng-ctl/load.c +++ b/src/lib/lttng-ctl/load.c @@ -195,7 +195,12 @@ int lttng_load_session_attr_set_session_name( goto error; } - strncpy(attr->session_name, session_name, len); + ret = lttng_strncpy(attr->session_name, session_name, + sizeof(attr->session_name)); + if (ret) { + ret = -LTTNG_ERR_INVALID; + goto error; + } } else { attr->session_name[0] = '\0'; } diff --git a/src/lib/lttng-ctl/save.c b/src/lib/lttng-ctl/save.c index 555006d0a..830222664 100644 --- a/src/lib/lttng-ctl/save.c +++ b/src/lib/lttng-ctl/save.c @@ -99,7 +99,12 @@ int lttng_save_session_attr_set_session_name( goto error; } - strncpy(attr->session_name, session_name, len); + ret = lttng_strncpy(attr->session_name, session_name, + sizeof(attr->session_name)); + if (ret) { + ret = -LTTNG_ERR_INVALID; + goto error; + } } else { attr->session_name[0] = '\0'; }