summaryrefslogtreecommitdiffstats
path: root/libmount/src/utils.c
diff options
context:
space:
mode:
authorDave Reisner2013-09-17 23:05:09 +0200
committerKarel Zak2013-09-20 10:05:45 +0200
commit4e9f59d1ee293108cd1d577f7b1a182f5b0ac9c0 (patch)
treefdff1db3879d924568925777b6728d8d8c8cd3d0 /libmount/src/utils.c
parentbash-completion: fix typos in mkfs.bfs logic (diff)
downloadkernel-qcow2-util-linux-4e9f59d1ee293108cd1d577f7b1a182f5b0ac9c0.tar.gz
kernel-qcow2-util-linux-4e9f59d1ee293108cd1d577f7b1a182f5b0ac9c0.tar.xz
kernel-qcow2-util-linux-4e9f59d1ee293108cd1d577f7b1a182f5b0ac9c0.zip
libmount: use memmove when overlap possible
When unmounting some mountpoints as an unprivileged user (via the 'user' option in fstab), the umount fails. Debug output of 'umount /opt' reveals: 17760: libmount: CXT: [0x22890e0]: do umount 17760: libmount: UTILS: moving to /opt parent 17760: libmount: CXT: current directory moved to / [last_component='opt'] 17760: libmount: CXT: [0x22890e0]: umount(2) [target='pt', flags=0x00000000] valgrind shows the problem: ==23544== Source and destination overlap in memcpy(0x58d1370, 0x58d1371, 4) ==23544== at 0x4C2BBC3: memcpy@@GLIBC_2.14 (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==23544== by 0x4E537C3: mnt_chdir_to_parent (utils.c:168) ==23544== by 0x4E45E4C: mnt_context_do_umount (context_umount.c:601) ==23544== by 0x4E46513: mnt_context_umount (context_umount.c:855) ==23544== by 0x403476: umount_one (umount.c:299) ==23544== by 0x402B34: main (umount.c:629) ==23544== ref: https://bugs.archlinux.org/task/36968 Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Diffstat (limited to 'libmount/src/utils.c')
-rw-r--r--libmount/src/utils.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/libmount/src/utils.c b/libmount/src/utils.c
index 9f992412f..3cab93644 100644
--- a/libmount/src/utils.c
+++ b/libmount/src/utils.c
@@ -165,7 +165,7 @@ int mnt_chdir_to_parent(const char *target, char **filename)
if (!last || !*last)
memcpy(*filename, ".", 2);
else
- memcpy(*filename, last, strlen(last) + 1);
+ memmove(*filename, last, strlen(last) + 1);
} else
free(buf);
return 0;