diff options
author | Dmitry V. Levin <ldv@altlinux.org> | 2021-09-01 08:00:00 +0000 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2021-09-17 14:04:16 +0200 |
commit | d2256ac2d44b0a5be9c0b49ce4ce8e5f6821ce2a (patch) | |
tree | a4f5e37904635e613736803ff0a7f9a2f18aa11b | |
parent | b0f95e3954f85d97a99f8a08645418945484dbca (diff) | |
download | linuxquota-d2256ac2d44b0a5be9c0b49ce4ce8e5f6821ce2a.tar.gz |
quotasys.c: fix strncpy usage
When quota is configured using --enable-werror, gcc -flto fails with
the following diagnostics:
In function 'strncpy',
inlined from 'sstrncpy' at common.c:107:2,
inlined from 'copy_mntoptarg' at quotasys.c:774:3,
inlined from 'copy_mntoptarg' at quotasys.c:769:13:
/usr/include/bits/string_fortified.h:91:10: error: '__builtin_strncpy' specified bound depends on the length of the source argument [-Werror=stringop-overflow=]
91 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
| ^
quotasys.c: In function 'copy_mntoptarg':
quotasys.c:774:25: note: length computed here
774 | sstrncpy(buf, optarg, min(buflen, strlen(optarg) + 1));
| ^
This diagnostics is correct: strcpy() copies at most "len" bytes of the string
pointed to by "src", including the terminating null byte, to the buffer
pointed to by "dest".
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Jan Kara <jack@suse.cz>
-rw-r--r-- | quotasys.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -771,7 +771,7 @@ static void copy_mntoptarg(char *buf, const char *optarg, int buflen) char *sep = strchr(optarg, ','); if (!sep) - sstrncpy(buf, optarg, min(buflen, strlen(optarg) + 1)); + sstrncpy(buf, optarg, buflen); else sstrncpy(buf, optarg, min(buflen, sep - optarg + 1)); } |