0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 03:52:22 +02:00

stream: check file descriptor passed to fd:// or fdclose://

This commit is contained in:
sfan5 2024-05-13 21:55:51 +02:00
parent 54c755b08d
commit 553fb024d4

View File

@ -299,10 +299,16 @@ static int open_f(stream_t *stream, const struct stream_open_args *args)
if (strncmp(url, "fd://", 5) == 0 || is_fdclose) {
char *begin = strstr(stream->url, "://") + 3, *end = NULL;
p->fd = strtol(begin, &end, 0);
if (!end || end == begin || end[0]) {
MP_ERR(stream, "Invalid FD: %s\n", stream->url);
if (!end || end == begin || end[0] || p->fd < 0) {
MP_ERR(stream, "Invalid FD number: %s\n", stream->url);
return STREAM_ERROR;
}
#ifdef F_SETFD
if (fcntl(p->fd, F_GETFD) == -1) {
MP_ERR(stream, "Invalid FD: %d\n", p->fd);
return STREAM_ERROR;
}
#endif
if (is_fdclose)
p->close = true;
} else if (!strict_fs && !strcmp(filename, "-")) {