Date: Sat, 1 Jun 2013 15:55:21 GMT From: Philippe Michel <philippe.michel7@sfr.fr> To: freebsd-gnats-submit@FreeBSD.org Subject: bin/179174: [patch] flex(1) generated files trigger an alarm from clang static analyzer Message-ID: <201306011555.r51FtLiU093407@oldred.FreeBSD.org> Resent-Message-ID: <201306011600.r51G01t9099572@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>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@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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201306011555.r51FtLiU093407>