undefined4 dhcp6_ctl_authinit(char *param_1,undefined4 *param_2,undefined4 *param_3)

{
  FILE *__stream;
  char *pcVar1;
  size_t __size;
  undefined4 *__ptr;
  void *__dest;
  int iVar2;
  int *piVar3;
  char acStack_818 [1024];
  undefined1 auStack_418 [1024];
  
  *param_3 = 0x10;
  __stream = fopen(param_1,"r")   //possible issue identified - semgrep
  if (__stream == (FILE *)0x0) {
    piVar3 = __errno_location();
    pcVar1 = strerror(*piVar3);
    dprintf(3,"dhcp6_ctl_authinit","failed to open %s: %s",param_1,pcVar1);
  }
  else {
    pcVar1 = fgets(acStack_818,0x400,__stream)   //possible issue identified - semgrep
    if ((pcVar1 == (char *)0x0) && (iVar2 = ferror(__stream), iVar2 != 0)) {
      piVar3 = __errno_location();
      pcVar1 = strerror(*piVar3);
      dprintf(3,"dhcp6_ctl_authinit","failed to read key file: %s",pcVar1);
    }
    else {
      __size = base64_decodestring(acStack_818,auStack_418,0x400)   //possible issue identified - semgrep
      if ((int)__size < 0) {   //possible issue identified - semgrep
        dprintf(3,"dhcp6_ctl_authinit","failed to decode base64 string");
      }
      else {
        __ptr = (undefined4 *)malloc(0x20)   //possible issue identified - semgrep
        if (__ptr != (undefined4 *)0x0) {
          *__ptr = 0;
          __ptr[1] = 0;
          __ptr[2] = 0;
          __ptr[3] = 0;
          __ptr[4] = 0;
          __ptr[5] = 0;
          __ptr[6] = 0;
          __ptr[7] = 0;
          __dest = malloc(__size)   //possible issue identified - semgrep
          __ptr[5] = __dest;
          if (__dest != (void *)0x0) {
            __ptr[6] = __size;
            memcpy(__dest,auStack_418,__size)   //possible issue identified - semgrep
            fclose(__stream);
            *param_2 = __ptr;
            return 0;
          }
          dprintf(4,"dhcp6_ctl_authinit","failed to allocate secret key");
          fclose(__stream);
          if ((void *)__ptr[5] != (void *)0x0) {
            free((void *)__ptr[5]);
          }
          free(__ptr);
          return 0xffffffff;
        }
        dprintf(4,"dhcp6_ctl_authinit","failed to allocate control key");
      }
    }
    fclose(__stream);
  }
  return 0xffffffff;
}