Download raw body.
gotwebd: fix cmdline_symset
On Mon, Sep 05, 2022 at 07:49:37PM +0200, Omar Polo wrote: > Thomas reported on IRC that -DFOO=bar crashes gotwebd. There's a typo > in cmdline_symset where we mangle a pointer instead of writing to what > it points to. However, also the computed value is wrong (symset gets > called with `sym' being "FOO=" instead of "FOO"). > > This brings us closer to the usual cmdline_symset. Looks like a job for strndup(). > > diff /home/op/w/got > commit - 3d8e0c5ede1a5654397b63a9f483d875543527d5 > path + /home/op/w/got > blob - 342886d6f2c8b12ed3548eb39f4ce4d40be487d1 > file + gotwebd/parse.y > --- gotwebd/parse.y > +++ gotwebd/parse.y > @@ -918,19 +918,16 @@ cmdline_symset(char *s) > { > char *sym, *val; > int ret; > - size_t len; > > val = strrchr(s, '='); > if (val == NULL) > return (-1); > > - len = strlen(s) - strlen(val) + 1; > - sym = malloc(len); > + sym = calloc(1, val - s + 1); > if (sym == NULL) > - fatal("%s: malloc", __func__); > + fatal("%s: calloc", __func__); > > - memcpy(&sym, s, len); > - > + memcpy(sym, s, val - s); > ret = symset(sym, val + 1, 1); > free(sym); > >
gotwebd: fix cmdline_symset