X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftinfo%2Fread_termcap.c;h=675f470a860d266e38d86ea1efccfd6a3a4d3985;hp=ecf76d9be751e2be4019724fa6af24fd94ee9eb5;hb=9f479192e3ca3413d235c66bf058f8cc63764898;hpb=fe8c285d2a2770ee40523303dbf27a9fd8d01188 diff --git a/ncurses/tinfo/read_termcap.c b/ncurses/tinfo/read_termcap.c index ecf76d9b..675f470a 100644 --- a/ncurses/tinfo/read_termcap.c +++ b/ncurses/tinfo/read_termcap.c @@ -1,5 +1,6 @@ /**************************************************************************** - * Copyright (c) 1998-2018,2019 Free Software Foundation, Inc. * + * Copyright 2018-2020,2021 Thomas E. Dickey * + * Copyright 1998-2016,2017 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 * @@ -56,7 +57,7 @@ #include #include -MODULE_ID("$Id: read_termcap.c,v 1.97 2019/01/26 20:07:30 tom Exp $") +MODULE_ID("$Id: read_termcap.c,v 1.100 2021/06/17 21:11:08 tom Exp $") #if !PURE_TERMINFO @@ -802,7 +803,7 @@ _nc_tgetent(char *bp, char **sourcename, int *lineno, const char *name) /* * TERMCAP can have one of two things in it. It can be the name of a file * to use instead of /etc/termcap. In this case it better start with a - * "/". Or it can be an entry to use so we don't have to read the file. + * "/". Or it can be an entry to use so we don't have to read the file. * In this case it has to already have the newlines crunched out. If * TERMCAP does not hold a file name then a path of names is searched * instead. The path is found in the TERMPATH variable, or becomes @@ -1063,14 +1064,16 @@ _nc_read_termcap_entry(const char *const tn, TERMTYPE2 *const tp) } } -#define PRIVATE_CAP "%s/.termcap" +#define PRIVATE_CAP "%.*s/.termcap" if (use_terminfo_vars() && (h = getenv("HOME")) != NULL && *h != '\0' && (strlen(h) + sizeof(PRIVATE_CAP)) < PATH_MAX) { /* user's .termcap, if any, should override it */ _nc_STRCPY(envhome, h, sizeof(envhome)); _nc_SPRINTF(pathbuf, _nc_SLIMIT(sizeof(pathbuf)) - PRIVATE_CAP, envhome); + PRIVATE_CAP, + (int) (sizeof(pathbuf) - sizeof(PRIVATE_CAP)), + envhome); ADD_TC(pathbuf, filecount); } } @@ -1163,7 +1166,7 @@ _nc_read_termcap_entry(const char *const tn, TERMTYPE2 *const tp) _nc_free_entry(_nc_head, &(ep->tterm)); /* - * OK, now try to write the type to user's terminfo directory. + * OK, now try to write the type to user's terminfo directory. * Next time he loads this, it will come through terminfo. * * Advantage: Second and subsequent fetches of this entry will