Static variables in NCproc for parsing
Julien ÉLIE
julien at trigofacile.com
Sat Oct 17 12:52:35 UTC 2009
Hi,
> Revision: 8667
>
> * If the length of NNTP arguments is too long (> 497 bytes),
> a 501 error is now returned.
>
> * If a command is given less (or more) arguments than expected,
> a 501 error is now returned.
>
> * Improve the HELP output for innd, specifying expected arguments.
>
> * HEAD answers 412 (not in a newsgroup) when requesting
> an article number. It was previously sending 501 (syntax error in
> mesasge-ID).
Full patch:
http://inn.eyrie.org/trac/changeset/8667/trunk
I just wanted to know if the implementation of a command parser
is right here in NCproc:
> --- innd/nc.c 2009-10-17 08:35:22 UTC (rev 8666)
> +++ innd/nc.c 2009-10-17 12:31:34 UTC (rev 8667)
> @@ -846,6 +878,10 @@
> bool readmore, movedata;
> ARTDATA *data = &cp->Data;
> HDRCONTENT *hc = data->HdrContent;
> + int ac;
> + static char **av;
> + char **v;
> + bool validcommandtoolong;
>
> readmore = movedata = false;
> if (Tracing || cp->Tracing)
> @@ -944,7 +980,12 @@
> cp->Start = cp->Next;
> break;
> }
> +
> + /* Guarantee null-termination. */
> p[-2] = '\0';
> + p = q;
> + ac = Argify(p, &av);
> +
> if (Tracing || cp->Tracing)
> syslog(L_TRACE, "%s < %s", CHANname(cp), q);
>
I've added a *static* variable "av" because Argify uses xstrdup
and we need to properly free what it created last time it was
called. I think it works because innd reads its channels
one by one, in sequence.
Otherwise, memory will leak.
Is it the right thing to do for "ac" and "av"?
NCproc is here: http://inn.eyrie.org/trac/browser/trunk/innd/nc.c
Argify is here: http://inn.eyrie.org/trac/browser/trunk/lib/argparse.c
--
Julien ÉLIE
« L'art de la médecine consiste à distraire le malade
pendant que la nature le guérit. » (Voltaire)
More information about the inn-workers
mailing list