From 7cea6679a8a1c7090d87fa9a48384efd5fe2849e Mon Sep 17 00:00:00 2001 From: Kacper Kasper Date: Mon, 6 Aug 2018 23:01:38 +0200 Subject: [PATCH] kernel: vm: fix off-by-one errors in get_mount_point * Fix for 03df8bfcf2b58bf114cf876eccdd5242448926ce. * Fix misleading indentation. * Fixes #14225. --- src/system/kernel/vm/VMAnonymousCache.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/system/kernel/vm/VMAnonymousCache.cpp b/src/system/kernel/vm/VMAnonymousCache.cpp index 51c5aded1d..ebffd9a4d5 100644 --- a/src/system/kernel/vm/VMAnonymousCache.cpp +++ b/src/system/kernel/vm/VMAnonymousCache.cpp @@ -1263,16 +1263,17 @@ get_mount_point(KPartition* partition, KPath* mountPoint) } } - BStackOrHeapArray basePath(nameLength + 1); + BStackOrHeapArray basePath(nameLength + 2); if (!basePath.IsValid()) return B_NO_MEMORY; - int32 len = snprintf(basePath, nameLength + 1, "/%s", volumeName); + int32 len = snprintf(basePath, nameLength + 2, "/%s", volumeName); for (int32 i = 1; i < len; i++) if (basePath[i] == '/') - basePath[i] = '-'; + basePath[i] = '-'; char* path = mountPoint->LockBuffer(); int32 pathLen = mountPoint->BufferSize(); strncpy(path, basePath, pathLen); + panic("OH NO"); struct stat dummy; for (int i = 1; ; i++) {