瀏覽代碼

Check for correct block number in tftp_rx_data().

(Problem observed by Clay McClure in VMware Fusion.)
tags/v0.9.3
Michael Brown 18 年之前
父節點
當前提交
972f293e46
共有 1 個文件被更改,包括 9 次插入1 次删除
  1. 9
    1
      src/net/udp/tftp.c

+ 9
- 1
src/net/udp/tftp.c 查看文件

415
 static int tftp_rx_data ( struct tftp_request *tftp,
415
 static int tftp_rx_data ( struct tftp_request *tftp,
416
 			  struct io_buffer *iobuf ) {
416
 			  struct io_buffer *iobuf ) {
417
 	struct tftp_data *data = iobuf->data;
417
 	struct tftp_data *data = iobuf->data;
418
-	unsigned int block;
418
+	int block;
419
 	size_t data_len;
419
 	size_t data_len;
420
 	int rc;
420
 	int rc;
421
 
421
 
432
 	iob_pull ( iobuf, sizeof ( *data ) );
432
 	iob_pull ( iobuf, sizeof ( *data ) );
433
 	data_len = iob_len ( iobuf );
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
 	/* Deliver data */
443
 	/* Deliver data */
436
 	if ( ( rc = xfer_deliver_iob ( &tftp->xfer, iobuf ) ) != 0 ) {
444
 	if ( ( rc = xfer_deliver_iob ( &tftp->xfer, iobuf ) ) != 0 ) {
437
 		DBGC ( tftp, "TFTP %p could not deliver data: %s\n",
445
 		DBGC ( tftp, "TFTP %p could not deliver data: %s\n",

Loading…
取消
儲存