mirror of
https://github.com/ascii-boxes/boxes.git
synced 2024-12-04 22:11:07 +01:00
remove: fix out-of-bound access
The `u32_move` will try to read `input.lines[j].num_chars - c + 1` `u32` octets from `input.lines[j].mbtext + input.lines[j].posmap[c]`. That means, it needs access memory at address `input.lines[j].mbtext + input.lines[j].posmap[c] + input.lines[j].num_chars - c` while the max range is `input.lines[j].mbtext + input.lines[j].num_chars`, which is out-of-bound because `input.lines[j].posmap[c] > c` obviously. Fix #103
This commit is contained in:
parent
7de6854fd9
commit
61562b0158
@ -983,10 +983,10 @@ int remove_box()
|
||||
fprintf(stderr, "u32_move(\"%s\", \"%s\", %d); // posmap[c]=%d\n",
|
||||
u32_strconv_to_output(input.lines[j].mbtext),
|
||||
u32_strconv_to_output(input.lines[j].mbtext + input.lines[j].posmap[c]),
|
||||
(int) (input.lines[j].num_chars - c + 1), (int) input.lines[j].posmap[c]);
|
||||
(int) (input.lines[j].num_chars - input.lines[j].posmap[c] + 1), (int) input.lines[j].posmap[c]);
|
||||
#endif
|
||||
u32_move(input.lines[j].mbtext, input.lines[j].mbtext + input.lines[j].posmap[c],
|
||||
input.lines[j].num_chars - c + 1); /* +1 for zero byte */
|
||||
input.lines[j].num_chars - input.lines[j].posmap[c] + 1); /* +1 for zero byte */
|
||||
input.lines[j].num_chars -= c;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user