undefined4 soapcgi_main(void)

{
  char cVar1;
  int iVar2;
  char *pcVar3;
  char *pcVar4;
  char *__s;
  char *pcVar5;
  int iVar6;
  size_t sVar7;
  __pid_t _Var8;
  FILE *__stream;
  undefined4 uVar9;
  undefined4 uVar10;
  
  iVar2 = FUN_0040b504();
  if (iVar2 < 0) {
    return 0;
  }
  pcVar3 = getenv("CONTENT_TYPE")   //possible issue identified - semgrep
  pcVar4 = getenv("REQUEST_URI")   //possible issue identified - semgrep
  __s = getenv("HTTP_SOAPACTION")   //possible issue identified - semgrep
  pcVar5 = getenv("REQUEST_METHOD")   //possible issue identified - semgrep
  if ((pcVar3 == (char *)0x0) || (iVar6 = strncasecmp(pcVar3,"text/xml",8), iVar6 != 0)) {
    uVar9 = 0x19f;
    pcVar3 = (char *)0x0;
    pcVar4 = (char *)0x0;
LAB_0040b8e4:
    uVar10 = 0xffffffff;
    cgibin_print_http_status(uVar9,pcVar3,pcVar4);
  }
  else {
    uVar10 = 0xffffffff;
    if ((pcVar4 == (char *)0x0) || (__s == (char *)0x0)) goto LAB_0040bb5c;
    pcVar3 = strchr(pcVar4,0x3f);
    if (pcVar3 != (char *)0x0) {
      iVar6 = strncmp(pcVar3,"?service=",9);
      uVar10 = 0xffffffff;
      if (iVar6 != 0) goto LAB_0040bb5c;
      sVar7 = strlen(__s);
      if (__s[sVar7 - 1] == '\"') {   //possible issue identified - semgrep
        __s[sVar7 - 1] = '\0'   //possible issue identified - semgrep
      }
      cVar1 = *__s;
      pcVar4 = strchr(__s + (cVar1 == '\"'),0x23);
      DAT_004322d0 = pcVar4;
      if (pcVar4 != (char *)0x0) {
        DAT_004322d0 = pcVar4 + 1;
        *pcVar4 = '\0';
        iVar6 = strcasecmp(pcVar5,"POST");
        if (iVar6 == 0) {
          _Var8 = getpid();
          sprintf(&DAT_00430e90,"%s/pid%d","/runtime/services/upnp",_Var8)   //possible issue identified - semgrep
          cgibin_parse_request(FUN_0040b3bc,0,0x10000);
          pcVar5 = getenv("SERVER_ID")   //possible issue identified - semgrep
          pcVar4 = DAT_004322d0;
          _Var8 = getpid();
          pcVar3 = pcVar3 + 9;
          sprintf(&DAT_00431ed0,
                  "%s/ACTION.%s.php\nACTION_NODEBASE=%s\nINF_UID=%s\nSERVICE_TYPE=%s\nACTION_NAME=%s\nSHELL_FILE=%s/%s_%d.sh"
                  ,"/htdocs/upnp",pcVar3,&DAT_00430e90,pcVar5,__s + (cVar1 == '\"'),pcVar4,
                  "/var/run",pcVar3,_Var8)   //possible issue identified - semgrep
          iVar6 = xmldbc_ephp_wb(0,0,&DAT_00431ed0,&DAT_00430ed0,0x1000);
          if (iVar6 == 0) {
            iVar6 = cgibin_fill_http_content_len(&DAT_00430ed0,0x1000);
            if (iVar6 == 0) {
              printf("%s",&DAT_00430ed0);
            }
            _Var8 = getpid();
            sprintf(&DAT_00431ed0,"%s/%s_%d.sh","/var/run",pcVar3,_Var8)   //possible issue identified - semgrep
            __stream = fopen(&DAT_00431ed0,"a+")   //possible issue identified - semgrep
            if (__stream != (FILE *)0x0) {
              _Var8 = getpid();
              fprintf(__stream,"rm -f %s/%s_%d.sh","/var/run",pcVar3,_Var8);
              fclose(__stream);
              _Var8 = getpid();
              sprintf(&DAT_00431ed0,"sh %s/%s_%d.sh > /dev/console &","/var/run",pcVar3,_Var8)   //possible issue identified - semgrep
              system(&DAT_00431ed0)   //possible issue identified - semgrep
            }
          }
          xmldbc_del(0,0,&DAT_00430e90);
          uVar10 = 0;
          goto LAB_0040bb5c;
        }
        pcVar3 = "";
        pcVar4 = "unsupported HTTP request";
        uVar9 = 400;
        goto LAB_0040b8e4;
      }
    }
    uVar10 = 0xffffffff;
  }
LAB_0040bb5c:
  FUN_0040b624(iVar2);
  return uVar10;
}