[comp.mail.uucp] Smail2.5 binary search bug

brian@cdp.UUCP (03/08/91)

i have just discoverd that the binary search routine in
smail 2.5 is faulty. it seems it can miss (at least) the
last line in the paths file. the version i have is:

**	@(#)defs.h	2.5 (smail) 9/15/87

my paths file looks like:
---------------------file starts below here------------
cdp	cdp!%s	100
cdp2	%s	0
smart-host	cdp!uunet!%s	100
---------------------file ends above here--------------

if i try to feed it "smail -dR anyhost!anyuser" i get:

resolve: parse address 'anyuser' = 'anyuser' @ '' (LOCAL)
resolve: parse address 'anyhost!anyuser' = 'anyuser' @ 'anyhost' (UUCP)
getpath: looking for '.anyhost'
getpath: looking for 'anyhost'
getpath: looking for 'smart-host'
route 'anyhost' failed
resolve 'anyhost!anyuser' = 'anyuser' @ 'anyhost' (UUCP)
COMMAND: /usr/bin/uux -aroot -r - anyhost!rmail '(anyuser)'

has there been a patch to fix this?

thanks


Brian J. Coan
Community Data Processing (CdP): 415-322-9069
Internet: brian@cdp.igc.org
Bitnet: cdp!brian%labrea@stanford
UUCP: uunet!cdp!brian
DASNet: [DE3MIR]brian

woods@eci386.uucp (Greg A. Woods) (03/14/91)

In article <135800005@cdp> brian@cdp.UUCP writes:
> i have just discoverd that the binary search routine in
> smail 2.5 is faulty. it seems it can miss (at least) the
> last line in the paths file. the version i have is:
> 
> **	@(#)defs.h	2.5 (smail) 9/15/87
> 
> my paths file looks like:
> ---------------------file starts below here------------
> cdp	cdp!%s	100
> cdp2	%s	0
> smart-host	cdp!uunet!%s	100
> ---------------------file ends above here--------------
> 
> if i try to feed it "smail -dR anyhost!anyuser" i get:
[a failure to find [smart-host]

I think this bug has been previously discovered, and perhaps there is
a patch for it.  I know I ran into it at one time.

However, if I remember correctly, the bug is only triggered on very
small files, and only on files such as yours where your smart-host
entry is the last thing in the file.

I know that my current copy of smail, with the same SCCS-id and date
as you show above, can correctly find smart-host in the paths file,
and can correctly find the last entry in the file.  Our current paths
file has an even number of records though (23014).
-- 
							Greg A. Woods
woods@{eci386,gate,robohack,ontmoh,tmsoft}.UUCP		ECI and UniForum Canada
+1-416-443-1734 [h]  +1-416-595-5425 [w]  VE3TCP	Toronto, Ontario CANADA
Political speech and writing are largely the defense of the indefensible-ORWELL

rob@array.UUCP (Rob Marchand) (03/14/91)

In article <1991Mar13.211418.20877@eci386.uucp> woods@eci386.UUCP (Greg A. Woods) writes:
>In article <135800005@cdp> brian@cdp.UUCP writes:
>> i have just discoverd that the binary search routine in
>> smail 2.5 is faulty. it seems it can miss (at least) the
>> last line in the paths file. the version i have is:
>> 
	[ Example of problem deleted ]
>
>I think this bug has been previously discovered, and perhaps there is
>a patch for it.  I know I ran into it at one time.
>
	For those who are interested, I have a copy of the patch to smail2.5
	which corrects the binary search problem  (well, `a' binary search
	problem anyways :-)  Send mail if you desire a copy....

	Cheers!
	Rob 

-- 
Rob Marchand                   UUCP  : uunet!attcan!lsuc!array!rob
Array Systems Computing        ARPA  : rob%array.UUCP@uunet.UU.NET
401 Magnetic Drive, Unit 24    Phone : +1(416)736-0900   Fax: (416)736-4715
Downsview, Ont CANADA M3J 3H9  Telex : 063666 (CNCP EOS TOR) .TO 21:ARY001

barrett@Daisy.EE.UND.AC.ZA (Alan P. Barrett) (03/19/91)

In article <1991Mar13.211418.20877@eci386.uucp>,
woods@eci386.UUCP (Greg A. Woods) writes:
> In article <135800005@cdp> brian@cdp.UUCP writes:
> > i have just discoverd that the binary search routine in
> > smail 2.5 is faulty. it seems it can miss (at least) the
> > last line in the paths file. the version i have is:

There are (at least) two binary search routines in smail2.5.  One deals
with the paths file and one deals with the fullnames file.  Both had
bugs.  Both are fixed in the apbmje900117 patches to smail2.5, which I
posted to alt.sources earlier this year.  (However, I have a nasty
suspicion that my posting did not propagate very well -- I don't think
it made it onto the list in alt.sources.index.  Should I post again?)

> I think this bug has been previously discovered, and perhaps there is
> a patch for it.  I know I ran into it at one time.
> 
> However, if I remember correctly, the bug is only triggered on very
> small files, and only on files such as yours where your smart-host
> entry is the last thing in the file.

I am not sure, but I seem to remember that the bug could bite at just
about any time, although small files are indeed more likely to trigger
it.  It had to do with the relationship between the length of a line in
the file being searched, and the distance between the start and end
pointers used during the binary search.  I am sure that smart-host was
not the only string that missed being found, although of course you are
more likely to notice if it misses the smart-host than if it misses some
other entry.

--apb
Alan Barrett, Dept. of Electronic Eng., Univ. of Natal, Durban, South Africa
Internet: barrett@ee.und.ac.za           UUCP: m2xenix!quagga!undeed!barrett