[U-Boot] [PATCH] removed '!' in for loop stop condition

2019-08-27 Thread Niv Shetrit
Signed-off-by: Niv Shetrit 
---
 drivers/usb/gadget/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/core.c b/drivers/usb/gadget/core.c
index ffaf161fb7..ae7387ee0a 100644
--- a/drivers/usb/gadget/core.c
+++ b/drivers/usb/gadget/core.c
@@ -307,7 +307,7 @@ struct usb_endpoint_descriptor 
*usbd_device_endpoint_descriptor (struct usb_devi
struct usb_endpoint_descriptor *endpoint_descriptor;
int i;
 
-   for (i = 0; !(endpoint_descriptor = 
usbd_device_endpoint_descriptor_index (device, port, configuration, interface, 
alternate, i)); i++) {
+   for (i = 0; endpoint_descriptor = usbd_device_endpoint_descriptor_index 
(device, port, configuration, interface, alternate, i); i++) {
if (endpoint_descriptor->bEndpointAddress == endpoint) {
return endpoint_descriptor;
}
-- 
2.17.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] logically dead code in drivers/usb/gadget/core.c

2019-08-27 Thread Niv Shetrit
Fixed 'Logically dead code' coverity warning: in for loop,
 stop condition is 'while descriptor==NULL' instead of 'while
 descriptor!=NULL'.


___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2] Prevented possible null dereference.

2019-08-26 Thread Niv Shetrit
Signed-off-by: Niv Shetrit 
---
 common/cli_hush.c | 73 ---
 1 file changed, 38 insertions(+), 35 deletions(-)

diff --git a/common/cli_hush.c b/common/cli_hush.c
index 8f86e4aa4a..c14302c3ad 100644
--- a/common/cli_hush.c
+++ b/common/cli_hush.c
@@ -3539,41 +3539,44 @@ static char *insert_var_value_sub(char *inp, int 
tag_subst)
}
inp = ++p;
/* find the ending marker */
-   p = strchr(inp, SPECIAL_VAR_SYMBOL);
-   *p = '\0';
-   /* look up the value to substitute */
-   if ((p1 = lookup_param(inp))) {
-   if (tag_subst)
-   len = res_str_len + strlen(p1) + 2;
-   else
-   len = res_str_len + strlen(p1);
-   res_str = xrealloc(res_str, (1 + len));
-   if (tag_subst) {
-   /*
-* copy the variable value to the result
-* string
-*/
-   strcpy((res_str + res_str_len + 1), p1);
-
-   /*
-* mark the replaced text to be accepted as
-* is
-*/
-   res_str[res_str_len] = SUBSTED_VAR_SYMBOL;
-   res_str[res_str_len + 1 + strlen(p1)] =
-   SUBSTED_VAR_SYMBOL;
-   } else
-   /*
-* copy the variable value to the result
-* string
-*/
-   strcpy((res_str + res_str_len), p1);
-
-   res_str_len = len;
-   }
-   *p = SPECIAL_VAR_SYMBOL;
-   inp = ++p;
-   done = 1;
+   p = strchr(inp, SPECIAL_VAR_SYMBOL)
+   if (p != NULL) {
+   *p = '\0';
+   /* look up the value to substitute */
+   p1 = lookup_param(inp)
+   if (p1 != NULL) {
+   if (tag_subst)
+   len = res_str_len + strlen(p1) + 2;
+   else
+   len = res_str_len + strlen(p1);
+   res_str = xrealloc(res_str, (1 + len));
+   if (tag_subst) {
+   /*
+* copy the variable value to the
+* result string
+*/
+   strcpy((res_str + res_str_len + 1), p1);
+
+   /*
+* mark the replaced text to be
+* accepted as is
+*/
+   res_str[res_str_len] = 
SUBSTED_VAR_SYMBOL;
+   res_str[res_str_len + 1 + strlen(p1)] =
+   SUBSTED_VAR_SYMBOL;
+   } else
+   /*
+* copy the variable value to the result
+* string
+*/
+   strcpy((res_str + res_str_len), p1);
+
+   res_str_len = len;
+   }
+   *p = SPECIAL_VAR_SYMBOL;
+   inp = ++p;
+   done = 1;
+   }
}
if (done) {
res_str = xrealloc(res_str, (1 + res_str_len + strlen(inp)));
-- 
2.17.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2] Prevented possible null dereference.

2019-08-26 Thread Niv Shetrit
Signed-off-by: Niv Shetrit 
---
 common/cli_hush.c | 73 ---
 1 file changed, 38 insertions(+), 35 deletions(-)

