Discussion:
[Libstoragemgmt-devel] Memory leaks to fix in lsm_rest.c
Tony Asleson
2014-10-28 18:09:00 UTC
Permalink
If anyone feels so inclined the following memory leaks have been
identified by coverity scan.

We need a REST unit test case too.

Thanks,
Tony


Error: CPPCHECK_WARNING: [#def2]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:60: error[memleak]: Memory leak:
new_para_node

Error: RESOURCE_LEAK (CWE-772): [#def3]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:53: alloc_fn: Storage is returned
from allocation function "malloc".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:53: var_assign: Assigning:
"new_para_node" = storage returned from "malloc(40UL)".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:60: leaked_storage: Variable
"new_para_node" going out of scope leaks the storage it points to.

Error: RESOURCE_LEAK (CWE-772): [#def4]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:142: alloc_fn: Storage is
returned from allocation function "malloc".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:142: var_assign: Assigning:
"uri_scheme" = storage returned from "malloc(uri_scheme_len + 1L)".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:143: noescape: Resource
"uri_scheme" is not freed or pointed-to in "memset". [Note: The source
code implementation of the function has been overridden by a builtin model.]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:144: noescape: Resource
"uri_scheme" is not freed or pointed-to in "memcpy". [Note: The source
code implementation of the function has been overridden by a builtin model.]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:152: noescape: Resource
"uri_scheme" is not freed or pointed-to in "asprintf".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:154: leaked_storage: Variable
"uri_scheme" going out of scope leaks the storage it points to.

Error: CLANG_WARNING: [#def5]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:157:14: warning: Potential leak
of memory pointed to by 'uri_scheme'
# socket_fd = socket(AF_UNIX, SOCK_STREAM, 0);
# ^~~~~~

Error: RESOURCE_LEAK (CWE-772): [#def6]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:157: open_fn: Returning handle
opened by "socket".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:157: var_assign: Assigning:
"socket_fd" = handle returned from "socket(1, SOCK_STREAM, 0)".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:163: overwrite_var: Overwriting
handle "socket_fd" in "socket_fd = -1" leaks the handle.

Error: NEGATIVE_RETURNS (CWE-394): [#def7]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:163: var_tested_neg: Assigning:
"socket_fd" = a negative value.
libstoragemgmt-1.0.0/daemon/lsm_rest.c:169: negative_returns:
"socket_fd" is passed to a parameter that cannot be negative.

Error: RESOURCE_LEAK (CWE-772): [#def8]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:142: alloc_fn: Storage is
returned from allocation function "malloc".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:142: var_assign: Assigning:
"uri_scheme" = storage returned from "malloc(uri_scheme_len + 1L)".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:143: noescape: Resource
"uri_scheme" is not freed or pointed-to in "memset". [Note: The source
code implementation of the function has been overridden by a builtin model.]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:144: noescape: Resource
"uri_scheme" is not freed or pointed-to in "memcpy". [Note: The source
code implementation of the function has been overridden by a builtin model.]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:152: noescape: Resource
"uri_scheme" is not freed or pointed-to in "asprintf".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:177: leaked_storage: Variable
"uri_scheme" going out of scope leaks the storage it points to.

Error: CPPCHECK_WARNING: [#def9]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:178: error[memleak]: Memory leak:
uri_scheme

Error: CLANG_WARNING: [#def10]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:201:35: warning: Potential leak
of memory pointed to by 'msg'
# if ((written == strlen(msg)) && *error_no == 0){
# ^~~~~~~~

Error: RESOURCE_LEAK (CWE-772): [#def11]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:185: alloc_fn: Storage is
returned from allocation function "malloc".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:185: var_assign: Assigning:
"msg_with_header" = storage returned from "malloc(strlen(msg) + 10UL +
1UL)".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:186: noescape: Resource
"msg_with_header" is not freed or pointed-to in "sprintf". [Note: The
source code implementation of the function has been overridden by a
builtin model.]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:188: var_assign: Assigning: "msg"
= "msg_with_header".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:189: noescape: Resource
"msg_with_header" is not freed or pointed-to in "strlen".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:201: noescape: Resource "msg" is
not freed or pointed-to in "strlen".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:204: leaked_storage: Variable
"msg_with_header" going out of scope leaks the storage it points to.
libstoragemgmt-1.0.0/daemon/lsm_rest.c:204: leaked_storage: Returning
without freeing "msg" leaks the storage that it points to.

Error: RESOURCE_LEAK (CWE-772): [#def12]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:185: alloc_fn: Storage is
returned from allocation function "malloc".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:185: var_assign: Assigning:
"msg_with_header" = storage returned from "malloc(strlen(msg) + 10UL +
1UL)".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:186: noescape: Resource
"msg_with_header" is not freed or pointed-to in "sprintf". [Note: The
source code implementation of the function has been overridden by a
builtin model.]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:188: var_assign: Assigning: "msg"
= "msg_with_header".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:189: noescape: Resource
"msg_with_header" is not freed or pointed-to in "strlen".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:191: noescape: Resource "msg" is
not freed or pointed-to in "strlen".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:191: noescape: Resource "msg +
written" is not freed or pointed-to in "send".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:201: noescape: Resource "msg" is
not freed or pointed-to in "strlen".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:204: leaked_storage: Variable
"msg_with_header" going out of scope leaks the storage it points to.
libstoragemgmt-1.0.0/daemon/lsm_rest.c:204: leaked_storage: Returning
without freeing "msg" leaks the storage that it points to.

Error: RESOURCE_LEAK (CWE-772): [#def13]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:185: alloc_fn: Storage is
returned from allocation function "malloc".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:185: var_assign: Assigning:
"msg_with_header" = storage returned from "malloc(strlen(msg) + 10UL +
1UL)".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:186: noescape: Resource
"msg_with_header" is not freed or pointed-to in "sprintf". [Note: The
source code implementation of the function has been overridden by a
builtin model.]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:188: var_assign: Assigning: "msg"
= "msg_with_header".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:189: noescape: Resource
"msg_with_header" is not freed or pointed-to in "strlen".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:191: noescape: Resource "msg" is
not freed or pointed-to in "strlen".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:191: noescape: Resource "msg +
written" is not freed or pointed-to in "send".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:191: noescape: Resource "msg" is
not freed or pointed-to in "strlen".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:191: noescape: Resource "msg +
written" is not freed or pointed-to in "send".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:201: noescape: Resource "msg" is
not freed or pointed-to in "strlen".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:204: leaked_storage: Variable
"msg_with_header" going out of scope leaks the storage it points to.
libstoragemgmt-1.0.0/daemon/lsm_rest.c:204: leaked_storage: Returning
without freeing "msg" leaks the storage that it points to.

Error: TAINTED_SCALAR (CWE-20): [#def14]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:244: tainted_data_return:
Function "_recv_msg" returns tainted data.
libstoragemgmt-1.0.0/daemon/lsm_rest.c:215:14: tainted_data_argument:
Function "recv" taints argument "buff". [Note: The source code
implementation of the function has been overridden by a builtin model.]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:218:4: tainted_data_transitive:
Call to function "memcpy" with tainted argument "buff" transitively
taints "msg". [Note: The source code implementation of the function has
been overridden by a builtin model.]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:233:3: return_tainted_data:
Returning tainted variable "msg".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:244: var_assign: Assigning:
"msg_len_str" = "_recv_msg", which taints "msg_len_str".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:252: tainted_data_transitive:
Call to function "strtoul" with tainted argument "msg_len_str" returns
tainted data.
libstoragemgmt-1.0.0/daemon/lsm_rest.c:252: var_assign: Assigning:
"msg_len" = "strtoul", which taints "msg_len".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:263: tainted_data: Passing
tainted variable "msg_len" to a tainted sink.
libstoragemgmt-1.0.0/daemon/lsm_rest.c:212:12:
tainted_data_sink_lv_call: Passing tainted variable "count + 1UL" to
tainted data sink "malloc".

Error: CLANG_WARNING: [#def15]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:236:3: warning: Potential leak of
memory pointed to by 'msg'
# fprintf(stderr, "recv() got error_no, : %d\n", *error_no);
# ^~~~~~~

Error: RESOURCE_LEAK (CWE-772): [#def16]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:212: alloc_fn: Storage is
returned from allocation function "malloc".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:212: var_assign: Assigning: "msg"
= storage returned from "malloc(count + 1UL)".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:213: noescape: Resource "msg" is
not freed or pointed-to in "memset". [Note: The source code
implementation of the function has been overridden by a builtin model.]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:237: leaked_storage: Variable
"msg" going out of scope leaks the storage it points to.

Error: CLANG_WARNING: [#def17]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:252:2: warning: Potential leak of
memory pointed to by 'msg_len_str'
# size_t msg_len = (size_t)strtoul(msg_len_str, NULL, 10);
# ^~~~~~~~~~~~~~

Error: CLANG_WARNING: [#def18]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:304:2: warning: Potential leak of
memory pointed to by 'recv_json_string'
# json_object *recv_json = json_tokener_parse(recv_json_string);
# ^~~~~~~~~~~~~~~~~~~~~~

Error: CPPCHECK_WARNING: [#def19]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:330: error[memleak]: Memory leak:
para_list

Error: RESOURCE_LEAK (CWE-772): [#def20]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:324: alloc_fn: Storage is
returned from allocation function "malloc".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:324: var_assign: Assigning:
"para_list" = storage returned from "malloc(8UL)".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:325: noescape: Resource
"para_list" is not freed or pointed-to in "para_list_init".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:44:33: noescape:
"para_list_init(ParaList_t *)" does not free or save its pointer
parameter "para_list".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:326: noescape: Resource
"para_list" is not freed or pointed-to in "para_list_add".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:49:31: noescape:
"para_list_add(ParaList_t *, char const *, void const *, enum
lsm_json_type const, ssize_t const)" does not free or save its pointer
parameter "para_list".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:327: noescape: Resource
"para_list" is not freed or pointed-to in "para_list_add".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:49:31: noescape:
"para_list_add(ParaList_t *, char const *, void const *, enum
lsm_json_type const, ssize_t const)" does not free or save its pointer
parameter "para_list".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:328: noescape: Resource
"para_list" is not freed or pointed-to in "para_list_add".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:49:31: noescape:
"para_list_add(ParaList_t *, char const *, void const *, enum
lsm_json_type const, ssize_t const)" does not free or save its pointer
parameter "para_list".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:329: noescape: Resource
"para_list" is not freed or pointed-to in "rpc".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:272:71: noescape: "rpc(int, char
const *, ParaList_t *, int *)" does not free or save its pointer
parameter "para_list".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:330: leaked_storage: Variable
"para_list" going out of scope leaks the storage it points to.

Error: CLANG_WARNING: [#def21]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:330:2: warning: Potential leak of
memory pointed to by 'para_list'
# return error_no;
# ^~~~~~~~~~~~~~~

Error: CPPCHECK_WARNING: [#def22]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:342: error[memleak]: Memory leak:
para_list

Error: RESOURCE_LEAK (CWE-772): [#def23]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:337: alloc_fn: Storage is
returned from allocation function "malloc".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:337: var_assign: Assigning:
"para_list" = storage returned from "malloc(8UL)".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:338: noescape: Resource
"para_list" is not freed or pointed-to in "para_list_init".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:44:33: noescape:
"para_list_init(ParaList_t *)" does not free or save its pointer
parameter "para_list".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:340: noescape: Resource
"para_list" is not freed or pointed-to in "para_list_add".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:49:31: noescape:
"para_list_add(ParaList_t *, char const *, void const *, enum
lsm_json_type const, ssize_t const)" does not free or save its pointer
parameter "para_list".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:341: noescape: Resource
"para_list" is not freed or pointed-to in "rpc".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:272:71: noescape: "rpc(int, char
const *, ParaList_t *, int *)" does not free or save its pointer
parameter "para_list".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:342: leaked_storage: Variable
"para_list" going out of scope leaks the storage it points to.

Error: CLANG_WARNING: [#def24]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:342:2: warning: Potential leak of
memory pointed to by 'para_list'
# return error_no;
# ^~~~~~~~~~~~~~~

Error: RESOURCE_LEAK (CWE-772): [#def25]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:350: alloc_fn: Storage is
returned from allocation function "malloc".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:350: var_assign: Assigning:
"para_list" = storage returned from "malloc(8UL)".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:351: noescape: Resource
"para_list" is not freed or pointed-to in "para_list_init".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:44:33: noescape:
"para_list_init(ParaList_t *)" does not free or save its pointer
parameter "para_list".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:354: noescape: Resource
"para_list" is not freed or pointed-to in "para_list_add".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:49:31: noescape:
"para_list_add(ParaList_t *, char const *, void const *, enum
lsm_json_type const, ssize_t const)" does not free or save its pointer
parameter "para_list".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:355: noescape: Resource
"para_list" is not freed or pointed-to in "rpc".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:272:71: noescape: "rpc(int, char
const *, ParaList_t *, int *)" does not free or save its pointer
parameter "para_list".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:355: leaked_storage: Returning
without freeing "para_list" leaks the storage that it points to.

Error: CLANG_WARNING: [#def26]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:355:2: warning: Potential leak of
memory pointed to by 'para_list'
# return rpc(socket_fd, method, para_list, error_no);
# ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Error: RESOURCE_LEAK (CWE-772): [#def27]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:370: open_fn: Returning handle
opened by "connect_socket".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:157:2: open_fn: Returning handle
opened by "socket".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:157:2: var_assign: Assigning:
"socket_fd" = "socket(1, SOCK_STREAM, 0)".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:169:3: noescape: Resource
"socket_fd" is not freed or pointed-to in function "connect".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:177:2: return_handle: Returning
opened handle "socket_fd".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:370: var_assign: Assigning:
"socket_fd" = handle returned from "connect_socket(uri, plugin_dir,
&error_no)".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:376: noescape: Resource
"socket_fd" is not freed or pointed-to in "plugin_startup".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:316:31: noescape:
"plugin_startup(int, char const *, char const *, int)" does not free or
save its handle parameter "socket_fd".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:380: noescape: Resource
"socket_fd" is not freed or pointed-to in "plugin_shutdown".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:333:32: noescape:
"plugin_shutdown(int)" does not free or save its handle parameter
"socket_fd".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:381: noescape: Resource
"socket_fd" is not freed or pointed-to in "shutdown".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:382: leaked_handle: Handle
variable "socket_fd" going out of scope leaks the handle.

Error: RESOURCE_LEAK (CWE-772): [#def28]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:370: open_fn: Returning handle
opened by "connect_socket".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:157:2: open_fn: Returning handle
opened by "socket".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:157:2: var_assign: Assigning:
"socket_fd" = "socket(1, SOCK_STREAM, 0)".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:169:3: noescape: Resource
"socket_fd" is not freed or pointed-to in function "connect".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:177:2: return_handle: Returning
opened handle "socket_fd".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:370: var_assign: Assigning:
"socket_fd" = handle returned from "connect_socket(uri, plugin_dir,
&error_no)".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:376: noescape: Resource
"socket_fd" is not freed or pointed-to in "plugin_startup".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:316:31: noescape:
"plugin_startup(int, char const *, char const *, int)" does not free or
save its handle parameter "socket_fd".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:391: noescape: Resource
"socket_fd" is not freed or pointed-to in "v01_query".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:345:34: noescape: "v01_query(int,
char const *, ParaList_t *, int *)" does not free or save its handle
parameter "socket_fd".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:404: noescape: Resource
"socket_fd" is not freed or pointed-to in "plugin_shutdown".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:333:32: noescape:
"plugin_shutdown(int)" does not free or save its handle parameter
"socket_fd".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:409: noescape: Resource
"socket_fd" is not freed or pointed-to in "shutdown".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:410: leaked_handle: Handle
variable "socket_fd" going out of scope leaks the handle.

Error: RESOURCE_LEAK (CWE-772): [#def29]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:445: alloc_fn: Storage is
returned from allocation function "malloc".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:445: var_assign: Assigning:
"url_no_api_ver" = storage returned from "malloc(url_no_api_ver_len + 1UL)".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:446: noescape: Resource
"url_no_api_ver" is not freed or pointed-to in "memset". [Note: The
source code implementation of the function has been overridden by a
builtin model.]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:447: noescape: Resource
"url_no_api_ver" is not freed or pointed-to in "memcpy". [Note: The
source code implementation of the function has been overridden by a
builtin model.]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:451: noescape: Resource
"url_no_api_ver" is not freed or pointed-to in "lsm_api_0_1".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:360:14: noescape:
"lsm_api_0_1(struct MHD_Connection *, char const *, char const *, char
const *, char const *, char const *)" does not free or save its pointer
parameter "url".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:454: leaked_storage: Variable
"url_no_api_ver" going out of scope leaks the storage it points to.

Error: CPPCHECK_WARNING: [#def30]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:457: error[memleak]: Memory leak:
url_no_api_ver

Error: RESOURCE_LEAK (CWE-772): [#def31]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:445: alloc_fn: Storage is
returned from allocation function "malloc".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:445: var_assign: Assigning:
"url_no_api_ver" = storage returned from "malloc(url_no_api_ver_len + 1UL)".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:446: noescape: Resource
"url_no_api_ver" is not freed or pointed-to in "memset". [Note: The
source code implementation of the function has been overridden by a
builtin model.]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:447: noescape: Resource
"url_no_api_ver" is not freed or pointed-to in "memcpy". [Note: The
source code implementation of the function has been overridden by a
builtin model.]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:457: leaked_storage: Variable
"url_no_api_ver" going out of scope leaks the storage it points to.

Error: CLANG_WARNING: [#def32]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:457:10: warning: Potential leak
of memory pointed to by 'url_no_api_ver'
# return MHD_NO;
# ^~~~~~
/usr/include/microhttpd.h:134:16: note: expanded from macro 'MHD_NO'
##define MHD_NO 0
# ^

Error: RESOURCE_LEAK (CWE-772): [#def33]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:445: alloc_fn: Storage is
returned from allocation function "malloc".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:445: var_assign: Assigning:
"url_no_api_ver" = storage returned from "malloc(url_no_api_ver_len + 1UL)".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:446: noescape: Resource
"url_no_api_ver" is not freed or pointed-to in "memset". [Note: The
source code implementation of the function has been overridden by a
builtin model.]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:447: noescape: Resource
"url_no_api_ver" is not freed or pointed-to in "memcpy". [Note: The
source code implementation of the function has been overridden by a
builtin model.]
libstoragemgmt-1.0.0/daemon/lsm_rest.c:451: noescape: Resource
"url_no_api_ver" is not freed or pointed-to in "lsm_api_0_1".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:360:14: noescape:
"lsm_api_0_1(struct MHD_Connection *, char const *, char const *, char
const *, char const *, char const *)" does not free or save its pointer
parameter "url".
libstoragemgmt-1.0.0/daemon/lsm_rest.c:467: leaked_storage: Variable
"url_no_api_ver" going out of scope leaks the storage it points to.

------------------------------------------------------------------------------
Gris Ge
2014-10-29 12:33:41 UTC
Permalink
Post by Tony Asleson
If anyone feels so inclined the following memory leaks have been
identified by coverity scan.
We need a REST unit test case too.
Thanks,
Tony
Hi Tony,

Thanks. I will look into it.
Best regards.
--
Gris Ge
Loading...