[totem-pl-parser] core: Fix compile-time warnings in XML parser



commit 76ea8d775cec900991c7c63e182583b42ca728f1
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Jun 13 18:00:37 2018 +0200

    core: Fix compile-time warnings in XML parser
    
    plparse/xmllexer.c: In function ‘lexer_get_token_d_r’:
    plparse/xmllexer.c:359:8: warning: ‘strncpy’ output truncated before terminating nul copying 7 bytes from 
a string of the same length [-Wstringop-truncation]
            strncpy(tok + tok_pos, "DOCTYPE", 7); /* FIXME */
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    plparse/xmllexer.c:369:8: warning: ‘strncpy’ output truncated before terminating nul copying 7 bytes from 
a string of the same length [-Wstringop-truncation]
            strncpy (tok + tok_pos, "[CDATA[", 7); /* FIXME */
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 plparse/xmllexer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/plparse/xmllexer.c b/plparse/xmllexer.c
index c3633df..5679053 100644
--- a/plparse/xmllexer.c
+++ b/plparse/xmllexer.c
@@ -356,7 +356,7 @@ int lexer_get_token_d_r(struct lexer * lexer, char ** _tok, int * _tok_size, int
          case 'D':
            lexer->lexbuf_pos++;
            if (strncmp(lexer->lexbuf + lexer->lexbuf_pos, "OCTYPE", 6) == 0) {
-             strncpy(tok + tok_pos, "DOCTYPE", 7); /* FIXME */
+             memcpy(tok + tok_pos, "DOCTYPE", strlen ("DOCTYPE"));
              lexer->lexbuf_pos += 6;
              return T_DOCTYPE_START;
            } else {
@@ -366,7 +366,7 @@ int lexer_get_token_d_r(struct lexer * lexer, char ** _tok, int * _tok_size, int
          case '[':
            lexer->lexbuf_pos++;
            if (strncmp(lexer->lexbuf + lexer->lexbuf_pos, "CDATA[", 6) == 0) {
-             strncpy (tok + tok_pos, "[CDATA[", 7); /* FIXME */
+             memcpy (tok + tok_pos, "[CDATA[", strlen ("[CDATA["));
              lexer->lexbuf_pos += 6;
              lexer->lex_mode = CDATA;
              return T_CDATA_START;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]