Hi Ken,

I just found that uip/new.c:get_msgnums() isn't locking the sequence file.
I've attached a patch for 1.5 but noted that you've reworked the locking on
the master branch so I thought you might appreciate the heads up.

Regards,

Harv

*** new.c.orig	2013-10-12 16:20:21.000000000 -0700
--- new.c	2013-10-12 15:39:42.000000000 -0700
***************
*** 91,109 ****
  static char *
  get_msgnums(char *folder, char *sequences[])
  {
!     char *seqfile = concat(m_maildir(folder), "/", mh_seq, (void *)NULL);
!     FILE *fp = fopen(seqfile, "r");
      int state;
      char name[NAMESZ], field[BUFSIZ];
      char *cp;
      char *msgnums = NULL, *this_msgnums, *old_msgnums;

-     /* no sequences file -> no messages */
-     if (fp == NULL) {
-         return NULL;
-     }
-
      /* copied from seq_read.c:seq_public */
      for (state = FLD;;) {
          switch (state = m_getfld (state, name, field, sizeof(field), fp)) {
              case FLD:
--- 91,120 ----
  static char *
  get_msgnums(char *folder, char *sequences[])
  {
!     char *seqfile;
!     FILE *fp;
      int state;
      char name[NAMESZ], field[BUFSIZ];
      char *cp;
      char *msgnums = NULL, *this_msgnums, *old_msgnums;

      /* copied from seq_read.c:seq_public */
+     /*
+      * If mh_seq == NULL (such as if nmh been compiled with
+      * NOPUBLICSEQ), or if *mh_seq == '\0' (the user has defined
+      * the "mh-sequences" profile entry, but left it empty),
+      * then just return, and do not initialize any public sequences.
+      */
+     if (mh_seq == NULL || *mh_seq == '\0')
+ 	return NULL;
+
+     /* get filename of sequence file */
+     seqfile = concat(m_maildir(folder), "/", mh_seq, (void *)NULL);
+
+     if ((fp = lkfopen (seqfile, "r")) == NULL)
+ 	return NULL;;
+
+     /* Use m_getfld to scan sequence file */
      for (state = FLD;;) {
          switch (state = m_getfld (state, name, field, sizeof(field), fp)) {
              case FLD:
***************
*** 166,172 ****
          break;  /* break from for loop */
      }

!     fclose(fp);

      return msgnums;
  }
--- 177,183 ----
          break;  /* break from for loop */
      }

!     lkfclose (fp, seqfile);

      return msgnums;
  }

Attachment: pgpTHL1SX1kmT.pgp
Description: PGP signature

_______________________________________________
Nmh-workers mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/nmh-workers

Reply via email to