summaryrefslogtreecommitdiffstats
path: root/lib/libalpm
diff options
context:
space:
mode:
authorAllan McRae <allan@archlinux.org>2015-02-24 15:47:17 +0100
committerAllan McRae <allan@archlinux.org>2015-03-03 07:54:17 +0100
commitd9b5cb238d7e1f7ec998ffd002e15cf9c1a48425 (patch)
treeddd9b929ee917e4ad5ad8f366314e9d58f6a5376 /lib/libalpm
parentfc5be14dac50798024a6dee1d6c3a1acb0154314 (diff)
downloadpacman-d9b5cb238d7e1f7ec998ffd002e15cf9c1a48425.tar.gz
pacman-d9b5cb238d7e1f7ec998ffd002e15cf9c1a48425.tar.xz
Abort of failure to add version file to empty local database
Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/be_local.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c
index 6fd6cd5b..556157d8 100644
--- a/lib/libalpm/be_local.c
+++ b/lib/libalpm/be_local.c
@@ -384,6 +384,11 @@ static int local_db_add_version(alpm_db_t UNUSED *db, const char *dbpath)
snprintf(dbverpath, PATH_MAX, "%sALPM_DB_VERSION", dbpath);
dbverfile = fopen(dbverpath, "w");
+
+ if(dbverfile == NULL) {
+ return 1;
+ }
+
fprintf(dbverfile, "%zu\n", ALPM_LOCAL_DB_VERSION);
fclose(dbverfile);
@@ -397,7 +402,10 @@ static int local_db_create(alpm_db_t *db, const char *dbpath)
dbpath, strerror(errno));
RET_ERR(db->handle, ALPM_ERR_DB_CREATE, -1);
}
- local_db_add_version(db, dbpath);
+ if(local_db_add_version(db, dbpath) != 0) {
+ return 1;
+ }
+
return 0;
}
@@ -459,7 +467,9 @@ static int local_db_validate(alpm_db_t *db)
}
}
- local_db_add_version(db, dbpath);
+ if(local_db_add_version(db, dbpath) != 0) {
+ goto version_error;
+ }
goto version_latest;
}