diff --git a/common/cli_hush.c b/common/cli_hush.c
index 8f86e4aa4a..c14302c3ad 100644
--- a/common/cli_hush.c
+++ b/common/cli_hush.c
@@ -3539,41 +3539,44 @@ static char *insert_var_value_sub(char *inp, int 
tag_subst)
}
inp = ++p;
/* find the ending marker */
-   p = strchr(inp, SPECIAL_VAR_SYMBOL);
-   *p = '\0';
-   /* look up the value to substitute */
-   if ((p1 = lookup_param(inp))) {
-   if (tag_subst)
-   len = res_str_len + strlen(p1) + 2;
-   else
-   len = res_str_len + strlen(p1);
-   res_str = xrealloc(res_str, (1 + len));
-   if (tag_subst) {
-   /*
-* copy the variable value to the result
-* string
-*/
-   strcpy((res_str + res_str_len + 1), p1);
-
-   /*
-* mark the replaced text to be accepted as
-* is
-*/
-   res_str[res_str_len] = SUBSTED_VAR_SYMBOL;
-   res_str[res_str_len + 1 + strlen(p1)] =
-   SUBSTED_VAR_SYMBOL;
-   } else
-   /*
-* copy the variable value to the result
-* string
-*/
-   strcpy((res_str + res_str_len), p1);
-
-   res_str_len = len;
-   }
-   *p = SPECIAL_VAR_SYMBOL;
-   inp = ++p;
-   done = 1;
+   p = strchr(inp, SPECIAL_VAR_SYMBOL)
+   if (p != NULL) {
+   *p = '\0';
+   /* look up the value to substitute */
+   p1 = lookup_param(inp)
+   if (p1 != NULL) {
+   if (tag_subst)
+   len = res_str_len + strlen(p1) + 2;
+   else
+   len = res_str_len + strlen(p1);
+   res_str = xrealloc(res_str, (1 + len));
+   if (tag_subst) {
+   /*
+* copy the variable value to the
+* result string
+*/
+   strcpy((res_str + res_str_len + 1), p1);
+
+   /*
+* mark the replaced text to be
+* accepted as is
+*/
+   res_str[res_str_len] = 
SUBSTED_VAR_SYMBOL;
+   res_str[res_str_len + 1 + strlen(p1)] =
+   SUBSTED_VAR_SYMBOL;
+   } else
+   /*
+* copy the variable value to the result
+* string
+*/
+   strcpy((res_str + res_str_len), p1);
+
+   res_str_len = len;
+   }
+   *p = SPECIAL_VAR_SYMBOL;
+   inp = ++p;
+   done = 1;
+   }
}
if (done) {
res_str = xrealloc(res_str, (1 + res_str_len + strlen(inp)));
-- 
2.17.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] FW: getenv coverity issue

2019-08-26 Thread Niv Shetrit
The function has been renamed, but the code was not changed. It is now located 
here:
https://gitlab.denx.de/u-boot/u-boot/blob/master/cmd/nvedit.c
Thanks!

From: Niv Shetrit
Sent: Sunday, August 25, 2019 6:44 PM
To: denx (i...@denx.de) 
Subject: getenv coverity issue

Hi
I was wondering if this is an issue:
Whenever strtoul is called, *cp is passed an an index to the _ctype array.
I know it is a native linux function, however shouldn't there be an external 
check before passing cp as an argument?
Thanks



Important Notice: This email message and any attachments thereto are 
confidential and/or privileged and/or subject to privacy laws and are intended 
only for use by the addressee(s) named above. If you are not the intended 
addressee, you are hereby kindly notified that any dissemination, distribution, 
copying or use of this email and any attachments thereto is strictly 
prohibited. If you have received this email in error, kindly delete it from 
your computer system and notify us at the telephone number or email address 
appearing above. The writer asserts in respect of this message and attachments 
all rights for confidentiality, privilege or privacy to the fullest extent 
permitted by law.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 1/1] null dereference in hush.c

2019-08-20 Thread Niv Shetrit
This patch takes care of potential null dereference and a few typos.

It has been detected by our static code analysis system.

The diff was created using p4.

The row numbering is incorrect because we're using outdated code.

Signed-off-by: Niv Shetrit 
niv.shet...@altair-semi.com<mailto:niv.shet...@altair-semi.com>

Commons/cli_hush.c

@@ -3508,9 +3508,9 @@
   char *p, *p1, *res_str = NULL;
while ((p = strchr(inp, SPECIAL_VAR_SYMBOL))) {
-  /* check the beginning of the string for normal 
charachters */
+ /* check the beginning of the string for normal 
characters */
   if (p != inp) {
-  /* copy any charachters to the 
result string */
+ /* copy any characters to the 
result string */
   len = p - inp;
   res_str = xrealloc(res_str, 
(res_str_len + len));
   strncpy((res_str + res_str_len), 
inp, len);
@@ -3518,41 +3518,42 @@
   }
   inp = ++p;
   /* find the ending marker */
-  p = strchr(inp, SPECIAL_VAR_SYMBOL);
-  *p = '\0';
-  /* look up the value to substitute */
-  if ((p1 = lookup_param(inp))) {
-  if (tag_subst)
-  len = 
res_str_len + strlen(p1) + 2;
-  else
-  len = 
res_str_len + strlen(p1);
-  res_str = xrealloc(res_str, (1 + 
len));
-  if (tag_subst) {
-  /*
-  * copy the 
variable value to the result
-  * string
-  */
-  strcpy((res_str 
+ res_str_len + 1), p1);
+ if ((p = strchr(inp, SPECIAL_VAR_SYMBOL))) {
+ *p = '\0';
+ /* look up the value to 
substitute */
+ if ((p1 = lookup_param(inp))) {
+ if (tag_subst)
+ 
len = res_str_len + strlen(p1) + 2;
+ else
+ 
len = res_str_len + strlen(p1);
+ res_str = 
xrealloc(res_str, (1 + len));
+ if (tag_subst) {
+ /*
+ * 
copy the variable value to the result
+ * 
string
+ */
+ 
strcpy((res_str + res_str_len + 1), p1);
-  /*
-  * mark the 
replaced text to be accepted as
-  * is
-  */
-  
res_str[res_str_len] = SUBSTED_VAR_SYMBOL;
-  
res_str[res_str_len + 1 + strlen(p1)] =
-  
SUBSTED_VAR_SYMBOL;
-  } else
-  /*
-  * copy the 
variable value to the result
-  * string
-  */
-  strcpy((res_str 
+ res_str_le