Ver código fonte

Check for correct block number in tftp_rx_data().

(Problem observed by Clay McClure in VMware Fusion.)
tags/v0.9.3
Michael Brown 17 anos atrás
pai
commit
972f293e46
1 arquivos alterados com 9 adições e 1 exclusões
  1. 9
    1
      src/net/udp/tftp.c

+ 9
- 1
src/net/udp/tftp.c Ver arquivo

@@ -415,7 +415,7 @@ static int tftp_rx_oack ( struct tftp_request *tftp, void *buf, size_t len ) {
415 415
 static int tftp_rx_data ( struct tftp_request *tftp,
416 416
 			  struct io_buffer *iobuf ) {
417 417
 	struct tftp_data *data = iobuf->data;
418
-	unsigned int block;
418
+	int block;
419 419
 	size_t data_len;
420 420
 	int rc;
421 421
 
@@ -432,6 +432,14 @@ static int tftp_rx_data ( struct tftp_request *tftp,
432 432
 	iob_pull ( iobuf, sizeof ( *data ) );
433 433
 	data_len = iob_len ( iobuf );
434 434
 
435
+	/* Check for correct block */
436
+	if ( block != ( tftp->state + 1 ) ) {
437
+		DBGC ( tftp, "TFTP %p received out-of-order block %d "
438
+		       "(expecting %d)\n", tftp, block, ( tftp->state + 1 ) );
439
+		free_iob ( iobuf );
440
+		return 0;
441
+	}
442
+
435 443
 	/* Deliver data */
436 444
 	if ( ( rc = xfer_deliver_iob ( &tftp->xfer, iobuf ) ) != 0 ) {
437 445
 		DBGC ( tftp, "TFTP %p could not deliver data: %s\n",

Carregando…
Cancelar
Salvar