Ensure memory segments stay within bounds

This commit is contained in:
stefanrueger
2025-10-22 22:40:42 +02:00
parent c2e86d2229
commit cda38d2876

View File

@@ -1701,6 +1701,12 @@ int segment_normalise(const AVRMEM *mem, Segment *segp) {
return -1;
}
if(len > 0 && addr+len-1 >= maxsize) {
pmsg_error("segment length %d with starting address 0x%0*x reaches beyond memory end 0x%0*x\n",
segp->len, digits, addr, digits, maxsize-1);
return -1;
}
segp->addr = addr;
segp->len = len;