[BusyBox] patch: util-linux/mount.c: long filenames in /etc/fstab
Kevin Hilman
khilman at equator.com
Fri Mar 22 13:44:03 UTC 2002
This patch fixes a problem if there are long pathnames in /etc/fstab.
The 'device' buffer is xmalloc'd using PATH_MAX, but after
simplify_path(), it nolonger points to the xmalloc'd region, instead,
it's pointing to a strdup'd region.
This is fine until later on when this is done:
strcpy(device, m->mnt_fsname);
Which, if m->mnt_fsname is long enough, you get some nice memory
corruption.
--
Kevin Hilman
Equator Technologies
Index: mount.c
===================================================================
RCS file: /var/cvs/busybox/util-linux/mount.c,v
retrieving revision 1.97
diff -c -r1.97 mount.c
*** mount.c 20 Dec 2001 23:13:26 -0000 1.97
--- mount.c 22 Mar 2002 20:34:26 -0000
***************
*** 424,430 ****
if (optind < argc) {
/* if device is a filename get its real path */
if (stat(argv[optind], &statbuf) == 0) {
! device = simplify_path(argv[optind]);
} else {
safe_strncpy(device, argv[optind], PATH_MAX);
}
--- 424,431 ----
if (optind < argc) {
/* if device is a filename get its real path */
if (stat(argv[optind], &statbuf) == 0) {
! char *tmp = simplify_path(argv[optind]);
! safe_strncpy(device, tmp, PATH_MAX);
} else {
safe_strncpy(device, argv[optind], PATH_MAX);
}
More information about the busybox
mailing list