To: vim-dev@vim.org Subject: patch 7.1.055 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 7.1.055 Problem: Using strcpy() with arguments that overlap. Solution: Use mch_memmove() instead. Files: src/buffer.c, src/charset.c, src/eval.c, src/ex_getln.c, src/misc1.c, src/regexp.c, src/termlib.c *** ../vim-7.1.054/src/buffer.c Tue Jun 19 15:40:51 2007 --- src/buffer.c Sun Aug 5 16:14:03 2007 *************** *** 4860,4866 **** */ for (e = s; *e != ':' && *e != NUL; ++e) if (e[0] == '\\' && e[1] == ':') ! STRCPY(e, e + 1); if (*e == NUL) end = TRUE; --- 4860,4866 ---- */ for (e = s; *e != ':' && *e != NUL; ++e) if (e[0] == '\\' && e[1] == ':') ! mch_memmove(e, e + 1, STRLEN(e)); if (*e == NUL) end = TRUE; *** ../vim-7.1.054/src/charset.c Tue Mar 27 12:41:45 2007 --- src/charset.c Sun Aug 5 21:53:44 2007 *************** *** 1898,1904 **** { for ( ; *p; ++p) if (rem_backslash(p)) ! STRCPY(p, p + 1); } /* --- 1898,1904 ---- { for ( ; *p; ++p) if (rem_backslash(p)) ! mch_memmove(p, p + 1, STRLEN(p)); } /* *** ../vim-7.1.054/src/eval.c Fri Jul 27 21:32:13 2007 --- src/eval.c Sun Aug 5 16:25:03 2007 *************** *** 13807,13813 **** } /* Shorten "remain". */ if (*q != NUL) ! STRCPY(remain, q - 1); else { vim_free(remain); --- 13807,13813 ---- } /* Shorten "remain". */ if (*q != NUL) ! mch_memmove(remain, q - 1, STRLEN(q - 1) + 1); else { vim_free(remain); *** ../vim-7.1.054/src/ex_getln.c Sat Jul 28 14:21:04 2007 --- src/ex_getln.c Sun Aug 5 21:55:56 2007 *************** *** 4306,4315 **** && pat[i + 1] == '\\' && pat[i + 2] == '\\' && pat[i + 3] == ' ') ! STRCPY(pat + i, pat + i + 3); if (xp->xp_backslash == XP_BS_ONE && pat[i + 1] == ' ') ! STRCPY(pat + i, pat + i + 1); } } --- 4306,4316 ---- && pat[i + 1] == '\\' && pat[i + 2] == '\\' && pat[i + 3] == ' ') ! mch_memmove(pat + i, pat + i + 3, ! STRLEN(pat + i + 3) + 1); if (xp->xp_backslash == XP_BS_ONE && pat[i + 1] == ' ') ! mch_memmove(pat + i, pat + i + 1, STRLEN(pat + i)); } } *************** *** 4552,4558 **** pat = vim_strsave(filepat); for (i = 0; pat[i]; ++i) if (pat[i] == '\\' && pat[i + 1] == ' ') ! STRCPY(pat + i, pat + i + 1); flags |= EW_FILE | EW_EXEC; --- 4553,4559 ---- pat = vim_strsave(filepat); for (i = 0; pat[i]; ++i) if (pat[i] == '\\' && pat[i + 1] == ' ') ! mch_memmove(pat + i, pat + i + 1, STRLEN(pat + i)); flags |= EW_FILE | EW_EXEC; *** ../vim-7.1.054/src/misc1.c Sat Aug 4 12:14:04 2007 --- src/misc1.c Sun Aug 5 21:57:15 2007 *************** *** 8635,8641 **** for (p = buf + wildoff; p < s; ++p) if (rem_backslash(p)) { ! STRCPY(p, p + 1); --e; --s; } --- 8635,8641 ---- for (p = buf + wildoff; p < s; ++p) if (rem_backslash(p)) { ! mch_memmove(p, p + 1, STRLEN(p)); --e; --s; } *************** *** 8936,8942 **** for (p = buf + wildoff; p < s; ++p) if (rem_backslash(p)) { ! STRCPY(p, p + 1); --e; --s; } --- 8936,8942 ---- for (p = buf + wildoff; p < s; ++p) if (rem_backslash(p)) { ! mch_memmove(p, p + 1, STRLEN(p)); --e; --s; } *** ../vim-7.1.054/src/regexp.c Mon Jul 30 22:32:11 2007 --- src/regexp.c Sun Aug 5 15:43:27 2007 *************** *** 6637,6645 **** } } else if (magic) ! STRCPY(p, p + 1); /* remove '~' */ else ! STRCPY(p, p + 2); /* remove '\~' */ --p; } else --- 6638,6646 ---- } } else if (magic) ! mch_memmove(p, p + 1, STRLEN(p)); /* remove '~' */ else ! mch_memmove(p, p + 2, STRLEN(p) - 1); /* remove '\~' */ --p; } else *** ../vim-7.1.054/src/termlib.c Thu May 10 20:20:59 2007 --- src/termlib.c Sun Aug 5 21:52:41 2007 *************** *** 191,197 **** lbuf[0] == '\t' && lbuf[1] == ':') { ! strcpy(lbuf, lbuf+2); llen -= 2; } if (lbuf[llen-2] == '\\') /* and continuations */ --- 191,197 ---- lbuf[0] == '\t' && lbuf[1] == ':') { ! mch_memmove(lbuf, lbuf + 2, strlen(lbuf + 2) + 1); llen -= 2; } if (lbuf[llen-2] == '\\') /* and continuations */ *** ../vim-7.1.054/src/version.c Sun Aug 5 20:10:16 2007 --- src/version.c Mon Aug 6 21:34:54 2007 *************** *** 668,669 **** --- 668,671 ---- { /* Add new patch number below this line */ + /**/ + 55, /**/ -- From "know your smileys": % Bike accident. A bit far-fetched, I suppose; although... o _ _ _ _o /\_ _ \\o (_)\__/o (_) _< \_ _>(_) (_)/<_ \_| \ _|/' \/ (_)>(_) (_) (_) (_) (_)' _\o_ /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ download, build and distribute -- http://www.A-A-P.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///