From: Panu Matilainen Date: Tue, 22 Apr 2008 10:55:41 +0000 (+0300) Subject: More path manipulation craziness eliminated in rpmdbRemoveDatabase() X-Git-Tag: rpm-4.6.0-rc1~776 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=338c9be61eef414ea361ac849bc1f926429957f6;p=platform%2Fupstream%2Frpm.git More path manipulation craziness eliminated in rpmdbRemoveDatabase() --- diff --git a/rpmdb/rpmdb.c b/rpmdb/rpmdb.c index e2c9565..ba6ef23 100644 --- a/rpmdb/rpmdb.c +++ b/rpmdb/rpmdb.c @@ -3224,31 +3224,19 @@ static int rpmdbRemoveDatabase(const char * prefix, const char * dbpath, int _dbapi) { int i; - char * filename; + char *path; int xx; - i = strlen(dbpath); - if (dbpath[i - 1] != '/') { - filename = alloca(i); - strcpy(filename, dbpath); - filename[i] = '/'; - filename[i + 1] = '\0'; - dbpath = filename; - } - - filename = alloca(strlen(prefix) + strlen(dbpath) + 40); - switch (_dbapi) { case 4: case 3: if (dbiTags.tags != NULL) for (i = 0; i < dbiTags.max; i++) { const char * base = rpmTagGetName(dbiTags.tags[i]); - sprintf(filename, "%s/%s/%s", prefix, dbpath, base); - (void)rpmCleanPath(filename); - if (access(filename, F_OK) != 0) - continue; - xx = unlink(filename); + path = rpmGetPath(prefix, "/", dbpath, "/", base, NULL); + if (access(path, F_OK) == 0) + xx = unlink(path); + free(path); } cleanDbenv(prefix, dbpath); break; @@ -3258,9 +3246,9 @@ static int rpmdbRemoveDatabase(const char * prefix, break; } - sprintf(filename, "%s/%s", prefix, dbpath); - (void)rpmCleanPath(filename); - xx = rmdir(filename); + path = rpmGetPath(prefix, "/", dbpath, NULL); + xx = rmdir(path); + free(path); return 0; }