From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 8EE872469F for ; Thu, 18 Jul 2019 07:32:41 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DF6OPedZdtqH for ; Thu, 18 Jul 2019 07:32:41 -0400 (EDT) Received: from smtp40.i.mail.ru (smtp40.i.mail.ru [94.100.177.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 4D7AE20EDB for ; Thu, 18 Jul 2019 07:32:41 -0400 (EDT) Date: Thu, 18 Jul 2019 14:32:38 +0300 From: Konstantin Osipov Subject: [tarantool-patches] Re: [PATCH] log: fix segfault on _say without filename Message-ID: <20190718113238.GA14210@atlas> References: <1563383901-12794-1-git-send-email-mons@cpan.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1563383901-12794-1-git-send-email-mons@cpan.org> Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org Cc: Mons Anderson * Mons Anderson [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