activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "yojay.li (JIRA)" <j...@apache.org>
Subject [jira] Created: (AMQCPP-285) If brokerURI is ipv4 format(127.0.0.1), createConnection will throw decaf::lang::exceptions::NumberFormatException.
Date Tue, 09 Feb 2010 01:53:34 GMT
If brokerURI is ipv4 format(127.0.0.1),  createConnection will throw decaf::lang::exceptions::NumberFormatException.
--------------------------------------------------------------------------------------------------------------------

                 Key: AMQCPP-285
                 URL: https://issues.apache.org/activemq/browse/AMQCPP-285
             Project: ActiveMQ C++ Client
          Issue Type: Bug
          Components: Decaf
    Affects Versions: 3.1
         Environment: vs2008,windows xp
            Reporter: yojay.li
            Assignee: Timothy Bish


file: 
  activemq-cpp-library-3.1.0\src\main\decaf\internal\net\URIHelper.cpp
funciton: 
  bool URIHelper::isValidIPv4Address( const std::string& host )
cause:
  The paramters of std::string.substr() is (start_pos, length) but not (start_pos, end_pos).
  Interger::parseInt(host.substr(..., ...)) will throw NumberFormatException.

fixed code:

bool URIHelper::isValidIPv4Address( const std::string& host ) {

    std::size_t index;
    std::size_t index2;

    try {

        int num;
        index = host.find( '.' );
		num = decaf::lang::Integer::parseInt( host.substr( 0, index ) );
        if( num < 0 || num > 255 ) {
            return false;
        }

        index2 = host.find( '.', index + 1 );
        num = decaf::lang::Integer::parseInt( host.substr( index + 1, index2 - index - 1)
);
        if( num < 0 || num > 255 ) {
            return false;
        }

        index = host.find( '.', index2 + 1 );
        num = decaf::lang::Integer::parseInt( host.substr( index2 + 1, index - index2 - 1)
);
        if( num < 0 || num > 255 ) {
            return false;
        }

        num = decaf::lang::Integer::parseInt( host.substr( index + 1, std::string::npos )
);
        if( num < 0 || num > 255 ) {
            return false;
        }

	} catch( decaf::lang::Exception& e ) {
        return false;
    }

    return true;
}
  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message