Subject: bug in env_unix.c

From: Karsten Ballueder <[email-masked]>
Date: Fri, 24 Mar 2000 10:53:28 +0000 (GMT)

Hi,

I wondered why our mailclient got so much slower in opening folders after
upgrading to c-client 4.7 and found the answer. Apparently, there is a bug in
env_unix.c:

At the end of dotlock_lock(), there is a little while loop doing a sleep(1) to
wait in case that it couldn't create a lock file.
That loop tests for base->lock. What it should test for is base->lock[0] as the
first byte is set to 0 if the code thinks that a re-try isn't necessary. In
fact, base->lock is guaranteed to be a non-NULL pointer anyway and has been
dereferenced further up in the function.

Apart from that, I also found that missing write-permissions (i.e. a EACCESS
errno if I remember correctly) would go into the loop, which appears kind of
pointless to me as write permissions are unlikely to change.
To improve that situation, I added a
base->lock[0] = '\0';
just above the EEXIST case label. So if the lock file does not exist but cannot
we don't have permission to create it (i.e. running as a mail client rather than
server, we don't have write permission in /var/spool/mail), it will not go into
the sleep(1) loop.

--
 Karsten Ballüder  http://Ballueder.home.dhs.org/  mailto:[email-masked]
 Physics Department, Heriot-Watt University, Edinburgh, EH14 4AS, Scotland
                     Tel. +44-(0)-131-4513068  Fax. +44-(0)-131-4513136
            "In a world without fences, who needs Gates?"  

-- 
------------------------------------------------------------------
 For information about this mailing list, and its archives, see: 
 http://www.washington.edu/imap/c-client-list.html
------------------------------------------------------------------