]> err.no Git - varnish/commitdiff
Further eliminate fixed-size buffers.
authordes <des@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sun, 22 Apr 2007 13:09:59 +0000 (13:09 +0000)
committerdes <des@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sun, 22 Apr 2007 13:09:59 +0000 (13:09 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1363 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishncsa/varnishncsa.c

index 184a2ca7eaa914b1ff57197e1dabd27167bc6296..c237a87a2f9d7af1dd0cace08490f601685bdc4e 100644 (file)
@@ -85,7 +85,9 @@ static struct logline {
        char *df_s;                     /* %s, Status */
        char *df_u;                     /* %u, Remote user */
        int bogus;                      /* bogus request */
-} *ll[65536];
+} **ll;
+
+static size_t nll;
 
 static int
 isprefix(const char *str, const char *prefix, const char *end, const char **next)
@@ -170,10 +172,8 @@ h_ncsa(void *priv, unsigned tag, unsigned fd,
        FILE *fo;
        time_t t;
        long l;
-       unsigned lu;
        struct tm tm;
        char tbuf[40];
-       char rubuf[128];
        struct logline *lp;
 
        end = ptr + len;
@@ -181,6 +181,18 @@ h_ncsa(void *priv, unsigned tag, unsigned fd,
        if (!(spec &VSL_S_CLIENT))
                return (0);
 
+       if (fd >= nll) {
+               struct logline **newll = ll;
+               size_t newnll = nll;
+
+               while (fd >= newnll)
+                       newnll += newnll + 1;
+               newll = realloc(newll, newnll * sizeof *newll);
+               assert(newll != NULL);
+               memset(newll + nll, 0, (newnll - nll) * sizeof *newll);
+               ll = newll;
+               nll = newnll;
+       }
        if (ll[fd] == NULL) {
                ll[fd] = calloc(sizeof *ll[fd], 1);
                assert(ll[fd] != NULL);
@@ -265,13 +277,19 @@ h_ncsa(void *priv, unsigned tag, unsigned fd,
 
                /* %u: decode authorization string */
                if (lp->df_u != NULL) {
+                       char *rubuf;
+                       size_t len;
+
                        base64_init();
-                       lu = sizeof rubuf;
-                       base64_decode(rubuf, lu, lp->df_u);
+                       len = ((strlen(lp->df_u) + 3) * 4) / 3;
+                       rubuf = malloc(len);
+                       assert(rubuf != NULL);
+                       base64_decode(rubuf, len, lp->df_u);
                        q = strchr(rubuf, ':');
                        if (q != NULL)
                                *q = '\0';
                        fprintf(fo, "%s ", rubuf);
+                       free(rubuf);
                } else {
                        fprintf(fo, "- ");
                }