userlandfs: Read()/Write() with user_memcpy().
Change-Id: I8be72d5fb18228c0ee0394a3f906f7a50113d7ea Reviewed-on: https://review.haiku-os.org/741 Reviewed-by: Axel Dörfler <[email protected]>
This commit is contained in:
committed by
Axel Dörfler
parent
f0a1a07c73
commit
cf6760f20c
@@ -2179,8 +2179,11 @@ Volume::Read(void* _node, void* cookie, off_t pos, void* buffer,
|
||||
|| reply->bytesRead > bufferSize) {
|
||||
return B_BAD_DATA;
|
||||
}
|
||||
if (reply->bytesRead > 0)
|
||||
memcpy(buffer, readBuffer, reply->bytesRead);
|
||||
if (reply->bytesRead > 0
|
||||
&& user_memcpy(buffer, readBuffer, reply->bytesRead) < B_OK) {
|
||||
return B_BAD_ADDRESS;
|
||||
}
|
||||
|
||||
*bytesRead = reply->bytesRead;
|
||||
_SendReceiptAck(port);
|
||||
return error;
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <KernelExport.h>
|
||||
|
||||
#include <kernel.h>
|
||||
|
||||
#include "AreaSupport.h"
|
||||
#include "Compatibility.h"
|
||||
#include "Debug.h"
|
||||
@@ -279,8 +281,14 @@ RequestAllocator::AllocateData(Address& address, const void* data, int32 size,
|
||||
deferredInit);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
if (size > 0)
|
||||
if (size > 0) {
|
||||
#ifndef _KERNEL_MODE
|
||||
memcpy(destination, data, size);
|
||||
#else
|
||||
if (user_memcpy(destination, data, size) < B_OK)
|
||||
return B_BAD_ADDRESS;
|
||||
#endif
|
||||
}
|
||||
} else
|
||||
address.SetTo(-1, 0, 0);
|
||||
return error;
|
||||
|
||||
Reference in New Issue
Block a user