X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftinfo%2Fread_entry.c;h=44811512fbaec600b1fbbb339ba1e8e1a864ca4c;hp=92b532636b03fe0869b58451b0b31ca8f16f859d;hb=74137fec04e130a88ef25618cf730af988a4f51a;hpb=073e4446d2def7ebf1f0ff4f124f0c8d4af0b788 diff --git a/ncurses/tinfo/read_entry.c b/ncurses/tinfo/read_entry.c index 92b53263..44811512 100644 --- a/ncurses/tinfo/read_entry.c +++ b/ncurses/tinfo/read_entry.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2016,2017 Free Software Foundation, Inc. * + * Copyright (c) 1998-2017,2018 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -41,7 +41,7 @@ #include -MODULE_ID("$Id: read_entry.c,v 1.144 2017/10/23 21:20:06 tom Exp $") +MODULE_ID("$Id: read_entry.c,v 1.147 2018/04/01 01:32:39 tom Exp $") #define TYPE_CALLOC(type,elts) typeCalloc(type, (unsigned)(elts)) @@ -384,18 +384,18 @@ _nc_read_termtype(TERMTYPE2 *ptr, char *buffer, int limit) int ext_bool_count = MyNumber(buf + 0); int ext_num_count = MyNumber(buf + 2); int ext_str_count = MyNumber(buf + 4); - int ext_str_size = MyNumber(buf + 6); + int ext_str_usage = MyNumber(buf + 6); int ext_str_limit = MyNumber(buf + 8); unsigned need = (unsigned) (ext_bool_count + ext_num_count + ext_str_count); int base = 0; if ((int) need >= (max_entry_size / 2) - || ext_str_size >= max_entry_size + || ext_str_usage >= max_entry_size || ext_str_limit >= max_entry_size || ext_bool_count < 0 || ext_num_count < 0 || ext_str_count < 0 - || ext_str_size < 0 + || ext_str_usage < 0 || ext_str_limit < 0) { returnDB(TGETENT_NO); } @@ -408,9 +408,15 @@ _nc_read_termtype(TERMTYPE2 *ptr, char *buffer, int limit) TYPE_REALLOC(NCURSES_INT2, ptr->num_Numbers, ptr->Numbers); TYPE_REALLOC(char *, ptr->num_Strings, ptr->Strings); - TR(TRACE_DATABASE, ("extended header is %d/%d/%d(%d:%d)", - ext_bool_count, ext_num_count, ext_str_count, - ext_str_size, ext_str_limit)); + TR(TRACE_DATABASE, ("extended header: " + "bool %d, " + "number %d, " + "string %d(%d:%d)", + ext_bool_count, + ext_num_count, + ext_str_count, + ext_str_usage, + ext_str_limit)); TR(TRACE_DATABASE, ("READ %d extended-booleans @%d", ext_bool_count, offset)); @@ -456,8 +462,11 @@ _nc_read_termtype(TERMTYPE2 *ptr, char *buffer, int limit) } if ((ptr->ext_Strings = UShort(ext_str_count)) != 0) { + int check = (ext_bool_count + ext_num_count + ext_str_count); + TR(TRACE_DATABASE, - ("Before computing extended-string capabilities str_count=%d, ext_str_count=%d", + ("Before computing extended-string capabilities " + "str_count=%d, ext_str_count=%d", str_count, ext_str_count)); convert_strings(buf, ptr->Strings + str_count, ext_str_count, ext_str_limit, ptr->ext_str_table); @@ -466,12 +475,22 @@ _nc_read_termtype(TERMTYPE2 *ptr, char *buffer, int limit) i, i + str_count, _nc_visbuf(ptr->Strings[i + str_count]))); ptr->Strings[i + STRCOUNT] = ptr->Strings[i + str_count]; - if (VALID_STRING(ptr->Strings[i + STRCOUNT])) + if (VALID_STRING(ptr->Strings[i + STRCOUNT])) { base += (int) (strlen(ptr->Strings[i + STRCOUNT]) + 1); + ++check; + } TR(TRACE_DATABASE, ("... to [%d] %s", i + STRCOUNT, _nc_visbuf(ptr->Strings[i + STRCOUNT]))); } + TR(TRACE_DATABASE, ("Check table-size: %d/%d", check, ext_str_usage)); +#if 0 + /* + * Phasing in a proper check will be done "later". + */ + if (check != ext_str_usage) + returnDB(TGETENT_NO); +#endif } if (need) {