[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Nmh-workers] Missing `/' in the result of m_mktemp2()

From: markus schnalke
Subject: [Nmh-workers] Missing `/' in the result of m_mktemp2()
Date: Tue, 14 Dec 2010 22:41:48 +0100
User-agent: nmh 1.3


I was moving my newest, and personally modified, version of nmh to a
different system. Now I encountered an error:

    mhbuild: unable to rename output /home/meillo/Mail/sendwvJV2J to
             /home/meillo/Mailmhbuild29ELnc: Invalid cross-device link

The cross-device link error comes from ~/Mail being a symlink to
another device:

    lrwxrwxrwx [...] /home/meillo/Mail -> /data/mail/

The point is, the second path (`/home/meillo/Mailmhbuild29ELnc') is
missing a slash.

I tracked the problem down.

uip/mhbuild.c in main():

357     /* output MIME message to this temporary file */
358     strncpy(outfile, m_mktemp2(compfile, invo_name, NULL, &fp_out),
359             sizeof(outfile)); 

If you print `outfile' you see the wrong path.

The problem comes from sbr/m_mktemp.c in m_mktemp2():

122     if ((cp = r1bindex ((char *)dir_in, '/')) == dir_in) {
123         /* No directory component */
124         return m_mktemp(pfx_in, fd_ret, fp_ret);
125     }
126     n = (int)(cp-dir_in-1); /* Length of dir component */
127     snprintf(buffer, sizeof(buffer), "%.*s%s", n, dir_in, pfx_in);
128     return m_mktemp(buffer, fd_ret, fp_ret);

`cp - dir_in - 1' excludes the trailing slash.

I don't know, and unfortunately don't have time to find out, where to

If the mail storage is no symlink to another device, one might not
notice this bug at all.

Maybe it is present in any use of m_mktemp2(), maybe only in those
with the first argument non-NULL.

A trivial hack to fix the problem is `126s/-1//' in sbr/m_mktemp.c.
But I have not clue if this solves the problem right, it just made
things work again for me.

Would be great if someone goes for the problem. I think I will be able
to test a fix.


Both files were not modified by my modifications.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]