To: vim_dev@googlegroups.com Subject: Patch 8.0.0636 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.0636 Problem: When reading the undo file fails may use uninitialized data. Solution: Always clear the buffer on failure. Files: src/undo.c *** ../vim-8.0.0635/src/undo.c 2017-03-16 17:23:26.839815753 +0100 --- src/undo.c 2017-06-11 23:03:10.198569279 +0200 *************** *** 1063,1068 **** --- 1063,1070 ---- static int undo_read(bufinfo_T *bi, char_u *buffer, size_t size) { + int retval = OK; + #ifdef FEAT_CRYPT if (bi->bi_buffer != NULL) { *************** *** 1078,1087 **** n = fread(bi->bi_buffer, 1, (size_t)CRYPT_BUF_SIZE, bi->bi_fp); if (n == 0) { ! /* Error may be checked for only later. Fill with zeros, ! * so that the reader won't use garbage. */ ! vim_memset(p, 0, size_todo); ! return FAIL; } bi->bi_avail = n; bi->bi_used = 0; --- 1080,1087 ---- n = fread(bi->bi_buffer, 1, (size_t)CRYPT_BUF_SIZE, bi->bi_fp); if (n == 0) { ! retval = FAIL; ! break; } bi->bi_avail = n; bi->bi_used = 0; *************** *** 1095,1106 **** size_todo -= (int)n; p += n; } - return OK; } #endif if (fread(buffer, (size_t)size, 1, bi->bi_fp) != 1) ! return FAIL; ! return OK; } /* --- 1095,1111 ---- size_todo -= (int)n; p += n; } } + else #endif if (fread(buffer, (size_t)size, 1, bi->bi_fp) != 1) ! retval = FAIL; ! ! if (retval == FAIL) ! /* Error may be checked for only later. Fill with zeros, ! * so that the reader won't use garbage. */ ! vim_memset(buffer, 0, size); ! return retval; } /* *** ../vim-8.0.0635/src/version.c 2017-06-11 17:09:50.614252000 +0200 --- src/version.c 2017-06-11 23:04:09.074198894 +0200 *************** *** 766,767 **** --- 766,769 ---- { /* Add new patch number below this line */ + /**/ + 636, /**/ -- I'm not familiar with this proof, but I'm aware of a significant following of toddlers who believe that peanut butter is the solution to all of life's problems... -- Tim Hammerquist /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///