Problem with spatch 1.0rc21
Hello,
Suricata is using some coccinelle based tests for its QA and it seems there has been a change leading to a problem in a recent coccinelle release. Running them with coccinelle rc21 lead to an error.
When I run the following spatch on a file using strcpy, I've got a match and an error:
@banned@
identifier func =~ "^(sprintf|strcat|strcpy|strncpy|strncat|strndup|strchrdup)$"; position p1;
@@
<+...
func(...)@p1
...+>
@script:python@
p1 << banned.p1;
func << banned.func;
@@
print("Banned function %s() used at %s:%s" % (func, p1[0].file, p1[0].line)) import syssys.exit(1)
The error is the following:
spatch --sp-file qa/coccinelle/banned-functions.cocci src/source-af-packet.cinit_defs_builtins: /usr/share/coccinelle/standard.h
HANDLING: src/source-af-packet.c
Fatal error: exception Invalid_argument("equal: abstract value")
After some try it seems that the crashing part is the affection of p1 and func. Commenting (p<< and func<<) result in a complaint about undefined variable which is logical.
Spatch version:
spatch version 1.0.0-rc21 with Python support and with PCRE support
BR,
Signature · 1 line
Eric Leblond <[email protected]>
Quoted 7 lines
Suricata is using some coccinelle based tests for its QA and it seems there has been a change leading to a problem in a recent coccinelle release. Running them with coccinelle rc21 lead to an error.
When I run the following spatch on a file using strcpy, I've got a match and an error:
Quoted 8 lines
@banned@
identifier func =~ "^(sprintf|strcat|strcpy|strncpy|strncat|strndup|strchrdup)$"; position p1;
@@<+...
func(...)@p1
...+>
You don't need the <+... ...+> in this case.
Quoted 10 lines
@script:python@
p1 << banned.p1;
func << banned.func;
@@
print("Banned function %s() used at %s:%s" % (func, p1[0].file, p1[0].line))import syssys.exit(1)
Quoted 6 lines
The error is the following:
spatch --sp-file
qa/coccinelle/banned-functions.coccisrc/source-af-packet.cinit_defs_builtins:/usr/share/coccinelle/standard.h
HANDLING:src/source-af-packet.c
Fatal error: exceptionInvalid_argument("equal: abstract value")
I believe that I have already fixed this problem, but it has not yet been released. The problem is with the regular expression. One solution would be not to use PCRE regular expressions. This is a configuration option.
--enable-pcre enable global package pcre (yes,no) (default: auto)
Alternatively, there is really no point to use a regular expression in your case. Just put
\(sprintf\|strcat\|strcpy\|strncpy\|strncat\|strndup\|strchrdup\)
in the code in place of func.
julia
Quoted 17 lines
After some try it seems that the crashing part is the affection of p1 and func. Commenting (p<< and func<<) result in a complaint about undefined variable which is logical.
Spatch version:
spatch version 1.0.0-rc21 with Python support and with PCRE support
BR,
--
Eric Leblond <[email protected]>_______________________________________________
Cocci mailing list
Cocci at systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci
Hello,
Thanks for you quick answer!
Quoted 12 lines · Julia Lawall
Quoted 12 lines
Suricata is using some coccinelle based tests for its QA and it seems there has been a change leading to a problem in a recent coccinelle release. Running them with coccinelle rc21 lead to an error.
When I run the following spatch on a file using strcpy, I've got a match and an error:
@banned@
identifier func =~ "^(sprintf|strcat|strcpy|strncpy|strncat|strndup|strchrdup)$"; position p1;
@@
Quoted 5 lines
Quoted 3 lines
<+...
func(...)@p1
...+>You don't need the <+... ...+> in this case.
OK, thanks. Fixing that.
Quoted 13 lines
Quoted 13 lines
@script:python@
p1 << banned.p1;
func << banned.func;
@@
print("Banned function %s() used at %s:%s" % (func, p1[0].file, p1[0].line))import syssys.exit(1)The error is the following:
Quoted 7 lines
Quoted 4 lines
spatch --sp-file
qa/coccinelle/banned-functions.coccisrc/source-af-packet.cinit_defs_builtins:/usr/share/coccinelle/standard.h
HANDLING:src/source-af-packet.c
Fatal error: exceptionInvalid_argument("equal: abstract value")I believe that I have already fixed this problem, but it has not yet been released.
OK, I can test the patch if you want.
Quoted 9 lines
The problem is with the regular expression. One solution would be not to use PCRE regular expressions. This is a configuration option.
--enable-pcre enable global package pcre (yes,no) (default: auto)
Alternatively, there is really no point to use a regular expression in your case. Just put
\(sprintf\|strcat\|strcpy\|strncpy\|strncat\|strndup\|strchrdup\)
in the code in place of func.
OK, this works with this change but how can I access to the function name afterward to have it displayed in the error message ? The line does not seem to be accessible in python code.
BR,
Signature · 1 line
Eric Leblond <[email protected]>
Quoted 53 lines · Eric Leblond
Hello,
Thanks for you quick answer!
Quoted 12 lines · Julia Lawall
Quoted 12 lines
Suricata is using some coccinelle based tests for its QA and it seems there has been a change leading to a problem in a recent coccinelle release. Running them with coccinelle rc21 lead to an error.
When I run the following spatch on a file using strcpy, I've got a match and an error:
@banned@
identifier func =~ "^(sprintf|strcat|strcpy|strncpy|strncat|strndup|strchrdup)$"; position p1;
@@Quoted 5 lines
Quoted 3 lines
<+...
func(...)@p1
...+>You don't need the <+... ...+> in this case.
OK, thanks. Fixing that.
Quoted 13 lines
Quoted 13 lines
@script:python@
p1 << banned.p1;
func << banned.func;
@@
print("Banned function %s() used at %s:%s" % (func, p1[0].file, p1[0].line))import syssys.exit(1)The error is the following:
Quoted 7 lines
Quoted 4 lines
spatch --sp-file
qa/coccinelle/banned-functions.coccisrc/source-af-packet.cinit_defs_builtins:/usr/share/coccinelle/standard.h
HANDLING:src/source-af-packet.c
Fatal error: exceptionInvalid_argument("equal: abstract value")I believe that I have already fixed this problem, but it has not yet been released.
OK, I can test the patch if you want.
Quoted 5 lines
The problem is with the regular expression. One solution would be not to use PCRE regular expressions. This is a configuration option.
--enable-pcre enable global package pcre (yes,no) (default: auto)
Quoted 8 lines
Quoted 4 lines
Alternatively, there is really no point to use a regular expression in your case. Just put
\(sprintf\|strcat\|strcpy\|strncpy\|strncat\|strndup\|strchrdup\)
in the code in place of func.OK, this works with this change but how can I access to the function name afterward to have it displayed in the error message ? The line does not seem to be accessible in python code.
Ah, OK I missed that detail. You can make an identifier metavariable i, and then put:
\(sprintf at i\|strcat at i\|strcpy at i\|strncpy at i\|strncat at i\|strndup at i\|strchrdup at i\)
Now you can inherit and print i.
julia