X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftinfo%2Fmake_hash.c;h=906dfafa29fa12128c9b30e56b93bd1fadf86ec0;hp=9274b87713434f338e45c28d4645be46509c5019;hb=5f288254c618ae86f3811f2797e4d942061c9101;hpb=cdaf29481becd3e1c21baa574ac1ab88ea5f3d38 diff --git a/ncurses/tinfo/make_hash.c b/ncurses/tinfo/make_hash.c index 9274b877..906dfafa 100644 --- a/ncurses/tinfo/make_hash.c +++ b/ncurses/tinfo/make_hash.c @@ -43,7 +43,7 @@ #include -MODULE_ID("$Id: make_hash.c,v 1.26 2019/03/10 01:10:15 tom Exp $") +MODULE_ID("$Id: make_hash.c,v 1.29 2019/10/19 21:02:19 tom Exp $") /* * _nc_make_hash_table() @@ -164,13 +164,11 @@ parse_columns(char *buffer) int col = 0; -#if NO_LEAKS if (buffer == 0) { free(list); list = 0; return 0; } -#endif if (*buffer != '#') { if (list == 0) { @@ -220,18 +218,24 @@ parse_columns(char *buffer) static char * get_type(int type_mask) { - static char result[40]; + static char result[80]; unsigned n; - strcpy(result, L_PAREN); + _nc_STRCPY(result, L_PAREN, sizeof(result)); for (n = 0; n < 3; ++n) { if ((1 << n) & type_mask) { + size_t want = 5 + strlen(typenames[n]); + if (want > sizeof(result)) { + fprintf(stderr, "Buffer is not large enough for %s + %s\n", + result, typenames[n]); + exit(EXIT_FAILURE); + } if (result[1]) - strcat(result, "|"); - strcat(result, "1<<"); - strcat(result, typenames[n]); + _nc_STRCAT(result, "|", sizeof(result)); + _nc_STRCAT(result, "1<<", sizeof(result)); + _nc_STRCAT(result, typenames[n], sizeof(result)); } } - strcat(result, R_PAREN); + _nc_STRCAT(result, R_PAREN, sizeof(result)); return result; } @@ -427,12 +431,11 @@ main(int argc, char **argv) } free(hash_table); -#if NO_LEAKS for (n = 0; (n < tablesize); ++n) { free((void *) name_table[n].ute_name); } free(name_table); parse_columns(0); -#endif + return EXIT_SUCCESS; }