[PATCH] fwts: lib: clean up static analysis warnings

Colin King colin.king at canonical.com
Tue May 17 07:57:14 UTC 2016


From: Colin Ian King <colin.king at canonical.com>

Although this is not possible, I'd like to clean up a warning
from static analysis just for the sake ensuring we never do
a write to a null pointer to the buffer.

CID 1354842:  Null pointer dereferences  (FORWARD_NULL)
Passing null pointer "in_buf" to "write", which dereferences it.

Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
 src/lib/src/fwts_pipeio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/lib/src/fwts_pipeio.c b/src/lib/src/fwts_pipeio.c
index 859e63e..b501f7b 100644
--- a/src/lib/src/fwts_pipeio.c
+++ b/src/lib/src/fwts_pipeio.c
@@ -206,7 +206,7 @@ int fwts_pipe_readwrite(
 			*(ptr+out_size) = 0;
 		}
 
-		if (pollfds[1].revents) {
+		if ((in_fd > 0) && in_buf && pollfds[1].revents) {
 			n = write(in_fd, in_buf, in_size);
 
 			if (n < 0) {
-- 
2.8.1




More information about the fwts-devel mailing list