Skip to content
This repository has been archived by the owner on Jul 30, 2021. It is now read-only.

Commit

Permalink
Move CLI_AUTH_RESPONSE_LEN define to cli.h, exclude terminating NUL.
Browse files Browse the repository at this point in the history
  • Loading branch information
bsdphk committed Jun 6, 2011
1 parent a39be7a commit 332c520
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion bin/varnishadm/varnishadm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion bin/varnishd/mgt_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion bin/varnishtest/vtc_varnish.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 2 additions & 0 deletions include/cli.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

4 changes: 1 addition & 3 deletions include/cli_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
4 changes: 2 additions & 2 deletions lib/libvarnish/cli_auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 332c520

Please sign in to comment.