sane-project-website/old-archive/1998-12/0130.html

145 wiersze
6.1 KiB
HTML

<!-- received="Thu Dec 10 04:50:23 1998 PST" -->
<!-- sent="Thu, 10 Dec 1998 13:48:40 +0100 (MET)" -->
<!-- name="becka@rz.uni-duesseldorf.de" -->
<!-- email="becka@rz.uni-duesseldorf.de" -->
<!-- subject="Re: PNM bugfix doesn't help" -->
<!-- id="199812101248.NAA00615@zeus.rz.uni-duesseldorf.de" -->
<!-- inreplyto="Pine.LNX.3.96.981209191550.19169C-100000@chef.ecs.soton.ac.uk" -->
<title>sane-devel: Re: PNM bugfix doesn't help</title>
<h1>Re: PNM bugfix doesn't help</h1>
<a href="mailto:becka@rz.uni-duesseldorf.de"><i>becka@rz.uni-duesseldorf.de</i></a><br>
<i>Thu, 10 Dec 1998 13:48:40 +0100 (MET)</i>
<p>
<ul>
<li> <b>Messages sorted by:</b> <a href="date.html#130">[ date ]</a><a href="index.html#130">[ thread ]</a><a href="subject.html#130">[ subject ]</a><a href="author.html#130">[ author ]</a>
<!-- next="start" -->
<li> <b>Next message:</b> <a href="0131.html">Milon Firikis: "Interesting surfing. Competition ?"</a>
<li> <b>Previous message:</b> <a href="0129.html">Nick Lamb: "PNM bugfix doesn't help"</a>
<!-- nextthread="start" -->
<!-- reply="end" -->
</ul>
<!-- body="start" -->
Hi !<br>
<p>
<i>&gt; &gt; If it is broken, it is probably largely my fault.</i><br>
<i>&gt; Good, I'm talking to the right guy.</i><br>
<p>
Seems not. I haven't touched it for some time, and the bug below is<br>
quite surely not (c) by me.<br>
<p>
<i>&gt; &gt; /* Suck in as much of the file as possible, since it's already in the</i><br>
<i>&gt; &gt; correct format. */</i><br>
<i>&gt; &gt; len = fread (data, 1, max_length, infile);</i><br>
<p>
<i>&gt; Well, the code you have here is totally different to the code in the</i><br>
<i>&gt; SANE 1.0 source tarball I have. Sigh...</i><br>
<p>
ARGH ! I checked against 0.76, thinking noone has touched the thing<br>
sinc then.<br>
<p>
<i>&gt; /* Suck in as much of the file as possible, since it's already in the</i><br>
<i>&gt; correct format. */</i><br>
<i>&gt; char *buf;</i><br>
<i>&gt; int doread = parms.bytes_per_line;</i><br>
<i>&gt; if (read_lines &gt;= bry) </i><br>
<i>&gt; return SANE_STATUS_EOF;</i><br>
<i>&gt; buf = alloca(doread);</i><br>
<i>&gt; len = fread (buf, 1, doread, infile);</i><br>
<p>
Hmm - this is simply wrong as far as I can tell.<br>
<p>
I'm just now downloading a copy to be able to make better comments. Sorry<br>
for the inconvenience. <br>
<p>
Who did that changes ?<br>
<p>
Hmmm: Changes written by G.ran Thyni &lt;<a href="mailto:goran@bildbasen.se">goran@bildbasen.se</a>&gt; but I'm not sure <br>
he's responsible for those changes.<br>
<p>
Anyway: Whoever does changes - could you make sure they do not break anything ?<br>
The PNM backend is a reference implementation. Not a playground.<br>
<p>
It is totally irrelevant, what it does. It is just there to look at and see<br>
how things are done.<br>
<p>
<i>&gt; &gt; Now let's have a look at the other branch ...</i><br>
<i>&gt; [snipped, I'm sure both cases are broken, because the PNM backend is</i><br>
<i>&gt; totally borked, and I'd like to see the author fix it, or rewrite it]</i><br>
<p>
*grin* Me too. I'll take care of it.<br>
<p>
It can't be, that the reference implementation backend is broken.<br>
<p>
<i>&gt; Tested, doesn't fix it (because we're in the other branch by this point)</i><br>
<p>
Yes, but that doesn't matter any more, as the code is too much different from<br>
what I analyzed.<br>
<p>
<i>&gt; Can't tell if it helps when Grayify/Three-pass are on, because they always</i><br>
<i>&gt; return total gibberish anyway. Make the easy case work first?</i><br>
<p>
Yep. I'll make that work here some way and send diffs.<br>
<p>
<i>&gt; &gt; &gt; If the PNM device has more data to send, it just writes past the end</i><br>
<i>&gt; &gt; &gt; of the buffer, </i><br>
<i>&gt; &gt; Hey - it's not that bad. Just some overly clever code, which misbehaves</i><br>
<i>&gt; &gt; when used in a somewhat unusual way. Who didn't make such a mistake once</i><br>
<i>&gt; &gt; upon a time ?</i><br>
<p>
<i>&gt; The SANE standard says I can pass any value for max_length, the PNM</i><br>
<i>&gt; backend assumes I will always pass &gt;= sizeof(one scanline), </i><br>
<p>
I didn't know it was _THAT_ broken in 1.0. Now I understand you being upset.<br>
<p>
The code I analyzed from 0.76 just broke in rare occasions, while the code<br>
snippet you sent suggest that it breaks _always_ ... !<br>
<p>
<i>&gt; which is a totally bogus assumption. I notice on the list that at least one</i><br>
<i>&gt; other backend makes such bogus assumptions.</i><br>
<p>
Yes. This is simply silly. The reason for having that maxlength parameter is<br>
to _avoid_ buffer overflows.<br>
<p>
<i>&gt; Perhaps I should write a test frontend, that behaves badly to crash</i><br>
<i>&gt; wrong-headed backends. </i><br>
<p>
Yes. Please !<br>
<p>
<p>
Use sane-read with widely varying max_sizes and adjust them up _and_ down<br>
in one scan.<br>
<p>
That would have crashed the old PNM backend as well.<br>
<p>
<i>&gt; If I did this would the SANE developers agree to not allow distribution </i><br>
<i>&gt; of backends that can't pass the test?</i><br>
<i>&gt; [They are non-conforming by SANE standard]</i><br>
<p>
Interesting idea. We should consider that.<br>
<p>
<i>&gt; Alternatively the standard could be revised to say "Backends reserve</i><br>
<i>&gt; the right to copy any amount of data into the buffer, even if this</i><br>
<i>&gt; causes overflows or the end of world civilisation, so there."</i><br>
*grin*. We should call that plan B :-).<br>
<p>
CU, Andy<br>
<p>
<pre>
--
Andreas Beck | Email : &lt;<a href="mailto:Andreas.Beck@ggi-project.org">Andreas.Beck@ggi-project.org</a>&gt;
<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="0131.html">Milon Firikis: "Interesting surfing. Competition ?"</a>
<li> <b>Previous message:</b> <a href="0129.html">Nick Lamb: "PNM bugfix doesn't help"</a>
<!-- nextthread="start" -->
<!-- reply="end" -->
</ul>