Hi,
Looking at this huge discussion, I suggest to try some static analysis
tool which should easily find bugs like this.
I have only used it in commercial environment, but there is also a free
service for open source projects: Coverity (https://scan.coverity.com/)
What do you think?
kind regards,
Markus
On Mar 23, Andy Carter <o...@ply.me.uk> wrote:
Date: Wed, 23 Mar 2016 08:09:53
From: Andy Carter <o...@ply.me.uk>
To: owfs-developers@lists.sourceforge.net
Subject: Re: [Owfs-developers] Louis Swart LCD issues
On Tuesday 22 Mar 2016 22:30:50 Johan Ström wrote:
On 22/03/16 21:56, Andy Carter wrote:
statement. Changing this to
if (extension == elements - 1) { // last element
entry_length = end - buffer_position - element - 1 ;
Typo, that should of course have been
if (extension == elements - 1) { // last element
entry_length = end - buffer_position - elements - 1 ;
My theory is, the buffer begins as "aaa,bbb,ccc,ddd".
After each iteration, it does memmove and trims away the comma (moves
rest of string down 1 byte).
That is, "bbb,ccc,ddd" is moved 1 byte earlier. But it does not
overwrite the data behind the "end". Result:
0 round: aaa,bbb,ccc,ddd\0
1 round: aaabbb,ccc,dddd\0
2 round: aaabbbccc,dddd\0\0
3 round: aaabbbcccdddd\0\0\0
Yes, I think so - it's just taken me a lot longer to get there than you :)
The first three elements are get's their length properly (3).
It looks to me that the lower section of the function is getting the result
right and calculating entry_length correctly
But the last one gets wrong length, instead of 3 it gets 6... Well, that
doesn't really match what you describe either..so..
My thinking was that we have an extra element for each comma and entry_length
is calculated wrongly within that if statement - but then that leaves the
extra 'd' :/
To nail this properly, I'm going to try to write some unittests for
this, so it is reproducible and works for all side-cases (wrong lengths
etc).
That would be most useful.
I'm sure there is no rush, the device is perfectly usable writing line by line
now following your earlier fix.
As for your offer on an LCD
Many of us rely heavily on the time and effort put in by OS developers but can
add little - other than causing more work by finding bugs
Non-developers providing the odd bit of hardware seems to me to be one way of
supporting the community.
Thanks
Andy
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785351&iu=/4140
_______________________________________________
Owfs-developers mailing list
Owfs-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/owfs-developers
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785351&iu=/4140
_______________________________________________
Owfs-developers mailing list
Owfs-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/owfs-developers