sane-project-website/old-archive/1999-03/0125.html

63 wiersze
2.8 KiB
HTML

<!-- received="Fri Mar 12 12:46:17 1999 PST" -->
<!-- sent="Fri, 12 Mar 1999 21:44:42 +0100 (MET)" -->
<!-- name="Ingo Wilken" -->
<!-- email="Ingo.Wilken@Informatik.Uni-Oldenburg.DE" -->
<!-- subject="Bugs in saned" -->
<!-- id="m10LYnS-0009zNC@petersfehn.Informatik.Uni-Oldenburg.DE" -->
<!-- inreplyto="" -->
<title>sane-devel: Bugs in saned</title>
<h1>Bugs in saned</h1>
<b>Ingo Wilken</b> (<a href="mailto:Ingo.Wilken@Informatik.Uni-Oldenburg.DE"><i>Ingo.Wilken@Informatik.Uni-Oldenburg.DE</i></a>)<br>
<i>Fri, 12 Mar 1999 21:44:42 +0100 (MET)</i>
<p>
<ul>
<li> <b>Messages sorted by:</b> <a href="date.html#125">[ date ]</a><a href="index.html#125">[ thread ]</a><a href="subject.html#125">[ subject ]</a><a href="author.html#125">[ author ]</a>
<!-- next="start" -->
<li> <b>Next message:</b> <a href="0126.html">Oliver Rauch: "16 bit per sample support"</a>
<li> <b>Previous message:</b> <a href="0124.html">Juha Sahakangas: "Re: Microtek scanners"</a>
<!-- nextthread="start" -->
<!-- reply="end" -->
</ul>
<!-- body="start" -->
Hi!<br>
<p>
Out of curiosity, I tried to access my scanner backend (st400) with the<br>
net interface. That was a good thing, because it triggered a bug in my<br>
backend, but after fixing that, there was still a minor problem: After<br>
scanning was complete, saned would not print it's "exiting" message to<br>
syslog. After some investigating, I found a bug in saned:<br>
<p>
In get_free_handle(), saned mallocs/reallocs a block of handles, but<br>
never initializes this memory. In quit(), it then runs through the<br>
entire block, trying to close the handles. If this block contained some<br>
garbage at allocation, it might call sane_close() on random memory.<br>
<p>
The fix is simple. After the if-malloc-else-realloc sequence at the<br>
end of get_free_handle(), add a line:<br>
memset(handle+last_handle_checked+1, 0, ALLOC_INCREMENT*sizeof (handle[0]));<br>
<p>
I think there's also a race condition with the watchdog alarm timer:<br>
process_request() blocks until it receives a request, then calls quit()<br>
if it is SANE_NET_EXIT (or SANE_NET_INIT/SANE_NET_AUTHORIZE). quit() now<br>
calls sane_close() on all file handles. If the watchdog timer happens to<br>
run out at this time, it calls quit() itself, triggering a second run,<br>
which calls sane_close() with invalid handles.<br>
<p>
Regards,<br>
Ingo<br>
<p>
<pre>
--
Source code, list archive, and docs: <a href="http://www.mostang.com/sane/">http://www.mostang.com/sane/</a>
To unsubscribe: echo unsubscribe sane-devel | mail <a href="mailto:majordomo@mostang.com">majordomo@mostang.com</a>
</pre>
<!-- body="end" -->
<p>
<ul>
<!-- next="start" -->
<li> <b>Next message:</b> <a href="0126.html">Oliver Rauch: "16 bit per sample support"</a>
<li> <b>Previous message:</b> <a href="0124.html">Juha Sahakangas: "Re: Microtek scanners"</a>
<!-- nextthread="start" -->
<!-- reply="end" -->
</ul>