X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftinfo%2Fread_entry.c;h=b34ed8ddc12822eb9adb09eb03d7a7da89a7343e;hp=6a050ee78e666179ba1cf50917bd56bcce565160;hb=cb9a015f6669e86dd5db0fcdf1a6d74c7ea5df55;hpb=40df80d8d3f96c991f55569bce475e71cc38be12 diff --git a/ncurses/tinfo/read_entry.c b/ncurses/tinfo/read_entry.c index 6a050ee7..b34ed8dd 100644 --- a/ncurses/tinfo/read_entry.c +++ b/ncurses/tinfo/read_entry.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2008,2009 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 * @@ -42,7 +42,7 @@ #include #include -MODULE_ID("$Id: read_entry.c,v 1.100 2007/11/17 23:56:50 tom Exp $") +MODULE_ID("$Id: read_entry.c,v 1.105 2009/12/06 01:22:26 tom Exp $") #define TYPE_CALLOC(type,elts) typeCalloc(type, (unsigned)(elts)) @@ -73,7 +73,7 @@ convert_strings(char *buf, char **Strings, int count, int size, char *table) Strings[i] = ABSENT_STRING; } else if (IS_NEG2(buf + 2 * i)) { Strings[i] = CANCELLED_STRING; - } else if (LOW_MSB(buf + 2 * i) > size) { + } else if ((int) LOW_MSB(buf + 2 * i) > size) { Strings[i] = ABSENT_STRING; } else { Strings[i] = (LOW_MSB(buf + 2 * i) + table); @@ -313,6 +313,8 @@ _nc_read_termtype(TERMTYPE *ptr, char *buffer, int limit) } if (need) { + if (ext_str_count >= (MAX_ENTRY_SIZE * 2)) + return (TGETENT_NO); if ((ptr->ext_Names = TYPE_CALLOC(char *, need)) == 0) return (TGETENT_NO); TR(TRACE_DATABASE, @@ -402,26 +404,22 @@ _nc_read_tic_entry(char *filename, /* * If we are looking in a directory, assume the entry is a file under that, * according to the normal rules. - * - * FIXME - add caseless-filename fixup. */ - if (_nc_is_dir_path(path)) { - unsigned need = 4 + strlen(path) + strlen(name); + unsigned need = LEAF_LEN + 3 + strlen(path) + strlen(name); + if (need <= limit) + (void) sprintf(filename, "%s/" LEAF_FMT "/%s", path, *name, name); - if (need <= limit) { - (void) sprintf(filename, "%s/" LEAF_FMT "/%s", path, *name, name); - result = _nc_read_file_entry(filename, tp); - } - } + if (_nc_is_dir_path(path)) + result = _nc_read_file_entry(filename, tp); #if USE_HASHED_DB else { static const char suffix[] = DBM_SUFFIX; DB *capdbp; unsigned lens = sizeof(suffix) - 1; unsigned size = strlen(path); - unsigned need = lens + size; + unsigned test = lens + size; - if (need <= limit) { + if (test < limit) { if (size >= lens && !strcmp(path + size - lens, suffix)) (void) strcpy(filename, path); @@ -513,6 +511,7 @@ _nc_read_entry(const char *const name, char *const filename, TERMTYPE *const tp) { int code = TGETENT_NO; + sprintf(filename, "%.*s", PATH_MAX - 1, name); if (strlen(name) == 0 || strcmp(name, ".") == 0 || strcmp(name, "..") == 0