mirror of
https://github.com/mpv-player/mpv
synced 2025-01-13 10:26:09 +00:00
stream: check file descriptor passed to fd:// or fdclose://
This commit is contained in:
parent
54c755b08d
commit
553fb024d4
@ -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, "-")) {
|
||||
|
Loading…
Reference in New Issue
Block a user