From 22e9b7cfee62d5e3855f5dfaefdbafcf31f99865 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Mon, 7 Oct 2024 09:10:35 +0200 Subject: [PATCH] import: accept video.info written by Win in *nix In MSW it seems like the video.info is written in text mode, so that line ending is CRLF. When read in POSIX systems, \r is not consumated so that expect it can be present. --- src/video_capture/import.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/video_capture/import.c b/src/video_capture/import.c index 30ed3a332..516490c41 100644 --- a/src/video_capture/import.c +++ b/src/video_capture/import.c @@ -288,13 +288,14 @@ static struct video_desc parse_video_desc_info(FILE *info, long *video_frame_cou desc.height = val; items_found |= 1U<<2U; } else if(strncmp(line, "fourcc ", strlen("fourcc ")) == 0) { - char *ptr = line + strlen("fourcc "); - if(strlen(ptr) != 5) { // including '\n' + char fcc[6]; + sscanf(line + strlen("fourcc "), "%5[^\r\n]", fcc); + if (strlen(fcc) != 4) { log_msg(LOG_LEVEL_ERROR, MOD_NAME "cannot read video FourCC tag.\n"); return (struct video_desc) { 0 }; } uint32_t fourcc = 0U; - memcpy((void *) &fourcc, ptr, sizeof(fourcc)); + memcpy((void *) &fourcc, fcc, sizeof(fourcc)); desc.color_spec = get_codec_from_fcc(fourcc); if(desc.color_spec == VIDEO_CODEC_NONE) { log_msg(LOG_LEVEL_ERROR, MOD_NAME "Requested codec not known.\n");