1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-12-23 00:08:50 -05:00

Fix issue with <dbpath>/db.lck being truncated

snprintf takes a length including the '\0' character, this wasn't accounted
for originally. Fix it.

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2007-07-10 14:31:39 -04:00
parent ea1fef69ad
commit d12c4f4b29

View File

@ -174,8 +174,8 @@ void SYMEXPORT alpm_option_set_dbpath(const char *dbpath)
_alpm_log(PM_LOG_DEBUG, "option 'dbpath' = %s", handle->dbpath);
const char *lf = "db.lck";
int lockfilelen = strlen(handle->dbpath) + strlen(lf);
handle->lockfile = calloc(lockfilelen + 1, sizeof(char));
int lockfilelen = strlen(handle->dbpath) + strlen(lf) + 1;
handle->lockfile = calloc(lockfilelen, sizeof(char));
snprintf(handle->lockfile, lockfilelen, "%s%s", handle->dbpath, lf);
_alpm_log(PM_LOG_DEBUG, "option 'lockfile' = %s", handle->lockfile);
}