From b1a89f313a2424b5b06349c141876b68903a1c05 Mon Sep 17 00:00:00 2001 From: Přemysl Janouch Date: Thu, 21 Jun 2018 23:37:40 +0200 Subject: degesch: add static analysis for the logger Caught two more occurences than I was able to find by just scanning the source, so the effort wasn't in vain. --- test-static | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100755 test-static (limited to 'test-static') diff --git a/test-static b/test-static new file mode 100755 index 0000000..0c22b0d --- /dev/null +++ b/test-static @@ -0,0 +1,14 @@ +#!/bin/sh +# We don't use printf's percent notation with our custom logging mechanism, +# so the compiler cannot check it for us like it usually does +perl -n0777 - "$(dirname "$0")"/degesch.c <<-'END' + while (/\blog_[^ ]+\s*\([^"()]*"[^"]*%[^%][^"]*"/gm) { + my ($p, $m) = ($`, $&); + printf "$ARGV:%d: suspicious log format string: %s...\n", + (1 + $p =~ tr/\n//), ($m =~ s/\s+/ /rg); + $status = 1; + } + END { + exit $status; + } +END -- cgit v1.2.3-70-g09d2