projects
/
pub
/
USBasp.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
9ab4455
)
Add checks to the endpoint and pipe configure functions and fail if the requested...
author
Dean Camera
<dean@fourwalledcubicle.com>
Sun, 10 Jun 2012 19:53:20 +0000
(19:53 +0000)
committer
Dean Camera
<dean@fourwalledcubicle.com>
Sun, 10 Jun 2012 19:53:20 +0000
(19:53 +0000)
LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.h
patch
|
blob
|
blame
|
history
LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.c
patch
|
blob
|
blame
|
history
LUFA/Drivers/USB/Core/UC3/Endpoint_UC3.h
patch
|
blob
|
blame
|
history
LUFA/Drivers/USB/Core/UC3/Pipe_UC3.c
patch
|
blob
|
blame
|
history
LUFA/Drivers/USB/Core/XMEGA/Endpoint_XMEGA.h
patch
|
blob
|
blame
|
history
LUFA/Drivers/USB/Core/XMEGA/USBController_XMEGA.c
patch
|
blob
|
blame
|
history
diff --git
a/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.h
b/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.h
index
056981a
..
57d9b0d
100644
(file)
--- a/
LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.h
+++ b/
LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.h
@@
-202,7
+202,12
@@
const uint16_t Size,
const uint8_t Banks)
{
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)));
}
((Type << EPTYPE0) | ((Address & ENDPOINT_DIR_IN) ? (1 << EPDIR) : 0)),
((1 << ALLOC) | ((Banks > 1) ? (1 << EPBK0) : 0) | Endpoint_BytesToEPSizeMask(Size)));
}
diff --git
a/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.c
b/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.c
index
1ddffb5
..
b643708
100644
(file)
--- a/
LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.c
+++ b/
LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.c
@@
-66,6
+66,9
@@
bool Pipe_ConfigurePipe(const uint8_t Address,
uint8_t Number = (Address & PIPE_EPNUM_MASK);
uint8_t Token = (Address & PIPE_DIR_IN) ? PIPE_TOKEN_IN : PIPE_TOKEN_OUT;
uint8_t Number = (Address & PIPE_EPNUM_MASK);
uint8_t Token = (Address & PIPE_DIR_IN) ? PIPE_TOKEN_IN : PIPE_TOKEN_OUT;
+ if (Number >= PIPE_TOTAL_PIPES)
+ return false;
+
if (Type == EP_TYPE_CONTROL)
Token = PIPE_TOKEN_SETUP;
if (Type == EP_TYPE_CONTROL)
Token = PIPE_TOKEN_SETUP;
diff --git
a/LUFA/Drivers/USB/Core/UC3/Endpoint_UC3.h
b/LUFA/Drivers/USB/Core/UC3/Endpoint_UC3.h
index
3bd9c55
..
1356952
100644
(file)
--- a/
LUFA/Drivers/USB/Core/UC3/Endpoint_UC3.h
+++ b/
LUFA/Drivers/USB/Core/UC3/Endpoint_UC3.h
@@
-208,7
+208,12
@@
const uint16_t Size,
const uint8_t Banks)
{
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,
(AVR32_USBB_ALLOC_MASK |
((uint32_t)Type << AVR32_USBB_EPTYPE_OFFSET) |
((Address & ENDPOINT_DIR_IN) ? AVR32_USBB_UECFG0_EPDIR_MASK : 0) |
(AVR32_USBB_ALLOC_MASK |
((uint32_t)Type << AVR32_USBB_EPTYPE_OFFSET) |
((Address & ENDPOINT_DIR_IN) ? AVR32_USBB_UECFG0_EPDIR_MASK : 0) |
diff --git
a/LUFA/Drivers/USB/Core/UC3/Pipe_UC3.c
b/LUFA/Drivers/USB/Core/UC3/Pipe_UC3.c
index
196eb07
..
23c004d
100644
(file)
--- a/
LUFA/Drivers/USB/Core/UC3/Pipe_UC3.c
+++ b/
LUFA/Drivers/USB/Core/UC3/Pipe_UC3.c
@@
-69,6
+69,9
@@
bool Pipe_ConfigurePipe(const uint8_t Address,
uint8_t Number = (Address & PIPE_EPNUM_MASK);
uint8_t Token = (Address & PIPE_DIR_IN) ? PIPE_TOKEN_IN : PIPE_TOKEN_OUT;
uint8_t Number = (Address & PIPE_EPNUM_MASK);
uint8_t Token = (Address & PIPE_DIR_IN) ? PIPE_TOKEN_IN : PIPE_TOKEN_OUT;
+ if (Number >= PIPE_TOTAL_PIPES)
+ return false;
+
if (Type == EP_TYPE_CONTROL)
Token = PIPE_TOKEN_SETUP;
if (Type == EP_TYPE_CONTROL)
Token = PIPE_TOKEN_SETUP;
diff --git
a/LUFA/Drivers/USB/Core/XMEGA/Endpoint_XMEGA.h
b/LUFA/Drivers/USB/Core/XMEGA/Endpoint_XMEGA.h
index
8be20d2
..
3d2926c
100644
(file)
--- a/
LUFA/Drivers/USB/Core/XMEGA/Endpoint_XMEGA.h
+++ b/
LUFA/Drivers/USB/Core/XMEGA/Endpoint_XMEGA.h
@@
-246,8
+246,12
@@
{
uint8_t EPConfigMask = (USB_EP_INTDSBL_bm | ((Banks > 1) ? USB_EP_PINGPONG_bm : 0) | Endpoint_BytesToEPSizeMask(Size));
{
uint8_t EPConfigMask = (USB_EP_INTDSBL_bm | ((Banks > 1) ? USB_EP_PINGPONG_bm : 0) | Endpoint_BytesToEPSizeMask(Size));
+ if ((Address & ENDPOINT_EPNUM_MASK) >= ENDPOINT_TOTAL_ENDPOINTS)
+ return false;
+
// TODO - Fix once limitations are lifted
// TODO - Fix once limitations are lifted
- if ((Banks > 1) || (Size > 64))
+ EPConfigMask &= ~USB_EP_PINGPONG_bm;
+ if (Size > 64)
return false;
switch (Type)
return false;
switch (Type)
diff --git
a/LUFA/Drivers/USB/Core/XMEGA/USBController_XMEGA.c
b/LUFA/Drivers/USB/Core/XMEGA/USBController_XMEGA.c
index
844ef65
..
09d4ab6
100644
(file)
--- a/
LUFA/Drivers/USB/Core/XMEGA/USBController_XMEGA.c
+++ b/
LUFA/Drivers/USB/Core/XMEGA/USBController_XMEGA.c
@@
-76,7
+76,7
@@
void USB_Init(
USB.CAL1 = pgm_read_byte(offsetof(NVM_PROD_SIGNATURES_t, USBCAL1));
NVM.CMD = 0;
USB.CAL1 = pgm_read_byte(offsetof(NVM_PROD_SIGNATURES_t, USBCAL1));
NVM.CMD = 0;
- /* Ugly workaround to ensure an aligned table, since __BIGGEST_ALIGNMENT__ == 1 for
8-bit AVR-GCC
*/
+ /* Ugly workaround to ensure an aligned table, since __BIGGEST_ALIGNMENT__ == 1 for
the 8-bit AVR-GCC toochain
*/
USB.EPPTR = ((intptr_t)&USB_EndpointTable[1] & ~(1 << 0));
USB.CTRLA = (USB_STFRNUM_bm | ((ENDPOINT_TOTAL_ENDPOINTS - 1) << USB_MAXEP_gp));
USB.EPPTR = ((intptr_t)&USB_EndpointTable[1] & ~(1 << 0));
USB.CTRLA = (USB_STFRNUM_bm | ((ENDPOINT_TOTAL_ENDPOINTS - 1) << USB_MAXEP_gp));