memory leaks fixing
This commit is contained in:
@@ -19,12 +19,8 @@ bool session_manager::validate_pass(){
|
||||
this->read_data(buffer, 256);
|
||||
std::string user=buffer;
|
||||
this->read_data(buffer, 256);
|
||||
// std::string pass=buffer;
|
||||
unsigned char hash[SHA512_DIGEST_LENGTH];
|
||||
SHA512(reinterpret_cast<unsigned const char*>(buffer), strlen(buffer), hash);
|
||||
unsigned char encodedData[200];
|
||||
EVP_EncodeBlock(encodedData, hash, sizeof (hash));
|
||||
std::string pass=std::string(reinterpret_cast<char*>(encodedData));
|
||||
std::string pass=std::string(data_acces::get_hash(buffer));
|
||||
delete[] (buffer);
|
||||
if(this->data->get_passwd(user)==pass){
|
||||
this->write_data("pass");
|
||||
if(this->data->get_admin(user)){
|
||||
@@ -62,6 +58,7 @@ void session_manager::start_dialog(){
|
||||
break;
|
||||
}
|
||||
}
|
||||
delete[] (buffer);
|
||||
}
|
||||
|
||||
int session_manager::execute(){
|
||||
@@ -75,11 +72,13 @@ int session_manager::execute(){
|
||||
this->read_data(use_conf,256);
|
||||
conf.change_uses(use_conf);
|
||||
}else if(strcmp(use_conf,"n")!=0){
|
||||
delete[] (n_package);
|
||||
perror("fail in protocol comunication");
|
||||
return -1;
|
||||
}
|
||||
delete [] (use_conf);
|
||||
std::string result = this->appli_command("--ask", n_package);
|
||||
delete[] (n_package);
|
||||
if(result=="err"){
|
||||
return -1;
|
||||
}else{
|
||||
@@ -94,6 +93,7 @@ int session_manager::remove(){
|
||||
char* n_package = new char[256];
|
||||
this->read_data(n_package, 256);
|
||||
std::string result = this->appli_command("--unmerge",n_package);
|
||||
delete[] (n_package);
|
||||
if(result=="err"){
|
||||
return -1;
|
||||
}else{
|
||||
@@ -121,10 +121,8 @@ std::string session_manager::appli_command(char comand[], char* n_package){
|
||||
if(status>0){
|
||||
this->write_data("ok");
|
||||
ret = n_package;
|
||||
delete[] (n_package);
|
||||
}else{
|
||||
this->write_data("bad");
|
||||
delete[] (n_package);
|
||||
ret = "err";
|
||||
}
|
||||
}
|
||||
@@ -167,6 +165,7 @@ void session_manager::remove_user(){
|
||||
this->read_data(buffer,256);
|
||||
this->read_data(buffer,256);
|
||||
this->data->remove_user(std::string(buffer));
|
||||
delete[] (buffer);
|
||||
}
|
||||
|
||||
int session_manager::read_data(char* input, int size){
|
||||
|
||||
Reference in New Issue
Block a user