[sane-devel] [dev] net backend and SANE_ACTION_SET_AUTO

mh crapsite@gmx.net
Wed, 5 Sep 2001 17:08:13 +0200


Hi all,
there seems to be a small problem with the net backend and calls to
sane_control_option(...) with the parameter SANE_ACTION_SET_AUTO
(SANE version 1.0.5).

According to the SANE standard, "the value of parameter v is completely
ignored in this case and may be NULL."
However, the net backend doesn't check for this case, which results in a
crash in the lines (around line 831, net.c)

 if (value_size > 0)
 {
    if ((SANE_Word) value_size == reply.value_size)
      memcpy (value, reply.value, reply.value_size);

(because value == NULL, but value_size > 0)

The line

if(action == SANE_ACTION_SET_AUTO) value_size = 0;

before (~ line 799, net.c)

req.handle = s->handle;
req.option = option;
req.action = action;
req.value_type = s->opt.desc[option]->type;
...

seems to fix the problem.
Can someone please take a look at this?

Thanks + bb
Michael