mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[ion] Add Ion::stackSafe
This allows asserting the stack is within bounds
This commit is contained in:
committed by
LeaNumworks
parent
f4f567814e
commit
f1198d3c76
@@ -23,8 +23,8 @@ void ImageView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
|
||||
KDColor pixelBuffer[maxPixelBufferSize];
|
||||
int pixelBufferSize = m_image->width() * m_image->height();
|
||||
// CAUTION: That's a VERY big buffer we're allocating on the stack
|
||||
assert(pixelBufferSize <= maxPixelBufferSize);
|
||||
assert(Ion::stackSafe()); // That's a VERY big buffer we're allocating on the stack
|
||||
|
||||
Ion::decompress(
|
||||
m_image->compressedPixelData(),
|
||||
|
||||
@@ -43,6 +43,9 @@ uint32_t random();
|
||||
// Decompress data
|
||||
void decompress(const uint8_t * src, uint8_t * dst, int srcSize, int dstSize);
|
||||
|
||||
// Tells wether the stack pointer is within acceptable bounds
|
||||
bool stackSafe();
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -19,6 +19,7 @@ objs += $(addprefix ion/src/shared/, \
|
||||
dummy/led.o \
|
||||
dummy/keyboard.o \
|
||||
dummy/serial_number.o \
|
||||
dummy/stack.o \
|
||||
dummy/usb.o \
|
||||
)
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ objs += $(addprefix ion/src/device/, \
|
||||
led.o\
|
||||
power.o\
|
||||
sd_card.o\
|
||||
stack.o\
|
||||
swd.o \
|
||||
usb.o \
|
||||
wakeup.o \
|
||||
|
||||
10
ion/src/device/stack.cpp
Normal file
10
ion/src/device/stack.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <ion.h>
|
||||
|
||||
extern const void * _stack_start;
|
||||
extern const void * _stack_end;
|
||||
|
||||
bool Ion::stackSafe() {
|
||||
volatile int stackDummy;
|
||||
volatile void * stackPointer = &stackDummy;
|
||||
return (stackPointer >= &_stack_end && stackPointer <= &_stack_start);
|
||||
}
|
||||
@@ -15,5 +15,6 @@ objs += $(addprefix ion/src/shared/, \
|
||||
dummy/fcc_id.o \
|
||||
dummy/led.o \
|
||||
dummy/serial_number.o \
|
||||
dummy/stack.o \
|
||||
dummy/usb.o \
|
||||
)
|
||||
|
||||
5
ion/src/shared/dummy/stack.cpp
Normal file
5
ion/src/shared/dummy/stack.cpp
Normal file
@@ -0,0 +1,5 @@
|
||||
#include <ion.h>
|
||||
|
||||
bool Ion::stackSafe() {
|
||||
return true;
|
||||
}
|
||||
@@ -18,6 +18,7 @@ objs += $(addprefix ion/src/shared/, \
|
||||
dummy/fcc_id.o \
|
||||
dummy/led.o \
|
||||
dummy/serial_number.o \
|
||||
dummy/stack.o \
|
||||
dummy/usb.o \
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user