linux-integrity.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH ima-evm-utils] Fix NULL pointer warning
@ 2021-07-13 19:24 Mimi Zohar
  2021-07-13 23:50 ` Lakshmi Ramasubramanian
  0 siblings, 1 reply; 2+ messages in thread
From: Mimi Zohar @ 2021-07-13 19:24 UTC (permalink / raw)
  To: linux-integrity; +Cc: Mimi Zohar

Static analysis reported an "invalid operation involving NULL pointer"
warning.  Although the code properly exits the loop without ever
using the variable, test the pointer isn't NULL before incrementing
it.

Fixes: 80d3fda6083f ("ima-evm-utils: Check for tsspcrread in runtime")
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
---
 src/utils.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/utils.c b/src/utils.c
index ce2cc285a930..fd9b4a84189f 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -77,7 +77,8 @@ int get_cmd_path(const char *prog_name, char *buf, size_t buf_len)
 		if (buf_len - size > ret && file_exist(buf))
 			return 0;
 
-		start = end + 1;
+		if (end != NULL)
+			start = end + 1;
 
 	} while (end != NULL);
 
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH ima-evm-utils] Fix NULL pointer warning
  2021-07-13 19:24 [PATCH ima-evm-utils] Fix NULL pointer warning Mimi Zohar
@ 2021-07-13 23:50 ` Lakshmi Ramasubramanian
  0 siblings, 0 replies; 2+ messages in thread
From: Lakshmi Ramasubramanian @ 2021-07-13 23:50 UTC (permalink / raw)
  To: Mimi Zohar, linux-integrity

On 7/13/2021 12:24 PM, Mimi Zohar wrote:
> Static analysis reported an "invalid operation involving NULL pointer"
> warning.  Although the code properly exits the loop without ever
> using the variable, test the pointer isn't NULL before incrementing
> it.
> 
> Fixes: 80d3fda6083f ("ima-evm-utils: Check for tsspcrread in runtime")
> Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
> ---
>   src/utils.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)

Reviewed-by: Lakshmi Ramasubramanian <nramas@linux.microsoft.com>

  -lakshmi

> 
> diff --git a/src/utils.c b/src/utils.c
> index ce2cc285a930..fd9b4a84189f 100644
> --- a/src/utils.c
> +++ b/src/utils.c
> @@ -77,7 +77,8 @@ int get_cmd_path(const char *prog_name, char *buf, size_t buf_len)
>   		if (buf_len - size > ret && file_exist(buf))
>   			return 0;
>   
> -		start = end + 1;
> +		if (end != NULL)
> +			start = end + 1;
>   
>   	} while (end != NULL);
>   
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-07-13 23:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-13 19:24 [PATCH ima-evm-utils] Fix NULL pointer warning Mimi Zohar
2021-07-13 23:50 ` Lakshmi Ramasubramanian

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).