diff --git a/daemon/x52ctl.c b/daemon/x52ctl.c index fa291d0..5ab3fd7 100644 --- a/daemon/x52ctl.c +++ b/daemon/x52ctl.c @@ -71,7 +71,7 @@ static int send_command(int sock_fd, int argc, char **argv) buflen += arglen; } - rc = x52d_send_command(sock_fd, buffer, buflen); + rc = x52d_send_command(sock_fd, buffer, buflen, sizeof(buffer)); if (rc >= 0) { if (write(STDOUT_FILENO, buffer, rc) < 0) { perror("write"); diff --git a/daemon/x52d_comm_client.c b/daemon/x52d_comm_client.c index 61905f6..3c40a73 100644 --- a/daemon/x52d_comm_client.c +++ b/daemon/x52d_comm_client.c @@ -51,7 +51,7 @@ int x52d_dial_command(const char *sock_path) return sock; } -int x52d_send_command(int sock_fd, char *buffer, size_t buflen) +int x52d_send_command(int sock_fd, char *buffer, size_t bufin, size_t bufout) { int rc; @@ -60,7 +60,7 @@ int x52d_send_command(int sock_fd, char *buffer, size_t buflen) * Unix sockets should have sufficient capacity to send the full * datagram in a single message. Assume that is the case. */ - rc = send(sock_fd, buffer, buflen, 0); + rc = send(sock_fd, buffer, bufin, 0); if (rc < 0) { // Error if (errno == EINTR) { @@ -77,7 +77,7 @@ int x52d_send_command(int sock_fd, char *buffer, size_t buflen) /* Wait till we get a response */ for (;;) { - rc = recv(sock_fd, buffer, buflen, 0); + rc = recv(sock_fd, buffer, bufout, 0); if (rc < 0) { // Error if (errno == EINTR) { diff --git a/daemon/x52dcomm.h b/daemon/x52dcomm.h index 902facc..b4bc4a7 100644 --- a/daemon/x52dcomm.h +++ b/daemon/x52dcomm.h @@ -75,12 +75,13 @@ int x52d_dial_command(const char *sock_path); * parameters. This is also used to save the returned * response. * - * @param[in] buflen Length of the buffer to hold the returned response. + * @param[in] bufin Length of the command in the input buffer + * @param[in] bufout Maximum length of the response * * @returns number of bytes returned from the server * @returns -1 on an error condition, and \c errno is set accordingly. */ -int x52d_send_command(int sock_fd, char *buffer, size_t buflen); +int x52d_send_command(int sock_fd, char *buffer, size_t bufin, size_t bufout); /** @} */ #ifdef __cplusplus