journal-remote: use macro wrapper instead of alloca to extend string
We would use alloca to extend the format string with "\n". We do this
automatically in order to not forget appending the newline everywhere.
We can simplify the whole thing by using a macro to append the newline instead,
which means that we don't need to copy the string.
Because we concatenate the string argument with another literal string, we know
it must a literal string. Thus it's not a problem that it is "evaluated" two
times.
Quoting Hristo Venev:
> Since commit
f5e757f1ce84c1d6ae932cf2b604238fb4cedc00, mhd_respond() adds a
> newline to its argument before passing it on to mhd_respond_internal(). This
> is done via an alloca()-allocated buffer. However, MHD_RESPMEM_PERSISTENT is
> given as a flag to MHD_create_response_from_buffer(), leading to a
> use-after-free later when the response is sent. Replacing
> MHD_RESPMEM_PERSISTENT with MHD_RESPMEM_MUST_COPY appears to fix the issue.
MHD_RESPMEM_MUST_COPY would work, but we also use mhd_respond() for mhd_oom(),
and we don't want to allocate in an oom scenario in order to maximize the
possibility that an answer will be delivered. Using the macro magic makes this
nicer and we get rid of the code doing alloca.
Fixes an issue reported by Hristo Venev.
Fixes https://github.com/systemd/systemd/issues/9858.