Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 283316 - mail-client/alpine: Segfault when starting second instance
Summary: mail-client/alpine: Segfault when starting second instance
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Net-Mail Packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-08-31 11:05 UTC by Alexander Prokofiev
Modified: 2009-09-05 05:56 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Prokofiev 2009-08-31 11:05:43 UTC
When starting two instances of alpine for the same maildir,
second alpine crashes.

Problem is in maildir_can_assign_uid() function:
pointer returned by readdir() is used after closedir().

CC: gcc-4.4.0
CFLAGS: -O2 -march=i686
GLIBC: GNU C Library stable release version 2.9

Below is the patch:

--- maildir.c.orig	2009-08-31 14:49:14.000000000 +0400
+++ maildir.c	2009-08-31 14:50:10.000000000 +0400
@@ -2396,7 +2396,6 @@
 	|| !strncmp(d->d_name, MDUIDTEMP, strlen(MDUIDTEMP)))
        break;
   }
-  closedir(dir);
   rv = d ? !strncmp(d->d_name, tmp, strlen(tmp)) : 1;
   createtemp = d ? 0 : 1;
   if (d && rv == 0){	/* is there a temp file that is not ours? */
@@ -2410,6 +2409,9 @@
 	unlink(tmp);
      }
   }
+
+  closedir(dir);
+
   if(createtemp){
     FILE *fp;
     sprintf(tmp,"%s/%s.%d.%lu", LOCAL->dir, MDUIDTEMP, getpid(), time(0));
Comment 1 Eduardo Chappa 2009-08-31 18:17:06 UTC
(In reply to comment #0)
> When starting two instances of alpine for the same maildir,
> second alpine crashes.
> 
> Problem is in maildir_can_assign_uid() function:
> pointer returned by readdir() is used after closedir().

Thank you for your message. You are right about the problem and the solution.
I have posted a new patch to solve this problem.

-- 
Eduardo
Comment 2 Torsten Veller (RETIRED) gentoo-dev 2009-09-05 05:56:42 UTC
Thanks. Bumped to -r2.