summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_install/lib
diff options
context:
space:
mode:
authoryamt <yamt@NetBSD.org>2002-06-09 03:38:59 +0000
committeryamt <yamt@NetBSD.org>2002-06-09 03:38:59 +0000
commitae85a7c2dfaf265462866fb00a2b1d45a1213f75 (patch)
tree982db53b19592119157ab949d20ddd683c76d9b4 /usr.sbin/pkg_install/lib
parentf214a6095eb5ec916b6f8522740594695fcb1e1c (diff)
- constify.
- avoid unneeded strcpy. - add more error checks. (avoid segv
Diffstat (limited to 'usr.sbin/pkg_install/lib')
-rw-r--r--usr.sbin/pkg_install/lib/ftpio.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/usr.sbin/pkg_install/lib/ftpio.c b/usr.sbin/pkg_install/lib/ftpio.c
index 936bc445838..e769ca1c8bd 100644
--- a/usr.sbin/pkg_install/lib/ftpio.c
+++ b/usr.sbin/pkg_install/lib/ftpio.c
@@ -1,8 +1,8 @@
-/* $NetBSD: ftpio.c,v 1.35 2002/04/23 10:14:59 hubertf Exp $ */
+/* $NetBSD: ftpio.c,v 1.36 2002/06/09 03:38:59 yamt 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.36 2002/06/09 03:38:59 yamt Exp $");
#endif
/*
@@ -361,7 +361,7 @@ ftp_stop(void)
#if defined(__svr4__) && defined(__sun__)
char env[BUFSIZ];
#endif
- char *tmp1, *tmp2;
+ const char *tmp1, *tmp2;
if (!ftp_started)
return;
@@ -398,15 +398,19 @@ ftp_stop(void)
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