undefined4 FUN_00403aac(char *param_1,undefined4 param_2,int param_3,int param_4,int param_5)
{
char cVar1;
undefined4 uVar2;
int iVar3;
void *__dest;
int iVar4;
int iVar5;
undefined4 uVar6;
size_t __size;
char *pcVar7;
iVar5 = *(int *)(param_4 + 0xcc);
cVar1 = *param_1;
if (iVar5 == -1) {
LAB_00403bc0:
uVar2 = 0;
}
else {
if (iVar5 == 2) {
iVar5 = *(int *)(param_4 + 0xd0);
if (iVar5 == 1) {
iVar5 = *(int *)(param_4 + 0xd4);
if (iVar5 == 0) {
if (param_3 == 0) {
uVar2 = duidstr(param_4);
}
else {
iVar5 = *(int *)(param_3 + 0x30);
if (iVar5 != 0) {
iVar3 = *(int *)(param_3 + 4);
dprintf(7,"process_auth","found key %s for client %s",*(undefined4 *)(iVar5 + 4),iVar3
);
if (cVar1 == '\x01') {
if ((*(uint *)(param_4 + 200) & 1) == 0) {
dprintf(6,"process_auth","authentication information provided in solicit from %s",
*(undefined4 *)(param_3 + 4),iVar3);
}
}
else {
if (*(int *)(param_3 + 0x34) == 0) {
dprintf(4,"process_auth","previous RD value for %s is unknown (accept it)",
*(undefined4 *)(param_3 + 4),iVar3);
}
else {
iVar3 = *(int *)(param_4 + 0xd8);
iVar4 = dhcp6_auth_replaycheck(*(undefined4 *)(param_4 + 0xd4));
if (iVar4 != 0) {
uVar2 = *(undefined4 *)(param_3 + 4);
pcVar7 = "possible replay attack detected for client %s";
goto LAB_00403e70;
}
}
if ((*(uint *)(param_4 + 200) & 1) != 0) {
uVar2 = *(undefined4 *)(param_3 + 4);
iVar5 = dhcp6msgstr(cVar1);
pcVar7 = "client %s did not provide authentication information in %s";
goto LAB_00403b34;
}
if (((*(int *)(param_4 + 0xe0) != *(int *)(iVar5 + 0x10)) ||
(*(size_t *)(param_4 + 0xe4) != *(size_t *)(iVar5 + 0xc))) ||
(iVar4 = memcmp(*(void **)(param_4 + 0xe8),*(void **)(iVar5 + 8),
*(size_t *)(param_4 + 0xe4)), iVar4 != 0)) {
dprintf(6,"process_auth","authentication key mismatch with client %s",
*(undefined4 *)(param_3 + 4),iVar3);
return 0xffffffff;
}
iVar4 = dhcp6_validate_key(iVar5);
if (iVar4 != 0) {
uVar2 = *(undefined4 *)(iVar5 + 4);
pcVar7 = "key %s has expired";
LAB_00403e70:
dprintf(6,"process_auth",pcVar7,uVar2,iVar3);
return 0xffffffff;
}
iVar3 = *(int *)(param_4 + 0xec) + 4;
iVar4 = dhcp6_verify_mac(param_1,param_2,*(undefined4 *)(param_4 + 0xcc),
*(undefined4 *)(param_4 + 0xd0),iVar3,iVar5);
if (iVar4 != 0) {
dprintf(6,"process_auth","invalid message authentication");
return 0xffffffff;
}
dprintf(7,"process_auth","message authentication validated for client %s",
*(undefined4 *)(param_3 + 4));
}
uVar6 = *(undefined4 *)(param_4 + 0xd4);
uVar2 = *(undefined4 *)(param_4 + 0xd0);
*(undefined4 *)(param_5 + 0xcc) = *(undefined4 *)(param_4 + 0xcc);
*(undefined4 *)(param_5 + 0xd0) = uVar2;
*(undefined4 *)(param_5 + 0xd4) = uVar6;
iVar4 = get_rdvalue(uVar6,param_5 + 0xd8,8);
if (iVar4 == 0) {
*(undefined4 *)(param_5 + 0xe0) = *(undefined4 *)(iVar5 + 0x10);
__size = *(size_t *)(iVar5 + 0xc) //possible issue identified - semgrep
*(size_t *)(param_5 + 0xe4) = __size;
__dest = malloc(__size) //possible issue identified - semgrep
*(void **)(param_5 + 0xe8) = __dest;
if (__dest != (void *)0x0) {
memcpy(__dest,*(void **)(iVar5 + 8),*(size_t *)(param_5 + 0xe4)) //possible issue identified - semgrep
if (cVar1 != '\x01') {
uVar2 = *(undefined4 *)(param_4 + 0xd8);
uVar6 = *(undefined4 *)(param_4 + 0xdc);
*(undefined4 *)(param_3 + 0x34) = 1;
*(undefined4 *)(param_3 + 0x38) = uVar2;
*(undefined4 *)(param_3 + 0x3c) = uVar6;
return 0;
}
goto LAB_00403bc0;
}
dprintf(3,"process_auth","failed to allocate memory for authentication realm for %s"
,*(undefined4 *)(param_3 + 4),iVar3);
}
else {
dprintf(3,"process_auth","failed to get a replay detection value for %s",
*(undefined4 *)(param_3 + 4),iVar3);
}
goto LAB_00403bb8;
}
uVar2 = *(undefined4 *)(param_3 + 4);
}
dprintf(6,"process_auth","client %s wanted authentication, but no key found",uVar2);
}
else {
if (param_3 == 0) {
uVar2 = duidstr(param_4);
}
else {
uVar2 = *(undefined4 *)(param_3 + 4);
}
dprintf(6,"process_auth","unknown RDM (%d) required by %s",iVar5,uVar2);
}
}
else {
if (param_3 == 0) {
uVar2 = duidstr(param_4);
}
else {
uVar2 = *(undefined4 *)(param_3 + 4);
}
dprintf(6,"process_auth","unknown authentication algorithm (%d) required by %s",iVar5,uVar2)
;
}
LAB_00403bb8:
if (cVar1 == '\x01') goto LAB_00403bc0;
}
else {
if (param_3 == 0) {
uVar2 = duidstr(param_4);
iVar5 = *(int *)(param_4 + 0xcc);
}
else {
uVar2 = *(undefined4 *)(param_3 + 4);
}
pcVar7 = "client %s wanted authentication with unsupported protocol (%d)";
LAB_00403b34:
dprintf(6,"process_auth",pcVar7,uVar2,iVar5);
}
uVar2 = 0xffffffff;
}
return uVar2;
}