vfs: check userland buffers before reading them.
[haiku.git] / src / kits / debugger / jobs / WriteMemoryJob.cpp
blob116b4438b127af92e094c76b8473cb6301444d9f
1 /*
2 * Copyright 2015, Rene Gollent, rene@gollent.com.
3 * Distributed under the terms of the MIT License.
4 */
6 #include "Jobs.h"
8 #include "Team.h"
9 #include "TeamMemory.h"
12 WriteMemoryJob::WriteMemoryJob(Team* team,
13 TeamMemory* teamMemory, target_addr_t address, void* data,
14 target_size_t size)
16 fKey(data, JOB_TYPE_WRITE_MEMORY),
17 fTeam(team),
18 fTeamMemory(teamMemory),
19 fTargetAddress(address),
20 fData(data),
21 fSize(size)
23 fTeamMemory->AcquireReference();
27 WriteMemoryJob::~WriteMemoryJob()
29 fTeamMemory->ReleaseReference();
33 const JobKey&
34 WriteMemoryJob::Key() const
36 return fKey;
40 status_t
41 WriteMemoryJob::Do()
43 ssize_t result = fTeamMemory->WriteMemory(fTargetAddress, fData, fSize);
44 if (result < 0)
45 return result;
47 fTeam->NotifyMemoryChanged(fTargetAddress, fSize);
49 return B_OK;