[tarantool-patches] Re: [PATCH] log: fix segfault on _say without filename

Konstantin Osipov kostja at tarantool.org
Thu Jul 18 14:32:38 MSK 2019


* Mons Anderson <mons at 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




More information about the Tarantool-patches mailing list