bin/179174: [patch] flex(1) generated files trigger an alarm from clang static analyzer
Philippe Michel
philippe.michel7 at sfr.fr
Sat Jun 1 16:00:02 UTC 2013
>Number: 179174
>Category: bin
>Synopsis: [patch] flex(1) generated files trigger an alarm from clang static analyzer
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Sat Jun 01 16:00:01 UTC 2013
>Closed-Date:
>Last-Modified:
>Originator: Philippe Michel
>Release: 9.1-STABLE
>Organization:
>Environment:
FreeBSD metropolis 9.1-STABLE FreeBSD 9.1-STABLE #0 r250981: Sat May 25 20:58:04 CEST 2013 pm at metropolis:/usr/obj/usr/src/sys/MYKERNEL amd64
>Description:
When compiled by clang static analyzer, C files generated by flex give the following alarm in yy_init_buffer() :
Access to field 'yy_input_file' results in a dereference of a null pointer (loaded from variable 'b')
>How-To-Repeat:
Compile a file generated by flex with ccc-analyzer (from ports' clang ; it is not installed with the base system compiler).
>Fix:
This may be a false positive and clang may not analyze the code deeply enough to discover it, but checking variable 'b' and exiting with a managed fatal error instead of a core dump if it is null would avoid the problem with no functional side-effects, and would be even more useful if there is indeed a code path that could end with a null buffer.
Patch attached with submission follows:
Index: usr.bin/lex/flex.skl
===================================================================
--- usr.bin/lex/flex.skl (revision 251159)
+++ usr.bin/lex/flex.skl (working copy)
@@ -1222,6 +1222,9 @@
%*
{
+ if ( ! b )
+ YY_FATAL_ERROR( "NULL buffer passed to yy_init_buffer()" );
+
yy_flush_buffer( b );
b->yy_input_file = file;
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list