mirror of
https://github.com/openharmony/drivers_adapter.git
synced 2026-07-19 18:23:38 -04:00
fix:Modify function parameter overflow risk
Signed-off-by: mahai <mahai5@huawei.com>
This commit is contained in:
@@ -105,6 +105,11 @@ static int GpioIoctl(struct file *filep, int cmd, unsigned long arg)
|
||||
struct drv_data* drvData = (struct drv_data* )filep->f_vnode->data;
|
||||
bitNum = (uint16_t)(uintptr_t)drvData->priv;
|
||||
|
||||
if (arg == 0) {
|
||||
HDF_LOGE("%s arg is 0", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
ret = LOS_CopyToKernel(&info, sizeof(struct GpioBitInfo),
|
||||
(const VOID *)(uintptr_t)arg, sizeof(struct GpioBitInfo));
|
||||
if (ret != 0) {
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
|
||||
#define HDF_LOG_TAG hdf_uart_dev
|
||||
#define HDF_UART_FS_MODE 0660
|
||||
#define ARG_MAX_RANG 0xFFFFFFFF
|
||||
|
||||
static int32_t UartDevOpen(struct file *filep)
|
||||
{
|
||||
@@ -145,6 +146,12 @@ static int32_t UartDevIoctl(struct file *filep, int32_t cmd, unsigned long arg)
|
||||
{
|
||||
int32_t ret = HDF_FAILURE;
|
||||
struct UartHost *host = NULL;
|
||||
|
||||
if (arg == 0) {
|
||||
HDF_LOGE("%s arg is 0", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
if (filep == NULL || filep->f_vnode == NULL) {
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
@@ -153,6 +160,11 @@ static int32_t UartDevIoctl(struct file *filep, int32_t cmd, unsigned long arg)
|
||||
|
||||
switch (cmd) {
|
||||
case UART_CFG_BAUDRATE:
|
||||
if (arg > ARG_MAX_RANG) {
|
||||
HDF_LOGE("%s arg out of range", __func__);
|
||||
ret = HDF_ERR_INVALID_PARAM;
|
||||
break;
|
||||
}
|
||||
ret = UartHostSetBaud(host, arg);
|
||||
break;
|
||||
case UART_CFG_RD_BLOCK:
|
||||
|
||||
Reference in New Issue
Block a user