[master] 332c520 Move CLI_AUTH_RESPONSE_LEN define to cli.h, exclude terminating NUL.
Poul-Henning Kamp
phk at varnish-cache.org
Mon Jun 6 10:35:14 CEST 2011
commit 332c520c34fb00f980be1e48204928a64a2b2a53
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Jun 6 08:34:52 2011 +0000
Move CLI_AUTH_RESPONSE_LEN define to cli.h, exclude terminating NUL.
diff --git a/bin/varnishadm/varnishadm.c b/bin/varnishadm/varnishadm.c
index e3f97a3..d52c363 100644
--- a/bin/varnishadm/varnishadm.c
+++ b/bin/varnishadm/varnishadm.c
@@ -88,7 +88,7 @@ cli_sock(const char *T_arg, const char *S_arg)
int sock;
unsigned status;
char *answer = NULL;
- char buf[CLI_AUTH_RESPONSE_LEN];
+ char buf[CLI_AUTH_RESPONSE_LEN + 1];
sock = VSS_open(T_arg, timeout);
if (sock < 0) {
diff --git a/bin/varnishd/mgt_cli.c b/bin/varnishd/mgt_cli.c
index b09eb44..ee62ada 100644
--- a/bin/varnishd/mgt_cli.c
+++ b/bin/varnishd/mgt_cli.c
@@ -275,7 +275,7 @@ static void
mcf_auth(struct cli *cli, const char *const *av, void *priv)
{
int fd;
- char buf[CLI_AUTH_RESPONSE_LEN];
+ char buf[CLI_AUTH_RESPONSE_LEN + 1];
AN(av[2]);
(void)priv;
diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c
index efcdde7..3863c64 100644
--- a/bin/varnishtest/vtc_varnish.c
+++ b/bin/varnishtest/vtc_varnish.c
@@ -339,7 +339,7 @@ varnish_launch(struct varnish *v)
nfd = open(abuf, O_RDONLY);
assert(nfd >= 0);
- assert(sizeof abuf >= CLI_AUTH_RESPONSE_LEN + 6);
+ assert(sizeof abuf >= CLI_AUTH_RESPONSE_LEN + 7);
strcpy(abuf, "auth ");
VCLI_AuthResponse(nfd, r, abuf + 5);
AZ(close(nfd));
diff --git a/include/cli.h b/include/cli.h
index a3500a6..3b16877 100644
--- a/include/cli.h
+++ b/include/cli.h
@@ -206,3 +206,5 @@ enum VCLI_status_e {
/* Length of first line of response */
#define CLI_LINE0_LEN 13
+#define CLI_AUTH_RESPONSE_LEN 64 /* 64 hex + NUL */
+
diff --git a/include/cli_common.h b/include/cli_common.h
index 9dd3968..602afb0 100644
--- a/include/cli_common.h
+++ b/include/cli_common.h
@@ -47,7 +47,5 @@ struct cli {
int VCLI_WriteResult(int fd, const struct cli *cli);
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,
- char reponse[CLI_AUTH_RESPONSE_LEN]);
+ char reponse[CLI_AUTH_RESPONSE_LEN + 1]);
diff --git a/lib/libvarnish/cli_auth.c b/lib/libvarnish/cli_auth.c
index 45c0909..35d2ad6 100644
--- a/lib/libvarnish/cli_auth.c
+++ b/lib/libvarnish/cli_auth.c
@@ -40,13 +40,13 @@
void
VCLI_AuthResponse(int S_fd, const char *challenge,
- char response[CLI_AUTH_RESPONSE_LEN])
+ char response[CLI_AUTH_RESPONSE_LEN + 1])
{
SHA256_CTX ctx;
uint8_t buf[BUFSIZ];
int i;
- assert(CLI_AUTH_RESPONSE_LEN == (SHA256_LEN * 2 + 1));
+ assert(CLI_AUTH_RESPONSE_LEN == (SHA256_LEN * 2));
SHA256_Init(&ctx);
SHA256_Update(&ctx, challenge, 32);
More information about the varnish-commit
mailing list