[sane-devel] Fix for array subscript error in niash.c

Johannes Meixner jsmeix at suse.de
Thu Feb 22 11:08:41 CET 2007


Hello,

On Feb 21 20:46 Bertrik Sikken wrote (shortened):
> Johannes Meixner wrote:
> > https://bugzilla.novell.com/show_bug.cgi?id=246654
...
> The optLast option is indeed used to signify the number of available
> options. By placing an option behind optLast, it becomes invisible and
> inaccessible from the SANE API (at least that's the intention).
> This was a convenient hack to quickly enable or disable an experimental
> option in the beginning of the development of the backend.

But even during development it cannot work to set up too small
arrays with a size of optLast when there are whatever kind of
options after optLast.

It seems optLast is actually an optLastVisible and at the
very end of the enumeration there should be the real optLast
(or keep optLast where it is and use an additional optEndOfList).
 

> How about simply removing the options beyond optLast (such that optLast
> is indeed the last option). They are not used in the backend anyway.

They are used in the code of the backend
(otherwise the complier would not have complained):
--------------------------------------------------------------------
          if (n == optGamma)
...
              _SetScalarGamma (s->aGammaTable, s->aValues[n].w);
--------------------------------------------------------------------
Where optGamma==17 but aValues has a size of optLast==12
and _SetScalarGamma is called with a random value in aValues[17].

Perhaps the condition n==optGamma is never fulfilled
but then the code is useless and should be removed at all.


Kind Regards
Johannes Meixner
-- 
SUSE LINUX Products GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany
AG Nuernberg, HRB 16746, GF: Markus Rex



More information about the sane-devel mailing list