[sane-devel] (patch) Small fixes for canon630u, coolscan and microtek2

Frank Zago fzago@austin.rr.com
Fri, 04 Oct 2002 22:37:27 -0500


Hi Andras, Petter,

>>If sizeof(size_t) is bigger then sizeof(u_int32_t), than the call to
>>sanei_scsi_cmd() will write outside the space allocated for
>>ms->n_control_bytes.  If it is smaller, the value in
>>ms->n_control_bytes will be wrong.  It only work as it should if
>>size_t and u_int32_t is the same type.  This is not the case on
>>64-bit machines.
> 
> 
> This is definitely a bug in that backend, but your solution doesn't
> solve anything. The only thing it might do is create a compiler
> warning which is not much use to the end user anyway. (In fact, it
> will certainly cause the compiler to warn about an unused variable.)
> 
> This needs fixing, I agree, and it should be done before 1.0.9. The
> solution should be rather easy, I guess the types involved should
> either be all size_t or all u_int32_t, but I can't tell (I haven't got
> the time to look at the code right now).

Using size_t for ms->n_control_bytes is the way to go. It's ok for ia32 since 
sizeof(size_t) == sizeof(int). It needs some testing of wider platforms, though, 
but that's a good start.

> BTW, is there any specified lower limit for sizeof(size_t), i.e. can
> we safely assume that size_t can always take 32-bit values? Probably

That's a safe assumption, at least for the platforms SANE runs on.

> not a problem in this case, but it could have interesting implications
> now that open-source software on embedded devices, PDAs etc. is taking
> off.

Frank.