client: keep array subscripts in bounds.

This commit is contained in:
Charlie Fenton 2014-07-16 06:05:01 -07:00
parent b37cf4cd9a
commit 64d76198ea
3 changed files with 18 additions and 6 deletions

View File

@ -37,6 +37,7 @@
#endif
#include "coproc.h"
#include "gpu_detect.h"
#include "file_names.h"
#include "util.h"
#include "str_replace.h"
@ -60,7 +61,7 @@ vector<COPROC_INTEL> intel_gpus;
vector<OPENCL_DEVICE_PROP> ati_opencls;
vector<OPENCL_DEVICE_PROP> nvidia_opencls;
vector<OPENCL_DEVICE_PROP> intel_gpu_opencls;
vector<OPENCL_DEVICE_PROP> other_opencls[MAX_RSC];
vector<OPENCL_DEVICE_PROP> other_opencls[MAX_OTHER_OPENCLS];
vector<OPENCL_CPU_PROP> cpu_opencls;
// Number of OpenCL coproc vendors other than AMD, NVIDIA or Intel
@ -281,7 +282,7 @@ void COPROCS::correlate_gpus(
ati_opencls.clear();
nvidia_opencls.clear();
intel_gpu_opencls.clear();
for (j=0; j<MAX_RSC; j++) {
for (j=0; j<MAX_OTHER_OPENCLS; j++) {
other_opencls[j].clear();
}
cpu_opencls.clear();
@ -373,7 +374,7 @@ int COPROCS::read_coproc_info_file(vector<string> &warnings) {
ati_opencls.clear();
nvidia_opencls.clear();
intel_gpu_opencls.clear();
for (int j=0; j<MAX_RSC; j++) {
for (int j=0; j<MAX_OTHER_OPENCLS; j++) {
other_opencls[j].clear();
}
cpu_opencls.clear();
@ -482,7 +483,7 @@ int COPROCS::read_coproc_info_file(vector<string> &warnings) {
}
}
if (vendor_index >= MAX_RSC) {
if (vendor_index >= MAX_OTHER_OPENCLS) {
// Too many OpenCL device vendors found (should never happen here)
continue; // Discard this coprocessor's info
}

View File

@ -15,14 +15,25 @@
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
#ifndef _GPU_DETECT_H_
#define _GPU_DETECT_H_
#include "coproc.h"
using std::vector;
// NOTE: coprocs[0] is reserved for CPU, leaving MAX_RSC-1
#define MAX_OTHER_OPENCLS MAX_RSC-1
extern vector<COPROC_ATI> ati_gpus;
extern vector<COPROC_NVIDIA> nvidia_gpus;
extern vector<COPROC_INTEL> intel_gpus;
extern vector<OPENCL_DEVICE_PROP> nvidia_opencls;
extern vector<OPENCL_DEVICE_PROP> ati_opencls;
extern vector<OPENCL_DEVICE_PROP> intel_gpu_opencls;
extern vector<OPENCL_DEVICE_PROP> other_opencls[MAX_RSC];
extern vector<OPENCL_DEVICE_PROP> other_opencls[MAX_OTHER_OPENCLS];
extern vector<OPENCL_CPU_PROP> cpu_opencls;
extern int num_other_opencl_types;
#endif

View File

@ -537,7 +537,7 @@ void COPROCS::get_opencl(
}
}
if (vendor_index >= MAX_RSC) {
if (vendor_index >= MAX_OTHER_OPENCLS) {
warnings.push_back("Too many OpenCL device vendors found");
continue; // Discard this coprocessor's info
}