summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2010-05-24 11:59:29 +0200
committerBram Moolenaar <Bram@vim.org>2010-05-24 11:59:29 +0200
commit7db5fc838a7f701e495d41b0ff6a070591c84340 (patch)
treeac8f061dafa07580e8b6cf3fedcd290a9f43d3ac
parent55debbe38429b81c0ce6e8400aef36812eb151d7 (diff)
Fix uninit memory read in undo code. Fix uint32_t in proto file.
A few minor changes.
-rw-r--r--runtime/doc/todo.txt15
-rw-r--r--runtime/doc/undo.txt5
-rw-r--r--src/blowfish.c2
-rw-r--r--src/ex_docmd.c2
-rw-r--r--src/fileio.c2
-rw-r--r--src/gui_mac.c2
-rw-r--r--src/gui_motif.c2
-rw-r--r--src/gui_w48.c8
-rw-r--r--src/hardcopy.c4
-rw-r--r--src/integration.c2
-rw-r--r--src/main.c2
-rw-r--r--src/misc2.c2
-rw-r--r--src/netbeans.c9
-rw-r--r--src/os_macosx.c2
-rw-r--r--src/os_mswin.c8
-rw-r--r--src/os_win32.c2
-rw-r--r--src/proto/sha256.pro2
-rw-r--r--src/sha256.c2
-rw-r--r--src/syntax.c4
-rw-r--r--src/undo.c5
-rw-r--r--src/vim.h12
21 files changed, 50 insertions, 44 deletions
diff --git a/runtime/doc/todo.txt b/runtime/doc/todo.txt
index 49fc70a4d5..e41a5da392 100644
--- a/runtime/doc/todo.txt
+++ b/runtime/doc/todo.txt
@@ -1084,9 +1084,14 @@ restored. (Luc St-Louis)
Vim 7.3:
+- Use NSIS 2.45, it includes Windows 7 support.
+ Include "RequestExecutionLevel highest"
+ Ron's version: http://dev.ronware.org/p/vim/finfo?name=gvim.nsi
+- Supply a 64 bit version of gvimext.dll for 64 bit windows.
+ http://code.google.com/p/vim-win3264/
+ Gvim can be 32 bit.
Patches to include:
-8 Persistent undo bugs / fixes:
- - Add tests. Also with different 'enc'
+- Persistent undo bugs / fixes:
- Add undofile(name): get undo file name for buffer "name".
- Extend test62 for gettabvar() and settabvar(). (Yegappan Lakshmanan, 2010
May 23)
@@ -1152,12 +1157,6 @@ Patches to include:
Patch for Make_ming.mak from Paul Moore (2008 Sep 1)
http://code.google.com/p/vim-iflua/ Download vim72-lua-0.7.patch.gz
Needs some work:
-- Use NSIS 2.45, it includes Windows 7 support.
- Include "RequestExecutionLevel highest"
- Ron's version: http://dev.ronware.org/p/vim/finfo?name=gvim.nsi
-- Supply a 64 bit version of gvimext.dll for 64 bit windows.
- http://code.google.com/p/vim-win3264/
- Gvim can be 32 bit.
- Have a look at patch to enable screen access from Python. (Marko Mahnic,
2010 Apr 12)
- Patch for Python 3 support. (Roland Puntaier, 2009 Sep 22)
diff --git a/runtime/doc/undo.txt b/runtime/doc/undo.txt
index 05e5555b77..2c5568ea27 100644
--- a/runtime/doc/undo.txt
+++ b/runtime/doc/undo.txt
@@ -263,9 +263,10 @@ Reading an existing undo file may fail for several reasons:
*E824* The version number of the undo file indicates that it's written by a
newer version of Vim. You need that newer version to open it. Don't
write the buffer if you want to keep the undo info in the file.
-"Undo file contents changed"
+"File contents changed, cannot use undo info"
The file text differs from when the undo file was written. This means
- the undo file cannot be used, it would corrupt the text.
+ the undo file cannot be used, it would corrupt the text. This also
+ happens when 'encoding' differs from when the undo file was written.
*E825* *E826* The undo file does not contain valid contents and cannot be
used.
*E827* The magic number at the end of the file was not found. This usually
diff --git a/src/blowfish.c b/src/blowfish.c
index 01e0993065..02d9008fdc 100644
--- a/src/blowfish.c
+++ b/src/blowfish.c
@@ -542,7 +542,7 @@ bf_ofb_init(iv, iv_len)
int i, mi;
randbyte_offset = update_offset = 0;
- memset(ofb_buffer, 0, BF_OFB_LEN);
+ vim_memset(ofb_buffer, 0, BF_OFB_LEN);
if (iv_len > 0)
{
mi = iv_len > BF_OFB_LEN ? iv_len : BF_OFB_LEN;
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 4097f1d8f2..6d0ce2413e 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -847,7 +847,7 @@ do_cmdline(cmdline, getline, cookie, flags)
if (flags & DOCMD_EXCRESET)
save_dbg_stuff(&debug_saved);
else
- memset(&debug_saved, 0, 1);
+ vim_memset(&debug_saved, 0, 1);
initial_trylevel = trylevel;
diff --git a/src/fileio.c b/src/fileio.c
index b7c86af7ef..779a0d6a95 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -4328,7 +4328,7 @@ restore_backup:
use_crypt_method = buf->b_p_cm; /* select pkzip or blowfish */
- memset(header, 0, sizeof(header));
+ vim_memset(header, 0, sizeof(header));
vim_strncpy(header, (char_u *)crypt_magic[use_crypt_method],
CRYPT_MAGIC_LEN);
diff --git a/src/gui_mac.c b/src/gui_mac.c
index 9112c56b71..8859857637 100644
--- a/src/gui_mac.c
+++ b/src/gui_mac.c
@@ -5654,7 +5654,7 @@ gui_mch_dialog(
button = 0;
/* initialize the hotkey mapping */
- memset(hotKeys, 0, sizeof(hotKeys));
+ vim_memset(hotKeys, 0, sizeof(hotKeys));
for (;*buttonChar != 0;)
{
diff --git a/src/gui_motif.c b/src/gui_motif.c
index 1a7e03872c..397ab597d5 100644
--- a/src/gui_motif.c
+++ b/src/gui_motif.c
@@ -2023,7 +2023,7 @@ do_mnemonic(Widget w, unsigned int keycode)
XmProcessTraversal(w, XmTRAVERSE_CURRENT);
- memset((char *) &keyEvent, 0, sizeof(XKeyPressedEvent));
+ vim_memset((char *) &keyEvent, 0, sizeof(XKeyPressedEvent));
keyEvent.type = KeyPress;
keyEvent.serial = 1;
keyEvent.send_event = True;
diff --git a/src/gui_w48.c b/src/gui_w48.c
index 2f36739834..6e567f69eb 100644
--- a/src/gui_w48.c
+++ b/src/gui_w48.c
@@ -3341,7 +3341,7 @@ gui_mch_browseW(
/* Convert the filter to Windows format. */
filterp = convert_filterW(filter);
- memset(&fileStruct, 0, sizeof(OPENFILENAMEW));
+ vim_memset(&fileStruct, 0, sizeof(OPENFILENAMEW));
#ifdef OPENFILENAME_SIZE_VERSION_400
/* be compatible with Windows NT 4.0 */
/* TODO: what to use for OPENFILENAMEW??? */
@@ -3503,7 +3503,7 @@ gui_mch_browse(
/* Convert the filter to Windows format. */
filterp = convert_filter(filter);
- memset(&fileStruct, 0, sizeof(OPENFILENAME));
+ vim_memset(&fileStruct, 0, sizeof(OPENFILENAME));
#ifdef OPENFILENAME_SIZE_VERSION_400
/* be compatible with Windows NT 4.0 */
fileStruct.lStructSize = OPENFILENAME_SIZE_VERSION_400;
@@ -3842,7 +3842,7 @@ get_cmd_args(char *prog, char *cmdline, char ***argvp, char **tofree)
/* Halve the number of backslashes. */
if (i > 1 && pnew != NULL)
{
- memset(pnew, '\\', i / 2);
+ vim_memset(pnew, '\\', i / 2);
pnew += i / 2;
}
@@ -3859,7 +3859,7 @@ get_cmd_args(char *prog, char *cmdline, char ***argvp, char **tofree)
/* Copy span of backslashes unmodified. */
if (pnew != NULL)
{
- memset(pnew, '\\', i);
+ vim_memset(pnew, '\\', i);
pnew += i;
}
p += i;
diff --git a/src/hardcopy.c b/src/hardcopy.c
index 0e7ee4ddd8..e70390d443 100644
--- a/src/hardcopy.c
+++ b/src/hardcopy.c
@@ -568,7 +568,7 @@ ex_hardcopy(eap)
int page_line;
int jobsplit;
- memset(&settings, 0, sizeof(prt_settings_T));
+ vim_memset(&settings, 0, sizeof(prt_settings_T));
settings.has_color = TRUE;
# ifdef FEAT_POSTSCRIPT
@@ -691,7 +691,7 @@ ex_hardcopy(eap)
prt_pos_T page_prtpos; /* print position at page start */
int side;
- memset(&page_prtpos, 0, sizeof(prt_pos_T));
+ vim_memset(&page_prtpos, 0, sizeof(prt_pos_T));
page_prtpos.file_line = eap->line1;
prtpos = page_prtpos;
diff --git a/src/integration.c b/src/integration.c
index c86a8a5fe7..9da6e2faa0 100644
--- a/src/integration.c
+++ b/src/integration.c
@@ -662,7 +662,7 @@ void workshop_connect(XtAppContext context)
/* Get the server internet address and put into addr structure */
/* fill in the socket address structure and connect to server */
- memset((char *)&server, '\0', sizeof(server));
+ vim_memset((char *)&server, '\0', sizeof(server));
server.sin_family = AF_INET;
server.sin_port = port;
if ((host = gethostbyname(NOCATGETS("localhost"))) == NULL) {
diff --git a/src/main.c b/src/main.c
index cba40ea0f3..ec7675e47a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -3643,7 +3643,7 @@ cmdsrv_main(argc, argv, serverName_arg, serverStr)
# endif
/* Wait for all files to unload in remote */
- memset(done, 0, numFiles);
+ vim_memset(done, 0, numFiles);
while (memchr(done, 0, numFiles) != NULL)
{
# ifdef WIN32
diff --git a/src/misc2.c b/src/misc2.c
index 6d13f1ce50..03af4cc8f4 100644
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -4178,7 +4178,7 @@ vim_findfile_init(path, filename, stopdirs, level, free_visited, find_what,
search_ctx = (ff_search_ctx_T*)alloc((unsigned)sizeof(ff_search_ctx_T));
if (search_ctx == NULL)
goto error_return;
- memset(search_ctx, 0, sizeof(ff_search_ctx_T));
+ vim_memset(search_ctx, 0, sizeof(ff_search_ctx_T));
}
search_ctx->ffsc_find_what = find_what;
diff --git a/src/netbeans.c b/src/netbeans.c
index 9e31fba0af..bd83f6489d 100644
--- a/src/netbeans.c
+++ b/src/netbeans.c
@@ -303,7 +303,7 @@ netbeans_connect(char *params, int abort)
/* Get the server internet address and put into addr structure */
/* fill in the socket address structure and connect to server */
- memset((char *)&server, '\0', sizeof(server));
+ vim_memset((char *)&server, '\0', sizeof(server));
server.sin_family = AF_INET;
server.sin_port = htons(port);
if ((host = gethostbyname(hostname)) == NULL)
@@ -1079,7 +1079,8 @@ nb_get_buf(int bufno)
buf_list_size += incr;
buf_list = (nbbuf_T *)vim_realloc(
buf_list, buf_list_size * sizeof(nbbuf_T));
- memset(buf_list + buf_list_size - incr, 0, incr * sizeof(nbbuf_T));
+ vim_memset(buf_list + buf_list_size - incr, 0,
+ incr * sizeof(nbbuf_T));
}
while (buf_list_used <= bufno)
@@ -3662,7 +3663,7 @@ addsigntype(
incr = globalsignmaplen - oldlen;
globalsignmap = (char **)vim_realloc(globalsignmap,
globalsignmaplen * sizeof(char *));
- memset(globalsignmap + oldlen, 0, incr * sizeof(char *));
+ vim_memset(globalsignmap + oldlen, 0, incr * sizeof(char *));
}
}
@@ -3691,7 +3692,7 @@ addsigntype(
incr = buf->signmaplen - oldlen;
buf->signmap = (int *)vim_realloc(buf->signmap,
buf->signmaplen*sizeof(int *));
- memset(buf->signmap + oldlen, 0, incr * sizeof(int *));
+ vim_memset(buf->signmap + oldlen, 0, incr * sizeof(int *));
}
}
diff --git a/src/os_macosx.c b/src/os_macosx.c
index 48023e3d3b..0868ef0479 100644
--- a/src/os_macosx.c
+++ b/src/os_macosx.c
@@ -291,7 +291,7 @@ iconv_open(const char* tocode, const char* fromcode)
cd = (iconv_t)alloc(sizeof(struct _iconv_t));
if (!cd)
goto ICONV_OPEN_ERR;
- memset(cd, 0, sizeof(struct _iconv_t));
+ vim_memset(cd, 0, sizeof(struct _iconv_t));
/* Create converter */
if (fromEnc != toEnc)
diff --git a/src/os_mswin.c b/src/os_mswin.c
index c3588e6f56..2e692a70eb 100644
--- a/src/os_mswin.c
+++ b/src/os_mswin.c
@@ -2077,7 +2077,7 @@ mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit)
int i;
bUserAbort = &(psettings->user_abort);
- memset(&prt_dlg, 0, sizeof(PRINTDLG));
+ vim_memset(&prt_dlg, 0, sizeof(PRINTDLG));
prt_dlg.lStructSize = sizeof(PRINTDLG);
#ifndef FEAT_GUI
GetConsoleHwnd(); /* get value of s_hwnd */
@@ -2192,7 +2192,7 @@ mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit)
/*
* Initialise the font according to 'printfont'
*/
- memset(&fLogFont, 0, sizeof(fLogFont));
+ vim_memset(&fLogFont, 0, sizeof(fLogFont));
if (get_logfont(&fLogFont, p_pfn, prt_dlg.hDC, TRUE) == FAIL)
{
EMSG2(_("E613: Unknown printer font: %s"), p_pfn);
@@ -2285,7 +2285,7 @@ mch_print_begin(prt_settings_T *psettings)
wsprintf(szBuffer, _("Printing '%s'"), gettail(psettings->jobname));
SetDlgItemText(hDlgPrint, IDC_PRINTTEXT1, (LPSTR)szBuffer);
- memset(&di, 0, sizeof(DOCINFO));
+ vim_memset(&di, 0, sizeof(DOCINFO));
di.cbSize = sizeof(DOCINFO);
di.lpszDocName = psettings->jobname;
ret = StartDoc(prt_dlg.hDC, &di);
@@ -3362,7 +3362,7 @@ get_logfont(
#if defined(FEAT_GUI_W32)
CHOOSEFONT cf;
/* if name is "*", bring up std font dialog: */
- memset(&cf, 0, sizeof(cf));
+ vim_memset(&cf, 0, sizeof(cf));
cf.lStructSize = sizeof(cf);
cf.hwndOwner = s_hwnd;
cf.Flags = CF_SCREENFONTS | CF_FIXEDPITCHONLY | CF_INITTOLOGFONTSTRUCT;
diff --git a/src/os_win32.c b/src/os_win32.c
index 3d0ba7ddfd..0ba2391077 100644
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -604,7 +604,7 @@ win32_kbd_patch_key(
if (pker->AChar != 0)
return 1;
- memset(abKeystate, 0, sizeof (abKeystate));
+ vim_memset(abKeystate, 0, sizeof (abKeystate));
// Should only be non-NULL on NT 4.0
if (s_pfnGetConsoleKeyboardLayoutName != NULL)
diff --git a/src/proto/sha256.pro b/src/proto/sha256.pro
index e9a3d3cdd8..c5237f439f 100644
--- a/src/proto/sha256.pro
+++ b/src/proto/sha256.pro
@@ -1,6 +1,6 @@
/* sha256.c */
void sha256_start __ARGS((context_sha256_T *ctx));
-void sha256_update __ARGS((context_sha256_T *ctx, char_u *input, uint32_t length));
+void sha256_update __ARGS((context_sha256_T *ctx, char_u *input, UINT32_T length));
void sha256_finish __ARGS((context_sha256_T *ctx, char_u digest[32]));
char_u *sha256_key __ARGS((char_u *buf));
int sha256_self_test __ARGS((void));
diff --git a/src/sha256.c b/src/sha256.c
index 048ce75fe1..6ea3f81f4a 100644
--- a/src/sha256.c
+++ b/src/sha256.c
@@ -360,7 +360,7 @@ sha256_self_test()
else
{
sha256_start(&ctx);
- memset(buf, 'a', 1000);
+ vim_memset(buf, 'a', 1000);
for (j = 0; j < 1000; j++)
sha256_update(&ctx, (char_u *)buf, 1000);
sha256_finish(&ctx, sha256sum);
diff --git a/src/syntax.c b/src/syntax.c
index 1eeb9bc8b3..9613482905 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -8986,7 +8986,7 @@ highlight_changed()
hlcnt = highlight_ga.ga_len;
if (id_S == 0)
{ /* Make sure id_S is always valid to simplify code below */
- memset(&HL_TABLE()[hlcnt + 9], 0, sizeof(struct hl_group));
+ vim_memset(&HL_TABLE()[hlcnt + 9], 0, sizeof(struct hl_group));
HL_TABLE()[hlcnt + 9].sg_term = highlight_attr[HLF_S];
id_S = hlcnt + 10;
}
@@ -9012,7 +9012,7 @@ highlight_changed()
# ifdef FEAT_STL_OPT
if (id_SNC == 0)
{
- memset(&hlt[hlcnt + i], 0, sizeof(struct hl_group));
+ vim_memset(&hlt[hlcnt + i], 0, sizeof(struct hl_group));
hlt[hlcnt + i].sg_term = highlight_attr[HLF_SNC];
hlt[hlcnt + i].sg_cterm = highlight_attr[HLF_SNC];
# ifdef FEAT_GUI
diff --git a/src/undo.c b/src/undo.c
index b4945d12e1..44a7c95315 100644
--- a/src/undo.c
+++ b/src/undo.c
@@ -595,6 +595,7 @@ u_savecommon(top, bot, newbot)
uep = (u_entry_T *)U_ALLOC_LINE((unsigned)sizeof(u_entry_T));
if (uep == NULL)
goto nomem;
+ vim_memset(uep, 0, sizeof(u_entry_T));
#ifdef U_DEBUG
uep->ue_magic = UE_MAGIC;
#endif
@@ -879,7 +880,7 @@ u_read_undo(name, hash)
if (p_verbose > 0 || name != NULL)
{
verbose_enter();
- give_warning((char_u *)_("Undo file contents changed"), TRUE);
+ give_warning((char_u *)_("File contents changed, cannot use undo info"), TRUE);
verbose_leave();
}
goto error;
@@ -967,9 +968,9 @@ u_read_undo(name, hash)
while ((uep_len = get4c(fp)) != -1)
{
uep = (u_entry_T *)U_ALLOC_LINE((unsigned)sizeof(u_entry_T));
- vim_memset(uep, 0, sizeof(u_entry_T));
if (uep == NULL)
goto error;
+ vim_memset(uep, 0, sizeof(u_entry_T));
uep->ue_top = get4c(fp);
uep->ue_bot = get4c(fp);
uep->ue_lcount = get4c(fp);
diff --git a/src/vim.h b/src/vim.h
index 0447273106..86d677be67 100644
--- a/src/vim.h
+++ b/src/vim.h
@@ -51,16 +51,16 @@
/* We may need to define the uint32_t on non-Unix system, but using the same
* identifier causes conflicts. Therefore use UINT32_T. */
-# define UINT32_T uint32_t
+# define UINT32_TYPEDEF uint32_t
#endif
-#if !defined(UINT32_T)
+#if !defined(UINT32_TYPEDEF)
# if defined(uint32_t) /* this doesn't catch typedefs, unfortunately */
-# define UINT32_T uint32_t
+# define UINT32_TYPEDEF uint32_t
# else
/* Fall back to assuming unsigned int is 32 bit. If this is wrong then the
* test in blowfish.c will fail. */
-# define UINT32_T unsigned int
+# define UINT32_TYPEDEF unsigned int
# endif
#endif
@@ -1317,6 +1317,10 @@ typedef enum
#define MAYBE 2 /* sometimes used for a variant on TRUE */
+#ifndef UINT32_T
+typedef UINT32_TYPEDEF UINT32_T;
+#endif
+
/*
* Operator IDs; The order must correspond to opchars[] in ops.c!
*/