[sane-devel] Bug in scanimage.c + Patch

abel deuring a.deuring@satzbau-gmbh.de
Wed, 20 Mar 2002 19:17:47 +0100


Klaas Freitag wrote:
> 
> Hi,
> 
> I think there is a small bug in the code handling the -f option. IMHO it mallocs
> a one byte to small buffer for a strcpy action. I could reproduce some crashes
> which disappeared after having applied the attached patch.
> 
> If you agree, please apply the patch.

Klaas,

right, the malloc argument was too small, but that's already fixed in
the CVS version: 

fmt = malloc(strlen(optarg)+1);

strdup would work too, but you should not remove the strcpy call in the
"for (i = 0; device_list[i]; ++i)" loop; without the strcpy, the "switch
(*percent)" will work only for the first pass of the loop.

Abel