Tarantool development patches archive
 help / color / mirror / Atom feed
* [tarantool-patches] [PATCH] log: fix segfault on _say without filename
@ 2019-07-17 17:18 Mons Anderson
  2019-07-18 11:32 ` [tarantool-patches] " Konstantin Osipov
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Mons Anderson @ 2019-07-17 17:18 UTC (permalink / raw)
  To: tarantool-patches; +Cc: Mons Anderson

---
 src/say.c              |  6 +++---
 test/box/misc.result   | 13 +++++++++++++
 test/box/misc.test.lua |  8 ++++++++
 3 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/src/say.c b/src/say.c
index def948d..6b01bc3 100644
--- a/src/say.c
+++ b/src/say.c
@@ -772,10 +772,10 @@ say_format_plain_tail(char *buf, int len, int level, const char *filename,
 
 	if (level == S_WARN || level == S_ERROR || level == S_SYSERROR) {
 		/* Primitive basename(filename) */
-		for (const char *f = filename; *f; f++)
-			if (*f == '/' && *(f + 1) != '\0')
-				filename = f + 1;
 		if (filename) {
+			for (const char *f = filename; *f; f++)
+				if (*f == '/' && *(f + 1) != '\0')
+					filename = f + 1;
 			SNPRINT(total, snprintf, buf, len, " %s:%i", filename,
 				line);
 		}
diff --git a/test/box/misc.result b/test/box/misc.result
index 699358d..e717493 100644
--- a/test/box/misc.result
+++ b/test/box/misc.result
@@ -1207,3 +1207,16 @@ box.cfg{too_long_threshold = too_long_threshold}
 s:drop()
 ---
 ...
+--
+--
+--
+box.cfg{}
+---
+...
+local ffi = require'ffi' ffi.C._say(ffi.C.S_WARN, nil, 0, nil, "%s", "test log")
+---
+...
+test_run:grep_log('default', 'test log')
+---
+- test log
+...
diff --git a/test/box/misc.test.lua b/test/box/misc.test.lua
index ee81c7b..b7154ff 100644
--- a/test/box/misc.test.lua
+++ b/test/box/misc.test.lua
@@ -342,3 +342,11 @@ rows == expected_rows
 lsn == expected_lsn
 box.cfg{too_long_threshold = too_long_threshold}
 s:drop()
+
+--
+-- Test for segfault
+--
+
+box.cfg{}
+local ffi = require'ffi' ffi.C._say(ffi.C.S_WARN, nil, 0, nil, "%s", "test log")
+test_run:grep_log('default', 'test log')
-- 
1.8.3.1

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

* [tarantool-patches] Re: [PATCH] log: fix segfault on _say without filename
  2019-07-17 17:18 [tarantool-patches] [PATCH] log: fix segfault on _say without filename Mons Anderson
@ 2019-07-18 11:32 ` Konstantin Osipov
  2019-07-25  8:42 ` Konstantin Osipov
  2019-08-28 23:23 ` Kirill Yukhin
  2 siblings, 0 replies; 4+ messages in thread
From: Konstantin Osipov @ 2019-07-18 11:32 UTC (permalink / raw)
  To: tarantool-patches; +Cc: Mons Anderson

* Mons Anderson <mons@cpan.org> [19/07/17 20:21]:

lgtm

