mariadb/plugin/auth_pam
Hugo Wen 7bdd878ae4 Fix few vulnerabilities found by Cppcheck
While performing SAST scanning using Cppcheck against source code of
commit 81196469, several code vulnerabilities were found.

Fix following issues:

1. Parameters of `snprintf` function are incorrect.

   Cppcheck error:

       client/mysql_plugin.c:1228: error: snprintf format string requires 6 parameters but only 5 are given.

   It is due to commit 630d7229 introduced option `--lc-messages-dir`
   in the bootstrap command. However the parameter was not even given
   in the `snprintf` after changing the format string.

   Fix:
   Restructure the code logic and correct the function parameters for
   `snprintf`.

2. Null pointer is used in a `snprintf` which could cause a crash.

   Cppcheck error:

       extra/mariabackup/xbcloud.cc:2534: error: Null pointer dereference

   The code intended to print the swift_project name, if the
   opt_swift_project_id is NULL but opt_swift_project is not NULL.
   However the parameter of `snprintf` was mistakenly using
   `opt_swift_project_id`.

   Fix:
   Change to use the correct string from `opt_swift_project`.

3. Potential double release of a memory

   Cppcheck error:

       plugin/auth_pam/testing/pam_mariadb_mtr.c:69: error: Memory pointed to by 'resp' is freed twice.

   A pointer `resp` is reused and allocated new memory after it has been
   freed. However, `resp` was not set to NULL after freed.
   Potential double release of the same pointer if the call back
   function doesn't allocate new memory for `resp` pointer.

   Fix:
   Set the `resp` pointer to NULL after the first free() to make sure
   the same address is not freed twice.

All new code of the whole pull request, including one or several files
that are either new files or modified ones, are contributed under the
BSD-new license. I am contributing on behalf of my employer Amazon Web
Services, Inc.
2023-03-02 14:38:24 +11:00
..
mapper MDEV-23926: Fix warnings generated during compilation of plugin/auth_pam/mapper/pam_user_map.c on MacOS 2020-10-23 17:18:39 +07:00
testing Fix few vulnerabilities found by Cppcheck 2023-03-02 14:38:24 +11:00
auth_pam.c MDEV-28431 auth_pam tool left zombie processes. 2022-04-28 15:40:08 +04:00
auth_pam_base.c Merge 10.3 into 10.4 2020-10-29 13:38:38 +02:00
auth_pam_common.c Merge branch '10.3' into 10.4 2019-05-19 20:55:37 +02:00
auth_pam_tool.c Fixed compiler warnings from gcc 7.4.1 2020-01-29 23:23:55 +02:00
auth_pam_tool.h MDEV-15473 Isolate/sandbox PAM modules, so that they can't crash the server. 2018-07-03 15:49:34 +04:00
auth_pam_v1.c MDEV-19880 pam v1: pam password authentication doesn't work at all in MariaDB 10.4 2019-07-02 14:27:31 +02:00
CMakeLists.txt Merge branch '10.3' into 10.4 2022-01-30 09:46:52 +01:00
config.h.cmake MDEV-23926: Follow-up patch to add missed file plugin/auth_pam/config.h.cmake 2020-10-23 18:10:16 +07:00