summaryrefslogtreecommitdiffstats
path: root/lib/libalpm
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2007-07-10 20:31:39 +0200
committerDan McGee <dan@archlinux.org>2007-07-10 20:31:39 +0200
commitd12c4f4b29458ff04671bf7b9686735ad988c775 (patch)
tree7e106488bbacd42c63462960eb1b1c6683f67213 /lib/libalpm
parentea1fef69add040b9e5b1de6e9238eda4576ccd3f (diff)
downloadpacman-d12c4f4b29458ff04671bf7b9686735ad988c775.tar.gz
pacman-d12c4f4b29458ff04671bf7b9686735ad988c775.tar.xz
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>
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/handle.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index 759c14cf..e45be016 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -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);
}