mirror of
https://github.com/red0124/ssp.git
synced 2025-01-22 20:55:18 +01:00
Fix buffer overflow on multiline csv data containing null characters (#38)
This commit is contained in:
parent
126329608c
commit
d8dcce7f2a
@ -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;
|
||||
}
|
||||
|
||||
|
5
ssp.hpp
5
ssp.hpp
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user