From: chuck Date: Sat, 20 Jan 1996 00:28:57 +0000 (+0000) Subject: cleanup: use snprintf() to prevent buffer overflow X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=bd5a5e593f111bcd7a7bfe7692a141486dd0f104;p=openbsd cleanup: use snprintf() to prevent buffer overflow --- 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