Added checks for bad handles for SANE_NET_CLOSE and SANE_NET_CANCEL. This is

intended to stop saned from segfaulting when a bad handle is used.
merge-requests/1/head
Henning Geinitz 2004-03-03 19:13:04 +00:00
rodzic ad0b4850a4
commit 524d3f3c47
2 zmienionych plików z 15 dodań i 4 usunięć

Wyświetl plik

@ -1,3 +1,9 @@
2004-03-03 Henning Meier-Geinitz <henning@meier-geinitz.de>
* frontend/saned.c: Added checks for bad handles for
SANE_NET_CLOSE and SANE_NET_CANCEL. This is intended to stop
saned from segfaulting when a bad handle is used.
2004-03-02 Karl Heinz Kremer <khk@khk.net>
* backend/epson.c: Added D8 function level for RX-500

Wyświetl plik

@ -1,6 +1,6 @@
/* sane - Scanner Access Now Easy.
Copyright (C) 1997 Andreas Beck
Copyright (C) 2001 - 2003 Henning Meier-Geinitz
Copyright (C) 2001 - 2004 Henning Meier-Geinitz
Copyright (C) 2003 Julien BLACHE <jb@jblache.org>
AF-independent + IPv6 code
@ -446,7 +446,7 @@ get_free_handle (void)
static void
close_handle (int h)
{
if (handle[h].inuse)
if (h >= 0 && handle[h].inuse)
sane_close (handle[h].handle);
handle[h].inuse = 0;
}
@ -1768,6 +1768,8 @@ process_request (Wire * w)
free (resource);
memset (&reply, 0, sizeof (reply)); /* avoid leaking bits */
reply.status = sane_open (name, &be_handle);
DBG (DBG_MSG, "process_request: sane_open returned: %s\n",
sane_strstatus (reply.status));
}
if (reply.status == SANE_STATUS_GOOD)
@ -2000,8 +2002,11 @@ process_request (Wire * w)
SANE_Word ack = 0;
h = decode_handle (w, "cancel");
sane_cancel (handle[h].handle);
handle[h].docancel = 1;
if (h >= 0)
{
sane_cancel (handle[h].handle);
handle[h].docancel = 1;
}
sanei_w_reply (w, (WireCodecFunc) sanei_w_word, &ack);
}
break;