Source-Changes-HG archive

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

[src/netbsd-1-6]: src/usr.sbin/pkg_install/lib Pull up revisions 1.36-1.38 (r...



details:   https://anonhg.NetBSD.org/src/rev/953713061883
branches:  netbsd-1-6
changeset: 528255:953713061883
user:      lukem <lukem%NetBSD.org@localhost>
date:      Fri Jun 28 12:42:15 2002 +0000

description:
Pull up revisions 1.36-1.38 (requested by taca in ticket #369):
- fix buffer size checks
- define PKG_PATTEN_MAX and PKG_SUFFIX_MAX and
  use them instead of constants like 255.
- add asserts and buffer size checks.
- constify and make WARNS=2 clean.
- Fixes provided by Stoned Elipot <seb%script.jussieu.fr@localhost> in PR 17323

diffstat:

 usr.sbin/pkg_install/lib/ftpio.c |  35 +++++++++++++++++++----------------
 1 files changed, 19 insertions(+), 16 deletions(-)

diffs (95 lines):

diff -r 1f1f251a3f06 -r 953713061883 usr.sbin/pkg_install/lib/ftpio.c
--- a/usr.sbin/pkg_install/lib/ftpio.c  Fri Jun 28 12:42:06 2002 +0000
+++ b/usr.sbin/pkg_install/lib/ftpio.c  Fri Jun 28 12:42:15 2002 +0000
@@ -1,8 +1,8 @@
-/*     $NetBSD: ftpio.c,v 1.35 2002/04/23 10:14:59 hubertf Exp $       */
+/*     $NetBSD: ftpio.c,v 1.35.2.1 2002/06/28 12:42:15 lukem Exp $     */
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: ftpio.c,v 1.35 2002/04/23 10:14:59 hubertf Exp $");
+__RCSID("$NetBSD: ftpio.c,v 1.35.2.1 2002/06/28 12:42:15 lukem Exp $");
 #endif
 
 /*
@@ -102,7 +102,7 @@
     int done;
     struct timeval timeout;
     int retval;
-    regmatch_t pmatch;
+    regmatch_t match;
     int verbose_expect=0;
 
 #if EXPECT_DEBUG
@@ -179,15 +179,15 @@
            }
 #endif /* EXPECT_DEBUG */
 
-           if (regexec(&rstr, buf, 1, &pmatch, 0) == 0) {
+           if (regexec(&rstr, buf, 1, &match, 0) == 0) {
 #if EXPECT_DEBUG
                if (expect_debug)
-                   printf("Gotcha -> %s!\n", buf+pmatch.rm_so+1);
+                   printf("Gotcha -> %s!\n", buf+match.rm_so+1);
                fflush(stdout);
 #endif /* EXPECT_DEBUG */
 
-               if (ftprc && isdigit(buf[pmatch.rm_so+1])) 
-                   *ftprc = atoi(buf+pmatch.rm_so+1);
+               if (ftprc && isdigit(buf[match.rm_so+1])) 
+                   *ftprc = atoi(buf+match.rm_so+1);
 
                done=1;
                retval=0;
@@ -297,7 +297,7 @@
            
            if (Verbose)
                    fprintf(stderr, "ftp -detv %s\n", base);
-           rc1 = execl("/usr/bin/ftp", "ftp", "-detv", base, NULL);
+           rc1 = execl(FTP_FULLPATHNAME, FTP_CMD, "-detv", base, NULL);
            warn("setupCoproc: execl() failed");
            exit(1);
            break;
@@ -361,7 +361,7 @@
 #if defined(__svr4__) && defined(__sun__)
        char    env[BUFSIZ];
 #endif
-       char *tmp1, *tmp2;
+       const char *tmp1, *tmp2;
        
        if (!ftp_started)
                return;
@@ -398,15 +398,19 @@
 int
 ftp_start(char *base)
 {
-       char *tmp1, *tmp2;
+       const char *tmp1, *tmp2;
        int rc;
-       char newHost[256];
-       char newDir[1024];
-       char *currentHost=getenv(PKG_FTPIO_CURRENTHOST);
-       char *currentDir=getenv(PKG_FTPIO_CURRENTDIR);
+       char newHost[MAXHOSTNAMELEN];
+       const char *newDir;
+       const char *currentHost=getenv(PKG_FTPIO_CURRENTHOST);
+       const char *currentDir=getenv(PKG_FTPIO_CURRENTDIR);
+       int urllen;
        
        fileURLHost(base, newHost, sizeof(newHost));
-       strcpy(newDir, strchr(base+URLlength(base), '/') + 1);
+       urllen = URLlength(base);
+       if (urllen < 0 || !(newDir = strchr(base + URLlength(base), '/')))
+               errx(1, "ftp_start: bad URL '%s'", base);
+       newDir++;
        if (currentHost
            && currentDir
            && ( strcmp(newHost, currentHost) != 0
@@ -633,7 +637,6 @@
 
        {
                /* Verify if the url is really ok */
-               int rc;
                char exp[FILENAME_MAX];
 
                rc=expandURL(exp, url);



Home | Main Index | Thread Index | Old Index