mbox series

[v3,0/5] telemetry: remove variable length arrays

Message ID 20230405160326.186921-1-bruce.richardson@intel.com (mailing list archive)
Headers
Series telemetry: remove variable length arrays |

Message

Bruce Richardson April 5, 2023, 4:03 p.m. UTC
  This patchset introduces a series of changes to remove variable-length
arrays from the telemetry code. The first patch replaces a VLA with
malloc memory for the serialization of the json objects contained within
the main response object, which fixes a crash observed on alpine linux.

Subsequent patches rework the json printing code to avoid the use of
temporary buffers where possible, or use malloc-allocated memory where
not.

Based off testing with the unit tests for telemetry, json serialization
for the telemetry callbacks should always use the path where a temporary
buffer is *not* used, but the allocation-case is kept to ensure that any
unexpected edge-cases are covered too.

V3: remove use of non-standard asprintf function in patch 2.

V2: expand from single fix for Alpine, to general cleanup to remove VLAs

Bruce Richardson (5):
  telemetry: fix autotest failures on Alpine
  telemetry: remove variable length array in printf fn
  telemetry: split out body of json string format fn
  telemetry: rename local variables
  telemetry: remove VLA in json string format function

 app/test/test_telemetry_json.c |   2 +-
 lib/telemetry/telemetry.c      |  21 ++++++-
 lib/telemetry/telemetry_json.h | 111 +++++++++++++++++++++++++--------
 3 files changed, 104 insertions(+), 30 deletions(-)

--
2.37.2
  

Comments

Thomas Monjalon May 24, 2023, 8:47 p.m. UTC | #1
05/04/2023 18:03, Bruce Richardson:
> This patchset introduces a series of changes to remove variable-length
> arrays from the telemetry code. The first patch replaces a VLA with
> malloc memory for the serialization of the json objects contained within
> the main response object, which fixes a crash observed on alpine linux.
> 
> Subsequent patches rework the json printing code to avoid the use of
> temporary buffers where possible, or use malloc-allocated memory where
> not.
> 
> Based off testing with the unit tests for telemetry, json serialization
> for the telemetry callbacks should always use the path where a temporary
> buffer is *not* used, but the allocation-case is kept to ensure that any
> unexpected edge-cases are covered too.
> 
> V3: remove use of non-standard asprintf function in patch 2.
> 
> V2: expand from single fix for Alpine, to general cleanup to remove VLAs
> 
> Bruce Richardson (5):
>   telemetry: fix autotest failures on Alpine
>   telemetry: remove variable length array in printf fn
>   telemetry: split out body of json string format fn
>   telemetry: rename local variables
>   telemetry: remove VLA in json string format function

Applied, thanks.