EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

2002  2003  2004  2005  2006  2007  2008  2009  <20102011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 2002  2003  2004  2005  2006  2007  2008  2009  <20102011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: Bug in macLib
From: Andrew Johnson <[email protected]>
To: Eric Norum <[email protected]>
Cc: Core-Talk <[email protected]>, Mark Rivers <[email protected]>
Date: Wed, 31 Mar 2010 10:53:02 -0500
On Wednesday 31 March 2010 08:58:28 Eric Norum wrote:
> >
> > I may be missing something, but this code actually looks OK to me.  Note
> > that valend is a pointer, not a counter.  So if valend actually points
> > to the last character in the buffer then the statement
> >
> >            if ( v <= valend ) *v   = '\0';
> >
> > should be OK, right?
>
> Nope.
> Despite its name, "valend" actually points to the location just past the
> end of the buffer.

I'm convinced that the original intention was as Mark suggests, which is 
obvious if you look at the two other calls to trans() which both allocate 
buffers of size maxlen+1.  Also two of the four functions that call 
macExpandString() give it a maxlen value which is explicitly 1 less than their 
available buffer size.

Unfortunately the documentation (src/libCom/macLib/macLibREADME) doesn't say 
anything about the maxlen parameter, and this really doesn't follow the C 
standard, so I would be in favour of checking and changing the meaning of the 
maxlen argument to macExpandString() but *not* the valend pointer in trans(), 
which I believe is being used correctly in all cases.

Eric's proposed change to trans() is wrong, this code is pretty subtle and 
there are several other places in trans() which you'd have to change to match.

- Andrew
-- 
The best FOSS code is written to be read by other humans -- Harald Welte


Replies:
RE: Bug in macLib Mark Rivers
References:
Bug in macLib Mark Rivers
RE: Bug in macLib Mark Rivers
Re: Bug in macLib Eric Norum

Navigate by Date:
Prev: Re: Bug in macLib Ralph Lange
Next: Re: Bug in macLib Andrew Johnson
Index: 2002  2003  2004  2005  2006  2007  2008  2009  <20102011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: Bug in macLib Eric Norum
Next: Re: Bug in macLib Andrew Johnson
Index: 2002  2003  2004  2005  2006  2007  2008  2009  <20102011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 02 Feb 2012 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·