[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    [BusyBox] patch: util-linux/mount.c: long filenames in /etc/fstab
From:       Kevin Hilman <khilman () equator ! com>
Date:       2002-03-22 13:44:03
[Download RAW message or body]

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);
  		}

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic