#8131 covscan memory leaks report
Closed: fixed by cheimes. Opened by abbra.

After running Red Hat's covscan tool, following issues were found:

Error: RESOURCE_LEAK (CWE-772):

freeipa-4.8.3/util/ipa_pwd_ntlm.c:63: alloc_fn: Storage is returned from allocation function "calloc".
freeipa-4.8.3/util/ipa_pwd_ntlm.c:63: var_assign: Assigning: "ucs2Passwd" = storage returned from "calloc(ol, 1UL)".
freeipa-4.8.3/util/ipa_pwd_ntlm.c:71: var_assign: Assigning: "outc" = "ucs2Passwd".
freeipa-4.8.3/util/ipa_pwd_ntlm.c:92: noescape: Resource "ucs2Passwd" is not freed or pointed-to in "MD4_Update".
freeipa-4.8.3/util/ipa_pwd_ntlm.c:108: leaked_storage: Variable "ucs2Passwd" going out of scope leaks the storage it points to.
freeipa-4.8.3/util/ipa_pwd_ntlm.c:108: leaked_storage: Variable "outc" going out of scope leaks the storage it points to.
#  106|   
#  107|   done:
#  108|->     return ret;
#  109|   }

Error: RESOURCE_LEAK (CWE-772):

freeipa-4.8.3/client/ipa-getkeytab.c:513: alloc_arg: "ipa_string_to_enctypes" allocates memory that is stored into "es".
freeipa-4.8.3/client/ipa-getkeytab.c:515: leaked_storage: Variable "es" going out of scope leaks the storage it points to.
#  513|           ret = ipa_string_to_enctypes(enctypes, &es, &num_es, err_msg);
#  514|           if (ret || num_es == 0) {
#  515|->             return LDAP_OPERATIONS_ERROR;
#  516|           }
#  517|       }

Metadata Update from @abbra:
- Issue assigned to abbra

Metadata Update from @frenaud:
- Custom field rhbz adjusted to https://bugzilla.redhat.com/show_bug.cgi?id=1777920

Issue linked to Bugzilla: Bug 1777920

PR: https://github.com/freeipa/freeipa/pull/3956

master:

  • e3ad78538e1dd2f63f171ef1c2b470a1a4f47a8c covscan: free encryption types in case there is an error
  • e9dd757763c76402e07f533f19e269eeebc554fa covscan: free ucs2-encoded password copy when generating NTLM hash

ipa-4-8:

  • 84592e32c5b59b7b654a0a74b5cc8c1350af6451 covscan: free encryption types in case there is an error
  • eebabb5c5fe7478b391770a857fb9be4f0d60a9c covscan: free ucs2-encoded password copy when generating NTLM hash

ipa-4-7:

  • 212e86eee15e883bffd01f969219ce644c3e45c6 covscan: free encryption types in case there is an error
  • c37081576d2f282e702b42652c04e053886c47cf covscan: free ucs2-encoded password copy when generating NTLM hash

ipa-4-6:

  • e8983f69ce1788144b2b348a65f709412c68e47e covscan: free encryption types in case there is an error
  • 830466c0489466d385a333cb829fe8cd5e59644c covscan: free ucs2-encoded password copy when generating NTLM hash

Metadata Update from @cheimes:
- Issue close_status updated to: fixed
- Issue status updated to: Closed (was: Open)

Metadata