telemetry: fix JSON string formatter
Checks
Commit Message
For large strings, we were incorrectly copying uninitialised data to the
output buffer.
Restore previous code.
Fixes: a515b7204e28 ("telemetry: remove VLA in JSON string formatter")
Signed-off-by: David Marchand <david.marchand@redhat.com>
---
lib/telemetry/telemetry_json.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Thu, May 25, 2023 at 09:20:35AM +0200, David Marchand wrote:
> For large strings, we were incorrectly copying uninitialised data to the
> output buffer.
> Restore previous code.
>
> Fixes: a515b7204e28 ("telemetry: remove VLA in JSON string formatter")
>
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
25/05/2023 10:30, Bruce Richardson:
> On Thu, May 25, 2023 at 09:20:35AM +0200, David Marchand wrote:
> > For large strings, we were incorrectly copying uninitialised data to the
> > output buffer.
> > Restore previous code.
> >
> > Fixes: a515b7204e28 ("telemetry: remove VLA in JSON string formatter")
> >
> > Signed-off-by: David Marchand <david.marchand@redhat.com>
> > ---
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Applied, thanks (and sorry for merging the commit triggering CI failures).
@@ -153,7 +153,7 @@ __json_format_str(char *buf, const int len, const char *prefix, const char *str,
ret = __json_format_str_to_buf(tmp, len, prefix, str, suffix);
if (ret > 0)
- strcpy(buf, saved);
+ strcpy(buf, tmp);
free(tmp);
return ret;