From vd@datamax.bg  Wed Jan 26 14:27:48 2005
Return-Path: <vd@datamax.bg>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id F164A16A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 26 Jan 2005 14:27:48 +0000 (GMT)
Received: from jengal.datamax.bg (jengal.datamax.bg [82.103.104.21])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 5236843D3F
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 26 Jan 2005 14:27:48 +0000 (GMT)
	(envelope-from vd@datamax.bg)
Received: from sinanica.bg.datamax (sinanica.bg.datamax [192.168.10.1])
	by jengal.datamax.bg (Postfix) with QMQP id D63F687CA
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 26 Jan 2005 16:27:46 +0200 (EET)
Received: (nullmailer pid 59749 invoked by uid 1004);
	Wed, 26 Jan 2005 14:27:46 -0000
Message-Id: <1106749666.788116.59748.nullmailer@sinanica.bg.datamax>
Date: Wed, 26 Jan 2005 16:27:46 +0200
From: Vasil Dimov <vd@datamax.bg>
Reply-To: Vasil Dimov <vd@datamax.bg>
To: FreeBSD-gnats-submit@freebsd.org
Subject: parse error in rm.c:check() while parsing value returned from strmode(3)
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         76711
>Category:       bin
>Synopsis:       [patch] rm(1): 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:  Mon Sep 29 03:31:04 UTC 2008
>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:
Adding to audit trail from misfiled PR bin/76751:

Date: Thu, 27 Jan 2005 15:34:00 +0200
From: Vasil Dimov <vd@datamax.bg>

 Sorry for disturbing you with such a cosmetic things, but either there
 should always be placed one space after modep (which will simplify the code),
 or modep[9] should be replaced with modep[10] as in the included patch.
 Checking if modep[9] is space is really nonsense, isn't it?
>Unformatted:
