All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ v1] shared/shell: add a check for NULL in bt_shell_init()
@ 2024-07-01 13:44 Roman Smirnov
  2024-07-01 14:20 ` patchwork-bot+bluetooth
  2024-07-01 15:42 ` [BlueZ,v1] " bluez.test.bot
  0 siblings, 2 replies; 3+ messages in thread
From: Roman Smirnov @ 2024-07-01 13:44 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Roman Smirnov

The opt variable is checked for NULL at the beginning of
the function. It is necessary to add a check to prevent null
pointer dereferencing.

Found with the SVACE static analysis tool.
---
 src/shared/shell.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/shared/shell.c b/src/shared/shell.c
index f3f7bab9a..2ecc41bf3 100644
--- a/src/shared/shell.c
+++ b/src/shared/shell.c
@@ -1328,13 +1328,15 @@ void bt_shell_init(int argc, char **argv, const struct bt_shell_opt *opt)
 				}
 			}
 
-			if (c != opt->options[index - offset].val) {
-				usage(argc, argv, opt);
-				exit(EXIT_SUCCESS);
-				return;
-			}
+			if (opt) {
+				if (c != opt->options[index - offset].val) {
+					usage(argc, argv, opt);
+					exit(EXIT_SUCCESS);
+					return;
+				}
 
-			*opt->optarg[index - offset] = optarg ? : "";
+				*opt->optarg[index - offset] = optarg ? : "";
+			}
 		}
 
 		index = -1;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH BlueZ v1] shared/shell: add a check for NULL in bt_shell_init()
  2024-07-01 13:44 [PATCH BlueZ v1] shared/shell: add a check for NULL in bt_shell_init() Roman Smirnov
@ 2024-07-01 14:20 ` patchwork-bot+bluetooth
  2024-07-01 15:42 ` [BlueZ,v1] " bluez.test.bot
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+bluetooth @ 2024-07-01 14:20 UTC (permalink / raw)
  To: Roman Smirnov; +Cc: linux-bluetooth

Hello:

This patch was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Mon, 1 Jul 2024 16:44:01 +0300 you wrote:
> The opt variable is checked for NULL at the beginning of
> the function. It is necessary to add a check to prevent null
> pointer dereferencing.
> 
> Found with the SVACE static analysis tool.
> ---
>  src/shared/shell.c | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)

Here is the summary with links:
  - [BlueZ,v1] shared/shell: add a check for NULL in bt_shell_init()
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=55f561a9cd0b

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [BlueZ,v1] shared/shell: add a check for NULL in bt_shell_init()
  2024-07-01 13:44 [PATCH BlueZ v1] shared/shell: add a check for NULL in bt_shell_init() Roman Smirnov
  2024-07-01 14:20 ` patchwork-bot+bluetooth
@ 2024-07-01 15:42 ` bluez.test.bot
  1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2024-07-01 15:42 UTC (permalink / raw)
  To: linux-bluetooth, r.smirnov

[-- Attachment #1: Type: text/plain, Size: 1316 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=867152

---Test result---

Test Summary:
CheckPatch                    PASS      0.42 seconds
GitLint                       PASS      0.28 seconds
BuildEll                      PASS      25.26 seconds
BluezMake                     PASS      1808.72 seconds
MakeCheck                     PASS      13.37 seconds
MakeDistcheck                 PASS      183.37 seconds
CheckValgrind                 PASS      255.21 seconds
CheckSmatch                   WARNING   359.93 seconds
bluezmakeextell               PASS      121.69 seconds
IncrementalBuild              PASS      1522.89 seconds
ScanBuild                     PASS      997.55 seconds

Details
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:
src/shared/shell.c: note: in included file (through /usr/include/readline/readline.h):src/shared/shell.c: note: in included file (through /usr/include/readline/readline.h):src/shared/shell.c: note: in included file (through /usr/include/readline/readline.h):


---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-07-01 15:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-01 13:44 [PATCH BlueZ v1] shared/shell: add a check for NULL in bt_shell_init() Roman Smirnov
2024-07-01 14:20 ` patchwork-bot+bluetooth
2024-07-01 15:42 ` [BlueZ,v1] " bluez.test.bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.