pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pkg/37083: pkg_add doesn't handle trailing / in $PKG_PATH



>Number:         37083
>Category:       pkg
>Synopsis:       pkg_add doesn't handle trailing / in $PKG_PATH
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pkg-manager
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Mon Oct 08 19:55:00 +0000 2007
>Originator:     Stathis Kamperis
>Release:        NetBSD 4.0 RC1
>Organization:
Aristotle University of Thessaloniki
>Environment:
NetBSD netbsd 4.0_RC1 NetBSD 4.0_RC1 (MYGENERIC) #0: Wed Sep 26 19:46:42 EEST 
2007  root@netbsd:/usr/obj/sys/arch/i386/compile/MYGENERIC i386

>Description:
pkg_add utility doesn't handle trailing / in $PKG_PATH

If for example we set the PKG_PATH variable to: 
ftp://ftp.fr.netbsd.org/pub/pkgsrc/packages/NetBSD/i386/4.0_2007Q2/All/

and the we call pkg_add, a / will be added to $PKG_PATH and the result will be:

ftp://ftp.fr.netbsd.org/pub/pkgsrc/packages/NetBSD/i386/4.0_2007Q2/All//

>How-To-Repeat:

>Fix:
Here there is a patch:

Index: path.c
===================================================================
RCS file: /cvsroot/src/usr.sbin/pkg_install/lib/Attic/path.c,v
retrieving revision 1.8
diff -u -r1.8 path.c
--- path.c      5 Nov 2005 13:11:02 -0000       1.8
+++ path.c      8 Oct 2007 18:51:00 -0000
@@ -73,6 +73,12 @@
        while (*cp) {
                len = strcspn(cp, ";");
                if (len > 0) {
+                       /* is there any trailing slash ? */
+                       if (cp[len-1] == '/') {
+                               if (Verbose)
+                                       printf("path has trailing slash 
(ignoring it)\n");
+                                len--;
+                        }
                        /* add a new path */
                        struct path *new;

@@ -82,7 +88,7 @@
                        TAILQ_INSERT_TAIL(&PkgPath, new, pl_entry);
                }

-               cp += len;
+               cp += (len != 0 && cp[len-1] == '/') ? len+1 : len;
                if (*cp == '\0')
                        break;
                cp++;


(I tested it and it seemed to work ok, but since I no nothing regarding the 
internals of pkg_install, it may break other code, etc)




Home | Main Index | Thread Index | Old Index