/* WARNING: Type propagation algorithm not settling */
undefined4 configure_keys(int *param_1)
{
undefined4 *puVar1;
void *pvVar2;
size_t sVar3;
time_t tVar4;
tm *__tp;
int iVar5;
char *pcVar6;
int *piVar7;
char *__s1;
int iVar8;
int iVar9;
int local_438;
undefined1 auStack_434 [1028];
undefined1 *local_30;
if (param_1 != (int *)0x0) {
local_30 = auStack_434;
__s1 = (char *)0x0;
do {
puVar1 = (undefined4 *)malloc(0x20) //possible issue identified - semgrep
if (puVar1 == (undefined4 *)0x0) {
dprintf(3,"configure_keys","memory allocation failed for key %s",param_1[1]);
joined_r0x004151e0:
if (__s1 == (char *)0x0) {
return 0xffffffff;
}
free(__s1);
return 0xffffffff;
}
puVar1[1] = 0;
puVar1[2] = 0;
puVar1[3] = 0;
puVar1[4] = 0;
puVar1[5] = 0;
puVar1[6] = 0;
puVar1[7] = 0;
pcVar6 = (char *)param_1[1];
*puVar1 = DAT_0043cd28;
DAT_0043cd28 = puVar1;
pcVar6 = strdup(pcVar6);
puVar1[1] = pcVar6;
if (pcVar6 == (char *)0x0) {
dprintf(3,"configure_keys","failed to copy key name: %s",param_1[1]);
goto joined_r0x004151e0;
}
piVar7 = (int *)param_1[3];
if (piVar7 != (int *)0x0) {
iVar5 = piVar7[2];
iVar8 = -1;
iVar9 = -1;
__s1 = (char *)0x0;
if (iVar5 == 0x2b) goto LAB_00414d50;
do {
if (iVar5 < 0x2c) {
if (iVar5 != 0x2a) {
LAB_00414c6c:
dprintf(3,"configure_keys","%s:%d invalid key parameter for %s",configfilename,
piVar7[3],param_1[1]);
goto joined_r0x004151e0;
}
if (puVar1[2] != 0) {
iVar5 = piVar7[3];
goto LAB_00414df0;
}
pcVar6 = (char *)qstrdup(piVar7[7]);
puVar1[2] = pcVar6;
if (pcVar6 == (char *)0x0) {
dprintf(4,"configure_keys","failed to allocate memory for realm");
goto joined_r0x004151e0;
}
sVar3 = strlen(pcVar6);
puVar1[3] = sVar3;
}
else if (iVar5 == 0x2c) {
if (puVar1[5] == 0) {
pvVar2 = (void *)qstrdup(piVar7[7]);
if (pvVar2 == (void *)0x0) {
dprintf(4,"configure_keys","failed to make a copy of secret");
goto joined_r0x004151e0;
}
memset(local_30,0,0x400) //possible issue identified - semgrep
sVar3 = base64_decodestring(pvVar2,local_30,0x400) //possible issue identified - semgrep
if ((int)sVar3 < 0) { //possible issue identified - semgrep
dprintf(3,"configure_keys","%s:%d failed to parse base64 key",configfilename,
piVar7[3]);
free(pvVar2);
goto joined_r0x004151e0;
}
free(pvVar2);
pvVar2 = malloc(sVar3) //possible issue identified - semgrep
puVar1[5] = pvVar2;
if (pvVar2 == (void *)0x0) {
dprintf(4,"configure_keys","failed to allocate memory for secret");
goto joined_r0x004151e0;
}
memcpy(pvVar2,local_30,sVar3) //possible issue identified - semgrep
puVar1[6] = sVar3;
}
else {
dprintf(4,"configure_keys","%s:%d duplicate secret for key %s (ignored)",
configfilename,piVar7[3],param_1[1]);
}
}
else {
if (iVar5 != 0x2d) goto LAB_00414c6c;
if (__s1 == (char *)0x0) {
__s1 = (char *)qstrdup(piVar7[7]);
}
else {
dprintf(4,"configure_keys","%s:%d duplicate expire for key %s (ignored)",
configfilename,piVar7[3],param_1[1]);
}
}
while( true ) {
piVar7 = (int *)*piVar7;
if (piVar7 == (int *)0x0) goto LAB_00414f78;
iVar5 = piVar7[2];
if (iVar5 != 0x2b) break;
LAB_00414d50:
if ((iVar8 == -1) && (iVar9 == -1)) {
iVar9 = piVar7[5];
iVar8 = piVar7[4];
if (iVar9 != 0) {
dprintf(4,"configure_keys","%s:%d key ID overflow",configfilename,piVar7[3]);
goto joined_r0x004151e0;
}
}
else {
iVar5 = piVar7[3];
LAB_00414df0:
dprintf(4,"configure_keys","%s:%d duplicate realm for key %s (ignored)",configfilename
,iVar5);
}
}
} while( true );
}
iVar8 = -1;
iVar9 = -1;
__s1 = (char *)0x0;
LAB_00414f78:
if (puVar1[2] == 0) {
dprintf(3,"configure_keys","realm not specified for key %s",param_1[1]);
goto joined_r0x004151e0;
}
if ((iVar8 == -1) && (iVar9 == -1)) {
dprintf(3,"configure_keys","key ID not specified for key %s",param_1[1]);
goto joined_r0x004151e0;
}
puVar1[4] = iVar8;
if (puVar1[5] == 0) {
dprintf(3,"configure_keys","secret not specified for key %s",param_1[1]);
goto joined_r0x004151e0;
}
puVar1[7] = 0;
if (__s1 != (char *)0x0) {
iVar5 = strcmp(__s1,"forever");
if (iVar5 != 0) {
tVar4 = time(&local_438);
if (tVar4 == -1) {
piVar7 = __errno_location();
pcVar6 = strerror(*piVar7);
dprintf(3,"configure_keys","cannot get current time: %s",pcVar6);
goto joined_r0x004151e0;
}
__tp = localtime(&local_438);
__tp->tm_sec = 0;
pcVar6 = strptime(__s1,"%Y-%m-%d %H:%M",__tp);
if (((pcVar6 == (char *)0x0) &&
(pcVar6 = strptime(__s1,"%m-%d %H:%M",__tp), pcVar6 == (char *)0x0)) &&
(pcVar6 = strptime(__s1,"%H:%M",__tp), pcVar6 == (char *)0x0)) {
dprintf(3,"configure_keys","invalid expiration time: %s");
goto joined_r0x004151e0;
}
tVar4 = mktime(__tp);
if (tVar4 < local_438) {
dprintf(3,"configure_keys","past expiration time specified: %s",__s1);
goto joined_r0x004151e0;
}
puVar1[7] = tVar4;
}
}
param_1 = (int *)*param_1;
} while (param_1 != (int *)0x0);
}
return 0;
}