Procházet zdrojové kódy

feat(ata): check buf_size in ata_read()

greatbridf před 2 roky
rodič
revize
b8cc71517a
1 změnil soubory, kde provedl 3 přidání a 1 odebrání
  1. 3 1
      src/kernel/hw/ata.cpp

+ 3 - 1
src/kernel/hw/ata.cpp

@@ -6,6 +6,7 @@
 #include <kernel/tty.h>
 #include <kernel/vfs.hpp>
 #include <types/allocator.hpp>
+#include <types/assert.h>
 #include <types/status.h>
 #include <types/stdint.h>
 
@@ -136,7 +137,8 @@ constexpr hw::ata** p_ata_sec = &ata_sec;
 template <hw::ata** ata_bus>
 size_t _ata_read(fs::special_node* sn, char* buf, size_t buf_size, size_t offset, size_t n)
 {
-    // TODO: check buf_size
+    assert_likely(buf_size >= n);
+
     char b[512] {};
     char* orig_buf = buf;
     size_t start = sn->data1 + offset / 512;