To: vim_dev@googlegroups.com Subject: Patch 8.1.08 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.0898 Problem: A messed up rgb.txt can crash Vim. (Pavel Cheremushkin) Solution: Limit to 10000 entries. Also don't retry many times when the file cannot be read. Files: src/term.c *** ../vim-8.1.0897/src/term.c 2019-01-24 17:18:37.595462334 +0100 --- src/term.c 2019-02-12 20:41:40.212978067 +0100 *************** *** 6985,6997 **** return rgb_table[i].color; /* ! * Last attempt. Look in the file "$VIM/rgb.txt". */ if (size == 0) { int counting; ! /* colornames_table not yet initialized */ fname = expand_env_save((char_u *)"$VIMRUNTIME/rgb.txt"); if (fname == NULL) return INVALCOLOR; --- 6985,6997 ---- return rgb_table[i].color; /* ! * Last attempt. Look in the file "$VIMRUNTIME/rgb.txt". */ if (size == 0) { int counting; ! // colornames_table not yet initialized fname = expand_env_save((char_u *)"$VIMRUNTIME/rgb.txt"); if (fname == NULL) return INVALCOLOR; *************** *** 7002,7007 **** --- 7002,7008 ---- { if (p_verbose > 1) verb_msg(_("Cannot open $VIMRUNTIME/rgb.txt")); + size = -1; // don't try again return INVALCOLOR; } *************** *** 7050,7055 **** --- 7051,7061 ---- colornames_table[size].color = (guicolor_T)RGB(r, g, b); } size++; + + // The distributed rgb.txt has less than 1000 entries. Limit to + // 10000, just in case the file was messed up. + if (size == 10000) + break; } } fclose(fd); *** ../vim-8.1.0897/src/version.c 2019-02-11 22:00:07.671917613 +0100 --- src/version.c 2019-02-12 20:42:30.340701182 +0100 *************** *** 785,786 **** --- 785,788 ---- { /* Add new patch number below this line */ + /**/ + 898, /**/ -- God made machine language; all the rest is the work of man. /// 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 ///