Shifting a 32-bit value by 32 bits is undefined behavior. To avoid this
exit the function early when ofs == 0.
Found with clang analyze.
Fixes: 13751fd88c4b ("Classifier: Track address prefixes.")
Signed-off-by: Mike Pattrick <[email protected]>
---
lib/classifier.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lib/classifier.c b/lib/classifier.c
index 7efa15022..294d05e84 100644
--- a/lib/classifier.c
+++ b/lib/classifier.c
@@ -1833,6 +1833,10 @@ raw_get_prefix(const ovs_be32 pr[], unsigned int ofs,
unsigned int plen)
ofs %= 32; /* How many bits to skip at 'pr'. */
prefix = ntohl(*pr) << ofs; /* Get the first 32 - ofs bits. */
+ if (!ofs) {
+ /* Avoid bit shifting entire uint32. */
+ return prefix;
+ }
if (plen > 32 - ofs) { /* Need more than we have already? */
prefix |= ntohl(*++pr) >> (32 - ofs);
}
--
2.53.0
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev