]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/tinfo/read_termcap.c
ncurses 6.2 - patch 20210424
[ncurses.git] / ncurses / tinfo / read_termcap.c
index ecf76d9be751e2be4019724fa6af24fd94ee9eb5..eb1c172d5af5fdf8f76da9a14f2cf17827977340 100644 (file)
@@ -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 <sys/types.h>
 #include <tic.h>
 
-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.99 2021/04/18 11:43:38 tom Exp $")
 
 #if !PURE_TERMINFO
 
@@ -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);
        }
     }