Browse Source

feat(ata): check buf_size in ata_read()

greatbridf 2 years ago
parent
commit
b8cc71517a
1 changed files with 3 additions and 1 deletions
  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;