Преглед на файлове

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