소스 검색

On firmware updates, only read the exact required length from the USB endpoint.
If there are any extra bytes (whichg there shouldn't be) we drop them on the floor.

Keir Fraser 4 년 전
부모
커밋
fa0ab25d5f
2개의 변경된 파일2개의 추가작업 그리고 0개의 파일을 삭제
  1. 1 0
      src/floppy.c
  2. 1 0
      src/fw_update.c

+ 1 - 0
src/floppy.c

@@ -1038,6 +1038,7 @@ static void update_continue(void)
 
     /* Read entire new bootloader into the u_buf[] ring. */
     if ((len = ep_rx_ready(EP_RX)) >= 0) {
+        len = min_t(int, len, update.len - u_prod);
         usb_read(EP_RX, &u_buf[u_prod], len);
         u_prod += len;
     }

+ 1 - 0
src/fw_update.c

@@ -105,6 +105,7 @@ static void update_continue(void)
     int len;
 
     if ((len = ep_rx_ready(EP_RX)) >= 0) {
+        len = min_t(int, len, update.len - update.cur);
         usb_read(EP_RX, &u_buf[u_prod], len);
         u_prod += len;
     }