nuttx-apps/fsutils
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
..
flash_eraseall Make.defs: Change "ifeq ($(XXX),y)" to "ifneq ($(XXX),) 2022-10-16 14:59:08 +02:00
inifile Remove the unnecessary cast for main_t, NULL and argv 2022-10-18 18:40:23 +02:00
inih Make.defs: Change "ifeq ($(XXX),y)" to "ifneq ($(XXX),) 2022-10-16 14:59:08 +02:00
ipcfg Make.defs: Change "ifeq ($(XXX),y)" to "ifneq ($(XXX),) 2022-10-16 14:59:08 +02:00
mkfatfs fsutils/examples: Include unistd.h explicitly 2023-02-05 08:46:59 +02:00
mkgpt apps: Fix bug by calling getrandom 2022-08-18 18:02:01 +08:00
mkmbr fsutils/mkmbr: support mbr partition format 2021-10-28 08:54:30 +02:00
mksmartfs Make.defs: Change "ifeq ($(XXX),y)" to "ifneq ($(XXX),) 2022-10-16 14:59:08 +02:00
passwd fsutils/passwd: fix warning: leak of ‘iobuffer’ [CWE-401] [-Wanalyzer-malloc-leak] 2023-02-18 17:24:54 +08:00
.gitignore Remove extra whitespace from files (#43) 2020-01-31 08:29:24 -06:00
Make.defs Makefile: Ken Pettit: update licenses to Apache 2021-06-07 21:35:33 -05:00
Makefile Makefiles: Gregory Nutt: update licenses to Apache 2021-06-07 21:35:33 -05:00