From cd2e82fbf803897fbbc28b2d654efda939d46fee Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Tue, 11 Mar 2014 15:33:35 -0700 Subject: [PATCH] Verify the injection error buffer is null-termined. --- Mach/Inject.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Mach/Inject.cpp b/Mach/Inject.cpp index 6ca0378..7d80599 100644 --- a/Mach/Inject.cpp +++ b/Mach/Inject.cpp @@ -292,8 +292,11 @@ void InjectLibrary(pid_t pid) { mach_vm_size_t error(sizeof(baton->error)); _krncall(mach_vm_read_overwrite(task, data + offsetof(Baton, error), sizeof(baton->error), reinterpret_cast(&baton->error), &error)); _assert(error == sizeof(baton->error)); - if (baton->error[0] != '\0') + + if (baton->error[0] != '\0') { + baton->error[sizeof(baton->error) - 1] = '\0'; CYThrow("%s", baton->error); + } _krncall(mach_vm_deallocate(task, code, trampoline->size_)); _krncall(mach_vm_deallocate(task, stack, size)); -- 2.49.0