123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- diff --git a/ncurses/tinfo/read_entry.c b/ncurses/tinfo/read_entry.c
- index 41ef0d0aa..66e3d31ee 100644
- --- a/ncurses/tinfo/read_entry.c
- +++ b/ncurses/tinfo/read_entry.c
- @@ -1,5 +1,5 @@
- /****************************************************************************
- - * Copyright 2018-2020,2021 Thomas E. Dickey *
- + * Copyright 2018-2021,2022 Thomas E. Dickey *
- * Copyright 1998-2016,2017 Free Software Foundation, Inc. *
- * *
- * Permission is hereby granted, free of charge, to any person obtaining a *
- @@ -42,7 +42,7 @@
-
- #include <tic.h>
-
- -MODULE_ID("$Id: read_entry.c,v 1.161 2021/06/26 19:43:17 tom Exp $")
- +MODULE_ID("$Id: read_entry.c,v 1.162 2022/04/16 21:00:00 tom Exp $")
-
- #define TYPE_CALLOC(type,elts) typeCalloc(type, (unsigned)(elts))
-
- @@ -145,6 +145,7 @@ convert_strings(char *buf, char **Strings, int count, int size, char *table)
- {
- int i;
- char *p;
- + bool corrupt = FALSE;
-
- for (i = 0; i < count; i++) {
- if (IS_NEG1(buf + 2 * i)) {
- @@ -154,8 +155,20 @@ convert_strings(char *buf, char **Strings, int count, int size, char *table)
- } else if (MyNumber(buf + 2 * i) > size) {
- Strings[i] = ABSENT_STRING;
- } else {
- - Strings[i] = (MyNumber(buf + 2 * i) + table);
- - TR(TRACE_DATABASE, ("Strings[%d] = %s", i, _nc_visbuf(Strings[i])));
- + int nn = MyNumber(buf + 2 * i);
- + if (nn >= 0 && nn < size) {
- + Strings[i] = (nn + table);
- + TR(TRACE_DATABASE, ("Strings[%d] = %s", i,
- + _nc_visbuf(Strings[i])));
- + } else {
- + if (!corrupt) {
- + corrupt = TRUE;
- + TR(TRACE_DATABASE,
- + ("ignore out-of-range index %d to Strings[]", nn));
- + _nc_warning("corrupt data found in convert_strings");
- + }
- + Strings[i] = ABSENT_STRING;
- + }
- }
-
- /* make sure all strings are NUL terminated */
|