pkgtools

morpheus pkg tools
git clone git://git.2f30.org/pkgtools.git
Log | Files | Refs | README | LICENSE

commit 9f4b9924116d6dff200081eb3920e3ea2f2db5fb
parent d748158df0823dca3d8039040c387a912226f5c5
Author: sin <sin@2f30.org>
Date:   Wed Jun 18 16:57:17 +0100

Check remaining realpath() for error cases

Diffstat:
db.c | 17+++++++++++++----
infopkg.c | 11+++++++----
installpkg.c | 5++++-
removepkg.c | 5++++-
4 files changed, 28 insertions(+), 10 deletions(-)
diff --git a/db.c b/db.c @@ -46,7 +46,7 @@ dbinit(const char *prefix) db = emalloc(sizeof(*db)); db->head = NULL; - if(!(realpath(prefix, db->prefix))) { + if(!realpath(prefix, db->prefix)) { weprintf("realpath %s:", prefix); free(db); return NULL; @@ -118,7 +118,10 @@ dbfscollide(struct db *db, const char *file) struct stat sb; int ok = 0, r; - realpath(file, pkgpath); + if (!realpath(file, pkgpath)) { + weprintf("realpath %s:", file); + return -1; + } ar = archive_read_new(); @@ -173,7 +176,10 @@ dbadd(struct db *db, const char *file) struct archive_entry *entry; int r; - realpath(file, pkgpath); + if (!realpath(file, pkgpath)) { + weprintf("realpath %s:", file); + return -1; + } estrlcpy(tmppath, pkgpath, sizeof(tmppath)); estrlcpy(path, db->path, sizeof(path)); @@ -362,7 +368,10 @@ dbpkginstall(struct db *db, const char *file) struct archive_entry *entry; int flags, r; - realpath(file, pkgpath); + if (!realpath(file, pkgpath)) { + weprintf("realpath %s:", file); + return -1; + } ar = archive_read_new(); diff --git a/infopkg.c b/infopkg.c @@ -26,6 +26,7 @@ int main(int argc, char *argv[]) { struct db *db; + char path[PATH_MAX]; char *prefix = "/"; int oflag = 0; int i, r; @@ -54,7 +55,11 @@ main(int argc, char *argv[]) } for (i = 0; i < argc; i++) { - r = dbwalk(db, ownpkg, argv[i]); + if (!realpath(argv[i], path)) { + weprintf("realpath %s:", argv[i]); + continue; + } + r = dbwalk(db, ownpkg, path); if (r < 0) { dbfree(db); exit(EXIT_FAILURE); @@ -69,11 +74,9 @@ main(int argc, char *argv[]) static int ownpkg(struct db *db, struct pkg *pkg, void *file) { + char *path = file; struct pkgentry *pe; struct stat sb1, sb2; - char path[PATH_MAX]; - - realpath(file, path); if (lstat(path, &sb1) < 0) eprintf("lstat %s:", path); diff --git a/installpkg.c b/installpkg.c @@ -54,7 +54,10 @@ main(int argc, char *argv[]) } for (i = 0; i < argc; i++) { - realpath(argv[i], path); + if (!realpath(argv[i], path)) { + weprintf("realpath %s:", argv[i]); + continue; + } if (vflag == 1) printf("installing %s\n", path); if (fflag == 0) { diff --git a/removepkg.c b/removepkg.c @@ -55,7 +55,10 @@ main(int argc, char *argv[]) } for (i = 0; i < argc; i++) { - realpath(argv[i], path); + if (!realpath(argv[i], path)) { + weprintf("realpath %s:", argv[i]); + continue; + } r = dbwalk(db, removepkg, path); if (r < 0) { dbfree(db);