summaryrefslogtreecommitdiff
authorzecke <zecke>2005-01-09 16:27:40 (UTC)
committer zecke <zecke>2005-01-09 16:27:40 (UTC)
commitebd352b30b5b0278e613e1d1ecc60a5fc7756961 (patch) (side-by-side diff)
tree0a7967a8cf668bf06fd949fbc7e1c9c33043fc60
parentc6432d421a0ec3d158bf40309e98fc0386c4a287 (diff)
downloadopie-ebd352b30b5b0278e613e1d1ecc60a5fc7756961.zip
opie-ebd352b30b5b0278e613e1d1ecc60a5fc7756961.tar.gz
opie-ebd352b30b5b0278e613e1d1ecc60a5fc7756961.tar.bz2
-Do not access the Array out of bounds
-Check that there is a driver before asking to query a non existant
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTGateway.cpp1
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTGateway.h2
2 files changed, 2 insertions, 1 deletions
diff --git a/noncore/settings/networksettings2/opietooth2/OTGateway.cpp b/noncore/settings/networksettings2/opietooth2/OTGateway.cpp
index e8137dd..1b61a2e 100644
--- a/noncore/settings/networksettings2/opietooth2/OTGateway.cpp
+++ b/noncore/settings/networksettings2/opietooth2/OTGateway.cpp
@@ -124,48 +124,49 @@ OTDevice * OTGateway::getOTDevice( ) {
// start bluetooth (if stopped)
// return TRUE if started
void OTGateway::SLOT_SetEnabled( bool Mode ) {
if( Mode ) {
SLOT_Enable();
return;
}
SLOT_Disable();
}
void OTGateway::SLOT_Enable() {
getOTDevice()->attach();
}
void OTGateway::SLOT_Disable() {
getOTDevice()->detach();
}
bool OTGateway::needsEnabling() {
return getOTDevice()->needsAttach();
}
bool OTGateway::isEnabled() {
if( getOTDevice()->deviceNr() >= 0 &&
+ AllDrivers.count() != 0 &&
driver( getOTDevice()->deviceNr() )->isUp() )
return TRUE;
// else check system
return getOTDevice()->isAttached();
}
void OTGateway::SLOT_ShowError( const QString & S ) {
odebug << S << oendl;
if( ErrorConnectCount > 0 ) {
// pass error
emit error( QString( "<p>" ) + S + "</p>" );
return;
}
QMessageBox::warning( 0,
tr("OTGateway error"),
S );
}
void OTGateway::connectNotify( const char * S ) {
if( S && strcmp( S, "error(const QString&)" ) == 0 ) {
diff --git a/noncore/settings/networksettings2/opietooth2/OTGateway.h b/noncore/settings/networksettings2/opietooth2/OTGateway.h
index d97ef35..11c6b30 100644
--- a/noncore/settings/networksettings2/opietooth2/OTGateway.h
+++ b/noncore/settings/networksettings2/opietooth2/OTGateway.h
@@ -68,49 +68,49 @@ public :
static void releaseOTGateway( void );
// convert device type as class to name for that class
static const char * deviceTypeToName( int Cls );
// open bluetooth system
OTGateway( void );
// close bluetooth system
~OTGateway( void );
// get access to system device
OTDevice * getOTDevice();
// return true if this device needs enabling of bluetooth
bool needsEnabling();
// return true if system is running
bool isEnabled();
void setRefreshTimer( int MilleSecs );
// return socket to HCI raw layer
inline int getSocket()
{ return HciCtl; }
OTDriverList & getDriverList()
{ return AllDrivers; }
OTDriver * driver( int nr )
- { return AllDrivers[nr]; }
+ { return AllDrivers.count() == 0 ? 0 : AllDrivers[nr]; }
void updateDrivers();
PANConnectionVector getPANConnections();
// scan neighbourhood using device
void scanNeighbourhood( OTDriver * D = 0 );
void stopScanOfNeighbourhood(void );
void setScanWith( OTDriver * D = 0 )
{ ScanWith = (D) ? D :
(AllDrivers.count() ) ? AllDrivers[0] : 0; }
OTDriver * scanWith( void )
{ return ScanWith; }
// get list of all detected peers
inline const PeerVector & peers( void )
{ return AllPeers; }
// ping peer to see if it is up
bool isPeerUp( const OTDeviceAddress & PAddr,
int timeoutInSec = 1,
int timeoutInUSec = 0,
int retry = 1 );
OTPeer * findPeer( const OTDeviceAddress & Addr );
void removePeer( OTPeer * P );
void addPeer( OTPeer * P );