changeset 4503:9784c3171a22 draft

BSD: Ignore coverity errors We could do ((char *)rtm) + rtm->rtm_msglen but that looks more ugly than rtm + 1.
author Roy Marples <roy@marples.name>
date Fri, 03 May 2019 16:27:35 +0100
parents 5d361d74621c
children d2b939b8b5bc
files src/dhcpcd.c src/if-bsd.c
diffstat 2 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/dhcpcd.c	Fri May 03 15:44:51 2019 +0100
+++ b/src/dhcpcd.c	Fri May 03 16:27:35 2019 +0100
@@ -1081,7 +1081,8 @@
 			dhcpcd_linkoverflow(ctx);
 			return;
 		}
-		logerr(__func__);
+		if (errno != ENOTSUP)
+			logerr(__func__);
 	}
 }
 
--- a/src/if-bsd.c	Fri May 03 15:44:51 2019 +0100
+++ b/src/if-bsd.c	Fri May 03 16:27:35 2019 +0100
@@ -655,6 +655,9 @@
 	}
 #endif
 
+	/* We have already checked that at least one address must be
+	 * present after the rtm structure. */
+	/* coverity[ptr_arith] */
 	if (get_addrs(rtm->rtm_addrs, rtm + 1,
 		      rtm->rtm_msglen - sizeof(*rtm), rti_info) == -1)
 		return -1;
@@ -1099,14 +1102,17 @@
 		errno = EINVAL;
 		return -1;
 	}
-
+	if (~ifam->ifam_addrs & RTA_IFA)
+		return 0;
 	if ((ifp = if_findindex(ctx->ifaces, ifam->ifam_index)) == NULL)
 		return 0;
+
+	/* We have already checked that at least one address must be
+	 * present after the ifam structure. */
+	/* coverity[ptr_arith] */
 	if (get_addrs(ifam->ifam_addrs, ifam + 1,
 		      ifam->ifam_msglen - sizeof(*ifam), rti_info) == -1)
 		return -1;
-	if (rti_info[RTAX_IFA] == NULL)
-		return 0;
 
 #ifdef HAVE_IFAM_PID
 	pid = ifam->ifam_pid;
@@ -1302,6 +1308,8 @@
 		return dhcpcd_linkoverflow(ctx);
 #endif
 	}
+
+	return 0;
 }
 
 int