(root)/
glib-2.79.0/
fuzzing/
fuzz_uri_parse_params.c
       1  /*
       2   * Copyright 2020 Endless OS Foundation, LLC
       3   * Copyright 2020 Red Hat, Inc.
       4   *
       5   * SPDX-License-Identifier: LGPL-2.1-or-later
       6   *
       7   * This library is free software; you can redistribute it and/or
       8   * modify it under the terms of the GNU Lesser General Public
       9   * License as published by the Free Software Foundation; either
      10   * version 2.1 of the License, or (at your option) any later version.
      11   *
      12   * This library is distributed in the hope that it will be useful,
      13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
      14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      15   * Lesser General Public License for more details.
      16   *
      17   * You should have received a copy of the GNU Lesser General Public
      18   * License along with this library; if not, see <http://www.gnu.org/licenses/>.
      19   */
      20  
      21  #include "fuzz.h"
      22  
      23  int
      24  LLVMFuzzerTestOneInput (const unsigned char *data, size_t size)
      25  {
      26    GError *error = NULL;
      27    GHashTable *parsed_params = NULL;
      28  
      29    fuzz_set_logging_func ();
      30  
      31    if (size > G_MAXSSIZE)
      32      return 0;
      33  
      34    parsed_params = g_uri_parse_params ((const gchar *) data, (gssize) size,
      35                                        "&", G_URI_PARAMS_NONE, &error);
      36    if (parsed_params == NULL)
      37      {
      38        g_assert (error);
      39        g_clear_error (&error);
      40        return 0;
      41      }
      42  
      43  
      44    g_assert_no_error (error);
      45    g_hash_table_unref (parsed_params);
      46  
      47    return 0;
      48  }