Subject: pkg/11352: pkg_delete incorrectly handles directories containing percent (%)
To: None <>
From: Brook Milligan <>
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
>Originator:     Brook Milligan
>Release:        pkgsrc-20001031
Brook G. Milligan                      Internet:
Department of Biology
New Mexico State University            Telephone:  (505) 646-7980
Las Cruces, New Mexico  88003  U.S.A.  FAX:        (505) 646-5665
System: NetBSD 1.4 NetBSD 1.4 (BIOLOGY) #0: Tue Nov 23 11:51:18 MST 1999 i386

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> ...
				*bufp++ = *fmt;

Consequently, filenames with a percent are modified incorrectly (e.g.,
XXX%YYY is transformed to XXXYYY) and the subsequent commands fail.
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.
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 @@
+				*bufp++ = '%';
 				*bufp++ = *fmt;