Philipp Matthias Hahn wrote:
Hello Matthew!
Hi Phillipp,
First of all, thanks for writing and providing ike.
No problem. Its been a fun project to work on and I'm very happy to have
more users trying out the software and providing feedback. Thanks to all
you folks who package and maintain this software. I know its a difficult
and mostly thankless job :)
On Wed, Sep 24, 2008 at 11:14:39AM -0500, Matthew Grooms wrote:
Nicolas Deschildre wrote:
Thanks for the detailed bug report!
I'm forwarding upstream.
Matthew : see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=500027
Thanks for the heads up. This and many other bugs have been fixed in the
2.1.2 maintenance release.
I think this particular bug is NOT fixed in 2.1.2, since I still
encountered the bug of inet_addr() returning 255.255.255.255 because it
gets passed a non-\0-terminated string.
I believe I understand the issue now. The ID information is stored
without null termination. In some instances its necessary to add the
terminator before evaluating / manipulating the ID data. As you have
discovered, I apparently missed one of these cases :)
Can you please try the attached patch? If it solves the problem for you
I will commit this to both the head and 2.1 maintenance branch. Perhaps
it can be added as a local patch until 2.1.3 is released.
Thanks again,
-Matthew
Index: ike.peerid.cpp
===================================================================
--- ike.peerid.cpp (revision 518)
+++ ike.peerid.cpp (working copy)
@@ -62,16 +62,12 @@
ph1->tunnel->peer->iddata_l,
ph1id.varid ) )
{
- char temp[ 512 ];
- size_t size =
ph1->tunnel->peer->iddata_l.size();
- if( size > 511 )
- size = 511;
+ BDATA temp;
+ temp = ph1->tunnel->peer->iddata_l;
+ temp.add( "", 1 );
- memcpy( temp,
ph1->tunnel->peer->iddata_l.buff(), size );
- temp[ size ] = 0;
-
log.txt( LLOG_ERROR,
- "!! : gen_ph1id_l failed.
invalid initiator id data \'%s\'\n", temp );
+ "!! : gen_ph1id_l failed.
invalid initiator id data \'%s\'\n", temp.text() );
return false;
}
@@ -90,8 +86,19 @@
{
if( ph1->tunnel->peer->iddata_l.size() )
{
- ph1id.addr.s_addr =
- inet_addr( ( char * )
ph1->tunnel->peer->iddata_l.buff() );
+ BDATA temp;
+ temp = ph1->tunnel->peer->iddata_l;
+ temp.add( "", 1 );
+
+ ph1id.addr.s_addr = inet_addr( temp.text() );
+
+ if( ph1id.addr.s_addr == INADDR_NONE )
+ {
+ log.txt( LLOG_ERROR,
+ "!! : gen_ph1id_l failed.
invalid initiator id data \'%s\'\n", temp.text() );
+
+ return false;
+ }
}
else
{