change add_logininfo_to_buffer

to accept size of data for future use
This commit is contained in:
Nikola Petrov 2024-07-21 23:43:52 +02:00
parent 6bfe732b7c
commit 8b60cdc81b
3 changed files with 8 additions and 8 deletions

View File

@ -30,7 +30,7 @@ int find_logininfo_in_buffer(Buffer &buffer, const char *label);
void delete_logininfo_from_buffer(Buffer &buffer, int index_of_pass);
void add_logininfo_to_buffer(Buffer &buffer, const char *label, const char *username, const char *password);
void add_logininfo_to_buffer(Buffer &buffer, const char *label, size_t label_size, const char *username, size_t username_size, const char *password, size_t password_size);
LoginInfoPointer get_logininfo_pointer_from_buffer(Buffer &buffer, int index_of_pass);

View File

@ -159,7 +159,7 @@ std::optional<LoginInfoPointer> arg_new_password(Buffer &decrypted_buffer, Buffe
}
}
add_logininfo_to_buffer(decrypted_buffer, name.c_str(), username.c_str(), password.c_str());
add_logininfo_to_buffer(decrypted_buffer, name.c_str(), name.size(), username.c_str(), username.size(), password.c_str(), password.size());
Aes256::encrypt(key, decrypted_buffer, encrypted_buffer);
encrypted_buffer.save_to_file();
Index *index = (Index *)decrypted_buffer.buffer;
@ -184,7 +184,7 @@ void arg_username(Buffer &decrypted_buffer, Buffer &encrypted_buffer, const char
std::getline(std::cin, username);
delete_logininfo_from_buffer(decrypted_buffer, pass);
add_logininfo_to_buffer(decrypted_buffer, name.c_str(), username.c_str(), password.c_str());
add_logininfo_to_buffer(decrypted_buffer, name.c_str(), name.size(), username.c_str(), username.size(), password.c_str(), password.size());
Aes256::encrypt(key, decrypted_buffer, encrypted_buffer);
encrypted_buffer.save_to_file();
}
@ -208,7 +208,7 @@ void arg_label_name(Buffer &decrypted_buffer, Buffer &encrypted_buffer, const ch
std::getline(std::cin, name);
delete_logininfo_from_buffer(decrypted_buffer, pass);
add_logininfo_to_buffer(decrypted_buffer, name.c_str(), username.c_str(), password.c_str());
add_logininfo_to_buffer(decrypted_buffer, name.c_str(), name.size(), username.c_str(), username.size(), password.c_str(), password.size());
Aes256::encrypt(key, decrypted_buffer, encrypted_buffer);
encrypted_buffer.save_to_file();
}

View File

@ -48,11 +48,11 @@ void delete_logininfo_from_buffer(Buffer &buffer, int index_of_pass)
in_index->offset -= sizeof(LoginInfo);
}
void add_logininfo_to_buffer(Buffer &buffer, const char *label, const char *username, const char *password)
void add_logininfo_to_buffer(Buffer &buffer, const char *label, size_t label_size, const char *username, size_t username_size, const char *password, size_t password_size)
{
uint32_t label_start = buffer.add_end((uint8_t *)label, strlen(label) + 1);
uint32_t username_start = buffer.add_end((uint8_t *)username, strlen(username) + 1);
uint32_t password_start = buffer.add_end((uint8_t *)password, strlen(password) + 1);
uint32_t label_start = buffer.add_end((uint8_t *)label, label_size + 1);
uint32_t username_start = buffer.add_end((uint8_t *)username, username_size + 1);
uint32_t password_start = buffer.add_end((uint8_t *)password, password_size + 1);
Index *index = (Index *)buffer.buffer;