mirror of
https://github.com/sipeed/LicheeRV-Nano-Build.git
synced 2026-11-09 18:04:55 -06:00
i2c: fix stack buffer overflow vulnerability in i2c md command
This commit is contained in:
@@ -248,10 +248,10 @@ int i2c_set_bus_speed(unsigned int speed)
|
|||||||
*
|
*
|
||||||
* Returns the address length.
|
* Returns the address length.
|
||||||
*/
|
*/
|
||||||
static uint get_alen(char *arg, int default_len)
|
static uint get_alen(char *arg, uint default_len)
|
||||||
{
|
{
|
||||||
int j;
|
uint j;
|
||||||
int alen;
|
uint alen;
|
||||||
|
|
||||||
alen = default_len;
|
alen = default_len;
|
||||||
for (j = 0; j < 8; j++) {
|
for (j = 0; j < 8; j++) {
|
||||||
@@ -295,7 +295,7 @@ static int do_i2c_read(struct cmd_tbl *cmdtp, int flag, int argc,
|
|||||||
{
|
{
|
||||||
uint chip;
|
uint chip;
|
||||||
uint devaddr, length;
|
uint devaddr, length;
|
||||||
int alen;
|
uint alen;
|
||||||
u_char *memaddr;
|
u_char *memaddr;
|
||||||
int ret;
|
int ret;
|
||||||
#if CONFIG_IS_ENABLED(DM_I2C)
|
#if CONFIG_IS_ENABLED(DM_I2C)
|
||||||
@@ -349,7 +349,7 @@ static int do_i2c_write(struct cmd_tbl *cmdtp, int flag, int argc,
|
|||||||
{
|
{
|
||||||
uint chip;
|
uint chip;
|
||||||
uint devaddr, length;
|
uint devaddr, length;
|
||||||
int alen;
|
uint alen;
|
||||||
u_char *memaddr;
|
u_char *memaddr;
|
||||||
int ret;
|
int ret;
|
||||||
#if CONFIG_IS_ENABLED(DM_I2C)
|
#if CONFIG_IS_ENABLED(DM_I2C)
|
||||||
@@ -517,8 +517,8 @@ static int do_i2c_md(struct cmd_tbl *cmdtp, int flag, int argc,
|
|||||||
{
|
{
|
||||||
uint chip;
|
uint chip;
|
||||||
uint addr, length;
|
uint addr, length;
|
||||||
int alen;
|
uint alen;
|
||||||
int j, nbytes, linebytes;
|
uint j, nbytes, linebytes;
|
||||||
int ret;
|
int ret;
|
||||||
#if CONFIG_IS_ENABLED(DM_I2C)
|
#if CONFIG_IS_ENABLED(DM_I2C)
|
||||||
struct udevice *dev;
|
struct udevice *dev;
|
||||||
@@ -637,9 +637,9 @@ static int do_i2c_mw(struct cmd_tbl *cmdtp, int flag, int argc,
|
|||||||
{
|
{
|
||||||
uint chip;
|
uint chip;
|
||||||
ulong addr;
|
ulong addr;
|
||||||
int alen;
|
uint alen;
|
||||||
uchar byte;
|
uchar byte;
|
||||||
int count;
|
uint count;
|
||||||
int ret;
|
int ret;
|
||||||
#if CONFIG_IS_ENABLED(DM_I2C)
|
#if CONFIG_IS_ENABLED(DM_I2C)
|
||||||
struct udevice *dev;
|
struct udevice *dev;
|
||||||
@@ -724,8 +724,8 @@ static int do_i2c_crc(struct cmd_tbl *cmdtp, int flag, int argc,
|
|||||||
{
|
{
|
||||||
uint chip;
|
uint chip;
|
||||||
ulong addr;
|
ulong addr;
|
||||||
int alen;
|
uint alen;
|
||||||
int count;
|
uint count;
|
||||||
uchar byte;
|
uchar byte;
|
||||||
ulong crc;
|
ulong crc;
|
||||||
ulong err;
|
ulong err;
|
||||||
@@ -1033,7 +1033,7 @@ static int do_i2c_loop(struct cmd_tbl *cmdtp, int flag, int argc,
|
|||||||
char *const argv[])
|
char *const argv[])
|
||||||
{
|
{
|
||||||
uint chip;
|
uint chip;
|
||||||
int alen;
|
uint alen;
|
||||||
uint addr;
|
uint addr;
|
||||||
uint length;
|
uint length;
|
||||||
u_char bytes[16];
|
u_char bytes[16];
|
||||||
|
|||||||
Reference in New Issue
Block a user