From 3bdc1db866383dddf166595db37777b585a1542e Mon Sep 17 00:00:00 2001 From: "David A. Wheeler" Date: Sat, 12 Jul 2014 06:21:34 -0400 Subject: [PATCH] flawfinder: Handle files not ending in newline (from Alexis Wilke) - Thanks to Alexis Wilke! --- flawfinder | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/flawfinder b/flawfinder index f0ba461..9d370c0 100755 --- a/flawfinder +++ b/flawfinder @@ -1300,7 +1300,10 @@ def process_c_file(f, patch_infos): if m: i = m.end(0) - c = text[i] + if i >= len(text): + c = '' + else: + c = text[i] if linebegin: # If at beginning of line, see if #include is there. linebegin = 0 if c == "#": codeinline = 1 # A directive, count as code. @@ -1436,9 +1439,9 @@ def display_header(): print "

Flawfinder Results

" print "Here are the security scan results from" print 'Flawfinder version %s,' % version - print '(C) 2001-2004 David A. Wheeler.' + print '(C) 2001-2007 David A. Wheeler.' else: - print "Flawfinder version %s, (C) 2001-2004 David A. Wheeler." % version + print "Flawfinder version %s, (C) 2001-2007 David A. Wheeler." % version displayed_header = 1