add check to prevent seg fault because out of bounds access
This commit is contained in:
parent
983734f7da
commit
5a42f353dd
7
config.c
7
config.c
@ -33,9 +33,14 @@ int loadConfig(char *str_file, char **str_entry,char **host,int *intervall,int s
|
||||
{
|
||||
char *ptr_host = strrchr(temp_str,'=')+1;//Without =
|
||||
ptr_host[strcspn(ptr_host,"\n")]=0;
|
||||
while(ptr_host[0]==' ')
|
||||
while(ptr_host[0]==' ') //Potential segfault??
|
||||
{
|
||||
if(ptr_host < (temp_str + strlen(temp_str)))
|
||||
{
|
||||
ptr_host = ptr_host + 1;
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
}
|
||||
*host = strdup(ptr_host);
|
||||
printf("my host is:%s\n",*host);
|
||||
|
Loading…
Reference in New Issue
Block a user