diff --git a/stream/stream_file.c b/stream/stream_file.c index 1744fc13a4..d5c2aaa673 100644 --- a/stream/stream_file.c +++ b/stream/stream_file.c @@ -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, "-")) {