* Check if the current ioctls list can be replaced by the new one. */
| 388 | * Check if the current ioctls list can be replaced by the new one. |
| 389 | */ |
| 390 | static int |
| 391 | cap_ioctl_limit_check(struct filedescent *fdep, const u_long *cmds, |
| 392 | size_t ncmds) |
| 393 | { |
| 394 | u_long *ocmds; |
| 395 | ssize_t oncmds; |
| 396 | u_long i; |
| 397 | long j; |
| 398 | |
| 399 | oncmds = fdep->fde_nioctls; |
| 400 | if (oncmds == -1) |
| 401 | return (0); |
| 402 | if (oncmds < (ssize_t)ncmds) |
| 403 | return (ENOTCAPABLE); |
| 404 | |
| 405 | ocmds = fdep->fde_ioctls; |
| 406 | for (i = 0; i < ncmds; i++) { |
| 407 | for (j = 0; j < oncmds; j++) { |
| 408 | if (cmds[i] == ocmds[j]) |
| 409 | break; |
| 410 | } |
| 411 | if (j == oncmds) |
| 412 | return (ENOTCAPABLE); |
| 413 | } |
| 414 | |
| 415 | return (0); |
| 416 | } |
| 417 | |
| 418 | int |
| 419 | kern_cap_ioctls_limit(struct thread *td, int fd, u_long *cmds, size_t ncmds) |
no outgoing calls
no test coverage detected