Merge pull request #90 from lakinduakash/mac-filter

Fix crash on non existing nac filter file
This commit is contained in:
Lakindu Akash 2020-10-31 01:28:08 +05:30 committed by GitHub
commit cad1c0cf52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 4 deletions

View File

@ -157,8 +157,7 @@ const char* build_kill_create_ap_command(char* pid){
void write_accepted_macs(char* filename, char* accepted_macs){
printf("%s \n",filename);
printf("%s \n",accepted_macs);
printf("mac filter file %s \n",filename);
snprintf(cmd_write_mac,BUFSIZE,"%s '%s' %s %s","echo", accepted_macs, "| sudo tee", filename);
int r=system(cmd_write_mac);
@ -174,7 +173,6 @@ char * read_mac_filter_file(char * filename){
if (fp == NULL)
{
perror("Error while opening the file.\n");
return NULL;
}

View File

@ -488,7 +488,7 @@ void init_ui_from_config(){
}
char *macs =read_mac_filter_file(values->accepted_mac_file);
if (macs!=NULL || strlen(macs)<1){
if (macs!=NULL && !strlen(macs)<1){
gtk_text_buffer_set_text(buffer_mac_filter,macs,strlen(macs));
}