From d29d80ebe249741b84a620fdbd987f81c0beb411 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Sun, 9 Feb 2020 18:17:01 -0500 Subject: [PATCH] kernel: Initialize allocated KPath buffers to 0. KPaths are most commonly used in the VFS syscall paths, and so they are typically user_memcpy'd to/from userland. In the "to" case this is not really necessary (but it should be so small of a performance difference as to not matter), but in the "from" case, we must always clear the buffer we received from the allocator, so as not to leak information to userland. Part of #14961. --- src/system/kernel/fs/KPath.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/system/kernel/fs/KPath.cpp b/src/system/kernel/fs/KPath.cpp index 1693cdfb22..d1d870f35a 100644 --- a/src/system/kernel/fs/KPath.cpp +++ b/src/system/kernel/fs/KPath.cpp @@ -432,6 +432,7 @@ KPath::_AllocateBuffer() else #endif fBuffer = (char*)malloc(fBufferSize); + memset(fBuffer, 0, fBufferSize); } if (fBuffer == NULL) { fFailed = true;