coverity: ignore tainted access reported in gf_free

Coverity reports tainted pointer access in _gf_free if the pointer passed in
was used by any IO related function by the caller. The taint within gf_free
is a false positive, as the tainted region is from the passed in pointer
till its allocated lenght, and not for contents before the pointer (i.e
the GF_MEM_HEADER_SIZE bytes before the passed in pointer), as that is
exclusively handled by the gf_alloc family of functions.

CID: 1228602, 1292646, 1292647, 1292648, 1292649, 1383192, 1383195, 1389691

Should additionally fix,
CID: 1292650, 1292651, 1357874, 1382373, 1382404, 1382407

Change-Id: I48c5a4028e7b0224c432bbc30f8c29408c2a466b
Updates: bz#789278
Signed-off-by: ShyamsundarR <srangana@redhat.com>
This commit is contained in:
ShyamsundarR 2018-10-15 20:45:18 -04:00 committed by Amar Tumballi
parent f179d09326
commit 39a1db1402

View File

@ -300,6 +300,16 @@ __gf_mem_invalidate(void *ptr)
}
#endif /* DEBUG */
/* Coverity taint NOTE: pointers passed to free, would operate on
pointer-GF_MEM_HEADER_SIZE content and if the pointer was used for any IO
related purpose, the pointer stands tainted, and hence coverity would consider
access to the said region as tainted. The following directive to coverity hence
sanitizes the pointer, thus removing any taint to the same within this function.
If the pointer is accessed outside the scope of this function without any
checks on content read from an IO operation, taints will still be reported, and
needs appropriate addressing. */
/* coverity[ +tainted_string_sanitize_content : arg-0 ] */
void
__gf_free(void *free_ptr)
{