What is the workaround for excluding memory access exception on ARM9 using C?

ARM9 architecture. C. programming language

We have a third-party stack, and one of the calls takes a pointer ( pBuffer) to a memory location. Inside the stack, they can freely move along the passed pointer and access it at their discretion. Unfortunately, they shift the one passed in in the pointer and pass it to another function that tried to do this from the memory cell odd / unaudited

         ((uint16 *)pBuffer)[index] = value;

where it valuehas a type uint16and is indexchecked by borders and indices pBuffer. This leads to the exclusion of unoccupied access to memory. pBufferpoints to char *on the heap.

As already mentioned, although we can peer into a third-party stack, we cannot officially update the code. Therefore, we notify the supplier, and they provide an update in the next version.

I want to understand if there is work for this. How to complete the above task without breaking uneven access? What is the best approach to solving such problems.

+3
source share
2 answers

Copy bytes bytes. Pass it to a pointer (unsigned) char, and then copy the byte at a time.

This is not very, but it looks like you have many options.

+6
source

There are three possibilities, and I still cannot determine from your question what is happening.

1: . : memmove() pBuffer 1 2: , . : memmove() pBuffer 1 , , . 3: , , . , .

+1

Source: https://habr.com/ru/post/1705186/


All Articles