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 70B4027339 for ; Wed, 18 Jul 2018 07:08:19 -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 ejASxEkrXs7M for ; Wed, 18 Jul 2018 07:08:19 -0400 (EDT) Received: from smtp29.i.mail.ru (smtp29.i.mail.ru [94.100.177.89]) (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 2AC9627329 for ; Wed, 18 Jul 2018 07:08:19 -0400 (EDT) Subject: [tarantool-patches] Re: [PATCH] Fix csv crash with ending space and empty field References: <68bfc349fad91265a56eb1c024a69f2ead030338.1531910937.git.alexander.turenko@tarantool.org> From: Vladislav Shpilevoy Message-ID: <75967f3c-e430-9a48-ca70-6ee3525f9920@tarantool.org> Date: Wed, 18 Jul 2018 14:08:16 +0300 MIME-Version: 1.0 In-Reply-To: <68bfc349fad91265a56eb1c024a69f2ead030338.1531910937.git.alexander.turenko@tarantool.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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: Alexander Turenko Cc: tarantool-patches@freelists.org Hi! Are you sure that I should review it? On 18/07/2018 13:51, Alexander Turenko wrote: > Fixes #3489. > --- > branch: Totktonada/gh-3489-fix-csv-crash > travis-ci: https://travis-ci.org/tarantool/tarantool/builds/405298528 > > src/lib/csv/csv.c | 1 + > test/app-tap/csv.test.lua | 7 ++++++- > 2 files changed, 7 insertions(+), 1 deletion(-) > > diff --git a/src/lib/csv/csv.c b/src/lib/csv/csv.c > index 5f4ff9a9c..0a2f7b4d0 100644 > --- a/src/lib/csv/csv.c > +++ b/src/lib/csv/csv.c > @@ -192,6 +192,7 @@ csv_parse_impl(struct csv *csv, const char *s, const char *end, bool firstonly) > /* end of field */ > csv->state = CSV_LEADING_SPACES; > csv->bufp -= csv->ending_spaces; > + csv->ending_spaces = 0; > if (firstonly) { > csv->state = CSV_NEWFIELD; > return p; > diff --git a/test/app-tap/csv.test.lua b/test/app-tap/csv.test.lua > index 472a8d23e..0a656aaa3 100755 > --- a/test/app-tap/csv.test.lua > +++ b/test/app-tap/csv.test.lua > @@ -36,7 +36,7 @@ local test6_ans = "|23|\t|456|\t|abcac|\t|'multiword field 4'|\t\n|none|" .. > "lag[ flag ])|\t\n||\t||\t||\t\n" > > test = tap.test("csv") > -test:plan(11) > +test:plan(12) > > readable = {} > readable.read = myread > @@ -128,4 +128,9 @@ fio.unlink(file3) > fio.unlink(file4) > fio.rmdir(tmpdir) > > +-- gh-3489: crash with ending space and empty field > +local res = csv.load('929,N1XDN ,,"Enfield, CT",') > +local exp = {{'929', 'N1XDN', '', 'Enfield, CT', ''}} > +test:is_deeply(res, exp, 'gh-3489') > + > test:check() >