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: EPICS core-talk <[email protected]>
Date: Wed, 31 Mar 2010 11:43:29 -0500
On Wednesday 31 March 2010 11:00:30 you wrote:
> Ah, I see.  So is this a better change to macExpandString?
>
> --- macCore.c.orig	2010-03-31 08:31:20.000000000 -0700
> +++ macCore.c	2010-03-31 08:58:32.000000000 -0700
> @@ -198,6 +198,10 @@
>      if ( handle->debug & 1 )
>          printf( "macExpandString( %s, maxlen = %ld )\n", src, maxlen );
>
> +    /* Check size */
> +    if (maxlen <= 1)
> +        return -1;
> +
>      /* expand raw values if necessary */
>      if ( expand( handle ) < 0 )
>          errlogPrintf( "macExpandString: failed to expand raw values\n" );
> @@ -211,7 +215,7 @@
>      s  = src;
>      d  = dest;
>      *d = '\0';
> -    trans( handle, &entry, 0, "", &s, &d, d + maxlen );
> +    trans( handle, &entry, 0, "", &s, &d, d + maxlen - 1 );
>
>      /* return +/- #chars copied depending on successful expansion */
>      length = d - dest;

Actually I think the real bugs only occur in macEnvExpand() and in the 
function check() in macLibTest.c, but given the unusual definition of the 
maxlen parameter I think it would be safest to change the parameter meaning as 
you suggest (maybe rename maxlen to buflen?) *and* modify all the places where 
it's currently used correctly.

If you generate a patch for this, please:

1. Also modify the comment describing the maxlen parameter, to clarify
2. Fix the length argument in the calls to macExpandString() in
      db_yyinput() - dbStatic/dbLexRoutines.c
      myInputFunction() - as/asLibRoutines.c
3. Attach it to a comment on the Launchpad bug report
	https://bugs.launchpad.net/epics-base/+bug/551909

Thanks,

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


References:
Bug in macLib Mark Rivers
Re: Bug in macLib Andrew Johnson

Navigate by Date:
Prev: Re: Bug in macLib Andrew Johnson
Next: naming the operating system independence layer Jeff Hill
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 Andrew Johnson
Next: RE: Bug in macLib Mark Rivers
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 ·