diff options
author | Maciej Słodczyk <m.slodczyk2@partner.samsung.com> | 2020-05-27 13:00:25 +0200 |
---|---|---|
committer | Maciej Słodczyk <m.slodczyk2@partner.samsung.com> | 2020-06-01 13:30:05 +0200 |
commit | efc76d963073c094d7f5ab0f6a86f5a40b6a14da (patch) | |
tree | 005297a2d454004aae365cc7ad7814222e179773 | |
parent | 7bcccb7b32f562f61e08fafe9675804c1811ede4 (diff) | |
download | resourced-headless-accepted/tizen_6.0_unified.tar.gz resourced-headless-accepted/tizen_6.0_unified.tar.bz2 resourced-headless-accepted/tizen_6.0_unified.zip |
avoid truncate string warning when copyingtizen_6.5.m2_releasetizen_6.0.m2_releasesubmit/tizen_6.5/20211028.162501submit/tizen_6.0_hotfix/20201103.114805submit/tizen_6.0_hotfix/20201102.192505submit/tizen_6.0/20201029.205105submit/tizen/20200602.140231accepted/tizen/unified/20200603.150029accepted/tizen/6.5/unified/20211028.115523accepted/tizen/6.0/unified/hotfix/20201103.001611accepted/tizen/6.0/unified/20201030.113614tizen_6.5tizen_6.0_hotfixtizen_6.0tizenaccepted/tizen_unifiedaccepted/tizen_6.5_unifiedaccepted/tizen_6.0_unified_hotfixaccepted/tizen_6.0_unified
Deliberately copying substring with strncpy() resulted
in 'output may be truncated' warning. Use memcpy()
to achieve the same without the warning.
Change-Id: I8759159e9dd823e78001d4812c52cf2e8588c4e0
Signed-off-by: Maciej Słodczyk <m.slodczyk2@partner.samsung.com>
-rw-r--r-- | src/common/procfs.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/common/procfs.c b/src/common/procfs.c index 12698cb..b59ed93 100644 --- a/src/common/procfs.c +++ b/src/common/procfs.c @@ -460,7 +460,7 @@ API int procfs_get_pid_stat(pid_t pid, struct procfs_pid_stat *pps) { FILE *fp = NULL; char buf[BUF_SIZE]; - char comm[BUF_SIZE]; + char comm[BUF_SIZE] = {}; if (pid < 1 || !pps) { _E("Invalid parameter"); @@ -484,7 +484,7 @@ API int procfs_get_pid_stat(pid_t pid, struct procfs_pid_stat *pps) fclose(fp); return -ENOENT; } - strncpy(pps->comm, comm, COMM_SIZE - 1); + memcpy(pps->comm, comm, COMM_SIZE - 1); pps->comm[COMM_SIZE - 1] = '\0'; fclose(fp); |