Message ID | 1463471834-29067-1-git-send-email-colin.king@canonical.com |
---|---|
State | Accepted |
Headers | show |
On 2016-05-17 03:57 PM, Colin King wrote: > From: Colin Ian King <colin.king@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@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) { > Acked-by: Alex Hung <alex.hung@canonical.com>
On 05/17/2016 03:57 PM, Colin King wrote: > From: Colin Ian King <colin.king@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@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) { Acked-by: Ivan Hu <ivan.hu@canonical.com>
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) {