commit | 36f93f01201bbff4a411c73adfbaf08bd93b1ad2 | [log] [tgz] |
---|---|---|
author | Stan Chesnutt <chesnutt@google.com> | Thu Dec 16 10:59:48 2010 -0800 |
committer | Stan Chesnutt <chesnutt@google.com> | Thu Dec 16 10:59:48 2010 -0800 |
tree | ff262884f4b778bd4b8132d57954b706b43ab1b3 | |
parent | e88a1b9e3d39376d2a33efff49229985fe8797e8 [diff] [blame] |
fix undefined behavior with certain left-shift count values Change-Id: I1b71de28312a56a3b1d27fcfaf0a7b71d5777e6c
diff --git a/libnetutils/ifc_utils.c b/libnetutils/ifc_utils.c index 0ca5fe6..95a144c 100644 --- a/libnetutils/ifc_utils.c +++ b/libnetutils/ifc_utils.c
@@ -224,6 +224,11 @@ { in_addr_t mask = 0; + // C99 (6.5.7): shifts of 32 bits have undefined results + if (prefix_length == 0) { + return 0; + } + mask = ~mask << (32 - prefix_length); mask = htonl(mask);