mutt change breaks vim syntax highlighting

Udo Schweigert Udo.Schweigert at siemens.com
Thu Apr 22 06:17:20 PDT 2004


On Thu, Apr 22, 2004 at 11:27:17 +0200, Jean-Baptiste Quenot wrote:
> Dear Udo,
> 
> Could you please  review PR 63192?  Since you introduced  a patch to the
> creation of  temp files in  Mutt with PR 62569,  there is now  a problem
> with Vim syntax highlighting.
> 
> Maintainer of Vim (David O'Brien) does  not understand why this patch is
> FreeBSD-specific and has not been  submitted to Mutt's upstreams author.
> Would you  be kind  to post  a follow-up to  this PR  and to  this list,
> explaining your motivation to do so?
> 

Adding the patch was done by another user's request, because the current mutt
code causes problems on open-session machines, when PIDs are reused and thus
mutt sometimes failes to open a tmp-file because it's already opened by
another user. Another benefit is that the usage of mktemp() gives (a little)
more security here.

I also submitted that to the mutt developers mailing list, but it seems it
hasn't been incorporated into the sources yet - and I doubt it will be done
soon, because the whole handling of tmp-files in mutt should be rewritten ...

A possible workaround would be to change the FreeBSD-patch so that the used
tmp-filenames are compatible with vim. That will again lower them security
as one would have to do something like that:

--- muttlib.c.orig	Thu Apr 22 14:43:58 2004
+++ muttlib.c	Thu Apr 22 14:51:01 2004
@@ -657,7 +657,11 @@
 
 void _mutt_mktemp (char *s, const char *src, int line)
 {
-  snprintf (s, _POSIX_PATH_MAX, "%s/mutt-%s-%d-%d", NONULL (Tempdir), NONULL(Hostname), (int) getpid (), Counter++);
+  char t[5];
+  snprintf (t, 5, "-%03d", Counter++);
+  snprintf (s, _POSIX_PATH_MAX-5, "%s/mutt-%s-XXXXXXXX", NONULL(Tempdir), NONULL(Hostname));
+  mktemp (s);
+  strncat(s, t, _POSIX_PATH_MAX);
   dprint (1, (debugfile, "%s:%d: mutt_mktemp returns \"%s\".\n", src, line, s));
   unlink (s);
 }

(Unfortunately there's no mktemps(), and mkstemps() isn't usable here)

It's a bit ugly but it works ;-)


Best regards

--
Udo Schweigert, Siemens AG   | Voice      : +49 89 636 42170
CT IC CERT, Siemens CERT     | Fax        : +49 89 636 41166
D-81730 Muenchen / Germany   | email      : udo.schweigert at siemens.com


More information about the freebsd-ports mailing list