xbps-pkgdb: play safe with strncpy().

--HG--
extra : convert_revision : 3562b4d657e4c10fdf734d149eec0bd6f36793f8
This commit is contained in:
Juan RP 2008-12-21 02:11:41 +01:00
parent 5722c8aca1
commit 9b3481a3b6

View file

@ -175,13 +175,13 @@ main(int argc, char **argv)
if ((dbfileenv = getenv("XBPS_REGPKGDB_PATH")) != NULL) {
/* Use path as defined by XBPS_REGPKGDB_PATH env var */
tmppath = strncpy(dbfile, dbfileenv, sizeof(dbfile));
tmppath = strncpy(dbfile, dbfileenv, sizeof(dbfile) - 1);
if (sizeof(*tmppath) >= sizeof(dbfile))
exit(1);
} else {
/* Use default path */
tmppath =
strncpy(dbfile, XBPS_REGPKGDB_DEFPATH, sizeof(dbfile));
strncpy(dbfile, XBPS_REGPKGDB_DEFPATH, sizeof(dbfile) - 1);
if (sizeof(*tmppath) >= sizeof(dbfile))
exit(1);
}