Explorar el Código

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 hace 4 años
padre
commit
fa0ab25d5f
Se han modificado 2 ficheros con 2 adiciones y 0 borrados
  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;
     }