0
0
mirror of https://github.com/vim/vim.git synced 2025-07-25 10:54:51 -04:00

Fix uninit memory read in undo code. Fix uint32_t in proto file.

A few minor changes.
This commit is contained in:
Bram Moolenaar 2010-05-24 11:59:29 +02:00
parent 55debbe384
commit 7db5fc838a
21 changed files with 50 additions and 44 deletions

View File

@ -1084,9 +1084,14 @@ restored. (Luc St-Louis)
Vim 7.3: 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: Patches to include:
8 Persistent undo bugs / fixes: - Persistent undo bugs / fixes:
- Add tests. Also with different 'enc'
- Add undofile(name): get undo file name for buffer "name". - Add undofile(name): get undo file name for buffer "name".
- Extend test62 for gettabvar() and settabvar(). (Yegappan Lakshmanan, 2010 - Extend test62 for gettabvar() and settabvar(). (Yegappan Lakshmanan, 2010
May 23) May 23)
@ -1152,12 +1157,6 @@ Patches to include:
Patch for Make_ming.mak from Paul Moore (2008 Sep 1) 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 http://code.google.com/p/vim-iflua/ Download vim72-lua-0.7.patch.gz
Needs some work: 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, - Have a look at patch to enable screen access from Python. (Marko Mahnic,
2010 Apr 12) 2010 Apr 12)
- Patch for Python 3 support. (Roland Puntaier, 2009 Sep 22) - Patch for Python 3 support. (Roland Puntaier, 2009 Sep 22)

View File

@ -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 *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 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. 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 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 *E825* *E826* The undo file does not contain valid contents and cannot be
used. used.
*E827* The magic number at the end of the file was not found. This usually *E827* The magic number at the end of the file was not found. This usually

View File

@ -542,7 +542,7 @@ bf_ofb_init(iv, iv_len)
int i, mi; int i, mi;
randbyte_offset = update_offset = 0; randbyte_offset = update_offset = 0;
memset(ofb_buffer, 0, BF_OFB_LEN); vim_memset(ofb_buffer, 0, BF_OFB_LEN);
if (iv_len > 0) if (iv_len > 0)
{ {
mi = iv_len > BF_OFB_LEN ? iv_len : BF_OFB_LEN; mi = iv_len > BF_OFB_LEN ? iv_len : BF_OFB_LEN;

View File

@ -847,7 +847,7 @@ do_cmdline(cmdline, getline, cookie, flags)
if (flags & DOCMD_EXCRESET) if (flags & DOCMD_EXCRESET)
save_dbg_stuff(&debug_saved); save_dbg_stuff(&debug_saved);
else else
memset(&debug_saved, 0, 1); vim_memset(&debug_saved, 0, 1);
initial_trylevel = trylevel; initial_trylevel = trylevel;

View File

@ -4328,7 +4328,7 @@ restore_backup:
use_crypt_method = buf->b_p_cm; /* select pkzip or blowfish */ 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], vim_strncpy(header, (char_u *)crypt_magic[use_crypt_method],
CRYPT_MAGIC_LEN); CRYPT_MAGIC_LEN);

View File

