Download raw body.
gotwebd: fix cmdline_symset
On 2022/09/05 19:49:37 +0200, Omar Polo <op@omarpolo.com> 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.
Err... I intended to send this version of the diff which is smaller.
Sorry.
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,18 +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 = malloc(1, val - s + 1);
if (sym == NULL)
fatal("%s: malloc", __func__);
- memcpy(&sym, s, len);
+ memcpy(sym, s, val - s);
ret = symset(sym, val + 1, 1);
free(sym);
gotwebd: fix cmdline_symset