Skip to content

Commit 728d9e4

Browse files
authored
fix(ioctl): _IOR() overflows in switch (int) #10650
1 parent 9567564 commit 728d9e4

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

components/drivers/ipc/pipe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ static int pipe_fops_ioctl(struct dfs_file *fd, int cmd, void *args)
190190

191191
pipe = (rt_pipe_t *)fd->vnode->data;
192192

193-
switch (cmd)
193+
switch ((rt_ubase_t)cmd)
194194
{
195195
case FIONREAD:
196196
*((int*)args) = rt_ringbuffer_data_len(pipe->fifo);

components/drivers/serial/dev_serial.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ static int serial_fops_ioctl(struct dfs_file *fd, int cmd, void *args)
125125
int mask = O_NONBLOCK | O_APPEND;
126126

127127
device = (rt_device_t)fd->vnode->data;
128-
switch (cmd)
128+
switch ((rt_ubase_t)cmd)
129129
{
130130
case FIONREAD:
131131
break;
@@ -1074,7 +1074,7 @@ static rt_err_t rt_serial_control(struct rt_device *dev,
10741074
RT_ASSERT(dev != RT_NULL);
10751075
serial = (struct rt_serial_device *)dev;
10761076

1077-
switch (cmd)
1077+
switch ((rt_ubase_t)cmd)
10781078
{
10791079
case RT_DEVICE_CTRL_SUSPEND:
10801080
/* suspend device */

components/drivers/serial/dev_serial_v2.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ static int serial_fops_ioctl(struct dfs_file *fd, int cmd, void *args)
121121
int mask = O_NONBLOCK | O_APPEND;
122122

123123
device = (rt_device_t)fd->vnode->data;
124-
switch (cmd)
124+
switch ((rt_ubase_t)cmd)
125125
{
126126
case FIONREAD:
127127
break;
@@ -1385,7 +1385,7 @@ static rt_err_t rt_serial_control(struct rt_device *dev,
13851385
RT_ASSERT(dev != RT_NULL);
13861386
serial = (struct rt_serial_device *)dev;
13871387

1388-
switch (cmd)
1388+
switch ((rt_ubase_t)cmd)
13891389
{
13901390
case RT_DEVICE_CTRL_SUSPEND:
13911391
/* suspend device */

0 commit comments

Comments
 (0)