While analysing the source code of memmove, I figure out that this code might have a stack corruption. The code looks like this:
memmove:
push {r0, lr}
cmp r0, r1
bgt __agbabi_rmemcpy
b __aeabi_memcpy
pop {r0, lr}
bx lr
The first line pushes r0 and lr into the stack (possibly for register preservation), but then it uses an unconditional branch in the code, so, assuming __agbabi_rmemcpy and __aeabi_memcpy return to their callers issuing a bx lr, the last two lines of code will never be executed, making the two registers "spill" into the caller frame, causing a stack corruption.
While analysing the source code of
memmove
, I figure out that this code might have a stack corruption. The code looks like this:The first line pushes
r0
andlr
into the stack (possibly for register preservation), but then it uses an unconditional branch in the code, so, assuming__agbabi_rmemcpy
and__aeabi_memcpy
return to their callers issuing abx lr
, the last two lines of code will never be executed, making the two registers "spill" into the caller frame, causing a stack corruption.I think you meant to use
bl
instead ofb
here?