Commit 332c520c authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Move CLI_AUTH_RESPONSE_LEN define to cli.h, exclude terminating NUL.

parent a39be7ab
...@@ -88,7 +88,7 @@ cli_sock(const char *T_arg, const char *S_arg) ...@@ -88,7 +88,7 @@ cli_sock(const char *T_arg, const char *S_arg)
int sock; int sock;
unsigned status; unsigned status;
char *answer = NULL; char *answer = NULL;
char buf[CLI_AUTH_RESPONSE_LEN]; char buf[CLI_AUTH_RESPONSE_LEN + 1];
sock = VSS_open(T_arg, timeout); sock = VSS_open(T_arg, timeout);
if (sock < 0) { if (sock < 0) {
......
...@@ -275,7 +275,7 @@ static void ...@@ -275,7 +275,7 @@ static void
mcf_auth(struct cli *cli, const char *const *av, void *priv) mcf_auth(struct cli *cli, const char *const *av, void *priv)
{ {
int fd; int fd;
char buf[CLI_AUTH_RESPONSE_LEN]; char buf[CLI_AUTH_RESPONSE_LEN + 1];
AN(av[2]); AN(av[2]);
(void)priv; (void)priv;
......
...@@ -339,7 +339,7 @@ varnish_launch(struct varnish *v) ...@@ -339,7 +339,7 @@ varnish_launch(struct varnish *v)
nfd = open(abuf, O_RDONLY); nfd = open(abuf, O_RDONLY);
assert(nfd >= 0); assert(nfd >= 0);
assert(sizeof abuf >= CLI_AUTH_RESPONSE_LEN + 6); assert(sizeof abuf >= CLI_AUTH_RESPONSE_LEN + 7);
strcpy(abuf, "auth "); strcpy(abuf, "auth ");
VCLI_AuthResponse(nfd, r, abuf + 5); VCLI_AuthResponse(nfd, r, abuf + 5);
AZ(close(nfd)); AZ(close(nfd));
......
...@@ -206,3 +206,5 @@ enum VCLI_status_e { ...@@ -206,3 +206,5 @@ enum VCLI_status_e {
/* Length of first line of response */ /* Length of first line of response */
#define CLI_LINE0_LEN 13 #define CLI_LINE0_LEN 13
#define CLI_AUTH_RESPONSE_LEN 64 /* 64 hex + NUL */
...@@ -47,7 +47,5 @@ struct cli { ...@@ -47,7 +47,5 @@ struct cli {
int VCLI_WriteResult(int fd, const struct cli *cli); int VCLI_WriteResult(int fd, const struct cli *cli);
int VCLI_ReadResult(int fd, unsigned *status, char **ptr, double tmo); int VCLI_ReadResult(int fd, unsigned *status, char **ptr, double tmo);
#define CLI_AUTH_RESPONSE_LEN 65 /* 64 hex + NUL */
void VCLI_AuthResponse(int S_fd, const char *challenge, void VCLI_AuthResponse(int S_fd, const char *challenge,
char reponse[CLI_AUTH_RESPONSE_LEN]); char reponse[CLI_AUTH_RESPONSE_LEN + 1]);
...@@ -40,13 +40,13 @@ ...@@ -40,13 +40,13 @@
void void
VCLI_AuthResponse(int S_fd, const char *challenge, VCLI_AuthResponse(int S_fd, const char *challenge,
char response[CLI_AUTH_RESPONSE_LEN]) char response[CLI_AUTH_RESPONSE_LEN + 1])
{ {
SHA256_CTX ctx; SHA256_CTX ctx;
uint8_t buf[BUFSIZ]; uint8_t buf[BUFSIZ];
int i; int i;
assert(CLI_AUTH_RESPONSE_LEN == (SHA256_LEN * 2 + 1)); assert(CLI_AUTH_RESPONSE_LEN == (SHA256_LEN * 2));
SHA256_Init(&ctx); SHA256_Init(&ctx);
SHA256_Update(&ctx, challenge, 32); SHA256_Update(&ctx, challenge, 32);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment