X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftinfo%2Fread_entry.c;h=c8aae6009242860fbd470b634e6cb5bb5f36efb0;hp=a237d60dbfbfbe6fbbccba0f85bfac84a6ea0197;hb=29ee95cea37c4bbf2014a35677d9a0750c6b52a8;hpb=af4c589f0c605e1a1dd3825678a0b1a97df02d37 diff --git a/ncurses/tinfo/read_entry.c b/ncurses/tinfo/read_entry.c index a237d60d..c8aae600 100644 --- a/ncurses/tinfo/read_entry.c +++ b/ncurses/tinfo/read_entry.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2010,2011 Free Software Foundation, Inc. * + * Copyright (c) 1998-2011,2012 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.116 2011/09/27 00:35:20 tom Exp $") +MODULE_ID("$Id: read_entry.c,v 1.119 2012/02/22 22:40:24 tom Exp $") #define TYPE_CALLOC(type,elts) typeCalloc(type, (unsigned)(elts)) @@ -99,7 +99,7 @@ fake_read(char *src, int *offset, int limit, char *dst, unsigned want) if (have > 0) { if ((int) want > have) want = (unsigned) have; - memcpy(dst, src + *offset, want); + memcpy(dst, src + *offset, (size_t) want); *offset += (int) want; } else { want = 0; @@ -107,10 +107,10 @@ fake_read(char *src, int *offset, int limit, char *dst, unsigned want) return (int) want; } -#define Read(buf, count) fake_read(buffer, &offset, limit, buf, count) +#define Read(buf, count) fake_read(buffer, &offset, limit, buf, (unsigned) count) #define read_shorts(buf, count) \ - (Read(buf, (unsigned) (count)*2) == (int) (count)*2) + (Read(buf, (count)*2) == (int) (count)*2) #define even_boundary(value) \ if ((value) % 2 != 0) Read(buf, 1) @@ -175,7 +175,7 @@ _nc_read_termtype(TERMTYPE *ptr, char *buffer, int limit) ptr->str_table = string_table; ptr->term_names = string_table; if ((have = (unsigned) Read(ptr->term_names, want)) != want) { - memset(ptr->term_names + have, 0, want - have); + memset(ptr->term_names + have, 0, (size_t) (want - have)); } ptr->term_names[want] = '\0'; string_table += (want + 1); @@ -410,9 +410,9 @@ make_db_filename(char *filename, unsigned limit, const char *const path) if (test < limit) { if (size >= lens && !strcmp(path + size - lens, suffix)) - (void) strcpy(filename, path); + _nc_STRCPY(filename, path, limit); else - (void) sprintf(filename, "%s%s", path, suffix); + _nc_SPRINTF(filename, _nc_SLIMIT(limit) "%s%s", path, suffix); result = TRUE; } return result; @@ -437,7 +437,8 @@ make_dir_filename(char *filename, unsigned need = (unsigned) (LEAF_LEN + 3 + strlen(path) + strlen(name)); if (need <= limit) { - (void) sprintf(filename, "%s/" LEAF_FMT "/%s", path, *name, name); + _nc_SPRINTF(filename, _nc_SLIMIT(limit) + "%s/" LEAF_FMT "/%s", path, *name, name); result = TRUE; } } @@ -524,7 +525,8 @@ _nc_read_tic_entry(char *filename, #if USE_TERMCAP else if (code != TGETENT_YES) { code = _nc_read_termcap_entry(name, tp); - sprintf(filename, "%.*s", PATH_MAX - 1, _nc_get_source()); + _nc_SPRINTF(filename, _nc_SLIMIT(PATH_MAX) + "%.*s", PATH_MAX - 1, _nc_get_source()); } #endif return code; @@ -545,7 +547,9 @@ _nc_read_entry(const char *const name, char *const filename, TERMTYPE *const tp) { int code = TGETENT_NO; - sprintf(filename, "%.*s", PATH_MAX - 1, name); + _nc_SPRINTF(filename, _nc_SLIMIT(PATH_MAX) + "%.*s", PATH_MAX - 1, name); + if (strlen(name) == 0 || strcmp(name, ".") == 0 || strcmp(name, "..") == 0 @@ -570,7 +574,8 @@ _nc_read_entry(const char *const name, char *const filename, TERMTYPE *const tp) #elif USE_TERMCAP if (code != TGETENT_YES) { code = _nc_read_termcap_entry(name, tp); - sprintf(filename, "%.*s", PATH_MAX - 1, _nc_get_source()); + _nc_SPRINTF(filename, _nc_SLIMIT(PATH_MAX) + "%.*s", PATH_MAX - 1, _nc_get_source()); } #endif }