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 Remove support for CONFIG_FS_WRITABLE and CONFIG_FS_READABLE 2020-03-22 08:23:28 -05:00
Make.defs Make.defs: Change "ifeq ($(XXX),y)" to "ifneq ($(XXX),) 2022-10-16 14:59:08 +02:00
Makefile build: Replace $(TOPDIR)/Make.defs with $(APPDIR)/Make.defs 2020-07-09 15:17:37 -03:00
passwd_adduser.c fsutils: update licenses to Apache 2021-06-08 08:43:15 -05:00
passwd_append.c fsutils: update licenses to Apache 2021-06-08 08:43:15 -05:00
passwd_delete.c fsutils: update licenses to Apache 2021-06-08 08:43:15 -05:00
passwd_deluser.c fsutils/passwd: fix compilation 2022-03-25 11:07:10 +02:00
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 fsutils: update licenses to Apache 2021-06-08 08:43:15 -05:00
passwd_update.c fsutils/passwd: fix compilation 2022-03-25 11:07:10 +02:00
passwd_verify.c fsutils: update licenses to Apache 2021-06-08 08:43:15 -05:00
passwd.h Run nxstyle against all modified .c and .h files 2020-03-22 08:23:28 -05:00