Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] [PATCH] cppcheck: box/alter.cc null pointer dereference
@ 2020-09-20 17:59 Sergey Kaplun
  2020-09-21 20:15 ` Vladislav Shpilevoy
  2020-09-28  6:59 ` Kirill Yukhin
  0 siblings, 2 replies; 5+ messages in thread
From: Sergey Kaplun @ 2020-09-20 17:59 UTC (permalink / raw)
  To: Vladislav Shpilevoy, Mergen Imeev; +Cc: tarantool-patches

Found and fixed Null pointer dereference with cppcheck:

[src/box/alter.cc:395]: (error) Null pointer dereference
---

cppcheck can be run from root project directory as follows:
```
$ cppcheck --force --enable=warning,performance,portability,information --error-exitcode=1 --verbose .
```

branch: https://github.com/tarantool/tarantool/tree/skaplun/cppcheck-alter-null-ptr-dereference

 src/box/alter.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/box/alter.cc b/src/box/alter.cc
index ba96d9c62..d106b7e0b 100644
--- a/src/box/alter.cc
+++ b/src/box/alter.cc
@@ -391,9 +391,9 @@ space_opts_decode(struct space_opts *opts, const char *map,
 	if (opts->sql != NULL) {
 		char *sql = strdup(opts->sql);
 		if (sql == NULL) {
+			size_t optlen = strlen(opts->sql) + 1;
 			opts->sql = NULL;
-			diag_set(OutOfMemory, strlen(opts->sql) + 1, "strdup",
-				 "sql");
+			diag_set(OutOfMemory, optlen, "strdup", "sql");
 			return -1;
 		}
 		opts->sql = sql;
-- 
2.28.0

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

* Re: [Tarantool-patches] [PATCH] cppcheck: box/alter.cc null pointer dereference
  2020-09-20 17:59 [Tarantool-patches] [PATCH] cppcheck: box/alter.cc null pointer dereference Sergey Kaplun
@ 2020-09-21 20:15 ` Vladislav Shpilevoy
  2020-09-21 20:37   ` Sergey Kaplun
  2020-09-28  6:59 ` Kirill Yukhin
  1 sibling, 1 reply; 5+ messages in thread
From: Vladislav Shpilevoy @ 2020-09-21 20:15 UTC (permalink / raw)
  To: Sergey Kaplun, Mergen Imeev; +Cc: tarantool-patches

Hi! Thanks for the patch!

Commit title should be a subsystem name + description. Since we
don't have 'cppcheck' subsystem, I propose to use 'alter'.

LGTM except the commit title.

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

* Re: [Tarantool-patches] [PATCH] cppcheck: box/alter.cc null pointer dereference
  2020-09-21 20:15 ` Vladislav Shpilevoy
@ 2020-09-21 20:37   ` Sergey Kaplun
  2020-09-21 21:39     ` Vladislav Shpilevoy
  0 siblings, 1 reply; 5+ messages in thread
From: Sergey Kaplun @ 2020-09-21 20:37 UTC (permalink / raw)
  To: Vladislav Shpilevoy; +Cc: tarantool-patches

Hi! Thanks for the review!

On 21.09.20, Vladislav Shpilevoy wrote:
> Hi! Thanks for the patch!
> 
> Commit title should be a subsystem name + description. Since we
> don't have 'cppcheck' subsystem, I propose to use 'alter'.
> 
> LGTM except the commit title.

I've updated commit message to:

```
alter: box/alter.cc null pointer dereference

Found and fixed Null pointer dereference with cppcheck:

[src/box/alter.cc:395]: (error) Null pointer dereference
```
and pushed it to the branch.

-- 
Best regards,
Sergey Kaplun

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

* Re: [Tarantool-patches] [PATCH] cppcheck: box/alter.cc null pointer dereference
  2020-09-21 20:37   ` Sergey Kaplun
@ 2020-09-21 21:39     ` Vladislav Shpilevoy
  0 siblings, 0 replies; 5+ messages in thread
From: Vladislav Shpilevoy @ 2020-09-21 21:39 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches

LGTM.

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

* Re: [Tarantool-patches] [PATCH] cppcheck: box/alter.cc null pointer dereference
  2020-09-20 17:59 [Tarantool-patches] [PATCH] cppcheck: box/alter.cc null pointer dereference Sergey Kaplun
  2020-09-21 20:15 ` Vladislav Shpilevoy
@ 2020-09-28  6:59 ` Kirill Yukhin
  1 sibling, 0 replies; 5+ messages in thread
From: Kirill Yukhin @ 2020-09-28  6:59 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: tarantool-patches, Vladislav Shpilevoy

Hello,

On 20 сен 20:59, Sergey Kaplun wrote:
> Found and fixed Null pointer dereference with cppcheck:
> 
> [src/box/alter.cc:395]: (error) Null pointer dereference
> ---
> 
> cppcheck can be run from root project directory as follows:
> ```
> $ cppcheck --force --enable=warning,performance,portability,information --error-exitcode=1 --verbose .
> ```

I've checked your patch into 2.4, 2.5 and master.

--
Regards, Kirill Yukhin

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

end of thread, other threads:[~2020-09-28  6:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-20 17:59 [Tarantool-patches] [PATCH] cppcheck: box/alter.cc null pointer dereference Sergey Kaplun
2020-09-21 20:15 ` Vladislav Shpilevoy
2020-09-21 20:37   ` Sergey Kaplun
2020-09-21 21:39     ` Vladislav Shpilevoy
2020-09-28  6:59 ` Kirill Yukhin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox