EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: devlib2 bugfix (rare string corruption)
From: Michael Davidsaver <[email protected]>
To: Till Straumann <[email protected]>
Cc: EPICS Techtalk <[email protected]>
Date: Thu, 20 Dec 2012 14:05:36 -0500
Committed.

http://epics.hg.sourceforge.net/hgweb/epics/devlib2/rev/542a4744b240


On 12/19/2012 12:59 PM, Till Straumann wrote:
vallocPrintf()

first calls vsnprintf() with a length argument of zero to determine
the necessary buffer size, allocates a buffer and then calls

size2 = vsprintf(buf,format,args)

It then goes on and complains if size2 is different from what the
initial vsnprintf() returned.

If, however, this really happens (and I have observed this under 64-bit ubuntu-12.10) then it is well possible that vsprintf() writes beyond the length of the buffer.

Hence, I suggest to replace vsprintf() by

size2 = vsnprintf(buf, size+1, format, args)

just to make sure. (Note that the 'size' argument to snprintf() includes space for
the terminating NUL whereas the return value does not.)

- Till

A patch is attached for sake of convenience.


References:
devlib2 bugfix (rare string corruption) Till Straumann

Navigate by Date:
Prev: Record processing: periodic vs. push vs. pull jon
Next: RE: structs and SNL Mark Rivers
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: devlib2 bugfix (rare string corruption) Till Straumann
Next: cross-compile error S. Banerian
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 18 Nov 2013 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·