summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVishal Mahaveer <vishalm@ti.com>2016-07-08 14:25:55 -0400
committerVishal Mahaveer <vishalm@ti.com>2016-07-08 14:44:42 -0400
commit9484ff0277c3c5938e0ca9d02cf59a00fb2157b3 (patch)
tree23ad5ecbea40bbb3ae7563464d14aa2857ed16e8
parentc3a858cf45b2612a662447aa7c9ae72fce5aea78 (diff)
downloaddra7xx-9484ff0277c3c5938e0ca9d02cf59a00fb2157b3.tar.gz
dra7xx: camera: avoid index overflow
Handle cases where there could be more camera devices. Change-Id: Idcb6ecc8381de162131b60ca3d44c4f02bc5afaa Signed-off-by: Vishal Mahaveer <vishalm@ti.com>
-rw-r--r--camera/V4LCameraAdapter/V4LM2M.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/camera/V4LCameraAdapter/V4LM2M.cpp b/camera/V4LCameraAdapter/V4LM2M.cpp
index 3c9ee0a..25f83b7 100644
--- a/camera/V4LCameraAdapter/V4LM2M.cpp
+++ b/camera/V4LCameraAdapter/V4LM2M.cpp
@@ -380,7 +380,7 @@ void detectVideoDevice(char** video_device_list, int& num_device) {
d = opendir(dir_path);
if(d) {
//read each entry in the /dev/ and find if there is videox entry.
- while ((dir = readdir(d)) != NULL) {
+ while ((dir = readdir(d)) != NULL && (index < 10)) {
filename = dir->d_name;
if (strncmp(filename, DEVICE_NAME, 5) == 0) {
strcpy(dev_list[index],DEVICE_PATH);
@@ -400,8 +400,8 @@ void detectVideoDevice(char** video_device_list, int& num_device) {
static char device[15];
char *detectM2MDevice()
{
- char device_list[5][15];
- char* video_device_list[5];
+ char device_list[10][15];
+ char* video_device_list[10];
int num_v4l_devices = 0;
int tempHandle = NULL;
int ret;
@@ -409,7 +409,7 @@ char *detectM2MDevice()
memset((void*)&cap, 0, sizeof(v4l2_capability));
- for (int i = 0; i < 5; i++) {
+ for (int i = 0; i < 10; i++) {
video_device_list[i] = device_list[i];
}
//look for the connected video devices