* Routine used by RCTL syscalls to read in input string. */
| 1537 | * Routine used by RCTL syscalls to read in input string. |
| 1538 | */ |
| 1539 | static int |
| 1540 | rctl_read_inbuf(char **inputstr, const char *inbufp, size_t inbuflen) |
| 1541 | { |
| 1542 | char *str; |
| 1543 | int error; |
| 1544 | |
| 1545 | ASSERT_RACCT_ENABLED(); |
| 1546 | |
| 1547 | if (inbuflen <= 0) |
| 1548 | return (EINVAL); |
| 1549 | if (inbuflen > RCTL_MAX_INBUFSIZE) |
| 1550 | return (E2BIG); |
| 1551 | |
| 1552 | str = malloc(inbuflen + 1, M_RCTL, M_WAITOK); |
| 1553 | error = copyinstr(inbufp, str, inbuflen, NULL); |
| 1554 | if (error != 0) { |
| 1555 | free(str, M_RCTL); |
| 1556 | return (error); |
| 1557 | } |
| 1558 | |
| 1559 | *inputstr = str; |
| 1560 | |
| 1561 | return (0); |
| 1562 | } |
| 1563 | |
| 1564 | /* |
| 1565 | * Routine used by RCTL syscalls to write out output string. |
no test coverage detected