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:12 +0200 |
commit | b0f95e3954f85d97a99f8a08645418945484dbca (patch) | |
tree | 8c25a6ae4b1ef9277ad6cbbb3fcb91dfd2444055 | |
parent | 100b8a8814152ca6f52564cb65f33bf7cf033c22 (diff) | |
download | linuxquota-b0f95e3954f85d97a99f8a08645418945484dbca.tar.gz |
common.c: fix strncat usage
When quota is configured using --enable-werror, gcc -flto fails with
the following diagnostics:
In function 'strncat',
inlined from 'sstrncat' at common.c:113:2,
inlined from 'get_proc_num' at quotastats.c:46:2:
/usr/include/bits/string_fortified.h:122:10: error: '__builtin___strncat_chk' specified bound 4096 equals destination size [-Werror=str
ingop-overflow=]
122 | return __builtin___strncat_chk (__dest, __src, __len, __bos (__dest));
| ^
This diagnostics is correct: when "src" contains "len" or more bytes,
strncat() writes "len"+1 bytes to "dest" ("len" from "src" plus
the terminating null byte).
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Jan Kara <jack@suse.cz>
-rw-r--r-- | common.c | 3 |
1 files changed, 1 insertions, 2 deletions
@@ -110,8 +110,7 @@ void sstrncpy(char *d, const char *s, size_t len) void sstrncat(char *d, const char *s, size_t len) { - strncat(d, s, len); - d[len - 1] = 0; + strncat(d, s, len - 1); } char *sstrdup(const char *s) |