aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Drivers/USB/Core/AVR8
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2012-06-10 19:53:20 +0000
committerDean Camera <dean@fourwalledcubicle.com>2012-06-10 19:53:20 +0000
commitc41bbf9fccd99de70c962ec6f7cac15efe06d3df (patch)
tree05918c6da856132fe8a38324fc7a3cd88db14b63 /LUFA/Drivers/USB/Core/AVR8
parent9ab445518a01e9b10b5d3e1c99f45d81d874278b (diff)
downloadlufa-c41bbf9fccd99de70c962ec6f7cac15efe06d3df.tar.gz
lufa-c41bbf9fccd99de70c962ec6f7cac15efe06d3df.tar.bz2
lufa-c41bbf9fccd99de70c962ec6f7cac15efe06d3df.zip
Add checks to the endpoint and pipe configure functions and fail if the requested endpoint or pipe number is above the maximum for that device.
Diffstat (limited to 'LUFA/Drivers/USB/Core/AVR8')
-rw-r--r--LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.h7
-rw-r--r--LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.c3
2 files changed, 9 insertions, 1 deletions
diff --git a/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.h b/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.h
index 056981a27..57d9b0d43 100644
--- 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)
{
- 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)));
}
diff --git a/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.c b/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.c
index 1ddffb51e..b64370835 100644
--- 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;
+ if (Number >= PIPE_TOTAL_PIPES)
+ return false;
+
if (Type == EP_TYPE_CONTROL)
Token = PIPE_TOKEN_SETUP;