Просмотр исходного кода

Fix evil portal html buffer overflow

Willy-JL 2 лет назад
Родитель
Сommit
8bfec3dfb9
1 измененных файлов с 3 добавлено и 1 удалено
  1. 3 1
      evil_portal/helpers/evil_portal_storage.c

+ 3 - 1
evil_portal/helpers/evil_portal_storage.c

@@ -23,7 +23,7 @@ void evil_portal_read_index_html(void* context) {
         File* index_html = storage_file_alloc(storage);
         if(storage_file_open(
                index_html, EVIL_PORTAL_INDEX_SAVE_PATH, FSAM_READ, FSOM_OPEN_EXISTING)) {
-            app->index_html = malloc((size_t)fi.size);
+            app->index_html = malloc((size_t)fi.size + 1);
             uint8_t* buf_ptr = app->index_html;
             size_t read = 0;
             while(read < fi.size) {
@@ -33,6 +33,8 @@ void evil_portal_read_index_html(void* context) {
                 read += now_read;
                 buf_ptr += now_read;
             }
+            *buf_ptr = '\0';
+            buf_ptr++;
             free(buf_ptr);
         }
         storage_file_close(index_html);