[tpop3d-discuss]sigsegv error, patch attached

Jeff Davis jdavis at empires.org
Fri, 12 Mar 2004 03:55:29 -0800


--=-Gs139vXRM3KwxJ5OWlC9
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

In version 1.5.3 I was getting a memory error when using the maildir
mbox type.

In summary, the function maildir_new would assign to the boolean var
"locked" similar to the following:

if( this_condition && !(locked = maildir_lock(M->name))) {
    ...
}

And the problem was, locked was not initialized to false. So, if
this_condition failed, the RHS would not be evaluated, and thus locked
would not be assigned, and then generally have a true value.

Later, of course the value of locked is tested, and succeeds, and then
attempts to maildir_unlock(M->name), which causes the segfault, since
maildir_unlock assumes M->name is locked (which it isn't, it's just
fooled by the uninitialized variable).

Regards,
	Jeff Davis


--=-Gs139vXRM3KwxJ5OWlC9
Content-Disposition: attachment; filename=tpop3d-1.5.3.patch
Content-Type: text/x-patch; name=tpop3d-1.5.3.patch; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Common subdirectories: tpop3d-1.5.3/TPOP3D-AuthDriver and tpop3d-1.5.3.new/TPOP3D-AuthDriver
Common subdirectories: tpop3d-1.5.3/config and tpop3d-1.5.3.new/config
Common subdirectories: tpop3d-1.5.3/darwin and tpop3d-1.5.3.new/darwin
Common subdirectories: tpop3d-1.5.3/init.d and tpop3d-1.5.3.new/init.d
diff -u tpop3d-1.5.3/maildir.c tpop3d-1.5.3.new/maildir.c
--- tpop3d-1.5.3/maildir.c	2003-11-24 12:23:20.000000000 -0800
+++ tpop3d-1.5.3.new/maildir.c	2004-03-12 03:39:12.000000000 -0800
@@ -205,7 +205,7 @@
     mailbox M, failM = NULL;
     struct timeval tv1, tv2;
     float f;
-    int locked;
+    int locked=0;
  
     alloc_struct(_mailbox, M);
     
Only in tpop3d-1.5.3.new: maildir.c~
Common subdirectories: tpop3d-1.5.3/scripts and tpop3d-1.5.3.new/scripts

--=-Gs139vXRM3KwxJ5OWlC9--