usb_hid: also use user_memcpy() in TabletProtocolHandler.

This commit is contained in:
Jérôme Duval 2018-02-23 23:26:07 +01:00
parent e0c304f798
commit 3da236362c

View File

@ -18,6 +18,7 @@
#include "HIDReportItem.h"
#include <new>
#include <kernel.h>
#include <string.h>
#include <usb/USB_hid.h>
@ -189,9 +190,17 @@ TabletProtocolHandler::Control(uint32 *cookie, uint32 op, void *buffer,
return B_BUFFER_OVERFLOW;
while (true) {
status_t result = _ReadReport(buffer, cookie);
if (result != B_INTERRUPTED)
return result;
tablet_movement movement;
status_t result = _ReadReport(&movement, cookie);
if (result == B_INTERRUPTED)
continue;
if (!IS_USER_ADDRESS(buffer)
|| user_memcpy(buffer, &movement, sizeof(movement))
!= B_OK) {
return B_BAD_ADDRESS;
}
return result;
}
}
@ -205,12 +214,13 @@ TabletProtocolHandler::Control(uint32 *cookie, uint32 op, void *buffer,
}
case MS_SET_CLICKSPEED:
#ifdef __HAIKU__
return user_memcpy(&fClickSpeed, buffer, sizeof(bigtime_t));
#else
fClickSpeed = *(bigtime_t *)buffer;
if (!IS_USER_ADDRESS(buffer)
|| user_memcpy(&fClickSpeed, buffer, sizeof(bigtime_t))
!= B_OK) {
return B_BAD_ADDRESS;
}
return B_OK;
#endif
}
return B_ERROR;