Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 14 Feb 1999 04:48:23 +0100 (CET)
From:      andreas@infosys.heitec.net
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Cc:        gnats@openbsd.org
Subject:   bin/10071: chflags does strange things
Message-ID:  <199902140348.EAA33722@weiden.infosys.heitec.net>

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

>Number:         10071
>Category:       bin
>Synopsis:       flags given to chflags depend on sequence
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Feb 13 20:00:00 PST 1999
>Closed-Date:
>Last-Modified:
>Originator:     Andreas Klussmann
>Release:        FreeBSD 4.0-CURRENT i386 (ctm 5068)
>Organization:
HEITEC Informationssysteme GmbH; Naegelsbachstrasse 26; 91052 Erlangen
>Environment:

	FreeBSD, OpenBSD; perhaps NetBSD
	kern_securelevel_enable set to NO

>Description:

chflags clears all flags supplied on the command line after a clearing flag like dump(!) or noschg, etc.
The error is in /usr/src/bin/ls/stat_flags.c in a loop scanning the arguments. The variable 'clear', which
is used as flag for the prepended 'no' string, is only initialised before the loop begins intead of beeing
reset on every iteration.

>How-To-Repeat:

	# touch /tmp/flags
	# chflags schg,uchg /tmp/flags
	# ls -lo /tmp/flags
	-rwx------  1 root  wheel  uchg,schg 0 Feb 14 04:29 /tmp/flags
	# chflags dump,schg,uchg /tmp/flags
	# ls -lo /tmp/flags
	-rwx------  1 root  wheel  - 0 Feb 14 04:29 /tmp/flags
	# chflags noschg,dump,uchg /tmp/flags
	# ls -lo /tmp/flags
	-rwx------  1 root  wheel  uchg,nodump 0 Feb 14 04:29 /tmp/flags


>Fix:
	
# cd /usr/src/bin/ls
# cvs diff -u
cvs diff: Diffing .
Index: stat_flags.c
===================================================================
RCS file: /home/cvs/src/bin/ls/stat_flags.c,v
retrieving revision 1.9
diff -u -r1.9 stat_flags.c
--- stat_flags.c	1998/01/09 06:14:59	1.9
+++ stat_flags.c	1999/02/14 03:16:31
@@ -118,13 +118,13 @@
 	int clear;
 	char *string, *p;
 
-	clear = 0;
 	if (setp)
 		*setp = 0;
 	if (clrp)
 		*clrp = 0;
 	string = *stringp;
 	while ((p = strsep(&string, "\t ,")) != NULL) {
+		clear = 0;
 		*stringp = p;
 		if (*p == '\0')
 			continue;



>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message



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