]> andersk Git - splint.git/blobdiff - src/cscanner.l
Fixed buffer overflow in cscanner.l
[splint.git] / src / cscanner.l
index aac8219e238b29d532cd64b81340d445b2f11f15..74a3779a8a07738bac204aee20ef4c8027cea494 100644 (file)
@@ -1,6 +1,6 @@
 /*;-*-C-*-; 
 ** Splint - annotation-assisted static program checker
-** Copyright (C) 1994-2001 University of Virginia,
+** Copyright (C) 1994-2002 University of Virginia,
 **         Massachusetts Institute of Technology
 **
 ** This program is free software; you can redistribute it and/or modify it
@@ -17,8 +17,8 @@
 ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 ** MA 02111-1307, USA.
 **
-** For information on lclint: lclint-request@cs.virginia.edu
-** To report a bug: lclint-bug@cs.virginia.edu
+** For information on splint: splint@cs.virginia.edu
+** To report a bug: splint-bug@cs.virginia.edu
 ** For more information: http://www.splint.org
 */
 /*
@@ -36,7 +36,7 @@
 /*
 ** Modified by Mike Smith 
 ** Corrected missing 'line' in scanf() calls in handleSpecial().
-** Without this, I get an error when LCLint hits a '#line' directive
+** Without this, I get an error when Splint hits a '#line' directive
 ** in the pre-pre-processed source files. For safety, I have made these
 ** conditional on OS2 and MSDOS because I don't understand why noone else
 ** has seen this problem.
@@ -64,14 +64,22 @@ IS                  (u|U|l|L)*
 ULSuffix                ({U}{L}|{L}{U})
 
 %{
-# include "lclintMacros.nf"
+# include "splintMacros.nf"
 # if defined(OS2) && defined(__IBMC__)
    /* needed for isatty()... */
 # include <io.h>
 # else
+
+/*
+** Win32 doesn't have unistd.h
+*/
+
+# ifndef WIN32
 # include <unistd.h>
 # endif
 
+# endif
+
 # include "basic.h"
 
 # include "cgrammar.h"
@@ -288,6 +296,8 @@ L\"(\\.|[^\\"])*\"([ \t\n]*\"(\\.|[^\\"])*\")* { RETURN_EXPR (processWideString
 "isnull"                { return (processSpec (QISNULL)); } 
 "truenull"              { return (processSpec (QTRUENULL)); } 
 "falsenull"             { return (processSpec (QFALSENULL)); } 
+"nullwhentrue"          { return (processSpec (QTRUENULL)); } 
+"nullwhenfalse"             { return (processSpec (QFALSENULL)); } 
 "relnull"               { return (processSpec (QRELNULL)); }
 "reldef"                { return (processSpec (QRELDEF)); }
 "exposed"               { return (processSpec (QEXPOSED)); }
@@ -610,6 +620,7 @@ struct skeyword s_parsetable[] = {
   { "testinRange", QTESTINRANGE},
   { "requires", QPRECLAUSE } ,
   { "ensures", QPOSTCLAUSE } ,
+  { "invariant", QINVARIANT} ,
   { NULL, BADTOK } 
 } ;
 
