X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftinfo%2Falloc_entry.c;h=9993cdf140443800ffc894492dcadfa19e3278af;hp=506fb386d208d914fca43142019317f593285693;hb=a5c5f83f5704909b0fcbfc2668d664cded977ff8;hpb=f79b52fddd95c7a6f1ead29ef9c39eb8cdf60795 diff --git a/ncurses/tinfo/alloc_entry.c b/ncurses/tinfo/alloc_entry.c index 506fb386..9993cdf1 100644 --- a/ncurses/tinfo/alloc_entry.c +++ b/ncurses/tinfo/alloc_entry.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2008,2010 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 * @@ -47,7 +47,7 @@ #include -MODULE_ID("$Id: alloc_entry.c,v 1.51 2010/12/25 23:06:01 tom Exp $") +MODULE_ID("$Id: alloc_entry.c,v 1.56 2012/02/22 22:34:31 tom Exp $") #define ABSENT_OFFSET -1 #define CANCELLED_OFFSET -2 @@ -73,7 +73,7 @@ _nc_init_entry(TERMTYPE *const tp) #endif if (stringbuf == 0) - stringbuf = (char *) malloc(MAX_STRTAB); + stringbuf = (char *) malloc((size_t) MAX_STRTAB); #if NCURSES_XNAMES tp->num_Booleans = BOOLCOUNT; @@ -131,7 +131,7 @@ _nc_save_str(const char *const string) result = (stringbuf + next_free - 1); } } else if (next_free + len < MAX_STRTAB) { - strcpy(&stringbuf[next_free], string); + _nc_STRCPY(&stringbuf[next_free], string, MAX_STRTAB); DEBUG(7, ("Saved string %s", _nc_visbuf(string))); DEBUG(7, ("at location %d", (int) next_free)); next_free += len; @@ -216,16 +216,19 @@ _nc_wrap_entry(ENTRY * const ep, bool copy_strings) if ((n = (unsigned) NUM_EXT_NAMES(tp)) != 0) { if (n < SIZEOF(offsets)) { size_t length = 0; + size_t offset; for (i = 0; i < n; i++) { length += strlen(tp->ext_Names[i]) + 1; offsets[i] = (int) (tp->ext_Names[i] - stringbuf); } if ((tp->ext_str_table = typeMalloc(char, length)) == 0) _nc_err_abort(MSG_NO_MEMORY); - for (i = 0, length = 0; i < n; i++) { - tp->ext_Names[i] = tp->ext_str_table + length; - strcpy(tp->ext_Names[i], stringbuf + offsets[i]); - length += strlen(tp->ext_Names[i]) + 1; + for (i = 0, offset = 0; i < n; i++) { + tp->ext_Names[i] = tp->ext_str_table + offset; + _nc_STRCPY(tp->ext_Names[i], + stringbuf + offsets[i], + length - offset); + offset += strlen(tp->ext_Names[i]) + 1; } } }