Tarantool development patches archive
 help / color / mirror / Atom feed
* [tarantool-patches] [PATCH] Fix csv crash with ending space and empty field
@ 2018-07-18 10:51 Alexander Turenko
  2018-07-18 11:08 ` [tarantool-patches] " Vladislav Shpilevoy
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Alexander Turenko @ 2018-07-18 10:51 UTC (permalink / raw)
  To: Vladislav Shpilevoy; +Cc: Alexander Turenko, tarantool-patches

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

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

* [tarantool-patches] Re: [PATCH] Fix csv crash with ending space and empty field
  2018-07-18 10:51 [tarantool-patches] [PATCH] Fix csv crash with ending space and empty field Alexander Turenko
@ 2018-07-18 11:08 ` Vladislav Shpilevoy
  2018-07-18 12:44   ` Alexander Turenko
  2018-07-18 15:28 ` Georgy Kirichenko
  2018-08-03 12:50 ` Kirill Yukhin
  2 siblings, 1 reply; 6+ messages in thread
From: Vladislav Shpilevoy @ 2018-07-18 11:08 UTC (permalink / raw)
  To: Alexander Turenko; +Cc: tarantool-patches

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()
> 

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

* [tarantool-patches] Re: [PATCH] Fix csv crash with ending space and empty field
  2018-07-18 11:08 ` [tarantool-patches] " Vladislav Shpilevoy
@ 2018-07-18 12:44   ` Alexander Turenko
  0 siblings, 0 replies; 6+ messages in thread
From: Alexander Turenko @ 2018-07-18 12:44 UTC (permalink / raw)
  To: Vladislav Shpilevoy, Georgy Kirichenko; +Cc: tarantool-patches

Nope :) I observed your commit for this file.

Georgy, maybe you can review me?

WBR, Alexander Turenko.

On Wed, Jul 18, 2018 at 02:08:16PM +0300, Vladislav Shpilevoy wrote:
> 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()
> > 

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

* [tarantool-patches] Re: [PATCH] Fix csv crash with ending space and empty field
  2018-07-18 10:51 [tarantool-patches] [PATCH] Fix csv crash with ending space and empty field Alexander Turenko
  2018-07-18 11:08 ` [tarantool-patches] " Vladislav Shpilevoy
@ 2018-07-18 15:28 ` Georgy Kirichenko
  2018-07-18 17:27   ` Alexander Turenko
  2018-08-03 12:50 ` Kirill Yukhin
  2 siblings, 1 reply; 6+ messages in thread
From: Georgy Kirichenko @ 2018-07-18 15:28 UTC (permalink / raw)
  To: tarantool-patches; +Cc: Alexander Turenko

[-- Attachment #1: Type: text/plain, Size: 121 bytes --]

Seems Ok for me

On Wednesday, July 18, 2018 1:51:43 PM MSK Alexander Turenko wrote:
> Totktonada/gh-3489-fix-csv-crash


[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* [tarantool-patches] Re: [PATCH] Fix csv crash with ending space and empty field
  2018-07-18 15:28 ` Georgy Kirichenko
@ 2018-07-18 17:27   ` Alexander Turenko
  0 siblings, 0 replies; 6+ messages in thread
From: Alexander Turenko @ 2018-07-18 17:27 UTC (permalink / raw)
  To: Kirill Yukhin; +Cc: tarantool-patches, Georgy Kirichenko

Kirill,

It is the one-line fix and I think one review before your one is enough.
Can you look, please?

WBR, Alexander Turenko.

On Wed, Jul 18, 2018 at 06:28:13PM +0300, Georgy Kirichenko wrote:
> Seems Ok for me
> 
> On Wednesday, July 18, 2018 1:51:43 PM MSK Alexander Turenko wrote:
> > Totktonada/gh-3489-fix-csv-crash
> 

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

* [tarantool-patches] Re: [PATCH] Fix csv crash with ending space and empty field
  2018-07-18 10:51 [tarantool-patches] [PATCH] Fix csv crash with ending space and empty field Alexander Turenko
  2018-07-18 11:08 ` [tarantool-patches] " Vladislav Shpilevoy
  2018-07-18 15:28 ` Georgy Kirichenko
@ 2018-08-03 12:50 ` Kirill Yukhin
  2 siblings, 0 replies; 6+ messages in thread
From: Kirill Yukhin @ 2018-08-03 12:50 UTC (permalink / raw)
  To: tarantool-patches; +Cc: Vladislav Shpilevoy, Alexander Turenko

Hello,
On 18 июл 13:51, Alexander Turenko wrote:
> Fixes #3489.
> ---
> branch: Totktonada/gh-3489-fix-csv-crash
> travis-ci: https://travis-ci.org/tarantool/tarantool/builds/405298528
Please in future mention link to the issue as well.

I've checked your patch into 1.9 branch.

--
Regards, Kirill Yukhin

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

end of thread, other threads:[~2018-08-03 12:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-18 10:51 [tarantool-patches] [PATCH] Fix csv crash with ending space and empty field Alexander Turenko
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

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