mirror of
https://github.com/kdave/btrfs-progs
synced 2024-12-24 15:12:47 +00:00
btrfs-progs: use proper path buffer in __ino_to_path_fd()
Commit d7492ec59e
("btrfs-progs: use on-stack buffer in
__ino_to_path_fd") was supposed to switch path buffer from dynamic
allocation to on-stack but it was done wrong. The btrfs_data_container
is a flexible array so it needs to be explicitly allocated to the right
size.
The conversion turned it to an array. Gcc 13.x started to warn about
access to fspath->val[i] being out of bounds. Fortunately overall size
was 65536 and used only first 4096 bytes.
cmds/inspect.c: In function ‘__ino_to_path_fd’:
cmds/inspect.c:86:35: warning: array subscript i is outside array bounds of ‘__u64[]’ {aka ‘long long unsigned int[]’} [-Warray-bounds=]
86 | ptr += fspath->val[i];
| ~~~~~~~~~~~^~~
In file included from ./kernel-shared/accessors.h:11,
from cmds/inspect.c:35:
./kernel-shared/uapi/btrfs.h:724:17: note: while referencing ‘val’
724 | __u64 val[]; /* out */
Add an on-stack buffer and map it over fspath, similar to the previous
dynamic array.
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
e8c729743a
commit
8d0bfe4c01
@ -60,7 +60,8 @@ static int __ino_to_path_fd(u64 inum, int fd, const char *prepend)
|
||||
int ret;
|
||||
int i;
|
||||
struct btrfs_ioctl_ino_path_args ipa;
|
||||
struct btrfs_data_container fspath[PATH_MAX];
|
||||
char pathbuf[PATH_MAX];
|
||||
struct btrfs_data_container *fspath = (struct btrfs_data_container *)pathbuf;
|
||||
|
||||
memset(fspath, 0, sizeof(*fspath));
|
||||
ipa.inum = inum;
|
||||
|
Loading…
Reference in New Issue
Block a user