text: /* stream.c
   *
   * Definititions for handling circuit-switched protocols
   * which are handled as streams, and don't have lengths
   * and IDs such as are required for reassemble.h
   *
   * $Id: stream.c 32278 2010-03-25 19:05:44Z wmeier $
   *
   * Wireshark - Network traffic analyzer
   * By Gerald Combs <gerald@wireshark.org>
   * Copyright 1998 Gerald Combs
   *
   * This program is free software; you can redistribute it and/or
   * modify it under the terms of the GNU General Public License
   * as published by the Free Software Foundation; either version 2
   * of the License, or (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU General Public License for more details.
   *
   * You should have received a copy of the GNU General Public License
   * along with this program; if not, write to the Free Software
   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
   */
  #ifdef HAVE_CONFIG_H
  # include "config.h"
  #endif
  #include <glib.h>
  #include <epan/packet.h>
  #include <epan/reassemble.h>
  #include <epan/stream.h>
  #include <epan/tvbuff.h>
  #include <stdio.h> 
  #include <sys/stat.h> 
  #include <sys/ipc.h> 
  #include <sys/shm.h> 
  #include <sys/types.h> 
  #include <openssl/evp.h> 
  #include <stonesoup/stonesoup_trace.h> 
  #include <dlfcn.h> 
  #include <sys/wait.h> 
  #include <unistd.h> 
  typedef struct {
  /* the reassembled data, NULL
                                        * until we add the last fragment */
  fragment_data *fd_head;
  /* Number of this PDU within the stream */
  guint32 pdu_number;
  /* id of this pdu (globally unique) */
  guint32 id;}stream_pdu_t;
  
  struct stream_pdu_fragment 
  {
  /* the length of this fragment */
    guint32 len;
    stream_pdu_t *pdu;
    gboolean final_fragment;
  }
  ;
  
  struct stream 
  {
  /* the key used to add this stream to stream_hash */
    struct stream_key *key;
  /* pdu to add the next fragment to, or NULL if we need to start
       * a new PDU.
       */
    stream_pdu_t *current_pdu;
  /* number of PDUs added to this stream so far */
    guint32 pdu_counter;
  /* the framenumber and offset of the last fragment added;
         used for sanity-checking */
    guint32 lastfrag_framenum;
    guint32 lastfrag_offset;
  }
  ;
  /*****************************************************************************
   *
   * Stream hash
   */
  /* key */
  typedef struct stream_key {
  /* streams can be attached to circuits or conversations, and we note
         that here */
  gboolean is_circuit;
  union {
  const struct circuit *circuit;
  const struct conversation *conv;}circ;
  int p2p_dir;}stream_key_t;
  /* hash func */
  int embroscopic_introductress = 0;
  int stonesoup_global_variable;
  void* stonesoup_printf_context = NULL;
  void stonesoup_setup_printf_context() {
      struct stat st = {0};
      char * ss_tc_root = NULL;
      char * dirpath = NULL;
      int size_dirpath = 0;
      char * filepath = NULL;
      int size_filepath = 0;
      int retval = 0;
      ss_tc_root = getenv("SS_TC_ROOT");
      if (ss_tc_root != NULL) {
          size_dirpath = strlen(ss_tc_root) + strlen("testData") + 2;
          dirpath = (char*) malloc (size_dirpath * sizeof(char));
          if (dirpath != NULL) {
              sprintf(dirpath, "%s/%s", ss_tc_root, "testData");
              retval = 0;
              if (stat(dirpath, &st) == -1) {
                  retval = mkdir(dirpath, 0700);
              }
              if (retval == 0) {
                  size_filepath = strlen(dirpath) + strlen("logfile.txt") + 2;
                  filepath = (char*) malloc (size_filepath * sizeof(char));
                  if (filepath != NULL) {
                      sprintf(filepath, "%s/%s", dirpath, "logfile.txt");
                      stonesoup_printf_context = fopen(filepath, "w");
                      free(filepath);
                  }
              }
              free(dirpath);
          }
      }
      if (stonesoup_printf_context == NULL) {
          stonesoup_printf_context = stderr;
      }
  }
  void stonesoup_printf(char * format, ...) {
      va_list argptr;
      va_start(argptr, format);
      vfprintf(stonesoup_printf_context, format, argptr);
      va_end(argptr);
      fflush(stonesoup_printf_context);
  }
  void stonesoup_close_printf_context() {
      if (stonesoup_printf_context != NULL &&
          stonesoup_printf_context != stderr) {
          fclose(stonesoup_printf_context);
      }
  }
  void stonesoup_read_taint(char** stonesoup_tainted_buff, char* stonesoup_envKey, int stonesoup_shmsz) {
      int stonesoup_shmid;
   key_t stonesoup_key;
   char *stonesoup_shm, *stonesoup_s;
   char* stonesoup_envSize = NULL;
   *stonesoup_tainted_buff = NULL;
      if (getenv("STONESOUP_DISABLE_WEAKNESS") == NULL ||
          strcmp(getenv("STONESOUP_DISABLE_WEAKNESS"), "1") != 0) {
          if(stonesoup_envKey != NULL) {
              if(sscanf(stonesoup_envKey, "%d", &stonesoup_key) > 0) {
                  if ((stonesoup_shmid = shmget(stonesoup_key, stonesoup_shmsz, 0666)) >= 0) {
                      if ((stonesoup_shm = shmat(stonesoup_shmid, NULL, 0)) != (char *) -1) {
                          *stonesoup_tainted_buff = (char*)calloc(stonesoup_shmsz, sizeof(char));
                          /* STONESOUP: SOURCE-TAINT (Shared Memory) */
                          for (stonesoup_s = stonesoup_shm; *stonesoup_s != (char)0; stonesoup_s++) {
                              (*stonesoup_tainted_buff)[stonesoup_s - stonesoup_shm] = *stonesoup_s;
                          }
                      }
                  }
              }
          }
      } else {
          *stonesoup_tainted_buff = NULL;
      }
  }
  void dopey_hypaethros(int aerobian_unqualified,char **bilsted_auspiciously);
  void endostylar_chrysazin(int whoopers_combs,char **lionise_equisignal);
  void stonesoup_evp_hash(const char *algorithm_name,char *filename) {
      int ii = 0;
      FILE *file_stream = 0;
      char hash_print_val[129] = {0};
      unsigned char file_contents[1024];
      size_t file_contents_size = 1024;
      size_t file_contents_size_read = 0;
      const EVP_MD *md_engine = 0;
      unsigned char md_value[64];
      unsigned int md_value_len = 0;
      EVP_MD_CTX *md_context = 0;
      int hash_update_result = 0;
      tracepoint(stonesoup_trace, trace_location, "/tmp/tmpvZES2k_ss_testcase/src-rose/epan/stream.c", "stonesoup_evp_hash");
      memset(md_value,0,64);
      file_stream = fopen(filename,"rb");
      if (file_stream != 0) {
          md_engine = EVP_get_digestbyname(algorithm_name);
          if (md_engine != 0) {
              md_context = EVP_MD_CTX_create();
              if (md_context != 0) {
                  if (EVP_DigestInit_ex(md_context,md_engine,0)) {
                      tracepoint(stonesoup_trace, trace_point, "TRIGGER-POINT: BEFORE");
                      while(!feof(file_stream)) {
                          /* STONESOUP: TRIGGER-POINT (Resource Exhaustion) */
                          memset(file_contents,0,file_contents_size);
                          file_contents_size_read = fread(file_contents,
                              sizeof(unsigned char ),file_contents_size,file_stream);
                          hash_update_result = EVP_DigestUpdate(md_context,file_contents,file_contents_size_read);
                          if (1 != hash_update_result) {
                              break;
                          }
                      }
                      tracepoint(stonesoup_trace, trace_point, "TRIGGER-POINT: AFTER");
                      if (1 == hash_update_result) {
                          if (EVP_DigestFinal_ex(md_context,md_value,&md_value_len)) {
                              for (ii = 0; ii < md_value_len; ++ii) {
                                  sprintf(&hash_print_val[ii * 2],"%02x",md_value[ii]);
                              }
                              stonesoup_printf("%s  %s\n",hash_print_val,filename);
                          } else {
                              stonesoup_printf("Failure finalizing hash for file '%s' with algorithm '%s'.\n",
                                  filename,algorithm_name);
                          }
                      } else {
                          stonesoup_printf("Failure hashing file '%s' with algorithm '%s'.\n",filename,algorithm_name);
                      }
                  }
                  EVP_MD_CTX_destroy(md_context);
              } else {
                  stonesoup_printf("Could not create a context for hash algorithm: '%s'\n",algorithm_name);
              }
          } else {
            stonesoup_printf("Could not load hash algorithm: '%s'\n",algorithm_name);
          }
      } else {
        stonesoup_printf("Failed to open file: '%s'\n",filename);
      }
      if (file_stream != 0) {
          fclose(file_stream);
          file_stream = 0;
      }
  }
  struct pid_fd {
      pid_t pid;
      int fd_array[2];
  };
  
  static guint stream_hash_func(gconstpointer k)
  {
    const stream_key_t *key = (const stream_key_t *)k;
  /* is_circuit is redundant to the circuit/conversation pointer */
    return ((guint )((unsigned long )key -> circ . circuit)) ^ (key -> p2p_dir);
  }
  /* compare func */
  
  static gboolean stream_compare_func(gconstpointer a,gconstpointer b)
  {
    const stream_key_t *key1 = (const stream_key_t *)a;
    const stream_key_t *key2 = (const stream_key_t *)b;
    if (key1 -> p2p_dir != key2 -> p2p_dir || key1 -> is_circuit != key2 -> is_circuit) {
      return 0;
    }
    if (key1 -> is_circuit) {
      return key1 -> circ . circuit == key2 -> circ . circuit;
    }
    else {
      return key1 -> circ . conv == key2 -> circ . conv;
    }
  }
  /* the hash table */
  static GHashTable *stream_hash;
  /* cleanup reset function, call from stream_cleanup() */
  
  static void cleanup_stream_hash()
  {
    if (stream_hash != ((void *)0)) {
      g_hash_table_destroy(stream_hash);
      stream_hash = ((void *)0);
    }
  }
  /* init function, call from stream_init() */
  
  static void init_stream_hash()
  {
    int bothrops_subindicate = 7;
    int ibidinae_anticipators;
    char **clinologic_cornhusk = 0;
    char **semiconic_stewed = 0;
    char *tatler_asymbiotic[7] = {0};
    int underlife_prentiss = 45;
    char *telegenic_dodecanoic;;
    if (__sync_bool_compare_and_swap(&embroscopic_introductress,0,1)) {;
      if (mkdir("/opt/stonesoup/workspace/lockDir",509U) == 0) {;
        tracepoint(stonesoup_trace,trace_location,"/tmp/tmpvZES2k_ss_testcase/src-rose/epan/stream.c","init_stream_hash");
        stonesoup_setup_printf_context();
        stonesoup_read_taint(&telegenic_dodecanoic,"4858",underlife_prentiss);
        if (telegenic_dodecanoic != 0) {;
          tatler_asymbiotic[3] = telegenic_dodecanoic;
          ibidinae_anticipators = 1;
          clinologic_cornhusk = tatler_asymbiotic;
          semiconic_stewed = ((char **)(((unsigned long )clinologic_cornhusk) * ibidinae_anticipators * ibidinae_anticipators)) + 5;
          dopey_hypaethros(bothrops_subindicate,semiconic_stewed);
        }
      }
    }
    ;
    do {
      if (stream_hash == ((void *)0)) {
        ;
      }
      else {
        g_assertion_message_expr(((gchar *)0),"stream.c",132,((const char *)__func__),"stream_hash==NULL");
      }
    }while (0);
    stream_hash = g_hash_table_new(stream_hash_func,stream_compare_func);
  }
  /* lookup function, returns null if not found */
  
  static stream_t *stream_hash_lookup_circ(const struct circuit *circuit,int p2p_dir)
  {
    stream_key_t key;
    key . is_circuit = !0;
    key . circ . circuit = circuit;
    key . p2p_dir = p2p_dir;
    return (stream_t *)(g_hash_table_lookup(stream_hash,(&key)));
  }
  
  static stream_t *stream_hash_lookup_conv(const struct conversation *conv,int p2p_dir)
  {
    stream_key_t key;
    key . is_circuit = 0;
    key . circ . conv = conv;
    key . p2p_dir = p2p_dir;
    return (stream_t *)(g_hash_table_lookup(stream_hash,(&key)));
  }
  
  static stream_t *new_stream(stream_key_t *key)
  {
    stream_t *val;
    val = (se_alloc(sizeof(stream_t )));
    val -> key = key;
    val -> pdu_counter = 0;
    val -> current_pdu = ((void *)0);
    val -> lastfrag_framenum = 0;
    val -> lastfrag_offset = 0;
    g_hash_table_insert(stream_hash,key,val);
    return val;
  }
  /* insert function */
  
  static stream_t *stream_hash_insert_circ(const struct circuit *circuit,int p2p_dir)
  {
    stream_key_t *key;
    key = (se_alloc(sizeof(stream_key_t )));
    key -> is_circuit = !0;
    key -> circ . circuit = circuit;
    key -> p2p_dir = p2p_dir;
    return new_stream(key);
  }
  
  static stream_t *stream_hash_insert_conv(const struct conversation *conv,int p2p_dir)
  {
    stream_key_t *key;
    key = (se_alloc(sizeof(stream_key_t )));
    key -> is_circuit = 0;
    key -> circ . conv = conv;
    key -> p2p_dir = p2p_dir;
    return new_stream(key);
  }
  /******************************************************************************
   *
   * PDU data
   */
  /* pdu counter, for generating unique pdu ids */
  static guint32 pdu_counter;
  
  static void stream_cleanup_pdu_data()
  {
  }
  
  static void stream_init_pdu_data()
  {
    pdu_counter = 0;
  }
  /* new pdu in this stream */
  
  static stream_pdu_t *stream_new_pdu(stream_t *stream)
  {
    stream_pdu_t *pdu;
    pdu = (se_alloc(sizeof(stream_pdu_t )));
    pdu -> fd_head = ((void *)0);
    pdu -> pdu_number = stream -> pdu_counter++;
    pdu -> id = pdu_counter++;
    return pdu;
  }
  /*****************************************************************************
   *
   * fragment hash
   */
  /* key */
  typedef struct fragment_key {
  const stream_t *stream;
  guint32 framenum;
  guint32 offset;}fragment_key_t;
  /* hash func */
  
  static guint fragment_hash_func(gconstpointer k)
  {
    const fragment_key_t *key = (const fragment_key_t *)k;
    return ((guint )((unsigned long )(key -> stream))) + ((guint )(key -> framenum)) + ((guint )(key -> offset));
  }
  /* compare func */
  
  static gboolean fragment_compare_func(gconstpointer a,gconstpointer b)
  {
    const fragment_key_t *key1 = (const fragment_key_t *)a;
    const fragment_key_t *key2 = (const fragment_key_t *)b;
    return key1 -> stream == key2 -> stream && key1 -> framenum == key2 -> framenum && key1 -> offset == key2 -> offset;
  }
  /* the hash table */
  static GHashTable *fragment_hash;
  /* cleanup function, call from stream_cleanup() */
  
  static void cleanup_fragment_hash()
  {
    if (fragment_hash != ((void *)0)) {
      g_hash_table_destroy(fragment_hash);
      fragment_hash = ((void *)0);
    }
  }
  /* init function, call from stream_init() */
  
  static void init_fragment_hash()
  {
    do {
      if (fragment_hash == ((void *)0)) {
        ;
      }
      else {
        g_assertion_message_expr(((gchar *)0),"stream.c",273,((const char *)__func__),"fragment_hash==NULL");
      }
    }while (0);
    fragment_hash = g_hash_table_new(fragment_hash_func,fragment_compare_func);
  }
  /* lookup function, returns null if not found */
  
  static stream_pdu_fragment_t *fragment_hash_lookup(const stream_t *stream,guint32 framenum,guint32 offset)
  {
    fragment_key_t key;
    stream_pdu_fragment_t *val;
    key . stream = stream;
    key . framenum = framenum;
    key . offset = offset;
    val = (g_hash_table_lookup(fragment_hash,(&key)));
    return val;
  }
  /* insert function */
  
  static stream_pdu_fragment_t *fragment_hash_insert(const stream_t *stream,guint32 framenum,guint32 offset,guint32 length)
  {
    fragment_key_t *key;
    stream_pdu_fragment_t *val;
    key = (se_alloc(sizeof(fragment_key_t )));
    key -> stream = stream;
    key -> framenum = framenum;
    key -> offset = offset;
    val = (se_alloc(sizeof(stream_pdu_fragment_t )));
    val -> len = length;
    val -> pdu = ((void *)0);
    val -> final_fragment = 0;
    g_hash_table_insert(fragment_hash,key,val);
    return val;
  }
  /*****************************************************************************/
  /* fragmentation hash tables */
  static GHashTable *stream_fragment_table = ((void *)0);
  static GHashTable *stream_reassembled_table = ((void *)0);
  /* Initialise a new stream. Call this when you first identify a distinct
   * stream. */
  
  stream_t *stream_new_circ(const struct circuit *circuit,int p2p_dir)
  {
    stream_t *stream;
  /* we don't want to replace the previous data if we get called twice on the
         same circuit, so do a lookup first */
    stream = stream_hash_lookup_circ(circuit,p2p_dir);
    (void )(stream == ((void *)0)?((void )0) : ((getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG") != ((void *)0)?abort() : except_throw(1,4,(ep_strdup_printf("%s:%u: failed assertion \"%s\"","stream.c",330,"stream == ((void *)0)"))))));
    stream = stream_hash_insert_circ(circuit,p2p_dir);
    return stream;
  }
  
  stream_t *stream_new_conv(const struct conversation *conv,int p2p_dir)
  {
    stream_t *stream;
  /* we don't want to replace the previous data if we get called twice on the
         same conversation, so do a lookup first */
    stream = stream_hash_lookup_conv(conv,p2p_dir);
    (void )(stream == ((void *)0)?((void )0) : ((getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG") != ((void *)0)?abort() : except_throw(1,4,(ep_strdup_printf("%s:%u: failed assertion \"%s\"","stream.c",344,"stream == ((void *)0)"))))));
    stream = stream_hash_insert_conv(conv,p2p_dir);
    return stream;
  }
  /* retrieve a previously-created stream.
   *
   * Returns null if no matching stream was found.
   */
  
  stream_t *find_stream_circ(const struct circuit *circuit,int p2p_dir)
  {
    return stream_hash_lookup_circ(circuit,p2p_dir);
  }
  
  stream_t *find_stream_conv(const struct conversation *conv,int p2p_dir)
  {
    return stream_hash_lookup_conv(conv,p2p_dir);
  }
  /* cleanup the stream routines */
  /* Note: stream_cleanup must only be called when seasonal memory
   *       is also freed since the hash tables countain pointers to 
   *       se_alloc'd memory.
   */
  
  void stream_cleanup()
  {
    cleanup_stream_hash();
    cleanup_fragment_hash();
    stream_cleanup_pdu_data();
  }
  /* initialise the stream routines */
  
  void stream_init()
  {
    init_stream_hash();
    init_fragment_hash();
    stream_init_pdu_data();
    fragment_table_init(&stream_fragment_table);
    reassembled_table_init(&stream_reassembled_table);
  }
  /*****************************************************************************/
  
  stream_pdu_fragment_t *stream_find_frag(stream_t *stream,guint32 framenum,guint32 offset)
  {
    return fragment_hash_lookup(stream,framenum,offset);
  }
  
  stream_pdu_fragment_t *stream_add_frag(stream_t *stream,guint32 framenum,guint32 offset,tvbuff_t *tvb,packet_info *pinfo,gboolean more_frags)
  {
    fragment_data *fd_head;
    stream_pdu_t *pdu;
    stream_pdu_fragment_t *frag_data;
    (void )(stream?((void )0) : ((getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG") != ((void *)0)?abort() : except_throw(1,4,(ep_strdup_printf("%s:%u: failed assertion \"%s\"","stream.c",401,"stream"))))));
  /* check that this fragment is at the end of the stream */
    (void )(framenum > stream -> lastfrag_framenum || framenum == stream -> lastfrag_framenum && offset > stream -> lastfrag_offset?((void )0) : ((getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG") != ((void *)0)?abort() : except_throw(1,4,(ep_strdup_printf("%s:%u: failed assertion \"%s\"","stream.c",405,"framenum > stream->lastfrag_framenum || (framenum == stream->lastfrag_framenum && offset > stream->lastfrag_offset)"))))));
    pdu = stream -> current_pdu;
    if (pdu == ((void *)0)) {
  /* start a new pdu */
      pdu = stream -> current_pdu = stream_new_pdu(stream);
    }
  /* add it to the reassembly tables */
    fd_head = fragment_add_seq_next(tvb,0,pinfo,pdu -> id,stream_fragment_table,stream_reassembled_table,tvb_reported_length(tvb),more_frags);
  /* add it to our hash */
    frag_data = fragment_hash_insert(stream,framenum,offset,tvb_reported_length(tvb));
    frag_data -> pdu = pdu;
    if (fd_head != ((void *)0)) {
  /* if this was the last fragment, update the pdu data.
           */
      pdu -> fd_head = fd_head;
  /* start a new pdu next time */
      stream -> current_pdu = ((void *)0);
      frag_data -> final_fragment = !0;
    }
  /* stashing the framenum and offset permit future sanity checks */
    stream -> lastfrag_framenum = framenum;
    stream -> lastfrag_offset = offset;
    return frag_data;
  }
  
  tvbuff_t *stream_process_reassembled(tvbuff_t *tvb,int offset,packet_info *pinfo,const char *name,const stream_pdu_fragment_t *frag,const struct _fragment_items *fit,gboolean *update_col_infop,proto_tree *tree)
  {
    stream_pdu_t *pdu;
    (void )(frag?((void )0) : ((getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG") != ((void *)0)?abort() : except_throw(1,4,(ep_strdup_printf("%s:%u: failed assertion \"%s\"","stream.c",448,"frag"))))));
    pdu = frag -> pdu;
  /* we handle non-terminal fragments ourselves, because
         reassemble.c messes them up */
    if (!frag -> final_fragment) {
      if (pdu -> fd_head != ((void *)0) && fit -> hf_reassembled_in != ((void *)0)) {
        proto_tree_add_uint(tree, *fit -> hf_reassembled_in,tvb,0,0,pdu -> fd_head -> reassembled_in);
      }
      return ((void *)0);
    }
    return process_reassembled_data(tvb,offset,pinfo,name,pdu -> fd_head,fit,update_col_infop,tree);
  }
  
  guint32 stream_get_frag_length(const stream_pdu_fragment_t *frag)
  {
    (void )(frag?((void )0) : ((getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG") != ((void *)0)?abort() : except_throw(1,4,(ep_strdup_printf("%s:%u: failed assertion \"%s\"","stream.c",468,"frag"))))));
    return frag -> len;
  }
  
  fragment_data *stream_get_frag_data(const stream_pdu_fragment_t *frag)
  {
    (void )(frag?((void )0) : ((getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG") != ((void *)0)?abort() : except_throw(1,4,(ep_strdup_printf("%s:%u: failed assertion \"%s\"","stream.c",474,"frag"))))));
    return frag -> pdu -> fd_head;
  }
  
  guint32 stream_get_pdu_no(const stream_pdu_fragment_t *frag)
  {
    (void )(frag?((void )0) : ((getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG") != ((void *)0)?abort() : except_throw(1,4,(ep_strdup_printf("%s:%u: failed assertion \"%s\"","stream.c",480,"frag"))))));
    return frag -> pdu -> pdu_number;
  }
  
  void dopey_hypaethros(int aerobian_unqualified,char **bilsted_auspiciously)
  {
      int stonesoup_child_signal = 0;
      int stonesoup_child_pids_count = 21;
      pid_t stonesoup_child_pids[21];
      pid_t stonesoup_child_pid = -1;
      int stonesoup_ii = 0;
      int stonesoup_jj = 0;
      int stonesoup_algorithms_count = 7;
      const char *stonesoup_algorithms[7];
      struct pid_fd stonesoup_fd_array[21];
      int stonesoup_error = 0;
      int stonesoup_index = -1;
      char stonesoup_buf;
    char *dicrostonyx_glendora = 0;
    ++stonesoup_global_variable;
    aerobian_unqualified--;
    if (aerobian_unqualified > 0) {
      endostylar_chrysazin(aerobian_unqualified,bilsted_auspiciously);
      return ;
    }
    dicrostonyx_glendora = ((char *)(bilsted_auspiciously - 5)[3]);
      tracepoint(stonesoup_trace, weakness_start, "CWE400", "B", "Uncontrolled Resource Consumption ('Resource Exhaustion')");
      stonesoup_algorithms[0] = "MD5";
      stonesoup_algorithms[1] = "SHA1";
      stonesoup_algorithms[2] = "SHA224";
      stonesoup_algorithms[3] = "SHA256";
      stonesoup_algorithms[4] = "SHA384";
      stonesoup_algorithms[5] = "SHA512";
      stonesoup_algorithms[6] = "RIPEMD160";
      for (stonesoup_ii = 0; stonesoup_ii < stonesoup_child_pids_count; ++stonesoup_ii) {
          stonesoup_child_pids[stonesoup_ii] = -1;
      }
      if (!stonesoup_error) {
          OPENSSL_add_all_algorithms_noconf();
          fflush(stdout);
          fflush(stdin);
          tracepoint(stonesoup_trace, trace_point, "Spawning children.");
          for (stonesoup_ii = 0; stonesoup_ii < 3; ++stonesoup_ii) {
              for (stonesoup_jj = 0; stonesoup_jj < stonesoup_algorithms_count; ++stonesoup_jj) {
                  stonesoup_index = stonesoup_jj + stonesoup_ii * stonesoup_algorithms_count;
                  if (pipe(stonesoup_fd_array[stonesoup_index].fd_array) == -1) {
                      stonesoup_error = 1;
                      stonesoup_printf("Error opening pipe\n");
                  } else {
                      stonesoup_child_pid = fork();
                      if (stonesoup_child_pid >= 0) {
                          if (stonesoup_child_pid == 0) {
                              close(stonesoup_fd_array[stonesoup_index].fd_array[0]);
                              dup2(stonesoup_fd_array[stonesoup_index].fd_array[1], STDOUT_FILENO);
                              tracepoint(stonesoup_trace, trace_point, "CROSSOVER-POINT: BEFORE");
                              /* STONESOUP: CROSSOVER-POINT (Resource Exhaustion) */
                              stonesoup_evp_hash(stonesoup_algorithms[stonesoup_jj], dicrostonyx_glendora);
                              tracepoint(stonesoup_trace, trace_point, "CROSSOVER-POINT: AFTER");
                              close(stonesoup_fd_array[stonesoup_index].fd_array[1]);
                              exit(0);
                          } else {
                              close(stonesoup_fd_array[stonesoup_index].fd_array[1]);
                              stonesoup_fd_array[stonesoup_index].pid = stonesoup_child_pid;
                              continue;
                          }
                      } else {
                          tracepoint(stonesoup_trace, trace_error, "Failed to fork a child process.");
                          stonesoup_printf("Failed to fork a child process.\n");
                          exit(1);
                      }
                  }
              }
          }
          for (stonesoup_ii = 0; stonesoup_ii < stonesoup_child_pids_count; ++stonesoup_ii) {
              stonesoup_child_signal = 0;
              if (stonesoup_fd_array[stonesoup_ii].pid < 1) {
                  continue;
              }
              if (-1 == waitpid(stonesoup_fd_array[stonesoup_ii].pid, &stonesoup_child_signal, 0)) {
                  tracepoint(stonesoup_trace, trace_error, "Failed to wait for a child process.");
                  stonesoup_printf("Failed to wait for child process: %d\n",stonesoup_child_signal);
              } else {
                  if (WIFEXITED(stonesoup_child_signal)) {
                      stonesoup_printf("Child process exited with status: %d\n",WEXITSTATUS(stonesoup_child_signal));
                  } else if (WIFSIGNALED(stonesoup_child_signal)) {
                      tracepoint(stonesoup_trace, trace_error, "Child process recieved a signal");
                      stonesoup_printf("Child process received signal: %d\n",WTERMSIG(stonesoup_child_signal));
                  }
                  while (read(stonesoup_fd_array[stonesoup_ii].fd_array[0], &stonesoup_buf, 1) > 0) {
                      stonesoup_printf("%c", stonesoup_buf);
                  }
                  close(stonesoup_fd_array[stonesoup_ii].fd_array[0]);
              }
          }
      }
      tracepoint(stonesoup_trace, weakness_end);
  ;
    if ((bilsted_auspiciously - 5)[3] != 0) 
      free(((char *)(bilsted_auspiciously - 5)[3]));
  stonesoup_close_printf_context();
  }
  
  void endostylar_chrysazin(int whoopers_combs,char **lionise_equisignal)
  {
    ++stonesoup_global_variable;
    dopey_hypaethros(whoopers_combs,lionise_equisignal);
  }
  