mirror of
https://github.com/nunuhara/xsystem4.git
synced 2026-10-09 15:20:01 +03:00
Fix buffer overflows
This commit is contained in:
@@ -156,7 +156,7 @@ static int _ald_get(struct ald_archive *ar, int no, int *disk_out, int *dataptr_
|
||||
int disk, ptr, dataptr, dataptr2;
|
||||
|
||||
// check that index is within range of file map
|
||||
if (no > ar->maxfile)
|
||||
if (no < 0 || no >= ar->maxfile)
|
||||
return 0;
|
||||
|
||||
// look up data in file map
|
||||
|
||||
@@ -284,7 +284,7 @@ void string_set_char(struct string **_str, int i, unsigned int c)
|
||||
str->size--;
|
||||
} else if (bytes_src == 2 && bytes_dst == 1) {
|
||||
// grow 1 byte
|
||||
str = xrealloc(str, sizeof(struct string) + str->size + 1);
|
||||
str = xrealloc(str, sizeof(struct string) + str->size + 2);
|
||||
str->size++;
|
||||
*_str = str;
|
||||
for (int j = str->size; j > i; j--) {
|
||||
|
||||
Reference in New Issue
Block a user