Add checks to the endpoint and pipe configure functions and fail if the requested...
[pub/USBasp.git] / LUFA / Drivers / USB / Core / AVR8 / Endpoint_AVR8.h
index 056981a..57d9b0d 100644 (file)
                                                                      const uint16_t Size,
                                                                      const uint8_t Banks)
                        {
-                               return Endpoint_ConfigureEndpoint_Prv((Address & ENDPOINT_EPNUM_MASK),
+                               uint8_t Number = (Address & ENDPOINT_EPNUM_MASK);
+                       
+                               if (Number >= ENDPOINT_TOTAL_ENDPOINTS)
+                                 return false;
+                       
+                               return Endpoint_ConfigureEndpoint_Prv(Number,
                                                                      ((Type << EPTYPE0) | ((Address & ENDPOINT_DIR_IN) ? (1 << EPDIR) : 0)),
                                                                      ((1 << ALLOC) | ((Banks > 1) ? (1 << EPBK0) : 0) | Endpoint_BytesToEPSizeMask(Size)));
                        }