[prev in list] [next in list] [prev in thread] [next in thread]
List: netcf-devel
Subject: [netcf-devel] Fixed a bug in netcf when netmask is bigger than 24
From: laine () laine ! org (Laine Stump)
Date: 2011-11-30 17:10:05
Message-ID: 4ED6636D.3060000 () laine ! org
[Download RAW message or body]
(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;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic