Kaynağa Gözat

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 yıl önce
ebeveyn
işleme
fa0ab25d5f
2 değiştirilmiş dosya ile 2 ekleme ve 0 silme
  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;
     }