fix: strncpy limits
This commit is contained in:
parent
831291cdac
commit
fc0e0b660a
3 changed files with 9 additions and 9 deletions
|
@ -77,8 +77,8 @@ controllers::put_one_by_id(const HttpRequestPtr &req, std::function<void(const H
|
|||
|
||||
if(controllers[0])
|
||||
{
|
||||
strncpy(controllers[0]->name, body["name"].asCString(), 128);
|
||||
strncpy(controllers[0]->ip, body["ip"].asCString(), 17);
|
||||
strncpy(controllers[0]->name, body["name"].asCString(), 127);
|
||||
strncpy(controllers[0]->ip, body["ip"].asCString(), 16);
|
||||
|
||||
controllers[0]->name[127] = '\0';
|
||||
controllers[0]->ip[16] = '\0';
|
||||
|
|
|
@ -71,8 +71,8 @@ controllers::put_relays_one_by_id_and_num(const HttpRequestPtr &req,
|
|||
|
||||
if(relay)
|
||||
{
|
||||
strncpy(relay->name, body["name"].asCString(), 128);
|
||||
strncpy(relay->active_schedule_id, body["active_schedule"].asCString(), 33);
|
||||
strncpy(relay->name, body["name"].asCString(), 127);
|
||||
strncpy(relay->active_schedule_id, body["active_schedule"].asCString(), 32);
|
||||
|
||||
db_action_result = relay->update();
|
||||
}
|
||||
|
@ -80,9 +80,9 @@ controllers::put_relays_one_by_id_and_num(const HttpRequestPtr &req,
|
|||
{
|
||||
relay = new relay_dbo();
|
||||
relay->number = relay_num;
|
||||
strncpy(relay->name, body["name"].asCString(), 128);
|
||||
strncpy(relay->active_schedule_id, body["active_schedule"].asCString(), 33);
|
||||
strncpy(relay->controller_id, controller_id.c_str(), 33);
|
||||
strncpy(relay->name, body["name"].asCString(), 127);
|
||||
strncpy(relay->active_schedule_id, body["active_schedule"].asCString(), 32);
|
||||
strncpy(relay->controller_id, controller_id.c_str(), 32);
|
||||
|
||||
db_action_result = relay->insert();
|
||||
}
|
||||
|
|
|
@ -40,10 +40,10 @@ relay_db_select_mapper(sqlite3_stmt *stmt)
|
|||
switch(name[0])
|
||||
{
|
||||
case 'a': // active_schedule_id
|
||||
strncpy(new_relay->active_schedule_id, (const char*)sqlite3_column_text(stmt, i), 33);
|
||||
strncpy(new_relay->active_schedule_id, (const char*)sqlite3_column_text(stmt, i), 32);
|
||||
break;
|
||||
case 'c': // controller_id
|
||||
strncpy(new_relay->controller_id, (const char*)sqlite3_column_text(stmt, i), 33);
|
||||
strncpy(new_relay->controller_id, (const char*)sqlite3_column_text(stmt, i), 32);
|
||||
break;
|
||||
case 'i':
|
||||
new_relay->id = sqlite3_column_int(stmt, i);
|
||||
|
|
Loading…
Reference in a new issue