Discussion:
Bug in octstr_shrink_blanks
Werner Coetzee
2018-07-19 12:19:33 UTC
Permalink
Hi all

I believe there's a bug in octstr_shrink_blanks() in gwlib/octstr.c

It does not shrink 2 whitespaces into 1, only when there's more than 2.
The issue is with the line "if (j - i > 1)", it should test for > 0

It's very easy to write a small test binary to see that it doesn't work.
After fixing it in my local repo it's working correctly (for 1, 2, 3+ consecutive spaces).

Regards
Werner Coetzee



Werner Coetzee
Senior Message Engine Engineer

Tel:+27219107878
Email: ***@clickatell.com<mailto:***@clickatell.com>


[cid:***@f43d4823.498236c0]<https://www.clickatell.com>

Note: This disclaimer<https://www.clickatell.com/legal/general-terms-notices/privacy-notice/> applies to this email and its attachments
a***@kannel.org
2018-07-19 12:30:54 UTC
Permalink
Hi Werner,

patch is very welcome


Thanks,
Alex
Post by Werner Coetzee
Hi all
I believe there's a bug in octstr_shrink_blanks() in gwlib/octstr.c
It does not shrink 2 whitespaces into 1, only when there's more than 2.
The issue is with the line "if (j - i > 1)", it should test for > 0
It's very easy to write a small test binary to see that it doesn't work.
After fixing it in my local repo it's working correctly (for 1, 2, 3+ consecutive spaces).
Regards
Werner Coetzee
Werner Coetzee
Senior Message Engine Engineer
Tel:+27219107878
<image56bcaa.JPG> <https://www.clickatell.com/>
Note: This disclaimer <https://www.clickatell.com/legal/general-terms-notices/privacy-notice/> applies to this email and its attachments
Werner Coetzee
2018-07-19 12:56:10 UTC
Permalink
HI Alex

I've attached unified diff, hope it's the correct format.
Create with command:
svn diff -x -u gwlib/octstr.c
against trunk revision 5239

Werner



Werner Coetzee
Senior Message Engine Engineer

Tel:+27219107878
Email: ***@clickatell.com<mailto:***@clickatell.com>


[cid:***@745843ab.4d9c0e40]<https://www.clickatell.com>

Note: This disclaimer<https://www.clickatell.com/legal/general-terms-notices/privacy-notice/> applies to this email and its attachments

From: Alexander Malysh <***@gmail.com> On Behalf Of ***@kannel.org
Sent: 19 July 2018 14:31
To: Werner Coetzee <***@clickatell.com>
Cc: ***@kannel.org
Subject: Re: Bug in octstr_shrink_blanks

Hi Werner,

patch is very welcome


Thanks,
Alex



Am 19.07.2018 um 14:19 schrieb Werner Coetzee <***@clickatell.com<mailto:***@clickatell.com>>:


Hi all

I believe there's a bug in octstr_shrink_blanks() in gwlib/octstr.c

It does not shrink 2 whitespaces into 1, only when there's more than 2.
The issue is with the line "if (j - i > 1)", it should test for > 0

It's very easy to write a small test binary to see that it doesn't work.
After fixing it in my local repo it's working correctly (for 1, 2, 3+ consecutive spaces).

Regards
Werner Coetzee



Werner Coetzee
Senior Message Engine Engineer

Tel:+27219107878
Email: ***@clickatell.com<mailto:***@clickatell.com>


<image56bcaa.JPG><https://www.clickatell.com/>


Note: This disclaimer<https://www.clickatell.com/legal/general-terms-notices/privacy-notice/> applies to this email and its attachments
a***@kannel.org
2018-08-12 19:26:43 UTC
Permalink
Hi Werner,

thanks for the patch, applied to trunk.

Alex
Post by Werner Coetzee
HI Alex
I've attached unified diff, hope it's the correct format.
svn diff -x -u gwlib/octstr.c
against trunk revision 5239
Werner
Werner Coetzee
Senior Message Engine Engineer
Tel:+27219107878
<image346b75.JPG> <https://www.clickatell.com/>
Note: This disclaimer <https://www.clickatell.com/legal/general-terms-notices/privacy-notice/> applies to this email and its attachments
Sent: 19 July 2018 14:31
Subject: Re: Bug in octstr_shrink_blanks
Hi Werner,
patch is very welcome

Thanks,
Alex
Hi all
I believe there's a bug in octstr_shrink_blanks() in gwlib/octstr.c
It does not shrink 2 whitespaces into 1, only when there's more than 2.
The issue is with the line "if (j - i > 1)", it should test for > 0
It's very easy to write a small test binary to see that it doesn't work.
After fixing it in my local repo it's working correctly (for 1, 2, 3+ consecutive spaces).
Regards
Werner Coetzee
Werner Coetzee
Senior Message Engine Engineer
Tel:+27219107878 <tel:+27219107878>
<image56bcaa.JPG> <https://www.clickatell.com/>
Note: This disclaimer <https://www.clickatell.com/legal/general-terms-notices/privacy-notice/> applies to this email and its attachments
<octstr.c.diff>
Loading...