> ---
>  src/say.c              |  6 +++---
>  test/box/misc.result   | 13 +++++++++++++
>  test/box/misc.test.lua |  8 ++++++++
>  3 files changed, 24 insertions(+), 3 deletions(-)
> 
> diff --git a/src/say.c b/src/say.c
> index def948d..6b01bc3 100644
> --- a/src/say.c
> +++ b/src/say.c
> @@ -772,10 +772,10 @@ say_format_plain_tail(char *buf, int len, int level, const char *filename,
>  
>  	if (level == S_WARN || level == S_ERROR || level == S_SYSERROR) {
>  		/* Primitive basename(filename) */
> -		for (const char *f = filename; *f; f++)
> -			if (*f == '/' && *(f + 1) != '\0')
> -				filename = f + 1;
>  		if (filename) {
> +			for (const char *f = filename; *f; f++)
> +				if (*f == '/' && *(f + 1) != '\0')
> +					filename = f + 1;
>  			SNPRINT(total, snprintf, buf, len, " %s:%i", filename,
>  				line);
>  		}
> diff --git a/test/box/misc.result b/test/box/misc.result
> index 699358d..e717493 100644
> --- a/test/box/misc.result
> +++ b/test/box/misc.result
> @@ -1207,3 +1207,16 @@ box.cfg{too_long_threshold = too_long_threshold}
>  s:drop()
>  ---
>  ...
> +--
> +--
> +--
> +box.cfg{}
> +---
> +...
> +local ffi = require'ffi' ffi.C._say(ffi.C.S_WARN, nil, 0, nil, "%s", "test log")
> +---
> +...
> +test_run:grep_log('default', 'test log')
> +---
> +- test log
> +...
> diff --git a/test/box/misc.test.lua b/test/box/misc.test.lua
> index ee81c7b..b7154ff 100644
> --- a/test/box/misc.test.lua
> +++ b/test/box/misc.test.lua
> @@ -342,3 +342,11 @@ rows == expected_rows
>  lsn == expected_lsn
>  box.cfg{too_long_threshold = too_long_threshold}
>  s:drop()
> +
> +--
> +-- Test for segfault
> +--
> +
> +box.cfg{}
> +local ffi = require'ffi' ffi.C._say(ffi.C.S_WARN, nil, 0, nil, "%s", "test log")
> +test_run:grep_log('default', 'test log')
> -- 
> 1.8.3.1
> 

-- 
Konstantin Osipov, Moscow, Russia

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

* [tarantool-patches] Re: [PATCH] log: fix segfault on _say without filename
  2019-07-17 17:18 [tarantool-patches] [PATCH] log: fix segfault on _say without filename Mons Anderson
  2019-07-18 11:32 ` [tarantool-patches] " Konstantin Osipov
@ 2019-07-25  8:42 ` Konstantin Osipov
  2019-08-28 23:23 ` Kirill Yukhin
  2 siblings, 0 replies; 4+ messages in thread
From: Konstantin Osipov @ 2019-07-25  8:42 UTC (permalink / raw)
  To: tarantool-patches; +Cc: Mons Anderson

* Mons Anderson <mons@cpan.org> [19/07/17 20:21]:

LGTM.

> ---
>  src/say.c              |  6 +++---
>  test/box/misc.result   | 13 +++++++++++++
>  test/box/misc.test.lua |  8 ++++++++
>  3 files changed, 24 insertions(+), 3 deletions(-)

-- 
Konstantin Osipov, Moscow, Russia

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

* [tarantool-patches] Re: [PATCH] log: fix segfault on _say without filename
  2019-07-17 17:18 [tarantool-patches] [PATCH] log: fix segfault on _say without filename Mons Anderson
  2019-07-18 11:32 ` [tarantool-patches] " Konstantin Osipov
  2019-07-25  8:42 ` Konstantin Osipov
@ 2019-08-28 23:23 ` Kirill Yukhin
  2 siblings, 0 replies; 4+ messages in thread
From: Kirill Yukhin @ 2019-08-28 23:23 UTC (permalink / raw)
  To: tarantool-patches; +Cc: Mons Anderson

Hello,

On 17 июл 17:18, Mons Anderson wrote:
> ---
>  src/say.c              |  6 +++---
>  test/box/misc.result   | 13 +++++++++++++
>  test/box/misc.test.lua |  8 ++++++++
>  3 files changed, 24 insertions(+), 3 deletions(-)

I've checked your patch to missing relase branches.
ALso I've committed missing testcase into all relase branches
and master.

--
Regards, Kirill Yukhin

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

end of thread, other threads:[~2019-08-28 23:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-17 17:18 [tarantool-patches] [PATCH] log: fix segfault on _say without filename Mons Anderson
2019-07-18 11:32 ` [tarantool-patches] " Konstantin Osipov
2019-07-25  8:42 ` Konstantin Osipov
2019-08-28 23:23 ` Kirill Yukhin

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