]> git.ipfire.org Git - thirdparty/shadow.git/commit
useradd.c: fix covscan RESOURCE_LEAK 354/head
authorIker Pedrosa <ipedrosa@redhat.com>
Thu, 10 Jun 2021 11:05:03 +0000 (13:05 +0200)
committerIker Pedrosa <ipedrosa@redhat.com>
Tue, 15 Jun 2021 07:40:40 +0000 (09:40 +0200)
commit1aed7ae945aafaeb253fc89a7ecedeaedf72654e
tree1fb2f1920b3873ca699e458b12105b39c2d31091
parenta6154b8572ef163ccc743d444a9317d6181ab4ec
useradd.c: fix covscan RESOURCE_LEAK

Error: RESOURCE_LEAK (CWE-772): [#def28]
shadow-4.8.1/src/useradd.c:1905: open_fn: Returning handle opened by "open". [Note: The source code implementation of the function has been overridden by a user model.]
shadow-4.8.1/src/useradd.c:1905: var_assign: Assigning: "fd" = handle returned from "open("/var/log/faillog", 2)".
shadow-4.8.1/src/useradd.c:1906: noescape: Resource "fd" is not freed or pointed-to in "lseek".
shadow-4.8.1/src/useradd.c:1917: leaked_handle: Handle variable "fd" going out of scope leaks the handle.
 1915|    /* continue */
 1916|    }
 1917|-> }
 1918|
 1919|   static void lastlog_reset (uid_t uid)

Error: RESOURCE_LEAK (CWE-772): [#def29]
shadow-4.8.1/src/useradd.c:1938: open_fn: Returning handle opened by "open". [Note: The source code implementation of the function has been overridden by a user model.]
shadow-4.8.1/src/useradd.c:1938: var_assign: Assigning: "fd" = handle returned from "open("/var/log/lastlog", 2)".
shadow-4.8.1/src/useradd.c:1939: noescape: Resource "fd" is not freed or pointed-to in "lseek".
shadow-4.8.1/src/useradd.c:1950: leaked_handle: Handle variable "fd" going out of scope leaks the handle.
 1948|    /* continue */
 1949|    }
 1950|-> }
 1951|
 1952|   static void tallylog_reset (const char *user_name)

Error: RESOURCE_LEAK (CWE-772): [#def30]
shadow-4.8.1/src/useradd.c:2109: alloc_fn: Storage is returned from allocation function "strdup".
shadow-4.8.1/src/useradd.c:2109: var_assign: Assigning: "bhome" = storage returned from "strdup(prefix_user_home)".
shadow-4.8.1/src/useradd.c:2131: noescape: Resource "bhome" is not freed or pointed-to in "strtok".
shadow-4.8.1/src/useradd.c:2207: leaked_storage: Variable "bhome" going out of scope leaks the storage it points to.
 2205|    }
 2206|   #endif
 2207|->  }
 2208|   }
 2209|
src/useradd.c