| 
				
			 | 
			
			
				
				@@ -35,7 +35,7 @@ 
			 | 
		
		
	
		
			
			| 
				35
			 | 
			
				35
			 | 
			
			
				
				  * False return value always indicates an error that should abort the 
			 | 
		
		
	
		
			
			| 
				36
			 | 
			
				36
			 | 
			
			
				
				  * transfer. 
			 | 
		
		
	
		
			
			| 
				37
			 | 
			
				37
			 | 
			
			
				
				  */ 
			 | 
		
		
	
		
			
			| 
				38
			 | 
			
				
			 | 
			
			
				
				-static inline int process_tftp_data ( struct tftp_state *state, 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				38
			 | 
			
			
				
				+static inline int tftp_process_data ( struct tftp_state *state, 
			 | 
		
		
	
		
			
			| 
				39
			 | 
			
				39
			 | 
			
			
				
				 				      struct tftp_data *data, 
			 | 
		
		
	
		
			
			| 
				40
			 | 
			
				40
			 | 
			
			
				
				 				      struct buffer *buffer, 
			 | 
		
		
	
		
			
			| 
				41
			 | 
			
				41
			 | 
			
			
				
				 				      int *eof ) { 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -97,18 +97,18 @@ static int tftp ( char *url __unused, struct sockaddr_in *server, char *file, 
			 | 
		
		
	
		
			
			| 
				97
			 | 
			
				97
			 | 
			
			
				
				 	state.server = *server; 
			 | 
		
		
	
		
			
			| 
				98
			 | 
			
				98
			 | 
			
			
				
				 	 
			 | 
		
		
	
		
			
			| 
				99
			 | 
			
				99
			 | 
			
			
				
				 	/* Open the file */ 
			 | 
		
		
	
		
			
			| 
				100
			 | 
			
				
			 | 
			
			
				
				-	if ( ! tftp_open ( &state, file, &reply ) ) { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				100
			 | 
			
			
				
				+	if ( ! tftp_open ( &state, file, &reply, 0 ) ) { 
			 | 
		
		
	
		
			
			| 
				101
			 | 
			
				101
			 | 
			
			
				
				 		DBG ( "TFTP: could not open %@:%d/%s : %m\n", 
			 | 
		
		
	
		
			
			| 
				102
			 | 
			
				102
			 | 
			
			
				
				 		      server->sin_addr.s_addr, server->sin_port, file ); 
			 | 
		
		
	
		
			
			| 
				103
			 | 
			
				103
			 | 
			
			
				
				 		return 0; 
			 | 
		
		
	
		
			
			| 
				104
			 | 
			
				104
			 | 
			
			
				
				 	} 
			 | 
		
		
	
		
			
			| 
				105
			 | 
			
				105
			 | 
			
			
				
				 	 
			 | 
		
		
	
		
			
			| 
				106
			 | 
			
				106
			 | 
			
			
				
				 	/* Fetch file, a block at a time */ 
			 | 
		
		
	
		
			
			| 
				107
			 | 
			
				
			 | 
			
			
				
				-	do { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				107
			 | 
			
			
				
				+	while ( 1 ) { 
			 | 
		
		
	
		
			
			| 
				108
			 | 
			
				108
			 | 
			
			
				
				 		twiddle(); 
			 | 
		
		
	
		
			
			| 
				109
			 | 
			
				109
			 | 
			
			
				
				 		switch ( ntohs ( reply->common.opcode ) ) { 
			 | 
		
		
	
		
			
			| 
				110
			 | 
			
				110
			 | 
			
			
				
				 		case TFTP_DATA: 
			 | 
		
		
	
		
			
			| 
				111
			 | 
			
				
			 | 
			
			
				
				-			if ( ! process_tftp_data ( &state, &reply->data, 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				111
			 | 
			
			
				
				+			if ( ! tftp_process_data ( &state, &reply->data, 
			 | 
		
		
	
		
			
			| 
				112
			 | 
			
				112
			 | 
			
			
				
				 						   buffer, &eof ) ) { 
			 | 
		
		
	
		
			
			| 
				113
			 | 
			
				113
			 | 
			
			
				
				 				tftp_error ( &state, TFTP_ERR_ILLEGAL_OP, 
			 | 
		
		
	
		
			
			| 
				114
			 | 
			
				114
			 | 
			
			
				
				 					     NULL ); 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -138,13 +138,19 @@ static int tftp ( char *url __unused, struct sockaddr_in *server, char *file, 
			 | 
		
		
	
		
			
			| 
				138
			 | 
			
				138
			 | 
			
			
				
				 			tftp_error ( &state, TFTP_ERR_ILLEGAL_OP, NULL ); 
			 | 
		
		
	
		
			
			| 
				139
			 | 
			
				139
			 | 
			
			
				
				 			return 0; 
			 | 
		
		
	
		
			
			| 
				140
			 | 
			
				140
			 | 
			
			
				
				 		} 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				141
			 | 
			
			
				
				+		/* If we have reached EOF, stop here */ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				142
			 | 
			
			
				
				+		if ( eof ) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				143
			 | 
			
			
				
				+			break; 
			 | 
		
		
	
		
			
			| 
				141
			 | 
			
				144
			 | 
			
			
				
				 		/* Fetch the next data block */ 
			 | 
		
		
	
		
			
			| 
				142
			 | 
			
				145
			 | 
			
			
				
				 		if ( ! tftp_ack ( &state, &reply ) ) { 
			 | 
		
		
	
		
			
			| 
				143
			 | 
			
				146
			 | 
			
			
				
				 			DBG ( "TFTP: could not get next block: %m\n" ); 
			 | 
		
		
	
		
			
			| 
				144
			 | 
			
				
			 | 
			
			
				
				-			tftp_error ( &state, TFTP_ERR_ILLEGAL_OP, NULL ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				147
			 | 
			
			
				
				+			if ( ! reply ) { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				148
			 | 
			
			
				
				+				tftp_error ( &state, TFTP_ERR_ILLEGAL_OP, 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				149
			 | 
			
			
				
				+					     NULL ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				150
			 | 
			
			
				
				+			} 
			 | 
		
		
	
		
			
			| 
				145
			 | 
			
				151
			 | 
			
			
				
				 			return 0; 
			 | 
		
		
	
		
			
			| 
				146
			 | 
			
				152
			 | 
			
			
				
				 		} 
			 | 
		
		
	
		
			
			| 
				147
			 | 
			
				
			 | 
			
			
				
				-	} while ( ! eof ); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				153
			 | 
			
			
				
				+	} 
			 | 
		
		
	
		
			
			| 
				148
			 | 
			
				154
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				149
			 | 
			
				155
			 | 
			
			
				
				 	/* ACK the final packet, as a courtesy to the server */ 
			 | 
		
		
	
		
			
			| 
				150
			 | 
			
				156
			 | 
			
			
				
				 	tftp_ack_nowait ( &state ); 
			 |