[Pkg-wmaker-commits] [wmbiff] 01/03: wmbiff: Manually copy mailbox path.

Doug Torrance dtorrance-guest at moszumanska.debian.org
Sat Jun 24 17:29:27 UTC 2017


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to branch upstream
in repository wmbiff.

commit 351cf81d481dcc9421f8723a2204569d1d2697b7
Author: Doug Torrance <dtorrance at piedmont.edu>
Date:   Sat Jun 24 10:56:19 2017 -0400

    wmbiff: Manually copy mailbox path.
    
    Patch by Demi <m at tfiu.de> to fix Debian bug #621690.
    
    From https://bugs.debian.org/621690:
    
    > wmbiff change path of my mailboxes next nearest.
    >
    > For example wmbiff change 'gleb' to 'glil' for second and fourth mailboxes.
    > However the 1st, 3rd and 5th mailboxes have correct path.
    
    Well, the indices don't really enter.  I'm actually surprised this
    isn't more trouble.
    
    The underlying reason is that in wmbiff.c:parse_mbox_path, the
    program calls
    
      mboxCreate((&mbox[item]), mbox[item].path);
    
    which for maildirs calls
    
      int maildirCreate(Pop3 pc, const char *str)
    
    in maildirClient.c.  str in this way is an alias for pc->path.
    
    In maildirCreate, after some char acrobatics, the program eventually
    does
    
      strncpy(pc->path, str + 8 + i, BUF_BIG - 1);
    
    to cut off the leading stuff from the maildir.  The result of this
    operation is not defined, as pc->path and str point to the same
    memory and thus the arguments overlap, which strncpy outlaws.
    
    A simple fix is to copy manually, like this:
    
    		DM(pc, DEBUG_ERROR, "maildir '%s' is too long.\n", str + 8 + i);
    		memset(pc->path, 0, BUF_BIG);
    	} else {
    +		const char *sp = str + 8 + i;
    +		char *dp = pc->path;
    +
    +		while (*sp && sp-str<BUF_BIG-1) {
    +			*dp++ = *sp++;
    +		}
    +		*dp = 0;
    -		strncpy(pc->path, , BUF_BIG - 1);	/* cut off ``maildir:'' */
    	}
    
    -- it's what I'm doing now.  But I give you that's a bit pedestrian.
---
 wmbiff/maildirClient.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/wmbiff/maildirClient.c b/wmbiff/maildirClient.c
index 5858e46..5df3349 100644
--- a/wmbiff/maildirClient.c
+++ b/wmbiff/maildirClient.c
@@ -168,7 +168,13 @@ int maildirCreate(Pop3 pc, const char *str)
 		DM(pc, DEBUG_ERROR, "maildir '%s' is too long.\n", str + 8 + i);
 		memset(pc->path, 0, BUF_BIG);
 	} else {
-		strncpy(pc->path, str + 8 + i, BUF_BIG - 1);	/* cut off ``maildir:'' */
+		const char *sp = str + 8 + i;
+		char *dp = pc->path;
+
+		while (*sp && sp-str<BUF_BIG-1) {
+			*dp++ = *sp++;
+		}
+		*dp = 0;
 	}
 
 	DM(pc, DEBUG_INFO, "maildir: str = '%s'\n", str);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmbiff.git



More information about the Pkg-wmaker-commits mailing list