Skip to content
Snippets Groups Projects
Commit 65bbdd9b authored by Kristof Szabados's avatar Kristof Szabados
Browse files

then lets store the text for MD5 calculation in a separate store.


Signed-off-by: default avatarKristof Szabados <Kristof.Szabados@ericsson.com>
parent 2efc645b
No related branches found
No related tags found
No related merge requests found
...@@ -208,7 +208,8 @@ TITAN "$#&&&(#TITANERRONEOUS$#&&^#% " ...@@ -208,7 +208,8 @@ TITAN "$#&&&(#TITANERRONEOUS$#&&^#% "
string literals */ string literals */
size_t dot_line = 0, dot_column = 0; /**< location of the previous '.' token */ size_t dot_line = 0, dot_column = 0; /**< location of the previous '.' token */
/* variables used when processing binary strings */ /* variables used when processing binary strings */
expstring_t binstr = NULL; /**< the string itself */ expstring_t origbinstr = NULL; /**< the string itself */
expstring_t binstr = NULL; /**< the string itself (with capital letters) */
bool valid_bit = false, /**< binstr is valid bitstring */ bool valid_bit = false, /**< binstr is valid bitstring */
valid_oct = false, /**< binstr is valid octetstring */ valid_oct = false, /**< binstr is valid octetstring */
half_oct = false, /**< binstr is not a valid octetstr but a valid hexstr */ half_oct = false, /**< binstr is not a valid octetstr but a valid hexstr */
...@@ -729,6 +730,7 @@ hostid RETURN(hostidKeyWord); ...@@ -729,6 +730,7 @@ hostid RETURN(hostidKeyWord);
NULL RETURN(NullValue); NULL RETURN(NullValue);
"'" { "'" {
origbinstr=memptystr();
binstr=memptystr(); binstr=memptystr();
valid_bit=true; valid_bit=true;
valid_oct=true; valid_oct=true;
...@@ -778,12 +780,14 @@ NULL RETURN(NullValue); ...@@ -778,12 +780,14 @@ NULL RETURN(NullValue);
} }
[01] { [01] {
origbinstr = mputc(origbinstr, yytext[0]);
binstr = mputc(binstr, yytext[0]); binstr = mputc(binstr, yytext[0]);
half_oct = !half_oct; half_oct = !half_oct;
current_column++; current_column++;
} }
[2-9A-F] { [2-9A-F] {
origbinstr = mputc(origbinstr, yytext[0]);
binstr = mputc(binstr, yytext[0]); binstr = mputc(binstr, yytext[0]);
valid_bit = false; valid_bit = false;
half_oct = !half_oct; half_oct = !half_oct;
...@@ -791,13 +795,15 @@ NULL RETURN(NullValue); ...@@ -791,13 +795,15 @@ NULL RETURN(NullValue);
} }
[a-f] { [a-f] {
binstr = mputc(binstr, yytext[0]); origbinstr = mputc(origbinstr, yytext[0]);
binstr = mputc(binstr, yytext[0] - 'a' + 'A');
valid_bit = false; valid_bit = false;
half_oct = !half_oct; half_oct = !half_oct;
current_column++; current_column++;
} }
"?"|"*" { "?"|"*" {
origbinstr = mputc(origbinstr, yytext[0]);
binstr = mputc(binstr, yytext[0]); binstr = mputc(binstr, yytext[0]);
contains_match = true; contains_match = true;
if (half_oct) valid_oct = false; if (half_oct) valid_oct = false;
...@@ -857,7 +863,8 @@ NULL RETURN(NullValue); ...@@ -857,7 +863,8 @@ NULL RETURN(NullValue);
"digits"); "digits");
} }
} }
MD5_Update(&md5_ctx, binstr, strlen(binstr)); MD5_Update(&md5_ctx, origbinstr, strlen(origbinstr));
Free(origbinstr);
Free(binstr); Free(binstr);
update_md5(); update_md5();
BEGIN(INITIAL); BEGIN(INITIAL);
...@@ -879,7 +886,8 @@ NULL RETURN(NullValue); ...@@ -879,7 +886,8 @@ NULL RETURN(NullValue);
Location loc(infile, yylloc); Location loc(infile, yylloc);
loc.error("Invalid binary string literal. Expecting `B', `H' or `O' after " loc.error("Invalid binary string literal. Expecting `B', `H' or `O' after "
"the closing `''"); "the closing `''");
MD5_Update(&md5_ctx, binstr, strlen(binstr)); MD5_Update(&md5_ctx, origbinstr, strlen(origbinstr));
Free(origbinstr);
Free(binstr); Free(binstr);
BEGIN(INITIAL); BEGIN(INITIAL);
RETURN_NOLOCUPD(TOK_errval); RETURN_NOLOCUPD(TOK_errval);
...@@ -891,7 +899,8 @@ NULL RETURN(NullValue); ...@@ -891,7 +899,8 @@ NULL RETURN(NullValue);
int c = static_cast<unsigned char>( yytext[0] ); int c = static_cast<unsigned char>( yytext[0] );
loc.error("Invalid character `%c' (0x%02X) in binary string", loc.error("Invalid character `%c' (0x%02X) in binary string",
isprint(c) ? c : '?', c); isprint(c) ? c : '?', c);
MD5_Update(&md5_ctx, binstr, strlen(binstr)); MD5_Update(&md5_ctx, origbinstr, strlen(origbinstr));
Free(origbinstr);
Free(binstr); Free(binstr);
MD5_Update(&md5_ctx, yytext, 1); MD5_Update(&md5_ctx, yytext, 1);
current_column++; current_column++;
...@@ -1130,6 +1139,7 @@ NULL RETURN(NullValue); ...@@ -1130,6 +1139,7 @@ NULL RETURN(NullValue);
loc.error("Unterminated block comment"); loc.error("Unterminated block comment");
break; break;
case SC_binstring: case SC_binstring:
Free(origbinstr);
Free(binstr); Free(binstr);
/* no break */ /* no break */
case SC_binstring_bad: case SC_binstring_bad:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment