8000 compliance: fix enum frame sizes/intervals errors · v4l2loopback/v4l2loopback@5511365 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5511365

Browse files
vicamoumlaeute
authored andcommitted
compliance: fix enum frame sizes/intervals errors
This change checks frame size/format from user input. Signed-off-by: You-Sheng Yang <vicamo@gmail.com> (cherry picked from commit 80639c9) Signed-off-by: You-Sheng Yang <vicamo@gmail.com> Gbp-Pq: Name 0009-compliance-fix-enum-frame-sizes-intervals-errors.patch
1 parent 6a7bc5b commit 5511365

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

v4l2loopback.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,13 +749,19 @@ static int vidioc_enum_framesizes(struct file *file, void *fh,
749749
/* format has already been negotiated
750750
* cannot change during runtime
751751
*/
752+
if (argp->pixel_format != dev->pix_format.pixelformat)
753+
return -EINVAL;
754+
752755
argp->type = V4L2_FRMSIZE_TYPE_DISCRETE;
753756

754757
argp->discrete.width = dev->pix_format.width;
755758
argp->discrete.height = dev->pix_format.height;
756759
} else {
757760
/* if the format has not been negotiated yet, we accept anything
758761
*/
762+
if (NULL == format_by_fourcc(argp->pixel_format))
763+
return -EINVAL;
764+
759765
argp->type = V4L2_FRMSIZE_TYPE_CONTINUOUS;
760766

761767
argp->stepwise.min_width = V4L2LOOPBACK_SIZE_MIN_WIDTH;
@@ -784,12 +790,20 @@ static int vidioc_enum_frameintervals(struct file *file, void *fh,
784790

785791
if (dev->ready_for_capture) {
786792
if (argp->width != dev->pix_format.width ||
787-
argp->height != dev->pix_format.height)
793+
argp->height != dev->pix_format.height ||
794+
argp->pixel_format != dev->pix_format.pixelformat)
788795
return -EINVAL;
789796

790797
argp->type = V4L2_FRMIVAL_TYPE_DISCRETE;
791798
argp->discrete = dev->capture_param.timeperframe;
792799
} else {
800+
if (argp->width < V4L2LOOPBACK_SIZE_MIN_WIDTH ||
801+
argp->width > max_width ||
802+
argp->height < V4L2LOOPBACK_SIZE_MIN_HEIGHT ||
803+
argp->height > max_height ||
804+
NULL == format_by_fourcc(argp->pixel_format))
805+
return -EINVAL;
806+
793807
argp->type = V4L2_FRMIVAL_TYPE_CONTINUOUS;
794808
argp->stepwise.min.numerator = 1;
795809
argp->stepwise.min.denominator = V4L2LOOPBACK_FPS_MAX;

0 commit comments

Comments
 (0)
0