1 |
commit: d2ac9484a50843e9996df1f3f7dfd3eb0eb6ed85 |
2 |
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Feb 28 16:29:10 2018 +0000 |
4 |
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Feb 28 16:29:10 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=d2ac9484 |
7 |
|
8 |
scripts/rsync-generation/hashgen: properly free members of lists |
9 |
|
10 |
scripts/rsync-generation/hashgen.c | 21 +++++++++++++-------- |
11 |
1 file changed, 13 insertions(+), 8 deletions(-) |
12 |
|
13 |
diff --git a/scripts/rsync-generation/hashgen.c b/scripts/rsync-generation/hashgen.c |
14 |
index a4df7ca850..3f7aaf65d6 100644 |
15 |
--- a/scripts/rsync-generation/hashgen.c |
16 |
+++ b/scripts/rsync-generation/hashgen.c |
17 |
@@ -1093,7 +1093,11 @@ verify_dir( |
18 |
curdentry++; |
19 |
} |
20 |
} |
21 |
+ |
22 |
+ while (dentrieslen-- > 0) |
23 |
+ free(dentries[dentrieslen]); |
24 |
free(dentries); |
25 |
+ |
26 |
return ret; |
27 |
} else { |
28 |
return 1; |
29 |
@@ -1205,6 +1209,9 @@ verify_manifest(const char *dir, const char *manifest) |
30 |
qsort(elems, elemslen, sizeof(elems[0]), compare_elems); |
31 |
snprintf(buf, sizeof(buf), "%s/%s", dir, manifest); |
32 |
ret = verify_dir(dir, elems, elemslen, 0, buf + 2); |
33 |
+ |
34 |
+ while (elemslen-- > 0) |
35 |
+ free(elems[elemslen]); |
36 |
free(elems); |
37 |
|
38 |
return ret; |
39 |
@@ -1213,7 +1220,6 @@ verify_manifest(const char *dir, const char *manifest) |
40 |
static char * |
41 |
process_dir_vrfy(const char *dir) |
42 |
{ |
43 |
- char *ret = NULL; |
44 |
char buf[8192]; |
45 |
int newhashes; |
46 |
|
47 |
@@ -1222,8 +1228,7 @@ process_dir_vrfy(const char *dir) |
48 |
if ((newhashes = parse_layout_conf(buf)) != 0) { |
49 |
hashes = newhashes; |
50 |
} else { |
51 |
- fprintf(stderr, "verification must be done on a full tree\n"); |
52 |
- return "not on full tree"; |
53 |
+ return "verification must be done on a full tree"; |
54 |
} |
55 |
|
56 |
if (chdir(dir) != 0) { |
57 |
@@ -1232,7 +1237,7 @@ process_dir_vrfy(const char *dir) |
58 |
} |
59 |
|
60 |
if (verify_gpg_sig(str_manifest) != 0) |
61 |
- ret = "gpg signature invalid"; |
62 |
+ return "gpg signature invalid"; |
63 |
|
64 |
/* verification goes like this: |
65 |
* - verify the signature of the top-level Manifest file (done |
66 |
@@ -1240,12 +1245,12 @@ process_dir_vrfy(const char *dir) |
67 |
* - read the contents of the Manifest file, and process the |
68 |
* entries - verify them, check there are no files which shouldn't |
69 |
* be there |
70 |
- * - recurse into directories for which Manifest files are defined */ |
71 |
- |
72 |
+ * - recurse into directories for which Manifest files are defined |
73 |
+ */ |
74 |
if (verify_manifest(".\0", str_manifest) != 0) |
75 |
- ret = "manifest verification failed"; |
76 |
+ return "manifest verification failed"; |
77 |
|
78 |
- return ret; |
79 |
+ return NULL; |
80 |
} |
81 |
|
82 |
int |