Skip to content

Conversation

@sbohrer
Copy link

@sbohrer sbohrer commented Jun 25, 2025

From the vsnprintf man page:

The  functions  snprintf() and vsnprintf() do not write more than
size bytes (including the terminating null byte ('\0')).  If the output
was truncated due to this limit, then the return value is the number of
characters (excluding the terminating null byte) which would have been
written to the final string if enough space had been available.  Thus,
a  re‐ turn value of size or more means that the output was truncated.
(See also below under CAVEATS.)

Without this fix performing an ipset list where n == length would result in a rust String that was terminated with a null byte, and this would fail to parse returning an error.

For example:

called `Result::unwrap()` on an `Err` value: InvalidOutput("91.99.252.18\0")

From the vsnprintf man page:

```
The  functions  snprintf() and vsnprintf() do not write more than
size bytes (including the terminating null byte ('\0')).  If the output
was truncated due to this limit, then the return value is the number of
characters (excluding the terminating null byte) which would have been
written to the final string if enough space had been available.  Thus,
a  re‐ turn value of size or more means that the output was truncated.
(See also below under CAVEATS.)
```

Without this fix performing an ipset list where `n == length` would
result in a rust String that was terminated with a null byte, and this
would fail to parse returning an error.

For example:
```
called `Result::unwrap()` on an `Err` value: InvalidOutput("91.99.252.18\0")
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant