lnstools

Linux namespace tools
git clone https://ccx.te2000.cz/git/lnstools
Log | Files | Refs | README

commit 82ca453321d2fdae8230fd3abf2e834de5240f2e
parent a92aafd1ac414e6276b010015dfc0f80cfc40d1a
Author: Jan Pobrislo <ccx@te2000.cz>
Date:   Fri, 12 Dec 2025 02:08:20 +0000

fix off-by-one in path intersection length

Diffstat:
Msrc/lns-lockdown_main.c | 13++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/lns-lockdown_main.c b/src/lns-lockdown_main.c @@ -65,15 +65,14 @@ void pivot_and_umount( char const *const put_old, struct unexport_s *const unex ) { - size_t newroot_len = 0; - for(size_t char_n=0; new_root[char_n]; char_n++) { - if(new_root[char_n] != put_old[char_n]) { + size_t newroot_len; + for(newroot_len=0; new_root[newroot_len]; newroot_len++) { + if(new_root[newroot_len] != put_old[newroot_len]) { strerr_dief1x(100, "first path is not prefix of second path"); } - if(char_n > PATH_MAX) { + if(newroot_len > PATH_MAX) { strerr_dief1x(111, "realpath() returned invalid string"); } - newroot_len = char_n; } if(newroot_len == 0) { strerr_dief1x(111, "got empty path?"); @@ -128,11 +127,11 @@ void pivot_and_umount( break; case EBUSY: if (umount2(sa_mtp.s, MNT_DETACH)) { - strerr_diefu2sys(111, "to detach mountpoint", sa_mtp.s) ; + strerr_diefu2sys(111, "to detach mountpoint: ", sa_mtp.s) ; } break; default: - strerr_diefu2sys(111, "to umount", sa_mtp.s) ; + strerr_diefu2sys(111, "to umount: ", sa_mtp.s) ; break; } }