diff options
author | Dan McGee <dan@archlinux.org> | 2011-09-19 19:57:29 -0500 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-09-20 10:23:11 -0500 |
commit | 8e3b39a9e0c2fbc268919a57fb1e3cf7aa2aedf4 (patch) | |
tree | 4586decbe2c03303c0839ca662fd147627ff5984 /src/pacman/sync.c | |
parent | 0f92fc59638e5d053966c8f39afd615a870141cc (diff) |
pacman: use dynamic string allocation where it makes sense
None of these are hot-code paths, and at least the target reading has
little need for an arbitrary length limitation (however crazy it might
be to have longer arguments).
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'src/pacman/sync.c')
-rw-r--r-- | src/pacman/sync.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 15eea955..1f2edb24 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -122,7 +122,7 @@ static int sync_cleandb(const char *dbpath, int keep_used) static int sync_cleandb_all(void) { const char *dbpath; - char newdbpath[PATH_MAX]; + char *newdbpath; int ret = 0; dbpath = alpm_option_get_dbpath(config->handle); @@ -135,8 +135,12 @@ static int sync_cleandb_all(void) * only the unused sync dbs in dbpath/sync/ */ ret += sync_cleandb(dbpath, 0); - sprintf(newdbpath, "%s%s", dbpath, "sync/"); + if(asprintf(&newdbpath, "%s%s", dbpath, "sync/") < 0) { + ret += 1; + return ret; + } ret += sync_cleandb(newdbpath, 1); + free(newdbpath); printf(_("Database directory cleaned up\n")); return ret; |