// 796 and 797 (out-of-bounds errors).
-elib(123) // size is both a variable and a macro with args
-emacro(736, isnan) // isnanf
+-efile(766, ../../config.h)
--sem(strchr, 1p, type(1), 2n == 0 ? (@p < 1p) : (@p < 1p || @p == 0 ))
+// -header(../../config.h)
--sem(vsb_new, @p == malloc(1))
--sem(vsb_delete, custodial(1))
+// Fix strchr() semtics, it can only return NULL if arg2 != 0
+-sem(strchr, 1p, type(1), 2n == 0 ? (@p < 1p) : (@p < 1p || @p == 0 ))
+//
+// -sem(vsb_new, @p == malloc(1))
+// -sem(vsb_delete, custodial(1))
-sem(lbv_assert, r_no)
-sem(lbv_xxxassert, r_no)
-
--ffc // No automatic custody
-
+// -sem(WS_Init, custodial(2))
+// -sem(http_Setup, custodial(2))
+//
+// -ffc // No automatic custody
+//
-e763 // Redundant declaration for symbol '...' previously declared
--e726 // Extraneous comma ignored
--e728 // Symbol ... not explicitly initialized
+// -e726 // Extraneous comma ignored
+// -e728 // Symbol ... not explicitly initialized
-e716 // while(1) ...
--e785 // Too few initializers for aggregate
--e786 // String concatenation within initializer
-
--emacro(740, VTAILQ_PREV) // Unusual pointer cast (incompatible indirect types)
--emacro(740, VTAILQ_LAST) // Unusual pointer cast (incompatible indirect types)
--emacro((826), VTAILQ_PREV) // Suspicious pointer-to-pointer conversion (area too small)
--emacro((826), VTAILQ_LAST) // Suspicious pointer-to-pointer conversion (area too small)
+// -e785 // Too few initializers for aggregate
+// -e786 // String concatenation within initializer
+//
+// -emacro(740, VTAILQ_PREV) // Unusual pointer cast (incompatible indirect types)
+// -emacro(740, VTAILQ_LAST) // Unusual pointer cast (incompatible indirect types)
+// -emacro((826), VTAILQ_PREV) // Suspicious pointer-to-pointer conversion (area too small)
+// -emacro((826), VTAILQ_LAST) // Suspicious pointer-to-pointer conversion (area too small)
-emacro(506, VTAILQ_FOREACH_SAFE) // constant value boolean
-
+//
-esym(534, sprintf) // Ignoring return value of function
--esym(534, asprintf) // Ignoring return value of function
+// -esym(534, asprintf) // Ignoring return value of function
-esym(534, printf) // Ignoring return value of function
-esym(534, fprintf) // Ignoring return value of function
-esym(534, memset) // Ignoring return value of function
--esym(534, memcpy) // Ignoring return value of function
--esym(534, memmove) // Ignoring return value of function
--esym(534, strcpy) // Ignoring return value of function
+// -esym(534, memcpy) // Ignoring return value of function
+// -esym(534, memmove) // Ignoring return value of function
+// -esym(534, strcpy) // Ignoring return value of function
-esym(534, vsb_printf) // Ignoring return value of function
-esym(534, vsb_cat) // Ignoring return value of function
-esym(534, vsb_bcat) // Ignoring return value of function
-esym(534, strcat) // Ignoring return value of function
-esym(534, strcpy) // Ignoring return value of function
-esym(534, strlcpy) // Ignoring return value of function
-
--emacro(506, isnan) // constant value boolean
--emacro(747, isnan) // significant coersion
--emacro(506, assert) // constant value boolean
--emacro(827, assert) // loop not reachable
--emacro(774, assert) // booelan always true
-
-// cache.h
--emacro(506, INCOMPL) // Constant value Boolean
-
-// Review all below this line ///////////////////////////////////////////////
-
+//
+// -emacro(506, isnan) // constant value boolean
+// -emacro(747, isnan) // significant coersion
+// -emacro(506, assert) // constant value boolean
+// -emacro(827, assert) // loop not reachable
+// -emacro(774, assert) // booelan always true
+// -emacro(774, HTTPH) // always false
+//
+// // cache.h
+// -emacro(506, INCOMPL) // Constant value Boolean
+//
+// // cache_center.c
+// -efunc(525, CNT_Session) // Negative indentation from line
+// -efunc(525, http_FilterFields) // Negative indentation from line
+// -efunc(539, http_FilterFields) // Positive indentation from line
+//
+// // cache_vcl.c
+// -efunc(525, vcl_handlingname) // Negative indentation from line
+// -esym(528, vcl_handlingname) // Not referenced
+// -e641 // Converting enum 'cli_status_e' to int
+//
+// // Review all below this line ///////////////////////////////////////////////
+//
-e732 // Loss of sign (arg. no. 2) (int to unsigned
-e737 // [45] Loss of sign in promotion from int to unsigned
-e713 // Loss of precision (assignment) (unsigned long long to long long)
-e574 // Signed-unsigned mix with relational
--e712 // Loss of precision (assignment) (long long to
--e747 // Significant prototype coercion (arg. no. 2) long
-
-/*
-
--e767 // Macro redef (system queue.h vs ours )
-
--e506 // Constant value boolean
--e818 // Pointer parameter '...' could be declared as pointing to const
--e774 // Boolean within 'if' always evaluates to False
--e534 // Ignoring return value of function
--e557 // unrecog format
-
-*/
+// -e712 // Loss of precision (assignment) (long long to
+// -e747 // Significant prototype coercion (arg. no. 2) long
+//
+// /*
+//
+// -e767 // Macro redef (system queue.h vs ours )
+//
+// -e506 // Constant value boolean
+// -e818 // Pointer parameter '...' could be declared as pointing to const
+// -e774 // Boolean within 'if' always evaluates to False
+// -e534 // Ignoring return value of function
+// -e557 // unrecog format
+//
+// */
-I. \
-I../../include \
-I../.. \
- -DVARNISH_STATE_DIR=\"foo\" \
flint.lnt \
*.c > $T 2>&1
-for t in Error Warning Info
+for t in Error Warning Info Note
do
sed -n "/$t [0-9][0-9][0-9]:/s/.*\($t [0-9][0-9][0-9]\).*/\1/p" $T
done | awk '
send "Transfer-encoding: chunked\r\n"
send "\r\n"
send "00000004\r\n1234\r\n"
- send "00000004\r\n1234\r\n"
- send "00000000\r\n"
+ chunked "1234"
+ chunked ""
}
server s1 -start
err(1, "Cannot open %s", fn);
buf = malloc(sz);
assert(buf != NULL);
- s = read(fd, buf, sz);
+ s = read(fd, buf, sz - 1);
if (s <= 0)
err(1, "Cannot read %s", fn);
- assert(s < sz); /* XXX: increase MAX_FILESIZE */
AZ(close (fd));
+ assert(s < sz); /* XXX: increase MAX_FILESIZE */
buf[s] = '\0';
buf = realloc(buf, s + 1);
assert(buf != NULL);
p++;
} else if (*p == '{') { /* Braces */
nest_brace = 0;
- token_s[tn] = p;
+ token_s[tn] = p + 1;
for (; *p != '\0'; p++) {
if (*p == '{')
nest_brace++;
}
}
assert(*p == '}');
- token_e[tn++] = ++p;
+ token_e[tn++] = p++;
} else { /* other tokens */
token_s[tn] = p;
for (; *p != '\0' && !isspace(*p); p++)
AN(av[1]);
AZ(av[2]);
vtc_dump(vl, 4, "shell", av[1]);
- system(av[1]);
+ (void)system(av[1]); /* XXX: assert ? */
}
/**********************************************************************
*/
int
-main(int argc, char **argv)
+main(int argc, char * const *argv)
{
int ch;
struct vtclog;
struct cmds;
-#define CMD_ARGS char **av, void *priv, const struct cmds *cmd
+#define CMD_ARGS char * const *av, void *priv, const struct cmds *cmd
typedef void cmd_f(CMD_ARGS);
struct cmds {
client_run(c);
continue;
}
- if (**av == '{') {
- c->spec = *av;
- continue;
+ if (**av == '-') {
+ vtc_log(c->vl, 0, "Unknown client argument: %s", *av);
+ exit (1);
}
- vtc_log(c->vl, 0, "Unknown client argument: %s", *av);
- exit (1);
+ c->spec = *av;
}
}
int timeout;
struct vtclog *vl;
+ struct vsb *vsb;
+
int nrxbuf;
char *rxbuf;
char *resp[MAX_HDR];
};
+/* XXX: we may want to vary this */
+static const char *nl = "\r\n";
+
+/**********************************************************************
+ * Finish and write the vsb to the fd
+ */
+
+static void
+http_write(const struct http *hp, int lvl, const char *pfx)
+{
+ int l;
+
+ vsb_finish(hp->vsb);
+ AZ(vsb_overflowed(hp->vsb));
+ vtc_dump(hp->vl, lvl, pfx, vsb_data(hp->vsb));
+ l = write(hp->fd, vsb_data(hp->vsb), vsb_len(hp->vsb));
+ assert(l == vsb_len(hp->vsb));
+}
+
/**********************************************************************
* find header
*/
static char *
-http_find_header(char **hh, const char *hdr)
+http_find_header(char * const *hh, const char *hdr)
{
int n, l;
char *r;
*/
static void
-http_swallow_body(struct http *hp, char **hh)
+http_swallow_body(const struct http *hp, char * const *hh)
{
char *p, b[BUFSIZ + 1];
int l, i;
cmd_http_txresp(CMD_ARGS)
{
struct http *hp;
- struct vsb *vsb;
const char *proto = "HTTP/1.1";
const char *status = "200";
const char *msg = "Ok";
const char *body = NULL;
int dohdr = 0;
- const char *nl = "\r\n";
- int l;
(void)cmd;
CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC);
assert(!strcmp(av[0], "txresp"));
av++;
- vsb = vsb_newauto();
+ vsb_clear(hp->vsb);
for(; *av != NULL; av++) {
if (!strcmp(*av, "-proto")) {
}
if (!strcmp(*av, "-hdr")) {
if (dohdr == 0) {
- vsb_printf(vsb, "%s %s %s%s",
+ vsb_printf(hp->vsb, "%s %s %s%s",
proto, status, msg, nl);
dohdr = 1;
}
- vsb_printf(vsb, "%s%s", av[1], nl);
+ vsb_printf(hp->vsb, "%s%s", av[1], nl);
av++;
continue;
}
exit (1);
}
if (dohdr == 0) {
- vsb_printf(vsb, "%s %s %s%s",
+ vsb_printf(hp->vsb, "%s %s %s%s",
proto, status, msg, nl);
dohdr = 1;
}
- vsb_cat(vsb, nl);
+ vsb_cat(hp->vsb, nl);
if (body != NULL) {
- vsb_cat(vsb, body);
- vsb_cat(vsb, nl);
+ vsb_cat(hp->vsb, body);
+ vsb_cat(hp->vsb, nl);
}
- vsb_finish(vsb);
- AZ(vsb_overflowed(vsb));
- vtc_dump(hp->vl, 4, NULL, vsb_data(vsb));
- l = write(hp->fd, vsb_data(vsb), vsb_len(vsb));
- assert(l == vsb_len(vsb));
- vsb_delete(vsb);
+ http_write(hp, 4, "txresp");
}
/**********************************************************************
cmd_http_txreq(CMD_ARGS)
{
struct http *hp;
- struct vsb *vsb;
const char *req = "GET";
const char *url = "/";
const char *proto = "HTTP/1.1";
const char *body = NULL;
int dohdr = 0;
- const char *nl = "\r\n";
- int l;
(void)cmd;
CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC);
assert(!strcmp(av[0], "txreq"));
av++;
- vsb = vsb_newauto();
+ vsb_clear(hp->vsb);
for(; *av != NULL; av++) {
if (!strcmp(*av, "-url")) {
}
if (!strcmp(*av, "-hdr")) {
if (dohdr == 0) {
- vsb_printf(vsb, "%s %s %s%s",
+ vsb_printf(hp->vsb, "%s %s %s%s",
req, url, proto, nl);
dohdr = 1;
}
- vsb_printf(vsb, "%s%s", av[1], nl);
+ vsb_printf(hp->vsb, "%s%s", av[1], nl);
av++;
continue;
}
exit (1);
}
if (dohdr == 0) {
- vsb_printf(vsb, "%s %s %s%s",
+ vsb_printf(hp->vsb, "%s %s %s%s",
req, url, proto, nl);
dohdr = 1;
}
- vsb_cat(vsb, nl);
+ vsb_cat(hp->vsb, nl);
if (body != NULL) {
- vsb_cat(vsb, body);
- vsb_cat(vsb, nl);
+ vsb_cat(hp->vsb, body);
+ vsb_cat(hp->vsb, nl);
}
- vsb_finish(vsb);
- AZ(vsb_overflowed(vsb));
- vtc_dump(hp->vl, 4, NULL, vsb_data(vsb));
- l = write(hp->fd, vsb_data(vsb), vsb_len(vsb));
- assert(l == vsb_len(vsb));
- vsb_delete(vsb);
+ http_write(hp, 4, "txreq");
}
/**********************************************************************
}
+/**********************************************************************
+ * Send a string as chunked encoding
+ */
+
+static void
+cmd_http_chunked(CMD_ARGS)
+{
+ struct http *hp;
+
+ (void)cmd;
+ CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC);
+ AN(av[1]);
+ AZ(av[2]);
+ vsb_clear(hp->vsb);
+ vsb_printf(hp->vsb, "%x%s%s%s", strlen(av[1]), nl, av[1], nl);
+ http_write(hp, 4, "chunked");
+}
+
/**********************************************************************
* Execute HTTP specifications
{ "rxresp", cmd_http_rxresp },
{ "expect", cmd_http_expect },
{ "send", cmd_http_send },
+ { "chunked", cmd_http_chunked },
{ "delay", cmd_delay },
{ NULL, NULL }
};
hp->client = client;
hp->timeout = 1000;
hp->nrxbuf = 8192;
+ hp->vsb = vsb_newauto();
+ AN(hp->vsb);
- s = strdup(spec + 1);
+ s = strdup(spec);
q = strchr(s, '\0');
assert(q > s);
- q--;
- assert(*q == '}');
- *q = '\0';
AN(s);
parse_string(s, http_cmds, hp);
+ vsb_delete(hp->vsb);
free(hp);
}
#define NLEAD (sizeof(lead)/sizeof(lead[0]))
+//lint -e{818}
void
vtc_log(struct vtclog *vl, unsigned lvl, const char *fmt, ...)
{
* Dump a string
*/
+//lint -e{818}
void
vtc_dump(struct vtclog *vl, unsigned lvl, const char *pfx, const char *str)
{
server_wait(s);
continue;
}
- if (**av == '{') {
- s->spec = *av;
- continue;
+ if (**av == '-') {
+ vtc_log(s->vl, 0, "Unknown server argument: %s", *av);
+ exit (1);
}
- vtc_log(s->vl, 0, "Unknown server argument: %s", *av);
- exit (1);
+ s->spec = *av;
}
}
#include <stdio.h>
-#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
-#include <pthread.h>
#include <signal.h>
+#include <pthread.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/socket.h>
-
#include "vqueue.h"
#include "miniobj.h"
#include "libvarnish.h"
assert(i == strlen(cmd));
i = write(v->cli_fd, "\n", 1);
assert(i == 1);
- i = cli_readres(v->cli_fd, &retval, &r, 1000);
+ i = cli_readres(v->cli_fd, &retval, &r, 1.0);
assert(i == 0);
vtc_dump(v->vl, 4, "CLI RX", r);
vtc_log(v->vl, 3, "CLI STATUS %u", retval);
*/
static void
-varnish_vclbackend(struct varnish *v, char *vcl)
+varnish_vclbackend(struct varnish *v, const char *vcl)
{
struct vsb *vsb, *vsb2;
- char *p;
enum cli_status_e u;
if (v->cli_fd < 0)
varnish_cli_encode(vsb, vsb_data(vsb2));
- if (*vcl == '{') {
- p = strchr(++vcl, '\0');
- if (p > vcl && p[-1] == '}')
- p[-1] = '\0';
- }
varnish_cli_encode(vsb, vcl);
vsb_printf(vsb, "\"", *vcl);