From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Tremer To: development@lists.ipfire.org Subject: Re: [PATCH] BUG10941: fix single ip-addresses when no subnet given Date: Fri, 16 Oct 2015 21:56:44 +0100 Message-ID: <1445029004.18375.97.camel@ipfire.org> In-Reply-To: <56213868.1020004@oab.de> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============7059514240457332813==" List-Id: --===============7059514240457332813== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Fri, 2015-10-16 at 19:48 +0200, Alexander Marx wrote: >=20 >=20 > Am 16.10.2015 um 17:54 schrieb Michael Tremer: > > On Fri, 2015-10-16 at 09:57 +0200, Alexander Marx wrote: > > > Signed-off-by: Alexander Marx > > > --- > > > html/cgi-bin/routing.cgi | 5 +++++ > > > 1 file changed, 5 insertions(+) > > >=20 > > > diff --git a/html/cgi-bin/routing.cgi b/html/cgi-bin/routing.cgi > > > index c460a74..3b5a2f7 100644 > > > --- a/html/cgi-bin/routing.cgi > > > +++ b/html/cgi-bin/routing.cgi > > > @@ -118,6 +118,11 @@ if ($settings{'ACTION'} eq $Lang::tr{'toggle > > > enable disable'}) { > > > } > > > =20 > > > if ($settings{'ACTION'} eq $Lang::tr{'add'}) { > > > + > > > + if (!&Network::check_prefix($settings{'IP'})){ > > > + $settings{'IP'} .=3D '/32'; > > > + } > > > + > > This won't work. The function &Network::check_prefix() takes the > > prefix > > (i.e. the number after the slash, e.g. 24). You are passing the IP > > address to the function which will never be a valid prefix and /32 > > will > > always be appended, even to valid inputs like 192.168.0.0/24 > > (result: > > 192.168.0.0/24/32). > I think it's not true that it's not true ;-) > The function takes a whole ip with subnetmask, true. But if you pass > only an ip to it or an ip with a wrong subnetmask , the function > returns false in which case i add /32 to it. http://git.ipfire.org/?p=3Dipfire-2.x.git;a=3Dblob;f=3Dconfig/cfgroot/network= -functions.pl;h=3Dcb4ca3dd88306f61290fab895308c0725c1ecdac;hb=3DHEAD#l136 This function clearly does what I said it would do. I don't know why you don't get an error, but this is not a solution to this bug. Is it possible that &General::iporsubtocidr() just ignores everything after the prefix? >=20 > In addition i tested several combinations of ip-addresses in cidr or > decimal notation and without subnetmask. > All tests passed with expected behaviour. >=20 > I just checked it twice. I could not find any side effects. But you > may drop this patch and i will try to find a new solution after my > holidays. When will you be back? >=20 >=20 > > > # Convert subnet masks to CIDR notation. > > > $settings{'IP'} =3D > > > &General::iporsubtocidr($settings{'IP'}); > > >=20 > > The remaining code should be amended that only prefixes are allowed > > when /32 is appended to hosts. > >=20 > > -Michael=20 -Michael --===============7059514240457332813== Content-Type: application/pgp-signature Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="signature.asc" MIME-Version: 1.0 LS0tLS1CRUdJTiBQR1AgU0lHTkFUVVJFLS0tLS0KVmVyc2lvbjogR251UEcgdjEKCmlRSWNCQUFC Q2dBR0JRSldJV1NNQUFvSkVJQjU4UDl2a0FrSFFUd1AvaWZhTlg1SVRucGxscWszSkJsZjhYUngK WXdlTFRzUmw0T3FVWnRHVnRiZG13Z2YzNHZIdWFXUDYzclZQSkw0SHlvUElTYy9XZGpsSFIvN0NK eTd3eThzSQphUUxLOU1ucUQvY1lyMmVSOEFjckFGbTRmVkxWWi8xU0RqdlRlU200Z0FQWlI1Rjlp TkFmanlmbnVVa3llMEdjCm1sdk1ZSG1JNW1IL291endmZmc4ZDlEVDZFY25rcmhkUDdhVTA4V3Zl NUphcU1BUUpGUnRPemc2UE9PYlUwWkYKK0trb1J6TzZrZ1dueTBXM011UFdBaTN4YjNFZ0pBTkpn ZXhhbDF6TnM2aXdtRmxZTTlTeXRRazZhNXJLSTRoWQpsTitzOWI1Q014L09qUEYxYVF6S0tDL3ZY aWtiZk9wUWtrYzkwVzhJWWlITE8weERRcnRQa04xNU56K0RLMktNCmR2akpLaUMvVVJMWXd3VkRU REZ4RVZkbFgweWpsWi8rWXV2b0phTEJmMXJTeERFWUtveFptTGhBS0dxS2JLaXYKRmNhVERYaS9p eUNlMHJvNXppSnpE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