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