This is an automatic generated email to let you know that the following patch 
were queued at the 
http://git.linuxtv.org/v4l-utils.git tree:

Subject: rds-ctl: fix segfault in list_devices()
Author:  Hans Verkuil <hans.verk...@cisco.com>
Date:    Thu Aug 15 10:29:22 2013 +0200

You can't use files.erase() in list_devices, since if the last element
is removed, then the for-loop will still do a ++iter, which will cause
a segfault the next time iter is derefenced.

This situation happens if there are radio *transmitter* devices, which
do not support G_TUNER.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>

 utils/rds-ctl/rds-ctl.cpp |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

---

http://git.linuxtv.org/v4l-utils.git?a=commitdiff;h=811e4836e33e917394e5f0df5a81ddd8100da911

diff --git a/utils/rds-ctl/rds-ctl.cpp b/utils/rds-ctl/rds-ctl.cpp
index 621b427..9ab2b65 100644
--- a/utils/rds-ctl/rds-ctl.cpp
+++ b/utils/rds-ctl/rds-ctl.cpp
@@ -364,6 +364,7 @@ static dev_vec list_devices(void)
        DIR *dp;
        struct dirent *ep;
        dev_vec files;
+       dev_vec valid_devices;
        dev_map links;
 
        struct v4l2_tuner vt;
@@ -385,22 +386,21 @@ static dev_vec list_devices(void)
                int fd = open(iter->c_str(), O_RDONLY | O_NONBLOCK);
                std::string bus_info;
 
-               if (fd < 0) {
-                       iter = files.erase(iter);
+               if (fd < 0)
                        continue;
-               }
                memset(&vt, 0, sizeof(vt));
-               if (doioctl(fd, VIDIOC_G_TUNER, &vt) != 0) {
+               if (ioctl(fd, VIDIOC_G_TUNER, &vt) != 0) {
                        close(fd);
-                       iter = files.erase(iter);
                        continue;
                }
                /* remove device if it doesn't support rds block I/O */
-               if (!(vt.capability & V4L2_TUNER_CAP_RDS_BLOCK_IO))
+               if (vt.capability & V4L2_TUNER_CAP_RDS_BLOCK_IO)
+                       valid_devices.push_back(*iter);
+               else
                        iter = files.erase(iter);
                close(fd);
        }
-       return files;
+       return valid_devices;
 }
 
 static int parse_subopt(char **subs, const char * const *subopts, char **value)

_______________________________________________
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to