瀏覽代碼

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;
     }