Unload_KM_KEYINFO called UnloadBlob_BYTE passing parameters in wrong order

Related to coverit CID 10254.

Blob parameter is the last one instead of the middle one.

Signed-off-by: Richard Maciel <rmaciel@linux.vnet.ibm.com>
memcmp result was being trunc'ed before the test

Related to coverit CID 10255.

Return value of memcmp was being converted to TSS_BOOL type before
being tested, thus possibly missing information (since it can return
an integer value != of zero, depending on the differences found).

Signed-off-by: Richard Maciel <rmaciel@linux.vnet.ibm.com>
Inserted missing va_end

Related to coverit CIDs 10332 and 10333.

Signed-off-by: Richard Maciel <rmaciel@linux.vnet.ibm.com>
Fixed modules where unitialized pointers could be freed

Related to coverit CIDs 10326 and 10323

In both cases proper pointer initialization was not
made, so, in some cases, the code could free the value of a
unitialized pointer.

Signed-off-by: Richard Maciel <rmaciel@linux.vnet.ibm.com>
Fixed code reading data from freed pointer.

Related to coverit CID 10331.

free call being executed over pointer, before the
LogError which used it.

Signed-off-by: Richard Maciel <rmaciel@linux.vnet.ibm.com>
Added check to prevent buffer overflow in name buffer.

Since the size of the name could be read from a file, but the buffer
to contain it was fixed size, a check was needed to ensure that
the fread doesn't overrun the buffer.

Signed-off-by: Richard Maciel <rmaciel@linux.vnet.ibm.com>
Fixed memory leak in ima_get_entry and fixed memset boundaries

Related to coverity CID 10311.

In some error cases the memory allocated wasn't being properly released,
so I grouped all the release in the end of the function and make error
cases point to the label there.

Also fixed a memset call which used a size 1-byte less than the
correct amount.

Signed-off-by: Richard Maciel <rmaciel@linux.vnet.ibm.com>
Fixed memory leak in tcs_wrap_KeyControlOwner

Related to coverity CID 10310.

rgbPublicKey member wasn't being released after the return of the
function (success or failure paths).

Signed-off-by: Richard Maciel <rmaciel@linux.vnet.ibm.com>
Removed dangled global var sd and fixed test that wrongfully used it

Related to coverity CID 10302

A global variable sd (which shouldn't exist, thus was removed) was
used as a consequence of a programming typo. The right variable to
be used is sd6.

Signed-off-by: Richard Maciel <rmaciel@linux.vnet.ibm.com>
Removing possibility of NULL-dereferencing pointer

Related to coverity CID 10304.

There was a possible code execution path, in function context_destroy
that have toKill pointer var with the NULL value.

Signed-off-by: Richard Maciel <rmaciel@linux.vnet.ibm.com>
Release delfamily_list lock in the case the object found is the tpm one.

Related to coverity CID 10298.

If function obj_delfamily_find_by_familyid code execution path is
the one where an object found is of the TPM type, then the
delfamily_list lock is never released.

Signed-off-by: Richard Maciel <rmaciel@linux.vnet.ibm.com>
Fixed memory leak in function Transport_TerminateHandle

Related to coverity CID 10307.

Pointer handles got memory allocated for it, but that memory is never
freed at the end of the function.
Note that since obj_context_transport_execute can also allocate memory
(through the same parameter handles), it's necessary to keep track of
both the address which goes in and the address which cames out.

Signed-off-by: Richard Maciel <rmaciel@linux.vnet.ibm.com>
Prevents dereference of null when calling TCTP_SetCapability_Internal

Related to Coverity CID 10291

The aforementioned function dereferenced the auth parameter without
checking for NULL first.

Signed-off-by: Richard Maciel <rmaciel@linux.vnet.ibm.com>
Prevents dereference of null when call TCSP_NV_WriteValueAuth_Internal

Related to coverity CID: 10290

pAuth variable could set to NULL in some cases, which, when passed
to the aforementioned function would result in a dereference of NULL.

Signed-off-by: Richard Maciel <rmaciel@linux.vnet.ibm.com>
Prevents dereference of null when call TCSP_NV_ReadValueAuth_Internal

Related coverity CID 10289

tcs_wrap_NV_ReadValueAuth can call TCSP_NV_ReadValueAuth_Internal
with a null auth. However, the latter was dereferencing the pointer
var containing the auth data without checking it, which possibly could
cause a dereference null error.

Signed-off-by: Richard Maciel <rmaciel@linux.vnet.ibm.com>
Removed dead code from tpm_rsp_parse function

Related to coverity CID 10288.

switch case TPM_ORD_ActivateIdentity included an if structure to check
for auth1 and auth2 values. However, auth2 was checked in a previous
if. That made the if (auth2) check the default case in the structure
and the else would never be reached.

Signed-off-by: Richard Maciel <rmaciel@linux.vnet.ibm.com>
Added simple code to close server socket(s)

Server sockets are now properly closed before the daemon stops
executing.

Signed-off-by: Richard Maciel <rmaciel@linux.vnet.ibm.com>
Bumped version to 0.3.13