mirror of
https://github.com/kdave/btrfs-progs
synced 2025-04-30 06:57:55 +00:00
btrfs-progs: prevent incorrect use of subvol_strip_mountpoint
Add additional bound checks to prevent memory corruption on incorrect usage of subvol_strip_mountpoint. Assert sane return value by properly comparing the mount point to the full_path before stripping it off. Mitigates issue: "btrfs send -p" fails if source and parent subvolumes are on different mountpoints (memory corruption): https://github.com/kdave/btrfs-progs/issues/96 Note that this does not properly fix this bug, but prevents a possible security issue by unexpected usage of "btrfs send -p". Issue: #96 Pull-request: #98 Signed-off-by: Axel Burri <axel@tty0.ch> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
d62bd38079
commit
c5dc299aff
5
utils.c
5
utils.c
@ -2484,6 +2484,11 @@ const char *subvol_strip_mountpoint(const char *mnt, const char *full_path)
|
|||||||
if (!len)
|
if (!len)
|
||||||
return full_path;
|
return full_path;
|
||||||
|
|
||||||
|
if ((strncmp(mnt, full_path, len) != 0) || (full_path[len] != '/')) {
|
||||||
|
error("not on mount point: %s", mnt);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
if (mnt[len - 1] != '/')
|
if (mnt[len - 1] != '/')
|
||||||
len += 1;
|
len += 1;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user