r4591 - in trunk/varnish-cache: include lib/libvarnish

phk at projects.linpro.no phk at projects.linpro.no
Fri Feb 26 13:12:00 CET 2010


Author: phk
Date: 2010-02-26 13:12:00 +0100 (Fri, 26 Feb 2010)
New Revision: 4591

Modified:
   trunk/varnish-cache/include/cli_common.h
   trunk/varnish-cache/lib/libvarnish/cli_auth.c
Log:
Make the response argument a #defined size buffer, and assert that
the #define is correct.



Modified: trunk/varnish-cache/include/cli_common.h
===================================================================
--- trunk/varnish-cache/include/cli_common.h	2010-02-26 12:04:06 UTC (rev 4590)
+++ trunk/varnish-cache/include/cli_common.h	2010-02-26 12:12:00 UTC (rev 4591)
@@ -48,4 +48,7 @@
 int cli_writeres(int fd, const struct cli *cli);
 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]);

Modified: trunk/varnish-cache/lib/libvarnish/cli_auth.c
===================================================================
--- trunk/varnish-cache/lib/libvarnish/cli_auth.c	2010-02-26 12:04:06 UTC (rev 4590)
+++ trunk/varnish-cache/lib/libvarnish/cli_auth.c	2010-02-26 12:12:00 UTC (rev 4591)
@@ -32,6 +32,7 @@
 SVNID("$Id$");
 
 #include <sys/types.h>
+#include <assert.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <stdint.h>
@@ -41,13 +42,17 @@
 #include "cli_common.h"
 #include "vsha256.h"
 
+
 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;
 	uint8_t buf[BUFSIZ];
 	int i;
 
+	assert(CLI_AUTH_RESPONSE_LEN == (SHA256_LEN * 2 + 1));
+
 	SHA256_Init(&ctx);
 	SHA256_Update(&ctx, challenge, 32);
 	SHA256_Update(&ctx, "\n", 1);



More information about the varnish-commit mailing list