commit 43be1edb0aebe761af9941921b0d17db40d98979 from: Omar Polo via: Thomas Adam date: Mon Sep 05 18:08:06 2022 UTC gotwebd: fix crash handling -D Avoid crashing by corrupting the pointer instead of writing to it and fix how sym is generated: it shouldn't include the '=' sign. ok / improvement tb@ commit - 41861f2b47879010d252aa5a6d8a7f8f734041f0 commit + 43be1edb0aebe761af9941921b0d17db40d98979 blob - 549aefc8c5a5cfc7a326e3afdb07d103ae12d8cd blob + ff344f27c72a411f63bffb62b5c4a456fb6603ff --- gotwebd/parse.y +++ gotwebd/parse.y @@ -917,18 +917,14 @@ 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 = strndup(s, val - s); if (sym == NULL) - fatal("%s: malloc", __func__); - - memcpy(&sym, s, len); + fatal("%s: strndup", __func__); ret = symset(sym, val + 1, 1); free(sym);