diff -ru -x changelog libsepol-2.0.42.nomod/src/genusers.c libsepol-2.0.42/src/genusers.c --- libsepol-2.0.42.nomod/src/genusers.c 2010-12-20 21:13:33.000000000 +0100 +++ libsepol-2.0.42/src/genusers.c 2011-04-06 14:25:31.120368538 +0200 @@ -268,7 +268,7 @@ const char *usersdir, void **newdata, size_t * newlen) { struct policydb policydb; - char path[PATH_MAX]; + char *path; /* Construct policy database */ if (policydb_init(&policydb)) @@ -277,7 +277,7 @@ goto err; /* Load locally defined users. */ - snprintf(path, sizeof path, "%s/local.users", usersdir); + asprintf(&path, "%s/local.users", usersdir); if (load_users(&policydb, path) < 0) goto err_destroy; @@ -286,25 +286,29 @@ goto err_destroy; policydb_destroy(&policydb); + free(path); return 0; err_destroy: policydb_destroy(&policydb); err: + free(path); return -1; } int hidden sepol_genusers_policydb(policydb_t * policydb, const char *usersdir) { - char path[PATH_MAX]; + char *path; /* Load locally defined users. */ - snprintf(path, sizeof path, "%s/local.users", usersdir); + asprintf(&path, "%s/local.users", usersdir); if (load_users(policydb, path) < 0) { + free(path); ERR(NULL, "unable to load local.users: %s", strerror(errno)); return -1; } + free(path); if (policydb_reindex_users(policydb) < 0) { ERR(NULL, "unable to reindex users: %s", strerror(errno)); diff -ru -x changelog libsepol-2.0.42.nomod/tests/helpers.c libsepol-2.0.42/tests/helpers.c --- libsepol-2.0.42.nomod/tests/helpers.c 2010-12-20 21:13:33.000000000 +0100 +++ libsepol-2.0.42/tests/helpers.c 2011-04-06 16:02:17.232369842 +0200 @@ -34,20 +34,21 @@ int test_load_policy(policydb_t * p, int policy_type, int mls, const char *test_name, const char *policy_name) { - char filename[PATH_MAX]; + char *filename; if (mls) { - if (snprintf(filename, PATH_MAX, "policies/%s/%s.mls", test_name, policy_name) < 0) { + if (asprintf(&filename, "policies/%s/%s.mls", test_name, policy_name) < 0) { return -1; } } else { - if (snprintf(filename, PATH_MAX, "policies/%s/%s.std", test_name, policy_name) < 0) { + if (asprintf(&filename, "policies/%s/%s.std", test_name, policy_name) < 0) { return -1; } } if (policydb_init(p)) { fprintf(stderr, "Out of memory"); + free(filename); return -1; } @@ -57,9 +58,11 @@ if (read_source_policy(p, filename, test_name)) { fprintf(stderr, "failed to read policy %s\n", filename); policydb_destroy(p); + free(filename); return -1; } + free(filename); return 0; } diff -ru -x changelog libsepol-2.0.42.nomod/tests/test-expander.c libsepol-2.0.42/tests/test-expander.c --- libsepol-2.0.42.nomod/tests/test-expander.c 2010-12-20 21:13:33.000000000 +0100 +++ libsepol-2.0.42/tests/test-expander.c 2011-04-06 16:03:27.160369064 +0200 @@ -73,8 +73,7 @@ int i; for (i = 0; i < num_modules + 1; i++) { - filename[i] = calloc(PATH_MAX, sizeof(char)); - if (snprintf(filename[i], PATH_MAX, "policies/test-expander/%s%s", myfiles[i], mls ? ".mls" : ".std") < 0) + if (asprintf(&(filename[i]), "policies/test-expander/%s%s", myfiles[i], mls ? ".mls" : ".std") < 0) return -1; }