Skip to content

Commit 483d21d

Browse files
committed
vcap/v4l2: fail on malformed size opt
When `size=1` or `size=b` was entered, the option was silently ignored.
1 parent 21db4b7 commit 483d21d

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/video_capture/v4l2.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -524,11 +524,10 @@ parse_fmt(char *fmt, struct parsed_opts *opts)
524524
} str_to_uint = { .fourcc = 0 };
525525
memcpy(str_to_uint.str, fmt, MIN(strlen(fmt), 4));
526526
opts->pixelformat = str_to_uint.fourcc;
527-
} else if (strncmp(item, "size=", strlen("size=")) == 0) {
528-
if (strchr(item, 'x')) {
529-
opts->width = atoi(item + strlen("size="));
530-
opts->height = atoi(strchr(item, 'x') + 1);
531-
}
527+
} else if (strstr(item, "size=") == item &&
528+
strchr(item, 'x') != NULL) {
529+
opts->width = atoi(strchr(item, '=') + 1);
530+
opts->height = atoi(strchr(item, 'x') + 1);
532531
} else if (strncmp(item, "tpf=", strlen("tpf=")) == 0) {
533532
opts->numerator = atoi(item + strlen("tpf="));
534533
opts->denominator = strchr(item, '/') == NULL

0 commit comments

Comments
 (0)