nuttx-apps/fsutils/passwd
Junbo Zheng 78b7318a04 fsutils/passwd: fix warning: leak of ‘iobuffer’ [CWE-401] [-Wanalyzer-malloc-leak]
In function ‘passwd_find’:
passwd_find.c:82:14: warning: leak of ‘iobuffer’ [CWE-401] [-Wanalyzer-malloc-leak]
   82 |       return -errcode;
      |              ^~~~~~~~
  ‘passwd_find’: events 1-5
    |
    |   65 |   iobuffer = (FAR char *)malloc(CONFIG_FSUTILS_PASSWD_IOBUFFER_SIZE);
    |      |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    |      |                          |
    |      |                          (1) allocated here
    |   66 |   if (iobuffer == NULL)
    |      |      ~
    |      |      |
    |      |      (2) assuming ‘iobuffer’ is non-NULL
    |      |      (3) following ‘false’ branch (when ‘iobuffer’ is non-NULL)...
    |......
    |   73 |   stream = fopen(CONFIG_FSUTILS_PASSWD_PATH, "r");
    |      |            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    |      |            |
    |      |            (4) ...to here
    |   74 |   if (stream == NULL)
    |      |      ~
    |      |      |
    |      |      (5) following ‘true’ branch (when ‘stream’ is NULL)...
    |
  ‘passwd_find’: event 6
    |
    |   80 |       int errcode = errno;
    |      |                     ^~~~~
    |      |                     |
    |      |                     (6) ...to here
    |
  ‘passwd_find’: event 7
    |
    |   82 |       return -errcode;
    |      |              ^~~~~~~~
    |      |              |
    |      |              (7) ‘iobuffer’ leaks here; was allocated at (1)
    |

Signed-off-by: Junbo Zheng <zhengjunbo1@xiaomi.com>
2023-02-18 17:24:54 +08:00
..
Kconfig
Make.defs Make.defs: Change "ifeq ($(XXX),y)" to "ifneq ($(XXX),) 2022-10-16 14:59:08 +02:00
Makefile
passwd_adduser.c
passwd_append.c
passwd_delete.c
passwd_deluser.c
passwd_encrypt.c fsutils/passwd: fix out of bounds array access during password encryption 2022-03-28 22:11:01 +08:00
passwd_find.c fsutils/passwd: fix warning: leak of ‘iobuffer’ [CWE-401] [-Wanalyzer-malloc-leak] 2023-02-18 17:24:54 +08:00
passwd_lock.c
passwd_update.c
passwd_verify.c
passwd.h