[PATCH] Serious bug on perl 5.8 may cause file/folder corruption

Paulo Matos <[email protected]> Mon, 15 Sep 2003 16:40:59 +0100 (WEST)
Newsgroups gmane.mail.neomail.general
Message-ID <[email protected]>
	Hi again!

	After all, we have to patch neomail to resist buggy tell()! See 
the attached file for details.

	Neo, due to severity of this bug, please consider to create a 
maintnence release.

	With this patch there is no need for changing the open() calls as 
suggested previously.

	Regards,

-- 
	Paulo Matos
neomail.pl.tellbug.patch (text/plain, 1.8 KB)
# 
# neomail.pl.tellbug.patch
# 2003.09.15 Paulo Matos <[email protected]> 
#
# This patch makes neomail resistent to the tell() bug introduced 
# with perl 5.8.0 (this version of perl is stocked in RedHat 8.0 
# distributuion).
#
# You might have experiencied some folder corruptions caused by this
# problem.
#
# This patch should work with no problems versions 1.21-1.26 of neomail. 
#
# Note: If you do this on a production system, be sure to delete all 
# var/users/*.db files.
#
#
# FAQ
# ---
# Q: I have an older version of neomail, how do I patch?
# A: Change dir to wherever is neomail.pl (or equivalent) and do:
#
#    patch < neomail.pl.tellbug.patch 
#
#    It might apperar a message like
#    File to patch:
#
# be sure you're in the correct dir, and if so, type 'neomail.pl' or 
# whatever name you gave 'neomail.pl' and press enter.
#
#
# IMPORTANT: Don't forget to check out permissions and ownership of the
# patched file, they might be changed. 
# 
# If something of the above is somehow incorrect please let me know.
#
--- neomail.template.orig	2003-09-15 16:18:47.000000000 +0100
+++ neomail.template	2003-09-15 16:21:06.000000000 +0100
@@ -24,5 +24,5 @@
 use CGI qw(:standard);
 use CGI::Carp qw(fatalsToBrowser);
-use Fcntl qw(:DEFAULT :flock);
+use Fcntl qw(:DEFAULT :flock :seek);
 use FileHandle;
 use Digest::MD5 'md5_hex';
@@ -1659,4 +1659,5 @@
             neomailerror("$lang_err{'couldnt_lock'} $sentfolder!");
          }
+         seek(SENT,0,SEEK_END);
 
          my @attr;  # Will hold message attributes to be written to DBM
@@ -2412,4 +2413,5 @@
                neomailerror("$lang_err{'couldnt_lock'} $destination!");
             }
+            seek(DEST,0,SEEK_END);
 
             update_headerdb("$userprefsdir$user/$destnoext", "$folderdir/$destination");