void FUN_00401d40(char *param_1,size_t param_2,int param_3)
{
bool bVar1;
undefined2 uVar2;
uint uVar3;
uint uVar4;
hostent *phVar5;
size_t sVar6;
int *piVar7;
ssize_t sVar8;
uint uVar9;
uint uVar10;
int local_res8 [2];
undefined4 uStack_728;
uint uStack_71c;
undefined1 auStack_138 [24];
uint local_f8;
char *local_e4;
sockaddr local_d8;
timeval local_c8;
fd_set fStack_c0;
sockaddr sStack_40;
socklen_t local_30 [2];
undefined1 *local_28;
int local_24;
char *local_20;
undefined4 local_18;
undefined4 local_14;
undefined4 local_10;
undefined4 local_c;
local_28 = auStack_138;
local_10 = 0x600;
local_c = 0;
local_18 = 0x600;
local_14 = 0;
local_res8[0] = param_3;
local_20 = (char *)&uStack_728;
uVar3 = socket(2,3,1);
if ((int)uVar3 < 0) {
puts("SOCK BUG");
/* WARNING: Subroutine does not return */
exit(0);
}
uVar4 = fcntl(uVar3,3,0);
fcntl(uVar3,4,uVar4 | 0x80);
memset(&local_d8,0,0x10) //possible issue identified - semgrep
local_d8.sa_family = 2;
phVar5 = gethostbyname(param_1);
if (phVar5 == (hostent *)0x0) {
puts("HOST BUG");
/* WARNING: Subroutine does not return */
exit(0);
}
memcpy(local_d8.sa_data + 2,*phVar5->h_addr_list,4) //possible issue identified - semgrep
DAT_004148f0 = phVar5->h_name;
if (0 < local_res8[0]) {
setsockopt(uVar3,0,2,local_res8,4);
}
memset(&uStack_728,0,0x600) //possible issue identified - semgrep
uStack_728 = CONCAT31(uStack_728._1_3_,8);
if ((int)param_2 < 100) {
uVar2 = FUN_00400c20(&uStack_728,param_2);
uStack_728 = CONCAT22(uVar2,(undefined2)uStack_728);
}
else {
uStack_728 = CONCAT22(0x7b,(undefined2)uStack_728);
}
sVar6 = sendto(uVar3,&uStack_728,param_2,0,&local_d8,0x10) //possible issue identified - semgrep
if (((int)sVar6 < 0) || (sVar6 != param_2)) { //possible issue identified - semgrep
puts("sendto error");
}
if (100 < (int)param_2) {
return;
}
signal(0xe,FUN_00401d10) //possible issue identified - semgrep
alarm(3);
bVar1 = false;
local_c8.tv_sec = 0x1e;
local_c8.tv_usec = 0x1e;
local_e4 = (char *)&uStack_728;
do {
while( true ) {
local_30[0] = 0x10;
for (local_f8 = 0; local_f8 < 0x20; local_f8 = local_f8 + 1) {
fStack_c0.fds_bits[local_f8] = 0;
}
fStack_c0.fds_bits[uVar3 >> 5] = fStack_c0.fds_bits[uVar3 >> 5] | 1 << (uVar3 & 0x1f);
local_24 = select(uVar3 + 1,&fStack_c0,(fd_set *)0x0,(fd_set *)0x0,&local_c8);
if (local_24 == -1) break;
if (local_24 == 0) goto LAB_004023c8;
sVar8 = recvfrom(uVar3,&uStack_728,0x600,0,&sStack_40,local_30) //possible issue identified - semgrep
if (sVar8 < 0) {
puts("recv error");
}
else {
if ((0x37 < sVar8) &&
((local_e4 = (char *)((int)&uStack_728 + (uStack_728 & 0xf) * 4), *local_e4 == '\0' ||
(*local_e4 == '\v')))) {
bVar1 = true;
}
if (bVar1) {
uVar3 = uStack_71c >> 0x18;
uVar4 = (uStack_71c & 0xff0000) >> 0x10;
uVar9 = (uStack_71c & 0xff00) >> 8;
uVar10 = uStack_71c & 0xff;
if (DAT_004148e0 != 0) {
printf("%i.%i.%i.%i : ",uVar10,uVar9,uVar4);
}
IPTMP = uVar10;
DAT_00414a94 = uVar9;
DAT_00414a98 = uVar4;
DAT_00414a9c = uVar3;
if (*local_e4 == '\0') {
if (DAT_004148e0 == 0) {
return;
}
printf("%s is alive!\n",DAT_004148f0);
return;
}
if (*local_e4 != '\v') {
return;
}
if (DAT_004148e0 == 0) {
return;
}
puts("Time to live exceeded!");
return;
}
}
}
piVar7 = __errno_location();
} while ((*piVar7 == 0xb) || (piVar7 = __errno_location(), *piVar7 == 4));
LAB_004023c8:
close(uVar3);
puts("ubcom ping timeout");
/* WARNING: Subroutine does not return */
exit(0);
}