From bd5a5e593f111bcd7a7bfe7692a141486dd0f104 Mon Sep 17 00:00:00 2001 From: chuck Date: Sat, 20 Jan 1996 00:28:57 +0000 Subject: [PATCH] cleanup: use snprintf() to prevent buffer overflow --- usr.sbin/ypserv/common/ypdb.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/usr.sbin/ypserv/common/ypdb.c b/usr.sbin/ypserv/common/ypdb.c index bf50d7c231b..32cfdd03690 100644 --- a/usr.sbin/ypserv/common/ypdb.c +++ b/usr.sbin/ypserv/common/ypdb.c @@ -38,7 +38,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ypdb.c,v 1.1 1995/11/01 16:56:16 deraadt Exp $ + * $Id: ypdb.c,v 1.2 1996/01/20 00:28:57 chuck Exp $ */ #include @@ -75,8 +75,7 @@ ypdb_open(file, flags, mode) info.cachesize = NULL; info.hash = NULL; info.lorder = 0; - (void)strcpy(path, file); - (void)strcat(path, YPDB_SUFFIX); + snprintf(path, sizeof(path), "%s%s", file, YPDB_SUFFIX); return ((DBM *)__hash_open(path, flags, mode, &info, 0)); #else BTREEINFO info; @@ -91,8 +90,7 @@ ypdb_open(file, flags, mode) info.compare = NULL; info.prefix = NULL; info.lorder = 0; - (void)strcpy(path, file); - (void)strcat(path, YPDB_SUFFIX); + snprintf(path, sizeof(path), "%s%s", file, YPDB_SUFFIX); db = (DBM *)__bt_open(path, flags, mode, &info, 0); return (db); #endif -- 2.20.1