Subject: pkg/11352: pkg_delete incorrectly handles directories containing percent (%)
To: None <gnats-bugs@gnats.netbsd.org>
From: Brook Milligan <brook@biology.nmsu.edu>
List: netbsd-bugs
Date: 10/31/2000 13:46:14
>Number: 11352
>Category: pkg
>Synopsis: pkg_delete incorrectly handles directories containing percent (%)
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: pkg-manager
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Oct 31 13:46:00 PST 2000
>Closed-Date:
>Last-Modified:
>Originator: Brook Milligan
>Release: pkgsrc-20001031
>Organization:
Brook G. Milligan Internet: brook@nmsu.edu
Department of Biology
New Mexico State University Telephone: (505) 646-7980
Las Cruces, New Mexico 88003 U.S.A. FAX: (505) 646-5665
>Environment:
System: NetBSD biology.nmsu.edu 1.4 NetBSD 1.4 (BIOLOGY) #0: Tue Nov 23 11:51:18 MST 1999 root@biology.nmsu.edu:/usr/src/sys/arch/i386/compile/BIOLOGY i386
>Description:
pkg_add/delete will not execute commands correctly if filenames
include a percent sign (%). This is a sideeffect of how format_cmd()
(in lib/file.c) rewrites names. It is intended that %D/%F/%B/%f are
replaced by appropriate strings. However, it is also true that single
percent signs (%) are silently dropped from the filenames. The
relevant code fragment is
if (*fmt == '%') {
switch (*++fmt) {
... <F/D/B/f cases deleted> ...
default:
*bufp++ = *fmt;
break;
}
++fmt;
}
Consequently, filenames with a percent are modified incorrectly (e.g.,
XXX%YYY is transformed to XXXYYY) and the subsequent commands fail.
>How-To-Repeat:
Construct a PLIST with a command like @unexec rmdir "%D/path/XXX%YYY"
and observe that this command is transformed into rmdir
%D/path/XXXYYY. Note that this type of line may not normally be part
of NetBSD packages PLISTs, but lines like this are created by rpm2pkg.
>Fix:
Apply the following patch:
--- pkg_install/lib/file.c.orig Sun Jul 23 16:42:43 2000
+++ pkg_install/lib/file.c Tue Oct 31 14:27:08 2000
@@ -699,6 +699,7 @@
break;
default:
+ *bufp++ = '%';
*bufp++ = *fmt;
break;
}
>Release-Note:
>Audit-Trail:
>Unformatted: