Fix buffer overflows

This commit is contained in:
Nunuhara Cabbage
2019-12-07 14:16:53 -08:00
parent c09e4b6601
commit ba6e6b33dd
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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--) {