Commit e3eea331 authored by Legodev's avatar Legodev

ADDED: code to prevent strings longer then 64 Kibibytes from being written to...

ADDED: code to prevent strings longer then 64 Kibibytes from being written to the database, the data is discarded to prevent issues.
parent 99ba7fbe
......@@ -178,6 +178,19 @@ int object_mysql::setData(unsigned int arraypos, std::string variableValue) {
if (mysql_bind[arraypos].buffer_type == MYSQL_TYPE_VAR_STRING) {
char * pointer = (char *) mysql_bind[arraypos].buffer;
int size = variableValue.size();
// the database text fields are of the MySQL datatype TEXT, which can store 64 Kibibytes data
// if our string is longer then these 64 Kibibytes we discard the data because truncation causes serious issues
if (size >= 65530) {
this->setNull(arraypos);
mysql_bind[arraypos].buffer = 0;
mysql_bind[arraypos].buffer_length = 0;
free(pointer);
pointer = 0;
return 0;
}
if (pointer == 0 || std::string(pointer) != variableValue) {
if (pointer != 0 && mysql_bind[arraypos].buffer_length < size) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment