Message ID | 49C133F6.3020202@freemail.hu (mailing list archive) |
---|---|
State | Superseded, archived |
Headers |
Return-path: <linux-media-owner@vger.kernel.org> Envelope-to: mchehab@infradead.org Delivery-date: Wed, 18 Mar 2009 17:48:52 +0000 Received: from vger.kernel.org ([209.132.176.167]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1Ljzsq-0006Io-2O; Wed, 18 Mar 2009 17:48:52 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754142AbZCRRsv (ORCPT <rfc822; kmpark@infradead.org> + 1 other); Wed, 18 Mar 2009 13:48:51 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754106AbZCRRsv (ORCPT <rfc822;linux-media-outgoing>); Wed, 18 Mar 2009 13:48:51 -0400 Received: from mail01d.mail.t-online.hu ([84.2.42.6]:64080 "EHLO mail01d.mail.t-online.hu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751361AbZCRRsu (ORCPT <rfc822;linux-media@vger.kernel.org>); Wed, 18 Mar 2009 13:48:50 -0400 Received: from [192.168.1.65] (dsl54029F41.pool.t-online.hu [84.2.159.65]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail01d.mail.t-online.hu (Postfix) with ESMTPSA id EA041758FA6; Wed, 18 Mar 2009 18:48:32 +0100 (CET) Message-ID: <49C133F6.3020202@freemail.hu> Date: Wed, 18 Mar 2009 18:48:38 +0100 From: =?UTF-8?B?TsOpbWV0aCBNw6FydG9u?= <nm127@freemail.hu> User-Agent: Mozilla/5.0 (X11; U; Linux i686; hu-HU; rv:1.8.1.16) Gecko/20080702 SeaMonkey/1.1.11 MIME-Version: 1.0 To: Jean-Francois Moine <moinejf@free.fr>, linux-media@vger.kernel.org CC: LKML <linux-kernel@vger.kernel.org> Subject: [PATCH] gspca: add missing .type field check in VIDIOC_G_PARM Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-DCC-mail.t-online.hu-Metrics: mail01d.mail.t-online.hu 32711; Body=3 Fuz1=3 Fuz2=3 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: <linux-media.vger.kernel.org> X-Mailing-List: linux-media@vger.kernel.org |
Commit Message
Németh Márton
March 18, 2009, 5:48 p.m. UTC
From: Márton Németh <nm127@freemail.hu> The gspca webcam driver does not check the .type field of struct v4l2_streamparm. This field is an input parameter for the driver according to V4L2 API specification, revision 0.24 [1]. Add the missing check. The missing check was recognised by v4l-test 0.10 [2] together with gspca_sunplus driver and with "Trust 610 LCD POWERC@M ZOOM" webcam. This patch was verified also with v4l-test 0.10. References: [1] V4L2 API specification, revision 0.24 http://v4l2spec.bytesex.org/spec/r11680.htm [2] v4l-test: Test environment for Video For Linux Two API http://v4l-test.sourceforge.net/ Signed-off-by: Márton Németh <nm127@freemail.hu> --- -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Comments
2009/3/18 Németh Márton <nm127@freemail.hu>: > From: Márton Németh <nm127@freemail.hu> > > The gspca webcam driver does not check the .type field of struct v4l2_streamparm. > This field is an input parameter for the driver according to V4L2 API specification, > revision 0.24 [1]. Add the missing check. > > The missing check was recognised by v4l-test 0.10 [2] together with gspca_sunplus driver > and with "Trust 610 LCD POWERC@M ZOOM" webcam. This patch was verified also with > v4l-test 0.10. > > References: > [1] V4L2 API specification, revision 0.24 > http://v4l2spec.bytesex.org/spec/r11680.htm > > [2] v4l-test: Test environment for Video For Linux Two API > http://v4l-test.sourceforge.net/ > > Signed-off-by: Márton Németh <nm127@freemail.hu> > --- > --- linux-2.6.29-rc8/drivers/media/video/gspca/gspca.c.orig 2009-03-14 12:29:38.000000000 +0100 > +++ linux-2.6.29-rc8/drivers/media/video/gspca/gspca.c 2009-03-18 16:51:03.000000000 +0100 > @@ -1320,6 +1320,9 @@ static int vidioc_g_parm(struct file *fi > { > struct gspca_dev *gspca_dev = priv; > > + if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) > + return -EINVAL; > + > memset(parm, 0, sizeof *parm); > parm->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; ^^^^^^^^^^^^^^^^^^^ This line should be deleted as it's no longer needed. > parm->parm.capture.readbuffers = gspca_dev->nbufread; > Regards, David Ellingsworth -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
David Ellingsworth wrote: > 2009/3/18 Németh Márton <nm127@freemail.hu>: >> From: Márton Németh <nm127@freemail.hu> >> >> The gspca webcam driver does not check the .type field of struct v4l2_streamparm. >> This field is an input parameter for the driver according to V4L2 API specification, >> revision 0.24 [1]. Add the missing check. >> >> The missing check was recognised by v4l-test 0.10 [2] together with gspca_sunplus driver >> and with "Trust 610 LCD POWERC@M ZOOM" webcam. This patch was verified also with >> v4l-test 0.10. >> >> References: >> [1] V4L2 API specification, revision 0.24 >> http://v4l2spec.bytesex.org/spec/r11680.htm >> >> [2] v4l-test: Test environment for Video For Linux Two API >> http://v4l-test.sourceforge.net/ >> >> Signed-off-by: Márton Németh <nm127@freemail.hu> >> --- >> --- linux-2.6.29-rc8/drivers/media/video/gspca/gspca.c.orig 2009-03-14 12:29:38.000000000 +0100 >> +++ linux-2.6.29-rc8/drivers/media/video/gspca/gspca.c 2009-03-18 16:51:03.000000000 +0100 >> @@ -1320,6 +1320,9 @@ static int vidioc_g_parm(struct file *fi >> { >> struct gspca_dev *gspca_dev = priv; >> >> + if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) >> + return -EINVAL; >> + >> memset(parm, 0, sizeof *parm); >> parm->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; > ^^^^^^^^^^^^^^^^^^^ > This line should be deleted as it's no longer needed. Because memset() clears the whole parm structure this line is necessary. In other drivers the following code is there: tmp = parm->type; memset(parm, 0, sizeof(*parm)); parm->type = parm; Maybe changing the code similar to this would be easier to read? Márton Németh -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Thu, 19 Mar 2009, [ISO-8859-1] Németh Márton wrote: > David Ellingsworth wrote: > > 2009/3/18 Németh Márton <nm127@freemail.hu>: > >> From: Márton Németh <nm127@freemail.hu> > >> > >> The gspca webcam driver does not check the .type field of struct v4l2_streamparm. > >> This field is an input parameter for the driver according to V4L2 API specification, > >> revision 0.24 [1]. Add the missing check. > >> > >> The missing check was recognised by v4l-test 0.10 [2] together with gspca_sunplus driver > >> and with "Trust 610 LCD POWERC@M ZOOM" webcam. This patch was verified also with > >> v4l-test 0.10. > >> > >> References: > >> [1] V4L2 API specification, revision 0.24 > >> http://v4l2spec.bytesex.org/spec/r11680.htm > >> > >> [2] v4l-test: Test environment for Video For Linux Two API > >> http://v4l-test.sourceforge.net/ > >> > >> Signed-off-by: Márton Németh <nm127@freemail.hu> > >> --- > >> --- linux-2.6.29-rc8/drivers/media/video/gspca/gspca.c.orig 2009-03-14 12:29:38.000000000 +0100 > >> +++ linux-2.6.29-rc8/drivers/media/video/gspca/gspca.c 2009-03-18 16:51:03.000000000 +0100 > >> @@ -1320,6 +1320,9 @@ static int vidioc_g_parm(struct file *fi > >> { > >> struct gspca_dev *gspca_dev = priv; > >> > >> + if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) > >> + return -EINVAL; > >> + > >> memset(parm, 0, sizeof *parm); > >> parm->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; > > ^^^^^^^^^^^^^^^^^^^ > > This line should be deleted as it's no longer needed. > > Because memset() clears the whole parm structure this line is necessary. In other > drivers the following code is there: > > tmp = parm->type; > memset(parm, 0, sizeof(*parm)); > parm->type = parm; The memset isn't needed anymore either, I put it into v4l2_ioctl. I removed most of the code like that but I may have missed some drivers. -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
--- linux-2.6.29-rc8/drivers/media/video/gspca/gspca.c.orig 2009-03-14 12:29:38.000000000 +0100 +++ linux-2.6.29-rc8/drivers/media/video/gspca/gspca.c 2009-03-18 16:51:03.000000000 +0100 @@ -1320,6 +1320,9 @@ static int vidioc_g_parm(struct file *fi { struct gspca_dev *gspca_dev = priv; + if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) + return -EINVAL; + memset(parm, 0, sizeof *parm); parm->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; parm->parm.capture.readbuffers = gspca_dev->nbufread;