From: Alexander Turenko <alexander.turenko@tarantool.org> To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> Cc: Alexander Turenko <alexander.turenko@tarantool.org>, tarantool-patches@freelists.org Subject: [tarantool-patches] [PATCH] Fix csv crash with ending space and empty field Date: Wed, 18 Jul 2018 13:51:43 +0300 [thread overview] Message-ID: <68bfc349fad91265a56eb1c024a69f2ead030338.1531910937.git.alexander.turenko@tarantool.org> (raw) 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() -- 2.17.1
next reply other threads:[~2018-07-18 10:51 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-07-18 10:51 Alexander Turenko [this message] 2018-07-18 11:08 ` [tarantool-patches] " Vladislav Shpilevoy 2018-07-18 12:44 ` Alexander Turenko 2018-07-18 15:28 ` Georgy Kirichenko 2018-07-18 17:27 ` Alexander Turenko 2018-08-03 12:50 ` Kirill Yukhin
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=68bfc349fad91265a56eb1c024a69f2ead030338.1531910937.git.alexander.turenko@tarantool.org \ --to=alexander.turenko@tarantool.org \ --cc=tarantool-patches@freelists.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [tarantool-patches] [PATCH] Fix csv crash with ending space and empty field' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox