You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by bdawley <be...@gmail.com> on 2015/03/02 12:45:06 UTC

Infinite Loop in SecureRandomImpl (with suggested fix)

I ran into an issue initializing a couple of weeks back, and it got caught in
the following section of SecureRandomImpl.cpp (lines 72-77 in activemq-cpp
3.8.3):

        do {
            // Attempt to find an OS source for secure random bytes.
            result = apr_file_open( &config->randFile, files[index],
                                    APR_READ, APR_OS_DEFAULT,
                                    config->pool.getAprPool() );
        } while( index < 2 && result != APR_SUCCESS );

We did not implement the /dev directory because it was not necessary for our
application and we were stripping out as much as possible to minimize memory
usage.  That doesn't seem to be an issue, as ActiveMQ will use its own
randomizer if none are found, but since index never gets incremented it just
gets stuck.  Our own workaround simply involved putting in /dev/random since
we weren't /that/ constrained, but it does warrant a mention, even if it's
rare that this would actually apply.

Suggested fix:  add a line incrementing index within the loop to ensure
eventual termination



--
View this message in context: http://activemq.2283324.n4.nabble.com/Infinite-Loop-in-SecureRandomImpl-with-suggested-fix-tp4692268.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.