[experimental-ims] 0af2c24 Make sure the CLI headers we produce tell the truth about the length
Geoff Simmons
geoff at varnish-cache.org
Mon Jan 9 21:52:33 CET 2012
commit 0af2c245047f904d91d800b659f62c3af2908413
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Sun Nov 13 22:08:33 2011 +0000
Make sure the CLI headers we produce tell the truth about the length
diff --git a/lib/libvarnish/cli_common.c b/lib/libvarnish/cli_common.c
index 3a44e9f..4a17de5 100644
--- a/lib/libvarnish/cli_common.c
+++ b/lib/libvarnish/cli_common.c
@@ -87,6 +87,7 @@ VCLI_WriteResult(int fd, unsigned status, const char *result)
int i, l;
struct iovec iov[3];
char nl[2] = "\n";
+ size_t len;
char res[CLI_LINE0_LEN + 2]; /*
* NUL + one more so we can catch
* any misformats by snprintf
@@ -95,15 +96,18 @@ VCLI_WriteResult(int fd, unsigned status, const char *result)
assert(status >= 100);
assert(status <= 999); /*lint !e650 const out of range */
+ len = strlen(result);
+
i = snprintf(res, sizeof res,
- "%-3d %-8jd\n", status, (intmax_t)strlen(result));
+ "%-3d %-8zd\n", status, len);
assert(i == CLI_LINE0_LEN);
+ assert(strtoul(res + 3, NULL, 10) == len);
iov[0].iov_base = res;
iov[0].iov_len = CLI_LINE0_LEN;
iov[1].iov_base = (void*)(uintptr_t)result; /* TRUST ME */
- iov[1].iov_len = strlen(result);
+ iov[1].iov_len = len;
iov[2].iov_base = nl;
iov[2].iov_len = 1;
More information about the varnish-commit
mailing list