Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 26 Jan 2005 16:27:46 +0200
From:      Vasil Dimov <vd@datamax.bg>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   bin/76711: parse error in rm.c:check() while parsing value returned from strmode(3)
Message-ID:  <1106749666.788116.59748.nullmailer@sinanica.bg.datamax>
Resent-Message-ID: <200501261430.j0QEUGs4076144@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         76711
>Category:       bin
>Synopsis:       parse error in rm.c:check() while parsing value returned from strmode(3)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jan 26 14:30:16 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Vasil Dimov
>Release:        FreeBSD 5.3-STABLE i386
>Organization:
DataMax
>Environment:

System: FreeBSD sinanica.bg.datamax 5.3-STABLE FreeBSD 5.3-STABLE #11: Wed Jan 5 09:46:27 EET 2005 root@sinanica.bg.datamax:/usr/src/sys/i386/compile/SINANICA-SMP i386

>Description:
rm's check() function uses strmode(3) to convert file's access bits into a
human-readable text (rw-r--r--).

As the 11th symbol returned from strmode(3) is either '+' or ' ' rm tries
to put additional space in case of '+', or nothing in case of ' '.

Instead of 11th the 10th symbol is checked which is never space -
others-execute-bit's representation is one of x-sStT.

As a result additional space arrives after file's mode string.

>How-To-Repeat:
$ su - root -c "touch /tmp/a"
$ rm /tmp/a
override rw-r--r--  root/wheel for /tmp/a?

(notice the two spaces before root/wheel, irritating?)

>Fix:

--- rm.c.modep.patch begins here ---
--- rm.c.orig	Fri Jan 21 11:46:28 2005
+++ rm.c	Wed Jan 26 15:37:39 2005
@@ -459,10 +459,10 @@
 		if ((flagsp = fflagstostr(sp->st_flags)) == NULL)
 			err(1, "fflagstostr");
 		(void)fprintf(stderr, "override %s%s%s/%s %s%sfor %s? ",
-		    modep + 1, modep[9] == ' ' ? "" : " ",
+		    modep + 1, modep[10] == ' ' ? "" : " ",
 		    user_from_uid(sp->st_uid, 0),
 		    group_from_gid(sp->st_gid, 0),
-		    *flagsp ? flagsp : "", *flagsp ? " " : "", 
+		    *flagsp ? flagsp : "", *flagsp ? " " : "",
 		    path);
 		free(flagsp);
 	}
--- rm.c.modep.patch ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1106749666.788116.59748.nullmailer>