diff --git a/input/ipc-unix.c b/input/ipc-unix.c index a416b54e1e..11468e48bd 100644 --- a/input/ipc-unix.c +++ b/input/ipc-unix.c @@ -395,11 +395,11 @@ struct mp_ipc_ctx *mp_init_ipc(struct mp_client_api *client_api, if (opts->ipc_client && opts->ipc_client[0]) { int fd = -1; - if (strncmp(opts->ipc_client, "fd://", 5) == 0) { - char *end; - unsigned long l = strtoul(opts->ipc_client + 5, &end, 0); - if (!end[0] && l <= INT_MAX) - fd = l; + bstr str = bstr0(opts->ipc_client); + if (bstr_eatstart0(&str, "fd://") && str.len) { + long long ll = bstrtoll(str, &str, 0); + if (!str.len && ll >= 0 && ll <= INT_MAX) + fd = ll; } if (fd < 0) { MP_ERR(arg, "Invalid IPC client argument: '%s'\n", opts->ipc_client); diff --git a/input/ipc-win.c b/input/ipc-win.c index c215a25953..b7e54669ab 100644 --- a/input/ipc-win.c +++ b/input/ipc-win.c @@ -466,11 +466,11 @@ struct mp_ipc_ctx *mp_init_ipc(struct mp_client_api *client_api, if (opts->ipc_client && opts->ipc_client[0]) { int fd = -1; - if (strncmp(opts->ipc_client, "fd://", 5) == 0) { - char *end; - unsigned long l = strtoul(opts->ipc_client + 5, &end, 0); - if (!end[0] && l <= INT_MAX) - fd = l; + bstr str = bstr0(opts->ipc_client); + if (bstr_eatstart0(&str, "fd://") && str.len) { + long long ll = bstrtoll(str, &str, 0); + if (!str.len && ll >= 0 && ll <= INT_MAX) + fd = ll; } if (fd < 0) { MP_ERR(arg, "Invalid IPC client argument: '%s'\n", opts->ipc_client);