projects
/
freeradius.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
5ae5839
)
fr_inaddr_mask fix 0 prefix
author
Sam Hartman
<hartmans@debian.org>
Thu, 10 Jul 2014 13:42:18 +0000
(09:42 -0400)
committer
Sam Hartman
<hartmans@debian.org>
Thu, 10 Jul 2014 13:42:18 +0000
(09:42 -0400)
Don't depend on the behavior of shifting by 32-bits on a 32-bit type.
src/lib/misc.c
patch
|
blob
|
history
diff --git
a/src/lib/misc.c
b/src/lib/misc.c
index
84d1624
..
af0616c
100644
(file)
--- a/
src/lib/misc.c
+++ b/
src/lib/misc.c
@@
-961,7
+961,9
@@
struct in_addr fr_inaddr_mask(struct in_addr const *ipaddr, uint8_t prefix)
return *ipaddr;
}
- ret = htonl(~((0x00000001UL << (32 - prefix)) - 1)) & ipaddr->s_addr;
+ if (prefix == 0)
+ ret = 0;
+ else ret = htonl(~((0x00000001UL << (32 - prefix)) - 1)) & ipaddr->s_addr;
return (*(struct in_addr *)&ret);
}