author | zecke <zecke> | 2005-01-09 16:27:40 (UTC) |
---|---|---|
committer | zecke <zecke> | 2005-01-09 16:27:40 (UTC) |
commit | ebd352b30b5b0278e613e1d1ecc60a5fc7756961 (patch) (unidiff) | |
tree | 0a7967a8cf668bf06fd949fbc7e1c9c33043fc60 | |
parent | c6432d421a0ec3d158bf40309e98fc0386c4a287 (diff) | |
download | opie-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
-rw-r--r-- | noncore/settings/networksettings2/opietooth2/OTGateway.cpp | 1 | ||||
-rw-r--r-- | noncore/settings/networksettings2/opietooth2/OTGateway.h | 2 |
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 | |||
@@ -116,64 +116,65 @@ OTDevice * OTGateway::getOTDevice( ) { | |||
116 | SIGNAL( error( const QString & ) ), | 116 | SIGNAL( error( const QString & ) ), |
117 | this, | 117 | this, |
118 | SLOT( SLOT_ShowError( const QString & ) ) ); | 118 | SLOT( SLOT_ShowError( const QString & ) ) ); |
119 | } | 119 | } |
120 | 120 | ||
121 | return TheOTDevice; | 121 | return TheOTDevice; |
122 | } | 122 | } |
123 | 123 | ||
124 | // start bluetooth (if stopped) | 124 | // start bluetooth (if stopped) |
125 | // return TRUE if started | 125 | // return TRUE if started |
126 | void OTGateway::SLOT_SetEnabled( bool Mode ) { | 126 | void OTGateway::SLOT_SetEnabled( bool Mode ) { |
127 | if( Mode ) { | 127 | if( Mode ) { |
128 | SLOT_Enable(); | 128 | SLOT_Enable(); |
129 | return; | 129 | return; |
130 | } | 130 | } |
131 | SLOT_Disable(); | 131 | SLOT_Disable(); |
132 | } | 132 | } |
133 | 133 | ||
134 | void OTGateway::SLOT_Enable() { | 134 | void OTGateway::SLOT_Enable() { |
135 | getOTDevice()->attach(); | 135 | getOTDevice()->attach(); |
136 | } | 136 | } |
137 | 137 | ||
138 | void OTGateway::SLOT_Disable() { | 138 | void OTGateway::SLOT_Disable() { |
139 | getOTDevice()->detach(); | 139 | getOTDevice()->detach(); |
140 | } | 140 | } |
141 | 141 | ||
142 | bool OTGateway::needsEnabling() { | 142 | bool OTGateway::needsEnabling() { |
143 | return getOTDevice()->needsAttach(); | 143 | return getOTDevice()->needsAttach(); |
144 | } | 144 | } |
145 | 145 | ||
146 | bool OTGateway::isEnabled() { | 146 | bool OTGateway::isEnabled() { |
147 | if( getOTDevice()->deviceNr() >= 0 && | 147 | if( getOTDevice()->deviceNr() >= 0 && |
148 | AllDrivers.count() != 0 && | ||
148 | driver( getOTDevice()->deviceNr() )->isUp() ) | 149 | driver( getOTDevice()->deviceNr() )->isUp() ) |
149 | return TRUE; | 150 | return TRUE; |
150 | 151 | ||
151 | // else check system | 152 | // else check system |
152 | return getOTDevice()->isAttached(); | 153 | return getOTDevice()->isAttached(); |
153 | } | 154 | } |
154 | 155 | ||
155 | void OTGateway::SLOT_ShowError( const QString & S ) { | 156 | void OTGateway::SLOT_ShowError( const QString & S ) { |
156 | 157 | ||
157 | odebug << S << oendl; | 158 | odebug << S << oendl; |
158 | 159 | ||
159 | if( ErrorConnectCount > 0 ) { | 160 | if( ErrorConnectCount > 0 ) { |
160 | // pass error | 161 | // pass error |
161 | emit error( QString( "<p>" ) + S + "</p>" ); | 162 | emit error( QString( "<p>" ) + S + "</p>" ); |
162 | return; | 163 | return; |
163 | } | 164 | } |
164 | 165 | ||
165 | QMessageBox::warning( 0, | 166 | QMessageBox::warning( 0, |
166 | tr("OTGateway error"), | 167 | tr("OTGateway error"), |
167 | S ); | 168 | S ); |
168 | } | 169 | } |
169 | 170 | ||
170 | void OTGateway::connectNotify( const char * S ) { | 171 | void OTGateway::connectNotify( const char * S ) { |
171 | if( S && strcmp( S, "error(const QString&)" ) == 0 ) { | 172 | if( S && strcmp( S, "error(const QString&)" ) == 0 ) { |
172 | ErrorConnectCount ++; | 173 | ErrorConnectCount ++; |
173 | } | 174 | } |
174 | } | 175 | } |
175 | 176 | ||
176 | void OTGateway::disconnectNotify( const char * S ) { | 177 | void OTGateway::disconnectNotify( const char * S ) { |
177 | if( S && strcmp( S, "error(const QString&)" ) == 0 ) { | 178 | if( S && strcmp( S, "error(const QString&)" ) == 0 ) { |
178 | ErrorConnectCount --; | 179 | ErrorConnectCount --; |
179 | } | 180 | } |
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 | |||
@@ -60,65 +60,65 @@ public : | |||
60 | class OTGateway : public QObject { | 60 | class OTGateway : public QObject { |
61 | 61 | ||
62 | Q_OBJECT | 62 | Q_OBJECT |
63 | 63 | ||
64 | public : | 64 | public : |
65 | 65 | ||
66 | // single instance | 66 | // single instance |
67 | static OTGateway * getOTGateway( void ); | 67 | static OTGateway * getOTGateway( void ); |
68 | static void releaseOTGateway( void ); | 68 | static void releaseOTGateway( void ); |
69 | // convert device type as class to name for that class | 69 | // convert device type as class to name for that class |
70 | static const char * deviceTypeToName( int Cls ); | 70 | static const char * deviceTypeToName( int Cls ); |
71 | 71 | ||
72 | // open bluetooth system | 72 | // open bluetooth system |
73 | OTGateway( void ); | 73 | OTGateway( void ); |
74 | // close bluetooth system | 74 | // close bluetooth system |
75 | ~OTGateway( void ); | 75 | ~OTGateway( void ); |
76 | 76 | ||
77 | // get access to system device | 77 | // get access to system device |
78 | OTDevice * getOTDevice(); | 78 | OTDevice * getOTDevice(); |
79 | 79 | ||
80 | // return true if this device needs enabling of bluetooth | 80 | // return true if this device needs enabling of bluetooth |
81 | bool needsEnabling(); | 81 | bool needsEnabling(); |
82 | // return true if system is running | 82 | // return true if system is running |
83 | bool isEnabled(); | 83 | bool isEnabled(); |
84 | void setRefreshTimer( int MilleSecs ); | 84 | void setRefreshTimer( int MilleSecs ); |
85 | // return socket to HCI raw layer | 85 | // return socket to HCI raw layer |
86 | inline int getSocket() | 86 | inline int getSocket() |
87 | { return HciCtl; } | 87 | { return HciCtl; } |
88 | 88 | ||
89 | OTDriverList & getDriverList() | 89 | OTDriverList & getDriverList() |
90 | { return AllDrivers; } | 90 | { return AllDrivers; } |
91 | OTDriver * driver( int nr ) | 91 | OTDriver * driver( int nr ) |
92 | { return AllDrivers[nr]; } | 92 | { return AllDrivers.count() == 0 ? 0 : AllDrivers[nr]; } |
93 | void updateDrivers(); | 93 | void updateDrivers(); |
94 | 94 | ||
95 | PANConnectionVector getPANConnections(); | 95 | PANConnectionVector getPANConnections(); |
96 | 96 | ||
97 | // scan neighbourhood using device | 97 | // scan neighbourhood using device |
98 | void scanNeighbourhood( OTDriver * D = 0 ); | 98 | void scanNeighbourhood( OTDriver * D = 0 ); |
99 | void stopScanOfNeighbourhood(void ); | 99 | void stopScanOfNeighbourhood(void ); |
100 | void setScanWith( OTDriver * D = 0 ) | 100 | void setScanWith( OTDriver * D = 0 ) |
101 | { ScanWith = (D) ? D : | 101 | { ScanWith = (D) ? D : |
102 | (AllDrivers.count() ) ? AllDrivers[0] : 0; } | 102 | (AllDrivers.count() ) ? AllDrivers[0] : 0; } |
103 | OTDriver * scanWith( void ) | 103 | OTDriver * scanWith( void ) |
104 | { return ScanWith; } | 104 | { return ScanWith; } |
105 | 105 | ||
106 | // get list of all detected peers | 106 | // get list of all detected peers |
107 | inline const PeerVector & peers( void ) | 107 | inline const PeerVector & peers( void ) |
108 | { return AllPeers; } | 108 | { return AllPeers; } |
109 | // ping peer to see if it is up | 109 | // ping peer to see if it is up |
110 | bool isPeerUp( const OTDeviceAddress & PAddr, | 110 | bool isPeerUp( const OTDeviceAddress & PAddr, |
111 | int timeoutInSec = 1, | 111 | int timeoutInSec = 1, |
112 | int timeoutInUSec = 0, | 112 | int timeoutInUSec = 0, |
113 | int retry = 1 ); | 113 | int retry = 1 ); |
114 | OTPeer * findPeer( const OTDeviceAddress & Addr ); | 114 | OTPeer * findPeer( const OTDeviceAddress & Addr ); |
115 | void removePeer( OTPeer * P ); | 115 | void removePeer( OTPeer * P ); |
116 | void addPeer( OTPeer * P ); | 116 | void addPeer( OTPeer * P ); |
117 | 117 | ||
118 | OTDriver * findDriver( const OTDeviceAddress & Addr ); | 118 | OTDriver * findDriver( const OTDeviceAddress & Addr ); |
119 | 119 | ||
120 | inline const LinkKeyArray & getLinkKeys() const | 120 | inline const LinkKeyArray & getLinkKeys() const |
121 | { return AllKeys; } | 121 | { return AllKeys; } |
122 | bool removeLinkKey( unsigned int index ); | 122 | bool removeLinkKey( unsigned int index ); |
123 | 123 | ||
124 | // return device number if we are connected over any device | 124 | // return device number if we are connected over any device |