mirror of
https://github.com/SELinuxProject/selinux
synced 2025-02-14 16:47:27 +00:00
checkpolicy: print warning on source line overflow
In case the source line value overflows or has a too big value in the source policy print a warning. policy_scan.l:273:19: runtime error: implicit conversion from type 'int' of value -2 (32-bit, signed) to type 'unsigned long' changed the value to 18446744073709551614 (64-bit, unsigned) policy_scan.l:66:20: runtime error: unsigned integer overflow: 18446744073709551615 + 1 cannot be represented in type 'unsigned long' Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
This commit is contained in:
parent
15fcc6df66
commit
ba18cf0cdf
@ -59,12 +59,17 @@ alnum [a-zA-Z0-9]
|
|||||||
hexval [0-9A-Fa-f]
|
hexval [0-9A-Fa-f]
|
||||||
|
|
||||||
%%
|
%%
|
||||||
\n.* { strncpy(linebuf[lno], yytext+1, 255);
|
\n.* {
|
||||||
linebuf[lno][254] = 0;
|
strncpy(linebuf[lno], yytext+1, 255);
|
||||||
lno = 1 - lno;
|
linebuf[lno][254] = 0;
|
||||||
policydb_lineno++;
|
lno = 1 - lno;
|
||||||
source_lineno++;
|
policydb_lineno++;
|
||||||
yyless(1); }
|
if (source_lineno == ULONG_MAX)
|
||||||
|
yywarn("source line number overflow");
|
||||||
|
else
|
||||||
|
source_lineno++;
|
||||||
|
yyless(1);
|
||||||
|
}
|
||||||
CLONE |
|
CLONE |
|
||||||
clone { return(CLONE); }
|
clone { return(CLONE); }
|
||||||
COMMON |
|
COMMON |
|
||||||
@ -270,7 +275,13 @@ GLBLUB { return(GLBLUB); }
|
|||||||
{hexval}{0,4}":"{hexval}{0,4}":"({hexval}|[:.])* { return(IPV6_ADDR); }
|
{hexval}{0,4}":"{hexval}{0,4}":"({hexval}|[:.])* { return(IPV6_ADDR); }
|
||||||
{digit}+(\.({alnum}|[_.])*)? { return(VERSION_IDENTIFIER); }
|
{digit}+(\.({alnum}|[_.])*)? { return(VERSION_IDENTIFIER); }
|
||||||
#line[ ]1[ ]\"[^\n]*\" { set_source_file(yytext+9); }
|
#line[ ]1[ ]\"[^\n]*\" { set_source_file(yytext+9); }
|
||||||
#line[ ]{digit}+ { source_lineno = atoi(yytext+6)-1; }
|
#line[ ]{digit}+ {
|
||||||
|
errno = 0;
|
||||||
|
source_lineno = strtoul(yytext+6, NULL, 10) - 1;
|
||||||
|
if (errno) {
|
||||||
|
yywarn("source line number too big");
|
||||||
|
}
|
||||||
|
}
|
||||||
#[^\n]* { /* delete comments */ }
|
#[^\n]* { /* delete comments */ }
|
||||||
[ \t\f]+ { /* delete whitespace */ }
|
[ \t\f]+ { /* delete whitespace */ }
|
||||||
"==" { return(EQUALS); }
|
"==" { return(EQUALS); }
|
||||||
|
Loading…
Reference in New Issue
Block a user