Commit 94d5c2aa authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Make the response argument a #defined size buffer, and assert that

the #define is correct.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4591 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 4f5c592e
...@@ -48,4 +48,7 @@ struct cli { ...@@ -48,4 +48,7 @@ struct cli {
int cli_writeres(int fd, const struct cli *cli); int cli_writeres(int fd, const struct cli *cli);
int cli_readres(int fd, unsigned *status, char **ptr, double tmo); int cli_readres(int fd, unsigned *status, char **ptr, double tmo);
void CLI_response(int S_fd, const char *challenge, char *reponse); #define CLI_AUTH_RESPONSE_LEN 65 /* 64 hex + NUL */
void CLI_response(int S_fd, const char *challenge,
char reponse[CLI_AUTH_RESPONSE_LEN]);
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
SVNID("$Id$"); SVNID("$Id$");
#include <sys/types.h> #include <sys/types.h>
#include <assert.h>
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <stdint.h> #include <stdint.h>
...@@ -41,13 +42,17 @@ SVNID("$Id$"); ...@@ -41,13 +42,17 @@ SVNID("$Id$");
#include "cli_common.h" #include "cli_common.h"
#include "vsha256.h" #include "vsha256.h"
void void
CLI_response(int S_fd, const char *challenge, char *response) CLI_response(int S_fd, const char *challenge,
char response[CLI_AUTH_RESPONSE_LEN])
{ {
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));
SHA256_Init(&ctx); SHA256_Init(&ctx);
SHA256_Update(&ctx, challenge, 32); SHA256_Update(&ctx, challenge, 32);
SHA256_Update(&ctx, "\n", 1); SHA256_Update(&ctx, "\n", 1);
......
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