Commit
165efde7 changed a_resolve to not require a port number.
Unfortunately, I botched it and wrote a test for av[i + 1] as
av[i + i]. Result with i = 0: very different.
While investigating this bug, I became nervous about the number of
is-av[i]-null tests going on when str_qsplit doesn't actually guarantee
to leave a null terminator behind if it uses all the array slots. So
I've allocated an extra slot and zeroed it explicitly.
r->sa.sin.sin_family = AF_INET;
r->sasz = sizeof(r->sa.sin);
r->addr = xstrdup(av[i]);
- if (!av[i + i])
+ if (!av[i + 1])
pt = TRIPE_PORT;
else {
pt = strtoul(av[i + 1], &p, 0);
{
admin *a = vp;
const acmd *c;
- char *av[16];
+ char *av[16 + 1];
size_t ac;
TIMER;
}
return;
}
- ac = str_qsplit(p, av, 16, 0, STRF_QUOTE);
+ ac = str_qsplit(p, av, N(av) - 1, 0, STRF_QUOTE);
if (!ac)
return;
+ av[ac] = 0;
for (c = acmdtab; c->name; c++) {
if (mystrieq(av[0], c->name)) {
ac--;