]> granicus.if.org Git - flex/commitdiff
scanner: Use strncpy
authorChristos Zoulas <christos@zoulas.com>
Sun, 22 Jan 2017 17:22:26 +0000 (18:22 +0100)
committerWill Estes <westes575@gmail.com>
Mon, 23 Jan 2017 16:38:36 +0000 (11:38 -0500)
src/scan.l

index 181b28c9d98383bc4f648c283d8fdbec1720194b..8400cf6ca0a5b81d831c72192f15204fd4a68559 100644 (file)
@@ -74,7 +74,7 @@ extern const char *escaped_qstart, *escaped_qend;
 #define RETURNNAME \
        if(yyleng < MAXLINE) \
          { \
-       strcpy( nmstr, yytext ); \
+       strncpy( nmstr, yytext, sizeof(nmstr) ); \
        return NAME; \
         } \
        else \
@@ -207,7 +207,7 @@ M4QEND      "]""]"
        ^{NAME}         {
                        if(yyleng < MAXLINE)
                         {
-                       strcpy( nmstr, yytext );
+                       strncpy( nmstr, yytext, sizeof(nmstr) );
                         }
                        else
                         {
@@ -318,7 +318,7 @@ M4QEND      "]""]"
        {NOT_WS}[^\r\n]*        {
                        if(yyleng < MAXLINE)
                         {
-                       strcpy( nmdef, yytext );
+                       strncpy( nmdef, yytext, sizeof(nmdef) );
                         }
                        else
                         {
@@ -460,7 +460,7 @@ M4QEND      "]""]"
        \"[^"\n]*\"     {
                        if(yyleng-1 < MAXLINE)
                         {
-                       strcpy( nmstr, yytext + 1 );
+                       strncpy( nmstr, yytext + 1, sizeof(nmstr) );
                         }
                        else
                         {
@@ -637,7 +637,7 @@ M4QEND      "]""]"
 
                        if(yyleng < MAXLINE)
                         {
-                       strcpy( nmstr, yytext );
+                       strncpy( nmstr, yytext, sizeof(nmstr) );
                         }
                        else
                         {
@@ -695,7 +695,7 @@ M4QEND      "]""]"
 
                        if(yyleng-1 < MAXLINE)
                         {
-                       strcpy( nmstr, yytext + 1 );
+                       strncpy( nmstr, yytext + 1, sizeof(nmstr) );
                         }
                        else
                         {