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

LibC: Ensure that `struct group::gr_mem` pointers are aligned

Otherwise, we get a UBSan crash in SystemServer before we could even
start running tests on AArch64.
Daniel Bertalan 2 лет назад
Родитель
Сommit
2e0e80db69
1 измененных файлов с 1 добавлено и 1 удалено
  1. 1 1
      Userland/Libraries/LibC/grp.cpp

+ 1 - 1
Userland/Libraries/LibC/grp.cpp

@@ -113,7 +113,7 @@ static bool parse_grpdb_entry(char* buffer, size_t buffer_size, struct group& gr
 
     // Must have room at the end of the buffer for the new table.
     // Remaining space is one byte past null terminator generated by original line.
-    size_t bytes_used = line_length + 1;
+    size_t bytes_used = round_up_to_power_of_two(line_length + 1, alignof(char*));
     size_t ptrs_size = sizeof(char const*) * members_ptrs.size();
 
     if (bytes_used + ptrs_size < buffer_size) {