Commit 8baa12d
committed
Fix -Werror=stringop-truncation errors
In the lib/vhd code:
In function 'safe_strncpy',
inlined from 'vhd_initialize_footer' at libvhd.c:2882:2:
include/util.h:46:17: error: 'strncpy' output truncated before terminating nul copying 3 bytes from a string of the same length [-Werror=stringop-truncation]
46 | pdest = strncpy(dest, src, n - 1);
In the lvm code twice:
In function 'safe_strncpy',
inlined from 'lvm_copy_name' at lvm-util.c:71:2,
inlined from 'lvm_scan_lvs' at lvm-util.c:289:9:
include/util.h:46:17: error: 'strncpy' output may be truncated copying 255 bytes from a string of length 255 [-Werror=stringop-truncation]
46 | pdest = strncpy(dest, src, n - 1);
For VHD, just set the footer bytes individually and avoid the string
ops.
For LVM, switching back to strncpy and providing the full destination
size silences the errors. strncpy does NUL terminate the string - it
just may truncate. (safe_strncpy silences many other instances of
stringop-truncation like:
"error: 'strncpy' specified bound 1024 equals destination size", so we
want to keep it.)
Signed-off-by: Jason Andryuk <jandryuk@gmail.com>1 parent 1594437 commit 8baa12d
2 files changed
+7
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
| 105 | + | |
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| |||
286 | 286 | | |
287 | 287 | | |
288 | 288 | | |
289 | | - | |
| 289 | + | |
290 | 290 | | |
291 | 291 | | |
292 | 292 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2879 | 2879 | | |
2880 | 2880 | | |
2881 | 2881 | | |
2882 | | - | |
| 2882 | + | |
| 2883 | + | |
| 2884 | + | |
| 2885 | + | |
2883 | 2886 | | |
2884 | 2887 | | |
2885 | 2888 | | |
| |||
0 commit comments