mirror of
https://github.com/nlohmann/json.git
synced 2026-09-01 05:57:14 +00:00
Rename get_bytes' local read to bytes_read
Flawfinder flags the bare identifier `read` as the POSIX read() syscall (CWE-120/CWE-20), producing several false-positive code-scanning alerts. Renaming the local variable removes them; the byte-copy itself is unchanged and remains bounds-checked (get_elements caps the copy to the bytes available). This is a pure rename with identical semantics. Signed-off-by: Niels Lohmann <mail@nlohmann.me> Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
282ff6ce5c
commit
5355190cff
@@ -13171,20 +13171,20 @@ class binary_reader
|
||||
: chunk_size;
|
||||
const std::size_t old_size = result.size();
|
||||
result.resize(old_size + wanted);
|
||||
const std::size_t read = ia.get_elements(&result[old_size], wanted);
|
||||
chars_read += read;
|
||||
if (JSON_HEDLEY_UNLIKELY(read < wanted))
|
||||
const std::size_t bytes_read = ia.get_elements(&result[old_size], wanted);
|
||||
chars_read += bytes_read;
|
||||
if (JSON_HEDLEY_UNLIKELY(bytes_read < wanted))
|
||||
{
|
||||
// premature end of input: shrink to what was actually read and
|
||||
// report the failure at the first missing byte (same position
|
||||
// accounting as get_to() for partial number reads)
|
||||
result.resize(old_size + read);
|
||||
result.resize(old_size + bytes_read);
|
||||
++chars_read;
|
||||
current = char_traits<char_type>::eof();
|
||||
return unexpect_eof(format, context);
|
||||
}
|
||||
// a full chunk was read; get_elements() never returns more than requested
|
||||
JSON_ASSERT(read == wanted);
|
||||
JSON_ASSERT(bytes_read == wanted);
|
||||
len = static_cast<NumberType>(len - static_cast<NumberType>(wanted));
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user