Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-24989

libeconf: solve static analyzer problems

    • Icon: Bug Bug
    • Resolution: Done-Errata
    • Icon: Major Major
    • rhel-9.5
    • rhel-9.3.0
    • libeconf
    • libeconf-0.4.1-4.el9
    • None
    • Low
    • rhel-sst-idm-sssd
    • ssg_idm
    • 8
    • 9
    • 5
    • False
    • Hide

      None

      Show
      None
    • None
    • None
    • None

      Problems

      Error: RESOURCE_LEAK (CWE-772):

      libeconf-0.4.1/lib/libeconf.c:312: alloc_arg: "econf_readDirsHistory" allocates memory that is stored into "key_files".
      libeconf-0.4.1/lib/libeconf.c:321: leaked_storage: Variable "key_files" going out of scope leaks the storage it points to.
      319| comment);
      320| if (error != ECONF_SUCCESS)
      321|-> return error;
      322|
      323| // Merge the list of acquired key_files into merged_file

      Error: UNINIT (CWE-457):

      libeconf-0.4.1/lib/libeconf.c:161: var_decl: Declaring variable "key_file" without initializer.
      libeconf-0.4.1/lib/libeconf.c:247: uninit_use_in_call: Using uninitialized value "key_file" when calling "econf_freeFile".
      245| key_files = calloc(*size, sizeof(econf_file));
      246| if (*key_files == NULL)

      { 247|-> econf_freeFile(key_file); 248| return ECONF_NOMEM; 249| }

      Error: RESOURCE_LEAK (CWE-772):

      libeconf-0.4.1/lib/libeconf.c:268: alloc_fn: Storage is returned from allocation function "combine_strings".
      libeconf-0.4.1/lib/libeconf.c:268: var_assign: Assigning: "project_path" = storage returned from "combine_strings(default_dirs[i], project_name, '/')".
      libeconf-0.4.1/lib/libeconf.c:271: leaked_storage: Variable "project_path" going out of scope leaks the storage it points to.
      269| char suffix_d = malloc (strlen(suffix) + 4); / + strlen(".d/") */
      270| if (suffix_d == NULL)
      271|-> return ECONF_NOMEM;
      272| cp = stpcpy(suffix_d, suffix);
      273| stpcpy(cp, ".d");

      Error: RESOURCE_LEAK (CWE-772):

      libeconf-0.4.1/util/econftool.c:241: alloc_arg: "econf_readDirsHistory" allocates memory that is stored into "key_files".
      libeconf-0.4.1/util/econftool.c:246: leaked_storage: Variable "key_files" going out of scope leaks the storage it points to.
      244| if (econf_error)

      { 245| fprintf(stderr, "%d: %s\n", econf_error, econf_errString(econf_error)); 246|-> return -1; 247| }

      248|

      Error: RESOURCE_LEAK (CWE-772):

      libeconf-0.4.1/util/econftool.c:241: alloc_arg: "econf_readDirsHistory" allocates memory that is stored into "key_files".
      libeconf-0.4.1/util/econftool.c:246: leaked_storage: Variable "key_files" going out of scope leaks the storage it points to.
      244| if (econf_error)

      { 245| fprintf(stderr, "%d: %s\n", econf_error, econf_errString(econf_error)); 246|-> return -1; 247| }

      248|

      Error: RESOURCE_LEAK (CWE-772):

      libeconf-0.4.1/util/econftool.c:185: alloc_arg: "econf_getExtValue" allocates memory that is stored into "value".
      libeconf-0.4.1/util/econftool.c:189: leaked_storage: Variable "value" going out of scope leaks the storage it points to.
      187| fprintf(stderr, "%d: %s\n", econf_error, econf_errString(econf_error));
      188| econf_free(keys);
      189|-> return econf_error;
      190| }
      191| if (value != NULL) {

              ipedrosa@redhat.com Iker Pedrosa
              ipedrosa@redhat.com Iker Pedrosa
              Iker Pedrosa Iker Pedrosa
              Anuj Borah Anuj Borah
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: