shared: prevent dereferencing of NULL pointers
It is necessary to add checks for NULL before dereferencing pointers.
Found with the SVACE static analysis tool.
diff --git a/src/shared/micp.c b/src/shared/micp.c
index b82bd92..1c34e9d 100644
--- a/src/shared/micp.c
+++ b/src/shared/micp.c
@@ -398,6 +398,10 @@
}
micp_op = iov_pull_mem(&iov, sizeof(*micp_op));
+ if (!micp_op) {
+ DBG(micp, "iov_pull_mem() returned NULL");
+ goto respond;
+ }
if ((*micp_op == MICS_DISABLED) || (*micp_op != MICS_NOT_MUTED
&& *micp_op != MICS_MUTED)) {
diff --git a/src/shared/vcp.c b/src/shared/vcp.c
index 06264a2..602d46d 100644
--- a/src/shared/vcp.c
+++ b/src/shared/vcp.c
@@ -925,6 +925,10 @@
}
vcp_op = iov_pull_mem(&iov, sizeof(*vcp_op));
+ if (!vcp_op) {
+ DBG(vcp, "iov_pull_mem() returned NULL");
+ goto respond;
+ }
for (handler = vcp_handlers; handler && handler->str; handler++) {
if (handler->op != *vcp_op)
@@ -985,6 +989,10 @@
}
vcp_op = iov_pull_mem(&iov, sizeof(*vcp_op));
+ if (!vcp_op) {
+ DBG(vcp, "iov_pull_mem() returned NULL");
+ goto respond;
+ }
for (handler = vocp_handlers; handler && handler->str; handler++) {
if (handler->op != *vcp_op)
@@ -1517,6 +1525,10 @@
}
aics_op = iov_pull_mem(&iov, sizeof(*aics_op));
+ if (!aics_op) {
+ DBG(vcp, "iov_pull_mem() returned NULL");
+ goto respond;
+ }
for (handler = aics_handlers; handler && handler->str; handler++) {
if (handler->op != *aics_op)