@ -5654,7 +5654,7 @@ gui_mch_dialog(
button = 0; button = 0;
/* initialize the hotkey mapping */ /* initialize the hotkey mapping */
memset(hotKeys, 0, sizeof(hotKeys)); vim_memset(hotKeys, 0, sizeof(hotKeys));
for (;*buttonChar != 0;) for (;*buttonChar != 0;)
{ {

View File

@ -2023,7 +2023,7 @@ do_mnemonic(Widget w, unsigned int keycode)
XmProcessTraversal(w, XmTRAVERSE_CURRENT); XmProcessTraversal(w, XmTRAVERSE_CURRENT);
memset((char *) &keyEvent, 0, sizeof(XKeyPressedEvent)); vim_memset((char *) &keyEvent, 0, sizeof(XKeyPressedEvent));
keyEvent.type = KeyPress; keyEvent.type = KeyPress;
keyEvent.serial = 1; keyEvent.serial = 1;
keyEvent.send_event = True; keyEvent.send_event = True;

View File

@ -3341,7 +3341,7 @@ gui_mch_browseW(
/* Convert the filter to Windows format. */ /* Convert the filter to Windows format. */
filterp = convert_filterW(filter); filterp = convert_filterW(filter);
memset(&fileStruct, 0, sizeof(OPENFILENAMEW)); vim_memset(&fileStruct, 0, sizeof(OPENFILENAMEW));
#ifdef OPENFILENAME_SIZE_VERSION_400 #ifdef OPENFILENAME_SIZE_VERSION_400
/* be compatible with Windows NT 4.0 */ /* be compatible with Windows NT 4.0 */
/* TODO: what to use for OPENFILENAMEW??? */ /* TODO: what to use for OPENFILENAMEW??? */
@ -3503,7 +3503,7 @@ gui_mch_browse(
/* Convert the filter to Windows format. */ /* Convert the filter to Windows format. */
filterp = convert_filter(filter); filterp = convert_filter(filter);
memset(&fileStruct, 0, sizeof(OPENFILENAME)); vim_memset(&fileStruct, 0, sizeof(OPENFILENAME));
#ifdef OPENFILENAME_SIZE_VERSION_400 #ifdef OPENFILENAME_SIZE_VERSION_400
/* be compatible with Windows NT 4.0 */ /* be compatible with Windows NT 4.0 */
fileStruct.lStructSize = OPENFILENAME_SIZE_VERSION_400; 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. */ /* Halve the number of backslashes. */
if (i > 1 && pnew != NULL) if (i > 1 && pnew != NULL)
{ {
memset(pnew, '\\', i / 2); vim_memset(pnew, '\\', i / 2);
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. */ /* Copy span of backslashes unmodified. */
if (pnew != NULL) if (pnew != NULL)
{ {
memset(pnew, '\\', i); vim_memset(pnew, '\\', i);
pnew += i; pnew += i;
} }
p += i; p += i;

View File

@ -568,7 +568,7 @@ ex_hardcopy(eap)
int page_line; int page_line;
int jobsplit; int jobsplit;
memset(&settings, 0, sizeof(prt_settings_T)); vim_memset(&settings, 0, sizeof(prt_settings_T));
settings.has_color = TRUE; settings.has_color = TRUE;
# ifdef FEAT_POSTSCRIPT # ifdef FEAT_POSTSCRIPT
@ -691,7 +691,7 @@ ex_hardcopy(eap)
prt_pos_T page_prtpos; /* print position at page start */ prt_pos_T page_prtpos; /* print position at page start */
int side; 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; page_prtpos.file_line = eap->line1;
prtpos = page_prtpos; prtpos = page_prtpos;

View File

@ -662,7 +662,7 @@ void workshop_connect(XtAppContext context)
/* Get the server internet address and put into addr structure */ /* Get the server internet address and put into addr structure */
/* fill in the socket address structure and connect to server */ /* 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_family = AF_INET;
server.sin_port = port; server.sin_port = port;
if ((host = gethostbyname(NOCATGETS("localhost"))) == NULL) { if ((host = gethostbyname(NOCATGETS("localhost"))) == NULL) {

View File

@ -3643,7 +3643,7 @@ cmdsrv_main(argc, argv, serverName_arg, serverStr)
# endif # endif
/* Wait for all files to unload in remote */ /* Wait for all files to unload in remote */
memset(done, 0, numFiles); vim_memset(done, 0, numFiles);
while (memchr(done, 0, numFiles) != NULL) while (memchr(done, 0, numFiles) != NULL)
{ {
# ifdef WIN32 # ifdef WIN32

View File

@ -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)); search_ctx = (ff_search_ctx_T*)alloc((unsigned)sizeof(ff_search_ctx_T));
if (search_ctx == NULL) if (search_ctx == NULL)
goto error_return; 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; search_ctx->ffsc_find_what = find_what;

View File

@ -303,7 +303,7 @@ netbeans_connect(char *params, int abort)
/* Get the server internet address and put into addr structure */ /* Get the server internet address and put into addr structure */
/* fill in the socket address structure and connect to server */ /* 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_family = AF_INET;
server.sin_port = htons(port); server.sin_port = htons(port);
if ((host = gethostbyname(hostname)) == NULL) if ((host = gethostbyname(hostname)) == NULL)
@ -1079,7 +1079,8 @@ nb_get_buf(int bufno)
buf_list_size += incr; buf_list_size += incr;
buf_list = (nbbuf_T *)vim_realloc( buf_list = (nbbuf_T *)vim_realloc(
buf_list, buf_list_size * sizeof(nbbuf_T)); 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) while (buf_list_used <= bufno)
@ -3662,7 +3663,7 @@ addsigntype(
incr = globalsignmaplen - oldlen; incr = globalsignmaplen - oldlen;
globalsignmap = (char **)vim_realloc(globalsignmap, globalsignmap = (char **)vim_realloc(globalsignmap,
globalsignmaplen * sizeof(char *)); 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; incr = buf->signmaplen - oldlen;
buf->signmap = (int *)vim_realloc(buf->signmap, buf->signmap = (int *)vim_realloc(buf->signmap,
buf->signmaplen*sizeof(int *)); buf->signmaplen*sizeof(int *));
memset(buf->signmap + oldlen, 0, incr * sizeof(int *)); vim_memset(buf->signmap + oldlen, 0, incr * sizeof(int *));
} }
} }

View File

@ -291,7 +291,7 @@ iconv_open(const char* tocode, const char* fromcode)
cd = (iconv_t)alloc(sizeof(struct _iconv_t)); cd = (iconv_t)alloc(sizeof(struct _iconv_t));
if (!cd) if (!cd)
goto ICONV_OPEN_ERR; goto ICONV_OPEN_ERR;
memset(cd, 0, sizeof(struct _iconv_t)); vim_memset(cd, 0, sizeof(struct _iconv_t));
/* Create converter */ /* Create converter */
if (fromEnc != toEnc) if (fromEnc != toEnc)

View File

@ -2077,7 +2077,7 @@ mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit)
int i; int i;
bUserAbort = &(psettings->user_abort); bUserAbort = &(psettings->user_abort);
memset(&prt_dlg, 0, sizeof(PRINTDLG)); vim_memset(&prt_dlg, 0, sizeof(PRINTDLG));
prt_dlg.lStructSize = sizeof(PRINTDLG); prt_dlg.lStructSize = sizeof(PRINTDLG);
#ifndef FEAT_GUI #ifndef FEAT_GUI
GetConsoleHwnd(); /* get value of s_hwnd */ 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' * 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) if (get_logfont(&fLogFont, p_pfn, prt_dlg.hDC, TRUE) == FAIL)
{ {
EMSG2(_("E613: Unknown printer font: %s"), p_pfn); 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)); wsprintf(szBuffer, _("Printing '%s'"), gettail(psettings->jobname));
SetDlgItemText(hDlgPrint, IDC_PRINTTEXT1, (LPSTR)szBuffer); SetDlgItemText(hDlgPrint, IDC_PRINTTEXT1, (LPSTR)szBuffer);
memset(&di, 0, sizeof(DOCINFO)); vim_memset(&di, 0, sizeof(DOCINFO));
di.cbSize = sizeof(DOCINFO); di.cbSize = sizeof(DOCINFO);
di.lpszDocName = psettings->jobname; di.lpszDocName = psettings->jobname;
ret = StartDoc(prt_dlg.hDC, &di); ret = StartDoc(prt_dlg.hDC, &di);
@ -3362,7 +3362,7 @@ get_logfont(
#if defined(FEAT_GUI_W32) #if defined(FEAT_GUI_W32)
CHOOSEFONT cf; CHOOSEFONT cf;
/* if name is "*", bring up std font dialog: */ /* if name is "*", bring up std font dialog: */
memset(&cf, 0, sizeof(cf)); vim_memset(&cf, 0, sizeof(cf));
cf.lStructSize = sizeof(cf); cf.lStructSize = sizeof(cf);
cf.hwndOwner = s_hwnd; cf.hwndOwner = s_hwnd;
cf.Flags = CF_SCREENFONTS | CF_FIXEDPITCHONLY | CF_INITTOLOGFONTSTRUCT; cf.Flags = CF_SCREENFONTS | CF_FIXEDPITCHONLY | CF_INITTOLOGFONTSTRUCT;

View File

@ -604,7 +604,7 @@ win32_kbd_patch_key(
if (pker->AChar != 0) if (pker->AChar != 0)
return 1; return 1;
memset(abKeystate, 0, sizeof (abKeystate)); vim_memset(abKeystate, 0, sizeof (abKeystate));
// Should only be non-NULL on NT 4.0 // Should only be non-NULL on NT 4.0
if (s_pfnGetConsoleKeyboardLayoutName != NULL) if (s_pfnGetConsoleKeyboardLayoutName != NULL)

View File

@ -1,6 +1,6 @@
/* sha256.c */ /* sha256.c */
void sha256_start __ARGS((context_sha256_T *ctx)); 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])); void sha256_finish __ARGS((context_sha256_T *ctx, char_u digest[32]));
char_u *sha256_key __ARGS((char_u *buf)); char_u *sha256_key __ARGS((char_u *buf));
int sha256_self_test __ARGS((void)); int sha256_self_test __ARGS((void));

View File

@ -360,7 +360,7 @@ sha256_self_test()
else else
{ {
sha256_start(&ctx); sha256_start(&ctx);
memset(buf, 'a', 1000); vim_memset(buf, 'a', 1000);
for (j = 0; j < 1000; j++) for (j = 0; j < 1000; j++)
sha256_update(&ctx, (char_u *)buf, 1000); sha256_update(&ctx, (char_u *)buf, 1000);
sha256_finish(&ctx, sha256sum); sha256_finish(&ctx, sha256sum);

View File

@ -8986,7 +8986,7 @@ highlight_changed()
hlcnt = highlight_ga.ga_len; hlcnt = highlight_ga.ga_len;
if (id_S == 0) if (id_S == 0)
{ /* Make sure id_S is always valid to simplify code below */ { /* 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]; HL_TABLE()[hlcnt + 9].sg_term = highlight_attr[HLF_S];
id_S = hlcnt + 10; id_S = hlcnt + 10;
} }
@ -9012,7 +9012,7 @@ highlight_changed()
# ifdef FEAT_STL_OPT # ifdef FEAT_STL_OPT
if (id_SNC == 0) 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_term = highlight_attr[HLF_SNC];
hlt[hlcnt + i].sg_cterm = highlight_attr[HLF_SNC]; hlt[hlcnt + i].sg_cterm = highlight_attr[HLF_SNC];
# ifdef FEAT_GUI # ifdef FEAT_GUI

View File

@ -595,6 +595,7 @@ u_savecommon(top, bot, newbot)
uep = (u_entry_T *)U_ALLOC_LINE((unsigned)sizeof(u_entry_T)); uep = (u_entry_T *)U_ALLOC_LINE((unsigned)sizeof(u_entry_T));
if (uep == NULL) if (uep == NULL)
goto nomem; goto nomem;
vim_memset(uep, 0, sizeof(u_entry_T));
#ifdef U_DEBUG #ifdef U_DEBUG
uep->ue_magic = UE_MAGIC; uep->ue_magic = UE_MAGIC;
#endif #endif
@ -879,7 +880,7 @@ u_read_undo(name, hash)
if (p_verbose > 0 || name != NULL) if (p_verbose > 0 || name != NULL)
{ {
verbose_enter(); 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(); verbose_leave();
} }
goto error; goto error;
@ -967,9 +968,9 @@ u_read_undo(name, hash)
while ((uep_len = get4c(fp)) != -1) while ((uep_len = get4c(fp)) != -1)
{ {
uep = (u_entry_T *)U_ALLOC_LINE((unsigned)sizeof(u_entry_T)); uep = (u_entry_T *)U_ALLOC_LINE((unsigned)sizeof(u_entry_T));
vim_memset(uep, 0, sizeof(u_entry_T));
if (uep == NULL) if (uep == NULL)
goto error; goto error;
vim_memset(uep, 0, sizeof(u_entry_T));
uep->ue_top = get4c(fp); uep->ue_top = get4c(fp);
uep->ue_bot = get4c(fp); uep->ue_bot = get4c(fp);
uep->ue_lcount = get4c(fp); uep->ue_lcount = get4c(fp);

View File

@ -51,16 +51,16 @@
/* We may need to define the uint32_t on non-Unix system, but using the same /* We may need to define the uint32_t on non-Unix system, but using the same
* identifier causes conflicts. Therefore use UINT32_T. */ * identifier causes conflicts. Therefore use UINT32_T. */
# define UINT32_T uint32_t # define UINT32_TYPEDEF uint32_t
#endif #endif
#if !defined(UINT32_T) #if !defined(UINT32_TYPEDEF)
# if defined(uint32_t) /* this doesn't catch typedefs, unfortunately */ # if defined(uint32_t) /* this doesn't catch typedefs, unfortunately */
# define UINT32_T uint32_t # define UINT32_TYPEDEF uint32_t
# else # else
/* Fall back to assuming unsigned int is 32 bit. If this is wrong then the /* Fall back to assuming unsigned int is 32 bit. If this is wrong then the
* test in blowfish.c will fail. */ * test in blowfish.c will fail. */
# define UINT32_T unsigned int # define UINT32_TYPEDEF unsigned int
# endif # endif
#endif #endif
@ -1317,6 +1317,10 @@ typedef enum
#define MAYBE 2 /* sometimes used for a variant on TRUE */ #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! * Operator IDs; The order must correspond to opchars[] in ops.c!
*/ */