View | Details | Raw Unified | Return to bug 13092
Collapse All | Expand All

(-)/tmp/fetch/Makefile (-1 / +1 lines)
Lines 1-5 Link Here
1
PROG = fetch
1
PROG = fetch
2
SRCS = file.c ftp.c http.c main.c util.c uri.c
2
SRCS = fetch.h file.c ftp.c http.c main.c util.c uri.c
3
3
4
CFLAGS+=	-Wall -Wwrite-strings -Wmissing-prototypes
4
CFLAGS+=	-Wall -Wwrite-strings -Wmissing-prototypes
5
5
(-)/tmp/fetch/fetch.h (+3 lines)
Lines 37-42 Link Here
37
#define	FETCH_VERSION "fetch/1.0"
37
#define	FETCH_VERSION "fetch/1.0"
38
#define PATH_CP "/bin/cp"
38
#define PATH_CP "/bin/cp"
39
39
40
#define DEFAULT_FTP_PORT 21
41
#define DEFAULT_HTTP_PORT 80
42
40
struct fetch_state {
43
struct fetch_state {
41
	const char *fs_status;
44
	const char *fs_status;
42
	const char *fs_outputfile;
45
	const char *fs_outputfile;
(-)/tmp/fetch/ftp.c (-4 / +5 lines)
Lines 117-123 Link Here
117
117
118
		port = ul;
118
		port = ul;
119
	} else {
119
	} else {
120
		port = 21;
120
		port = DEFAULT_FTP_PORT;
121
	}
121
	}
122
122
123
	p = slash + 1;
123
	p = slash + 1;
Lines 253-259 Link Here
253
	hostname = getenv("FTP_PROXY");
253
	hostname = getenv("FTP_PROXY");
254
	port = strchr(hostname, ':');
254
	port = strchr(hostname, ':');
255
	if (port == 0) {
255
	if (port == 0) {
256
		portno = 21;
256
		portno = DEFAULT_FTP_PORT;
257
	} else {
257
	} else {
258
		unsigned long ul;
258
		unsigned long ul;
259
		char *ep;
259
		char *ep;
Lines 289-300 Link Here
289
	user = ftps->ftp_user ? ftps->ftp_user : "anonymous";
289
	user = ftps->ftp_user ? ftps->ftp_user : "anonymous";
290
	/* user @ hostname [ @port ] \0 */
290
	/* user @ hostname [ @port ] \0 */
291
	newuser = safe_malloc(strlen(user) + 1 + strlen(ftps->ftp_hostname)
291
	newuser = safe_malloc(strlen(user) + 1 + strlen(ftps->ftp_hostname)
292
			      + ((ftps->ftp_port != 21) ? 6 : 0) + 1);
292
			      + ((ftps->ftp_port != DEFAULT_FTP_PORT) ? 6 : 0)
293
			      + 1);
293
294
294
	strcpy(newuser, user);
295
	strcpy(newuser, user);
295
	strcat(newuser, "@");
296
	strcat(newuser, "@");
296
	strcat(newuser, ftps->ftp_hostname);
297
	strcat(newuser, ftps->ftp_hostname);
297
	if (ftps->ftp_port != 21) {
298
	if (ftps->ftp_port != DEFAULT_FTP_PORT) {
298
		char numbuf[6];
299
		char numbuf[6];
299
300
300
		snprintf(numbuf, sizeof(numbuf), "%d", ftps->ftp_port);
301
		snprintf(numbuf, sizeof(numbuf), "%d", ftps->ftp_port);
(-)/tmp/fetch/http.c (-2 / +4 lines)
Lines 179-185 Link Here
179
179
180
		port = ul;
180
		port = ul;
181
	} else {
181
	} else {
182
		port = 80;
182
		port = DEFAULT_HTTP_PORT;
183
	}
183
	}
184
184
185
	p = slash;
185
	p = slash;
Lines 476-482 Link Here
476
	memset(&sin, 0, sizeof sin);
476
	memset(&sin, 0, sizeof sin);
477
	sin.sin_family = AF_INET;
477
	sin.sin_family = AF_INET;
478
	sin.sin_len = sizeof sin;
478
	sin.sin_len = sizeof sin;
479
	sin.sin_port = htons(https->http_port);
479
	sin.sin_port = htons(https->http_port != 0
480
				? https->http_port
481
				: DEFAULT_HTTP_PORT);
480
482
481
	fs->fs_status = "looking up hostname";
483
	fs->fs_status = "looking up hostname";
482
	if (inet_aton(https->http_hostname, &sin.sin_addr) == 0) {
484
	if (inet_aton(https->http_hostname, &sin.sin_addr) == 0) {

Return to bug 13092