Fix IP and UDP header validation in DHCP client

The validation of IP and UDP headers in the DHCP was bypassed and
packets were always considered valid as long as they were large enough.
This change the behavior so that a packet has to pass all validation
steps to be considered a valid packet.

BUG: 74514143
Test: Build emulator image and manually verify that WiFi is working
Change-Id: I88e958aeb2b224fe8cb1332ba05889ead8374216
(cherry picked from commit b7d6da339ecd08f9d0cd6567d4c59a282eef8ee1)
(cherry picked from commit 6b318275d60a8266a9e6d480cbd2b75957cfa3e1)
(cherry picked from commit 0b155d761916f65665e2125596ac63a2fab68ccf)
diff --git a/dhcp/common/socket.cpp b/dhcp/common/socket.cpp
index 96a2f2a..8fd7b9f 100644
--- a/dhcp/common/socket.cpp
+++ b/dhcp/common/socket.cpp
@@ -287,12 +287,11 @@
         *isValid = false;
         return Result::success();
     }
-    if (ip.version != IPVERSION) *isValid = false;
-    if (ip.ihl != (sizeof(ip) >> 2)) *isValid = false;
-    if (ip.protocol != IPPROTO_UDP) *isValid = false;
-    if (udp.dest != htons(expectedPort)) *isValid = false;
+    *isValid = ip.version == IPVERSION &&
+               ip.ihl == (sizeof(ip) >> 2) &&
+               ip.protocol == IPPROTO_UDP &&
+               udp.dest == htons(expectedPort);
 
-    *isValid = true;
     message->setSize(bytesRead - sizeof(ip) - sizeof(udp));
     return Result::success();
 }