Codebase list openfortivpn / 928250f
New upstream version 1.14.1 Daniel Echeverri 3 years ago
6 changed file(s) with 132 addition(s) and 45 deletion(s). Raw diff Collapse all Expand all
1212
1313 This high level changelog is usually updated when a release is tagged.
1414 On the master branch there may be changes that are not (yet) described here.
15
16 ### 1.14.1
17
18 * [-] fix out of bounds array access
1519
1620 ### 1.14.0
1721
2630 * [+] allow logging with both smartcard and username
2731 * [+] fix GCC 9 and clang warnings
2832 * [+] bump default minimal TLS version from TLSv1.0 to TLSv1.2
29 * [-] fix a couple coverity warnin
33 * [-] fix a couple coverity warnings
3034
3135 ### 1.13.3
3236
11 # Process this file with autoconf to produce a configure script.
22
33 AC_PREREQ([2.63])
4 AC_INIT([openfortivpn], [1.14.0])
4 AC_INIT([openfortivpn], [1.14.1])
55 AC_CONFIG_SRCDIR([src/main.c])
66 AM_INIT_AUTOMAKE([foreign subdir-objects])
77
10621062 int ret = -1;
10631063 FILE *file;
10641064 struct stat stat;
1065 #define NS_SIZE ARRAY_SIZE("nameserver xxx.xxx.xxx.xxx")
1065 #define NS_SIZE ARRAY_SIZE("nameserver xxx.xxx.xxx.xxx\n")
10661066 char ns1[NS_SIZE], ns2[NS_SIZE];
10671067 #undef NS_SIZE
1068 #define DNS_SUFFIX_SIZE (ARRAY_SIZE("search ") + MAX_DOMAIN_LENGTH)
1068 #define DNS_SUFFIX_SIZE (ARRAY_SIZE("search \n") + MAX_DOMAIN_LENGTH)
10691069 char dns_suffix[DNS_SUFFIX_SIZE];
10701070 #undef DNS_SUFFIX_SIZE
10711071 char *buffer = NULL;
4949 " --pppd-plugin=<file> Use specified pppd plugin instead of configuring\n" \
5050 " resolver and routes directly.\n" \
5151 " --pppd-ifname=<string> Set the pppd interface name, if supported by pppd.\n" \
52 " --pppd-ipparam=<string> Provides an extra parameter to the ip-up, ip-pre-up\n" \
52 " --pppd-ipparam=<string> Provides an extra parameter to the ip-up, ip-pre-up\n" \
5353 " and ip-down scripts. See man (8) pppd\n" \
5454 " --pppd-call=<name> Move most pppd options from pppd cmdline to\n" \
5555 " /etc/ppp/peers/<name> and invoke pppd with\n" \
6363 my $allow_c99_comments = 1; # Can be overridden by --ignore C99_COMMENT_TOLERANCE
6464 # git output parsing needs US English output, so first set backtick child process LANGUAGE
6565 my $git_command ='export LANGUAGE=en_US.UTF-8; git';
66 my $tabsize = 8;
6667
6768 sub help {
6869 my ($exitcode) = @_;
9798 --show-types show the specific message type in the output
9899 --max-line-length=n set the maximum line length, if exceeded, warn
99100 --min-conf-desc-length=n set the min description length, if shorter, warn
101 --tab-size=n set the number of spaces for tab (default 8)
100102 --root=PATH PATH to the kernel tree root
101103 --no-summary suppress the per-file summary
102104 --mailback only produce a report in case of warnings/errors
214216 'list-types!' => \$list_types,
215217 'max-line-length=i' => \$max_line_length,
216218 'min-conf-desc-length=i' => \$min_conf_desc_length,
219 'tab-size=i' => \$tabsize,
217220 'root=s' => \$root,
218221 'summary!' => \$summary,
219222 'mailback!' => \$mailback,
265268 } else {
266269 die "Invalid color mode: $color\n";
267270 }
271
272 # skip TAB size 1 to avoid additional checks on $tabsize - 1
273 die "Invalid TAB size: $tabsize\n" if ($tabsize < 2);
268274
269275 sub hash_save_array_words {
270276 my ($hashRef, $arrayRef) = @_;
472478 (?:kv|k|v)[czm]alloc(?:_node|_array)? |
473479 kstrdup(?:_const)? |
474480 kmemdup(?:_nul)?) |
475 (?:\w+)?alloc_skb(?:ip_align)? |
481 (?:\w+)?alloc_skb(?:_ip_align)? |
476482 # dev_alloc_skb/netdev_alloc_skb, et al
477483 dma_alloc_coherent
478484 )};
803809 }x;
804810 $Type = qr{
805811 $NonptrType
806 (?:(?:\s|\*|\[\])+\s*const|(?:\s|\*\s*(?:const\s*)?|\[\])+|(?:\s*\[\s*\])+)?
812 (?:(?:\s|\*|\[\])+\s*const|(?:\s|\*\s*(?:const\s*)?|\[\])+|(?:\s*\[\s*\])+){0,4}
807813 (?:\s+$Inline|\s+$Modifier)*
808814 }x;
809815 $TypeMisordered = qr{
810816 $NonptrTypeMisordered
811 (?:(?:\s|\*|\[\])+\s*const|(?:\s|\*\s*(?:const\s*)?|\[\])+|(?:\s*\[\s*\])+)?
817 (?:(?:\s|\*|\[\])+\s*const|(?:\s|\*\s*(?:const\s*)?|\[\])+|(?:\s*\[\s*\])+){0,4}
812818 (?:\s+$Inline|\s+$Modifier)*
813819 }x;
814820 $Declare = qr{(?:$Storage\s+(?:$Inline\s+)?)?$Type};
11171123 my ($formatted_email) = @_;
11181124
11191125 my $name = "";
1126 my $name_comment = "";
11201127 my $address = "";
11211128 my $comment = "";
11221129
11491156
11501157 $name = trim($name);
11511158 $name =~ s/^\"|\"$//g;
1159 $name =~ s/(\s*\([^\)]+\))\s*//;
1160 if (defined($1)) {
1161 $name_comment = trim($1);
1162 }
11521163 $address = trim($address);
11531164 $address =~ s/^\<|\>$//g;
11541165
11571168 $name = "\"$name\"";
11581169 }
11591170
1160 return ($name, $address, $comment);
1171 return ($name, $name_comment, $address, $comment);
11611172 }
11621173
11631174 sub format_email {
11811192 }
11821193
11831194 return $formatted_email;
1195 }
1196
1197 sub reformat_email {
1198 my ($email) = @_;
1199
1200 my ($email_name, $name_comment, $email_address, $comment) = parse_email($email);
1201 return format_email($email_name, $email_address);
1202 }
1203
1204 sub same_email_addresses {
1205 my ($email1, $email2) = @_;
1206
1207 my ($email1_name, $name1_comment, $email1_address, $comment1) = parse_email($email1);
1208 my ($email2_name, $name2_comment, $email2_address, $comment2) = parse_email($email2);
1209
1210 return $email1_name eq $email2_name &&
1211 $email1_address eq $email2_address;
11841212 }
11851213
11861214 sub which {
12161244 if ($c eq "\t") {
12171245 $res .= ' ';
12181246 $n++;
1219 for (; ($n % 8) != 0; $n++) {
1247 for (; ($n % $tabsize) != 0; $n++) {
12201248 $res .= ' ';
12211249 }
12221250 next;
22292257 sub tabify {
22302258 my ($leading) = @_;
22312259
2232 my $source_indent = 8;
2260 my $source_indent = $tabsize;
22332261 my $max_spaces_before_tab = $source_indent - 1;
22342262 my $spaces_to_tab = " " x $source_indent;
22352263
22712299 return length(expand_tabs(substr($line, 0, $last_openparen))) + 1;
22722300 }
22732301
2302 sub get_raw_comment {
2303 my ($line, $rawline) = @_;
2304 my $comment = '';
2305
2306 for my $i (0 .. (length($line) - 1)) {
2307 if (substr($line, $i, 1) eq "$;") {
2308 $comment .= substr($rawline, $i, 1);
2309 }
2310 }
2311
2312 return $comment;
2313 }
2314
22742315 sub process {
22752316 my $filename = shift;
22762317
22932334 my $is_binding_patch = -1;
22942335 my $in_header_lines = $file ? 0 : 1;
22952336 my $in_commit_log = 0; #Scanning lines before patch
2337 my $has_patch_separator = 0; #Found a --- line
22962338 my $has_commit_log = 0; #Encountered lines before patch
22972339 my $commit_log_lines = 0; #Number of commit log lines
22982340 my $commit_log_possible_stack_dump = 0;
24322474 $sline =~ s/$;/ /g; #with comments as spaces
24332475
24342476 my $rawline = $rawlines[$linenr - 1];
2477 my $raw_comment = get_raw_comment($line, $rawline);
24352478
24362479 # check if it's a mode change, rename or start of a patch
24372480 if (!$in_commit_log &&
26032646 $author = $1;
26042647 $author = encode("utf8", $author) if ($line =~ /=\?utf-8\?/i);
26052648 $author =~ s/"//g;
2649 $author = reformat_email($author);
26062650 }
26072651
26082652 # Check the patch for a signoff:
2609 if ($line =~ /^\s*signed-off-by:/i) {
2653 if ($line =~ /^\s*signed-off-by:\s*(.*)/i) {
26102654 $signoff++;
26112655 $in_commit_log = 0;
26122656 if ($author ne '') {
2613 my $l = $line;
2614 $l =~ s/"//g;
2615 if ($l =~ /^\s*signed-off-by:\s*\Q$author\E/i) {
2616 $authorsignoff = 1;
2617 }
2618 }
2657 if (same_email_addresses($1, $author)) {
2658 $authorsignoff = 1;
2659 }
2660 }
2661 }
2662
2663 # Check for patch separator
2664 if ($line =~ /^---$/) {
2665 $has_patch_separator = 1;
2666 $in_commit_log = 0;
26192667 }
26202668
26212669 # Check if MAINTAINERS is being updated. If so, there's probably no need to
26632711 }
26642712 }
26652713
2666 my ($email_name, $email_address, $comment) = parse_email($email);
2714 my ($email_name, $name_comment, $email_address, $comment) = parse_email($email);
26672715 my $suggested_email = format_email(($email_name, $email_address));
26682716 if ($suggested_email eq "") {
26692717 ERROR("BAD_SIGN_OFF",
26742722 $dequoted =~ s/" </ </;
26752723 # Don't force email to have quotes
26762724 # Allow just an angle bracketed address
2677 if ("$dequoted$comment" ne $email &&
2678 "<$email_address>$comment" ne $email &&
2679 "$suggested_email$comment" ne $email) {
2725 if (!same_email_addresses($email, $suggested_email)) {
26802726 WARN("BAD_SIGN_OFF",
26812727 "email address '$email' might be better as '$suggested_email$comment'\n" . $herecurr);
26822728 }
27192765 "A patch subject line should describe the change not the tool that found it\n" . $herecurr);
27202766 }
27212767
2722 # Check for unwanted Gerrit info
2723 if ($in_commit_log && $line =~ /^\s*change-id:/i) {
2768 # Check for Gerrit Change-Ids not in any patch context
2769 if ($realfile eq '' && !$has_patch_separator && $line =~ /^\s*change-id:/i) {
27242770 ERROR("GERRIT_CHANGE_ID",
2725 "Remove Gerrit Change-Id's before submitting upstream.\n" . $herecurr);
2771 "Remove Gerrit Change-Id's before submitting upstream\n" . $herecurr);
27262772 }
27272773
27282774 # Check if the commit log is in a possible stack dump
27602806
27612807 # Check for git id commit length and improperly formed commit descriptions
27622808 if ($in_commit_log && !$commit_log_possible_stack_dump &&
2763 $line !~ /^\s*(?:Link|Patchwork|http|https|BugLink):/i &&
2809 $line !~ /^\s*(?:Link|Patchwork|http|https|BugLink|base-commit):/i &&
27642810 $line !~ /^This reverts commit [0-9a-f]{7,40}/ &&
27652811 ($line =~ /\bcommit\s+[0-9a-f]{5,}\b/i ||
27662812 ($line =~ /(?:\s|^)[0-9a-f]{12,40}(?:[\s"'\(\[]|$)/i &&
30863132 $comment = '/*';
30873133 } elsif ($realfile =~ /\.(c|dts|dtsi)$/) {
30883134 $comment = '//';
3089 } elsif (($checklicenseline == 2) || $realfile =~ /\.(sh|pl|py|awk|tc)$/) {
3135 } elsif (($checklicenseline == 2) || $realfile =~ /\.(sh|pl|py|awk|tc|yaml)$/) {
30903136 $comment = '#';
30913137 } elsif ($realfile =~ /\.rst$/) {
30923138 $comment = '..';
31093155 if (!is_SPDX_License_valid($spdx_license)) {
31103156 WARN("SPDX_LICENSE_TAG",
31113157 "'$spdx_license' is not supported in LICENSES/...\n" . $herecurr);
3158 }
3159 if ($realfile =~ m@^Documentation/devicetree/bindings/@ &&
3160 not $spdx_license =~ /GPL-2\.0.*BSD-2-Clause/) {
3161 my $msg_level = \&WARN;
3162 $msg_level = \&CHK if ($file);
3163 if (&{$msg_level}("SPDX_LICENSE_TAG",
3164
3165 "DT binding documents should be licensed (GPL-2.0-only OR BSD-2-Clause)\n" . $herecurr) &&
3166 $fix) {
3167 $fixed[$fixlinenr] =~ s/SPDX-License-Identifier: .*/SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)/;
3168 }
31123169 }
31133170 }
31143171 }
31973254 next if ($realfile !~ /\.(h|c|pl|dtsi|dts)$/);
31983255
31993256 # at the beginning of a line any tabs must come first and anything
3200 # more than 8 must use tabs.
3257 # more than $tabsize must use tabs.
32013258 if ($rawline =~ /^\+\s* \t\s*\S/ ||
32023259 $rawline =~ /^\+\s* \s*/) {
32033260 my $herevet = "$here\n" . cat_vet($rawline) . "\n";
32163273 "please, no space before tabs\n" . $herevet) &&
32173274 $fix) {
32183275 while ($fixed[$fixlinenr] =~
3219 s/(^\+.*) {8,8}\t/$1\t\t/) {}
3276 s/(^\+.*) {$tabsize,$tabsize}\t/$1\t\t/) {}
32203277 while ($fixed[$fixlinenr] =~
32213278 s/(^\+.*) +\t/$1\t/) {}
32223279 }
32383295 if ($perl_version_ok &&
32393296 $sline =~ /^\+\t+( +)(?:$c90_Keywords\b|\{\s*$|\}\s*(?:else\b|while\b|\s*$)|$Declare\s*$Ident\s*[;=])/) {
32403297 my $indent = length($1);
3241 if ($indent % 8) {
3298 if ($indent % $tabsize) {
32423299 if (WARN("TABSTOP",
32433300 "Statements should start on a tabstop\n" . $herecurr) &&
32443301 $fix) {
3245 $fixed[$fixlinenr] =~ s@(^\+\t+) +@$1 . "\t" x ($indent/8)@e;
3302 $fixed[$fixlinenr] =~ s@(^\+\t+) +@$1 . "\t" x ($indent/$tabsize)@e;
32463303 }
32473304 }
32483305 }
32603317 my $newindent = $2;
32613318
32623319 my $goodtabindent = $oldindent .
3263 "\t" x ($pos / 8) .
3264 " " x ($pos % 8);
3320 "\t" x ($pos / $tabsize) .
3321 " " x ($pos % $tabsize);
32653322 my $goodspaceindent = $oldindent . " " x $pos;
32663323
32673324 if ($newindent ne $goodtabindent &&
37323789 #print "line<$line> prevline<$prevline> indent<$indent> sindent<$sindent> check<$check> continuation<$continuation> s<$s> cond_lines<$cond_lines> stat_real<$stat_real> stat<$stat>\n";
37333790
37343791 if ($check && $s ne '' &&
3735 (($sindent % 8) != 0 ||
3792 (($sindent % $tabsize) != 0 ||
37363793 ($sindent < $indent) ||
37373794 ($sindent == $indent &&
37383795 ($s !~ /^\s*(?:\}|\{|else\b)/)) ||
3739 ($sindent > $indent + 8))) {
3796 ($sindent > $indent + $tabsize))) {
37403797 WARN("SUSPECT_CODE_INDENT",
37413798 "suspect code indent for conditional statements ($indent, $sindent)\n" . $herecurr . "$stat_real\n");
37423799 }
40134070 }
40144071
40154072 # check for function declarations without arguments like "int foo()"
4016 if ($line =~ /(\b$Type\s+$Ident)\s*\(\s*\)/) {
4073 if ($line =~ /(\b$Type\s*$Ident)\s*\(\s*\)/) {
40174074 if (ERROR("FUNCTION_WITHOUT_ARGS",
40184075 "Bad function definition - $1() should probably be $1(void)\n" . $herecurr) &&
40194076 $fix) {
45814638 ($op eq '>' &&
45824639 $ca =~ /<\S+\@\S+$/))
45834640 {
4584 $ok = 1;
4641 $ok = 1;
45854642 }
45864643
45874644 # for asm volatile statements
49164973 # conditional.
49174974 substr($s, 0, length($c), '');
49184975 $s =~ s/\n.*//g;
4919 $s =~ s/$;//g; # Remove any comments
4976 $s =~ s/$;//g; # Remove any comments
49204977 if (length($c) && $s !~ /^\s*{?\s*\\*\s*$/ &&
49214978 $c !~ /}\s*while\s*/)
49224979 {
49555012 # if and else should not have general statements after it
49565013 if ($line =~ /^.\s*(?:}\s*)?else\b(.*)/) {
49575014 my $s = $1;
4958 $s =~ s/$;//g; # Remove any comments
5015 $s =~ s/$;//g; # Remove any comments
49595016 if ($s !~ /^\s*(?:\sif|(?:{|)\s*\\?\s*$)/) {
49605017 ERROR("TRAILING_STATEMENTS",
49615018 "trailing statements should be on next line\n" . $herecurr);
51315188 {
51325189 }
51335190
5134 # Flatten any obvious string concatentation.
5191 # Flatten any obvious string concatenation.
51355192 while ($dstat =~ s/($String)\s*$Ident/$1/ ||
51365193 $dstat =~ s/$Ident\s*($String)/$1/)
51375194 {
62296286 }
62306287
62316288 # check for function declarations that have arguments without identifier names
6289 # while avoiding uninitialized_var(x)
62326290 if (defined $stat &&
6233 $stat =~ /^.\s*(?:extern\s+)?$Type\s*(?:$Ident|\(\s*\*\s*$Ident\s*\))\s*\(\s*([^{]+)\s*\)\s*;/s &&
6234 $1 ne "void") {
6235 my $args = trim($1);
6291 $stat =~ /^.\s*(?:extern\s+)?$Type\s*(?:($Ident)|\(\s*\*\s*$Ident\s*\))\s*\(\s*([^{]+)\s*\)\s*;/s &&
6292 (!defined($1) ||
6293 (defined($1) && $1 ne "uninitialized_var")) &&
6294 $2 ne "void") {
6295 my $args = trim($2);
62366296 while ($args =~ m/\s*($Type\s*(?:$Ident|\(\s*\*\s*$Ident?\s*\)\s*$balanced_parens)?)/g) {
62376297 my $arg = trim($1);
6238 if ($arg =~ /^$Type$/ && $arg !~ /enum\s+$Ident$/) {
6298 if ($arg =~ /^$Type$/ &&
6299 $arg !~ /enum\s+$Ident$/) {
62396300 WARN("FUNCTION_ARGUMENTS",
62406301 "function definition argument '$arg' should also have an identifier name\n" . $herecurr);
62416302 }
63886449 }
63896450 }
63906451
6452 # check for /* fallthrough */ like comment, prefer fallthrough;
6453 my @fallthroughs = (
6454 'fallthrough',
6455 '@fallthrough@',
6456 'lint -fallthrough[ \t]*',
6457 'intentional(?:ly)?[ \t]*fall(?:(?:s | |-)[Tt]|t)hr(?:ough|u|ew)',
6458 '(?:else,?\s*)?FALL(?:S | |-)?THR(?:OUGH|U|EW)[ \t.!]*(?:-[^\n\r]*)?',
6459 'Fall(?:(?:s | |-)[Tt]|t)hr(?:ough|u|ew)[ \t.!]*(?:-[^\n\r]*)?',
6460 'fall(?:s | |-)?thr(?:ough|u|ew)[ \t.!]*(?:-[^\n\r]*)?',
6461 );
6462 if ($raw_comment ne '') {
6463 foreach my $ft (@fallthroughs) {
6464 if ($raw_comment =~ /$ft/) {
6465 my $msg_level = \&WARN;
6466 $msg_level = \&CHK if ($file);
6467 &{$msg_level}("PREFER_FALLTHROUGH",
6468 "Prefer 'fallthrough;' over fallthrough comment\n" . $herecurr);
6469 last;
6470 }
6471 }
6472 }
6473
63916474 # check for switch/default statements without a break;
63926475 if ($perl_version_ok &&
63936476 defined $stat &&
1111
1212 "$checkpatch_path" --no-tree --terse \
1313 --max-line-length=90 \
14 --ignore LEADING_SPACE,SPDX_LICENSE_TAG,CODE_INDENT,NAKED_SSCANF,VOLATILE,NEW_TYPEDEFS,LONG_LINE,LONG_LINE_STRING \
14 --ignore LEADING_SPACE,SPDX_LICENSE_TAG,CODE_INDENT,NAKED_SSCANF,VOLATILE,NEW_TYPEDEFS,LONG_LINE,LONG_LINE_STRING,QUOTED_WHITESPACE_BEFORE_NEWLINE \
1515 -f "$file" | tee "$tmp"
1616
1717 if [ -s "$tmp" ]; then