History

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

sfan5 committed 2 years ago

Commit 553fb021 parent 54c755b1 file · +8 −2Browse files

Unified · Split

stream/stream_file.c+8−2
@@ -299,10 +299,16 @@ static int open_f(stream_t *stream, const struct stream_open_args *args) · 298 unmodified lines
299 if (strncmp(url, "fd://", 5) == 0 || is_fdclose) {299 if (strncmp(url, "fd://", 5) == 0 || is_fdclose) {
300 char *begin = strstr(stream->url, "://") + 3, *end = NULL;300 char *begin = strstr(stream->url, "://") + 3, *end = NULL;
301 p->fd = strtol(begin, &end, 0);301 p->fd = strtol(begin, &end, 0);
302 if (!end || end == begin || end[0]) {302 if (!end || end == begin || end[0] || p->fd < 0) {
303 MP_ERR(stream, "Invalid FD: %s\n", stream->url);303 MP_ERR(stream, "Invalid FD number: %s\n", stream->url);
304 return STREAM_ERROR;304 return STREAM_ERROR;
305 }305 }
306#ifdef F_SETFD
307 if (fcntl(p->fd, F_GETFD) == -1) {
308 MP_ERR(stream, "Invalid FD: %d\n", p->fd);
309 return STREAM_ERROR;
310 }
311#endif
306 if (is_fdclose)312 if (is_fdclose)
307 p->close = true;313 p->close = true;
308 } else if (!strict_fs && !strcmp(filename, "-")) {314 } else if (!strict_fs && !strcmp(filename, "-")) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t