| 3 | #include <paging.h> |
| 4 | |
| 5 | long strlenSafe(const char* str, size_t& size, address_space_t* aSpace) |
| 6 | { |
| 7 | size_t pageBoundary = PAGE_SIZE_4K - (reinterpret_cast<uintptr_t>(str) & (PAGE_SIZE_4K - 1)); // Get amount of bytes to page boundary |
| 8 | if(!Memory::CheckUsermodePointer(reinterpret_cast<uintptr_t>(str), pageBoundary, aSpace)){ |
| 9 | return 1; |
| 10 | } |
| 11 | |
| 12 | size_t& i = size; |
| 13 | i = 0; |
| 14 | |
| 15 | while(i < pageBoundary){ |
| 16 | if(str[i] == '\0'){ |
| 17 | return 0; |
| 18 | } |
| 19 | |
| 20 | i++; |
| 21 | } |
| 22 | |
| 23 | |
| 24 | for(;;){ |
| 25 | if(!Memory::CheckUsermodePointer(reinterpret_cast<uintptr_t>(str) + i, PAGE_SIZE_4K, aSpace)){ |
| 26 | return 1; |
| 27 | } |
| 28 | |
| 29 | size_t pageBoundary = i + PAGE_SIZE_4K; |
| 30 | while(i < pageBoundary){ |
| 31 | if(str[i] == '\0'){ |
| 32 | return 0; |
| 33 | } |
| 34 | |
| 35 | i++; |
| 36 | } |
| 37 | } |
| 38 | } |
no test coverage detected