diff options
author | 2020-11-15 19:00:18 -0800 | |
---|---|---|
committer | 2020-11-19 10:17:14 -0500 | |
commit | e50e96a017b7527b7944c18324ac563b551909a8 (patch) | |
tree | a6890ab5ca9822bbab802e85c37b459a38c0e704 | |
parent | 91024cb50b9281ea5d05f0001e8ea11e3f943e78 (diff) | |
download | linux-yocto-v5.2/standard/edgerouter.tar.gz linux-yocto-v5.2/standard/edgerouter.tar.bz2 linux-yocto-v5.2/standard/edgerouter.zip |
ext4: fix -Wstringop-truncation warningsv5.2/standard/tiny/intel-x86v5.2/standard/tiny/common-pcv5.2/standard/tiny/basev5.2/standard/qemuppcv5.2/standard/qemuarm64v5.2/standard/intel-x86v5.2/standard/edgerouterv5.2/standard/beaglebonev5.2/standard/base
The strncpy() function may create a unterminated string,
use strscpy_pad() instead.
This fixes the following warning:
fs/ext4/super.c: In function '__save_error_info':
fs/ext4/super.c:349:2: warning: 'strncpy' specified bound 32 equals destination size [-Wstringop-truncation]
strncpy(es->s_last_error_func, func, sizeof(es->s_last_error_func));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/ext4/super.c:353:3: warning: 'strncpy' specified bound 32 equals destination size [-Wstringop-truncation]
strncpy(es->s_first_error_func, func,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sizeof(es->s_first_error_func));
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Wenlin Kang <wenlin.kang@windriver.com>
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
-rw-r--r-- | fs/ext4/super.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 8f66e4f4256e..19f2e7c77be8 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -365,12 +365,12 @@ static void __save_error_info(struct super_block *sb, const char *func, return; es->s_state |= cpu_to_le16(EXT4_ERROR_FS); ext4_update_tstamp(es, s_last_error_time); - strncpy(es->s_last_error_func, func, sizeof(es->s_last_error_func)); + strscpy_pad(es->s_last_error_func, func, sizeof(es->s_last_error_func)); es->s_last_error_line = cpu_to_le32(line); if (!es->s_first_error_time) { es->s_first_error_time = es->s_last_error_time; es->s_first_error_time_hi = es->s_last_error_time_hi; - strncpy(es->s_first_error_func, func, + strscpy_pad(es->s_first_error_func, func, sizeof(es->s_first_error_func)); es->s_first_error_line = cpu_to_le32(line); es->s_first_error_ino = es->s_last_error_ino; |