(Thanks to Eric for reminding me about these patches.)
On 10/31/2011 07:23 AM, Jens Nyberg I wrote:
Hi,
I noticed a bug in netcf when setting a netmask larger than /24.
This patch consist of:
* Removed a -1 in the inet_ntop call which is the actual bug that made the string
incorrect.
Yep. Genuine bug!
* Changed the way you calculate the netmask ip in a more intuitive
way - feel free to ignore it if you want.
I like your way better too, but I turned 0xffffffff into 0xffffffffu
before pushing just because I'm paranoid about left shifts and
unintentionally signed operands :-)\
ACK and pushed (with the one small change noted above). Thanks!
--- xslt_ext.c 2011-10-26 17:42:54.000000000 +0200
+++ xslt_ext.c.new 2011-10-26 17:39:16.000000000 +0200
@@ -71,10 +71,10 @@
struct in_addr netmask;
xmlChar netmask_str[16];
- netmask.s_addr = htonl(~((1<< (32 - prefix)) - 1));
+ netmask.s_addr = htonl(~(0xffffffff>> prefix));
if (! inet_ntop(AF_INET,&netmask,
- (char *) netmask_str, sizeof(netmask_str) - 1)) {
+ (char *) netmask_str, sizeof(netmask_str))) {
xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
"ipcalc:netmask: internal error: inet_ntop failed");
goto error;