Project

General

Profile

Actions

Bug #6921

open

jsonbuilder: serializes Rust f64 NaNs to an invalid literal

Added by Simen Lybekk about 1 month ago. Updated about 1 month ago.

Status:
Resolved
Priority:
Normal
Assignee:
Target version:
Affected Versions:
Effort:
Difficulty:
Label:

Description

Flagging as a bug, although could be argued that it's not.

The JSON builder has two methods for handling floats:

These do not check whether the float value is NaN (https://doc.rust-lang.org/std/primitive.f64.html#method.is_nan), and may as such serialize a float as the literal keyword "NaN".
Some JSON parsers like serde_json will not accept this as valid JSON. serde-rs writes a bit more about this here: https://github.com/serde-rs/json/issues/879

We decided to patch this to a string "NaN" as this is good enough for our use, patch attached.
Doing this does mean that all the JSON Schemas for EVE logs needs to be updated.

I expect that "Infinity" will behave similarly to "NaN", although I haven't checked this.


Files

json-nan.patch (1.47 KB) json-nan.patch Simen Lybekk, 04/05/2024 10:33 AM

Subtasks 1 (0 open1 closed)

Bug #6923: jsonbuilder: serializes Rust f64 NaNs to an invalid literal (7.0.x backport)ClosedJason IshActions
Actions

Also available in: Atom PDF