strlcat(cp, ensure_tgz(spec), sizeof(fname));
strlcat(fname, ensure_tgz(spec), sizeof(fname));
fileGetURL(char *base, char *spec){    char host[MAXHOSTNAMELEN], file[FILENAME_MAX];    char *cp, *rp;    char fname[FILENAME_MAX];    char pen[FILENAME_MAX];    FILE *ftp;    pid_t tpid;    int i, status;    char *hint;    rp = NULL;    /* Special tip that sysinstall left for us */    hint = getenv("PKG_ADD_BASE");    if (!isURL(spec)) {	if (!base && !hint)	    return NULL;	/* We've been given an existing URL (that's known-good) and now we need	   to construct a composite one out of that and the basename we were	   handed as a dependency. */	if (base) {	    strlcpy(fname, base, sizeof(fname));	    /* OpenBSD packages are currently stored in a flat space, so	       we don't yet need to backup the category and switch to all.	     */	    cp = strrchr(fname, '/');	    if (cp) {		*(cp + 1) = '\0';		strlcat(cp, ensure_tgz(spec), sizeof(fname));	    }	    else		return NULL;	}	else {	    /* Otherwise, we've been given an environment variable hinting at the right location from sysinstall */	    snprintf(fname, sizeof(fname), "%s%s", hint, spec);	}    }    else	strlcpy(fname, spec, sizeof(fname));    cp = fileURLHost(fname, host, sizeof(host));    if (!*cp) {	pwarnx("URL `%s' has bad host part!", fname);	return NULL;    }    cp = fileURLFilename(fname, file, sizeof(fname));    if (!*cp) {	pwarnx("URL `%s' has bad filename part!", fname);	return NULL;    }    if (Verbose)	printf("Trying to fetch %s.\n", fname);    ftp = ftpGetURL(fname, &status);    if (ftp) {	pen[0] = '\0';	if ((rp = make_playpen(pen, sizeof(pen), 0)) != NULL) {            rp=strdup(pen); /* be safe for nested calls */	    if (Verbose)		printf("Extracting from FTP connection into %s\n", pen);	    tpid = fork();	    if (!tpid) {		dup2(fileno(ftp), 0);		i = execl("/bin/tar", "tar", Verbose ? "-xpzvf" : "-xpzf", "-", (char *)NULL);		exit(i);	    }	    else {		int pstat;		fclose(ftp);		tpid = waitpid(tpid, &pstat, 0);		if (Verbose)		    printf("tar command returns %d status\n", WEXITSTATUS(pstat));	    }	}	else	    printf("Error: Unable to construct a new playpen for FTP!\n");	fclose(ftp);    }    else	printf("Error: FTP Unable to get %s: %s\n",	       fname,	       status ? "Error while performing FTP" :	       hstrerror(h_errno));    return rp;}