FreeBSD/libexec/tftpd/tftpd.c
/*
 * WRQ - receive a file from the client
 */
receive a file from the client
receive a file from the client
void
tftp_wrq(int peer, char *recvbuffer, ssize_t size)
{
	char *cp;
	int has_options = 0, ecode;
	char *filename, *mode;
	char fnbuf[PATH_MAX];
	cp = parse_header(peer, recvbuffer, size, &filename, &mode);
	size -= (cp - recvbuffer) + 1;
	strcpy(fnbuf, filename);
	reduce_path(fnbuf);
	filename = fnbuf;
	if (size > 0) {
		if (options_rfc_enabled)
			has_options = !parse_options(peer, cp, size);
		else
			tftp_log(LOG_INFO, "Options found but not enabled");
	}
	ecode = validate_access(peer, &filename, WRQ);
	if (ecode == 0) {
		if (has_options)
			send_oack(peer);
		else
			send_ack(peer, 0);
	}
	if (logging) {
		tftp_log(LOG_INFO, "%s: write request for %s: %s", peername,
			    filename, errtomsg(ecode));
	}
	tftp_recvfile(peer, mode);
	exit(0);
}
void tftp_wrq ( int peer , char * recvbuffer , ssize_t size ) { char * cp ; int has_options = 0 , ecode ; char * filename , * mode ; char fnbuf [ PATH_MAX ] ; cp = parse_header ( peer , recvbuffer , size , & filename , & mode ) ; size -= ( cp - recvbuffer ) + 1 ; strcpy ( fnbuf , filename ) ; reduce_path ( fnbuf ) ; filename = fnbuf ; if ( size > 0 ) { if ( options_rfc_enabled ) has_options = ! parse_options ( peer , cp , size ) ; else tftp_log ( LOG_INFO , " " ) ; } ecode = validate_access ( peer , & filename , WRQ ) ; if ( ecode == 0 ) { if ( has_options ) send_oack ( peer ) ; else send_ack ( peer , 0 ) ; } if ( logging ) { tftp_log ( LOG_INFO , " " , peername , filename , errtomsg ( ecode ) ) ; } tftp_recvfile ( peer , mode ) ; exit ( 0 ) ; }
WRQ - receive a file from the client
WRQ - receive a file from the client