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.
* Changed the way you calculate the netmask ip in a more intuitive way - feel 
free to ignore it if you want.

--- 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;


_______________________________________________
netcf-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/netcf-devel

Reply via email to