xbps-pkgdb: play safe with strncpy().
--HG-- extra : convert_revision : 3562b4d657e4c10fdf734d149eec0bd6f36793f8
This commit is contained in:
@@ -175,13 +175,13 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
if ((dbfileenv = getenv("XBPS_REGPKGDB_PATH")) != NULL) {
|
if ((dbfileenv = getenv("XBPS_REGPKGDB_PATH")) != NULL) {
|
||||||
/* Use path as defined by XBPS_REGPKGDB_PATH env var */
|
/* 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))
|
if (sizeof(*tmppath) >= sizeof(dbfile))
|
||||||
exit(1);
|
exit(1);
|
||||||
} else {
|
} else {
|
||||||
/* Use default path */
|
/* Use default path */
|
||||||
tmppath =
|
tmppath =
|
||||||
strncpy(dbfile, XBPS_REGPKGDB_DEFPATH, sizeof(dbfile));
|
strncpy(dbfile, XBPS_REGPKGDB_DEFPATH, sizeof(dbfile) - 1);
|
||||||
if (sizeof(*tmppath) >= sizeof(dbfile))
|
if (sizeof(*tmppath) >= sizeof(dbfile))
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user