Net backend bug [patch]

Nick Lamb (njl98r@ecs.soton.ac.uk)
Mon, 29 Mar 1999 05:38:49 +0100 (BST)

I think I've found a bug in the net backend.
It certainly doesn't conform to the current SANE standard (but IMHO the
current standard document could be tightened up more)

The SANE_TYPE_BUTTON doesn't have a corresponding size. Therefore it is
wrong of the net backend to insist on doing things with this size, or
manipulating value at all.

This patch checks for SANE_TYPE_BUTTON, where previously the Net backend
crashed for me. I cannot tell if this is the only place where the wrong
assumption about SANE_TYPE_BUTTON is made. But I hope this patch can go
into a future version of the SANE sample implementation.

Nick.

--- net.c.old Thu Oct 29 07:42:27 1998
+++ net.c Mon Mar 29 05:13:50 1999
@@ -697,11 +697,13 @@
{
if (info)
*info = reply.info;
- if (s->opt.desc[option]->size == reply.value_size)
- memcpy (value, reply.value, reply.value_size);
- else
+ if (s->opt.desc[option]->type == SANE_TYPE_BUTTON)
+ ; /* Do nothing -- buttons have no value */
+ else if (s->opt.desc[option]->size != reply.value_size)
DBG(1, "control_option: size changed from %d to %d\n",
s->opt.desc[option]->size, reply.value_size);
+ else
+ memcpy (value, reply.value, reply.value_size);

if (reply.info & SANE_INFO_RELOAD_OPTIONS)
s->options_valid = 0;

--
Source code, list archive, and docs: http://www.mostang.com/sane/
To unsubscribe: echo unsubscribe sane-devel | mail majordomo@mostang.com