@@ -632,6 +643,8 @@ struct skeyword s_keytable[] = {
   { "special", QSPECIAL } ,
   { "truenull", QTRUENULL } ,
   { "falsenull", QFALSENULL } ,
+  { "nullwhentrue", QTRUENULL } ,
+  { "falsewhennull", QFALSENULL } ,
   { "keep", QKEEP } ,
   { "kept", QKEPT } ,
   { "notnull", QNOTNULL } ,
@@ -772,9 +785,8 @@ static int tokenMacroCode (cstring s)
              voptgenerror
                (FLG_WARNLINTCOMMENTS,
                 cstring_makeLiteral
-                ("Traditional lint comment /*FALLTHROUGH*/ used.  "
-                 "This is interpreted by "
-                 "LCLint in the same way as most Unix lints, but it is "
+                ("Traditional lint comment /*FALLTHROUGH*/ used. "
+                 "Splint interprets this in the same way as most Unix lints, but it is "
                  "preferable to replace it with the /*@fallthrough@*/ "
                  "semantic comment"),
                 g_currentloc);
@@ -785,9 +797,8 @@ static int tokenMacroCode (cstring s)
              voptgenerror 
                (FLG_WARNLINTCOMMENTS,
                 cstring_makeLiteral
-                ("Traditional lint comment /*FALLTHRU*/ used.  "
-                 "This is interpreted by "
-                 "LCLint in the same way as most Unix lints, but it is "
+                ("Traditional lint comment /*FALLTHRU*/ used. "
+                 "Splint interprets this in the same way as most Unix lints, but it is "
                  "preferable to replace it with the /*@fallthrough@*/ "
                  "semantic comment"),
                 g_currentloc);
@@ -798,9 +809,8 @@ static int tokenMacroCode (cstring s)
              voptgenerror 
                (FLG_WARNLINTCOMMENTS,
                 cstring_makeLiteral
-                ("Traditional lint comment /*NOTREACHED*/ used.  "
-                 "This is interpreted by "
-                 "LCLint in the same way as most Unix lints, but it is "
+                ("Traditional lint comment /*NOTREACHED*/ used. "
+                 "Splint interprets this in the same way as most Unix lints, but it is "
                  "preferable to replace it with the /*@notreached@*/ "
                  "semantic comment."),
                 g_currentloc);
@@ -817,9 +827,8 @@ static int tokenMacroCode (cstring s)
              voptgenerror 
                (FLG_WARNLINTCOMMENTS,
                 cstring_makeLiteral
-                ("Traditional lint comment /*PRINTFLIKE*/ used.  "
-                 "This is interpreted by "
-                 "LCLint in the same way as most Unix lints, but it is "
+                ("Traditional lint comment /*PRINTFLIKE*/ used. "
+                 "Splint interprets this in the same way as most Unix lints, but it is "
                  "preferable to replace it with either /*@printflike@*/, "
                  "/*@scanflike@*/ or /*@messagelike@*/."),
                 g_currentloc);
@@ -842,9 +851,8 @@ static int tokenMacroCode (cstring s)
              voptgenerror
                (FLG_WARNLINTCOMMENTS,
                 cstring_makeLiteral
-                ("Traditional lint comment /*ARGSUSED*/ used.  "
-                 "This is interpreted by "
-                 "LCLint in the same way as most Unix lints, but it is "
+                ("Traditional lint comment /*ARGSUSED*/ used. "
+                 "Splint interprets this in the same way as most Unix lints, but it is "
                  "preferable to use /*@unused@*/ annotations on "
                  "the unused parameters."),
                 g_currentloc);
@@ -1705,20 +1713,23 @@ static bool handleSpecial (char *yyt)
   char c;
   char *ol;
   cstring olc;
-  
-  strcpy (l, yyt + 1);
 
-  /* Need to safe original l for deallocating. */
-  ol = l;
+  int len_yyt;
 
-  l += strlen (yyt) - 1;
+  len_yyt = strlen (yyt +1) ;
+
+  l = mstring_copy (yyt + 1);
   
   while ((c = char_fromInt (lminput ())) != '\n' && c != '\0')
     {
-      *l++ = c;
+      l = mstring_append(l, c);
     }
 
-  *l = '\0';
+    /* Need to safe original l for deallocating. */
+  ol = l;
+
+  l += strlen (l);
+
   olc = cstring_fromChars (ol);
   
   if (cstring_equalPrefixLit (olc, "pragma"))
@@ -2132,7 +2143,11 @@ static int handleLlSpecial ()
                            {
                              s--;
                              
-                             if (flagcode_hasValue (fflag))
+                             if (flagcode_hasNumber (fflag))
+                               {
+                                 setValueFlag (fflag, extra);
+                               }
+                             else if (flagcode_hasChar (fflag))
                                {
                                  setValueFlag (fflag, extra);
                                }
This page took 0.06262 seconds and 4 git commands to generate.