Fix buffer overflow on multiline csv data containing null characters (#38)

This commit is contained in:
red0124 2024-02-29 22:03:20 +01:00 committed by GitHub
parent 126329608c
commit d8dcce7f2a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 4 deletions

View File

@ -912,16 +912,17 @@ private:
void undo_remove_eol(char* buffer, size_t& string_end) {
if (crlf_) {
std::copy_n("\r\n\0", 3, buffer + string_end);
std::copy_n("\r\n", 2, buffer + string_end);
string_end += 2;
} else {
std::copy_n("\n\0", 2, buffer + string_end);
std::copy_n("\n", 1, buffer + string_end);
string_end += 1;
}
}
size_t remove_eol(char*& buffer, size_t ssize) {
if (buffer[ssize - 1] != '\n') {
crlf_ = false;
return ssize;
}

View File

@ -3088,16 +3088,17 @@ private:
void undo_remove_eol(char* buffer, size_t& string_end) {
if (crlf_) {
std::copy_n("\r\n\0", 3, buffer + string_end);
std::copy_n("\r\n", 2, buffer + string_end);
string_end += 2;
} else {
std::copy_n("\n\0", 2, buffer + string_end);
std::copy_n("\n", 1, buffer + string_end);
string_end += 1;
}
}
size_t remove_eol(char*& buffer, size_t ssize) {
if (buffer[ssize - 1] != '\n') {
crlf_ = false;
return ssize;
}