mirror of
https://github.com/Stichting-MINIX-Research-Foundation/u-boot.git
synced 2025-09-10 12:39:22 -04:00
env: Check for NULL pointer in envmatch()
If the pointer passed into envmatch() is NULL, return -1 instead of crashing. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
This commit is contained in:
parent
e4a223f04d
commit
586197dfe4
@ -650,6 +650,9 @@ U_BOOT_CMD(
|
|||||||
*/
|
*/
|
||||||
int envmatch(uchar *s1, int i2)
|
int envmatch(uchar *s1, int i2)
|
||||||
{
|
{
|
||||||
|
if (s1 == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
while (*s1 == env_get_char(i2++))
|
while (*s1 == env_get_char(i2++))
|
||||||
if (*s1++ == '=')
|
if (*s1++ == '=')
|
||||||
return i2;
|
return i2;
|
||||||
|
2
tools/env/fw_env.c
vendored
2
tools/env/fw_env.c
vendored
@ -1057,6 +1057,8 @@ exit:
|
|||||||
|
|
||||||
static char *envmatch (char * s1, char * s2)
|
static char *envmatch (char * s1, char * s2)
|
||||||
{
|
{
|
||||||
|
if (s1 == NULL || s2 == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
while (*s1 == *s2++)
|
while (*s1 == *s2++)
|
||||||
if (*s1++ == '=')
|
if (*s1++ == '=')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user