utf8: don't allow NUL in decoded strings.
[ccan] / tools / ccanlint / tests / license_depends_compat.c
1 #include <tools/ccanlint/ccanlint.h>
2 #include <ccan/foreach/foreach.h>
3 #include <sys/types.h>
4 #include <sys/stat.h>
5 #include <fcntl.h>
6 #include <unistd.h>
7 #include <limits.h>
8 #include <errno.h>
9 #include <stdlib.h>
10 #include <stdio.h>
11 #include <err.h>
12
13 static void check_license_depends_compat(struct manifest *m,
14                                          unsigned int *timeleft UNNEEDED,
15                                          struct score *score)
16 {
17         struct manifest *i;
18
19         score->pass = true;
20
21         /* If our license is unknown, we can't know the answer. */
22         if (m->license == LICENSE_UNKNOWN) {
23                 score->score = score->total = 0;
24                 return;
25         }
26
27         list_for_each(&m->deps, i, list) {
28                 struct doc_section *d = find_license_tag(i);
29                 i->license = which_license(d);
30
31                 if (i->license != LICENSE_UNKNOWN
32                     && !license_compatible[m->license][i->license]) {
33                         score_file_error(score, i->info_file, 0,
34                                          "Dependency ccan/%s has"
35                                          " incompatible license '%s'",
36                                          i->modname,
37                                          licenses[i->license].name);
38                         score->pass = false;
39                 }
40         }
41
42         if (score->pass)
43                 score->score = score->total;
44 }
45
46 struct ccanlint license_depends_compat = {
47         .key = "license_depends_compat",
48         .name = "CCAN dependencies don't contain incompatible licenses",
49         .check = check_license_depends_compat,
50         .needs = "license_exists depends_exist"
51 };
52 REGISTER_TEST(license_depends_compat);