add check to prevent seg fault because out of bounds access

This commit is contained in:
Jonathan Wyss 2024-10-08 17:02:53 +02:00
parent 983734f7da
commit 5a42f353dd

View File

@ -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);