diff --git a/addons/cert.py b/addons/cert.py index 34454e76a..cac9d0c26 100755 --- a/addons/cert.py +++ b/addons/cert.py @@ -233,6 +233,16 @@ def int31(data, platform): 'Ensure that integer conversions do not result in lost or misinterpreted data (casting ' + str(value.intvalue) + ' to ' + destType + ')', 'INT31-c') break + + +# ENV33-C +# Do not call system() +def env33(data): + for token in data.tokenlist: + if isFunctionCall(token, ('system',), 1): + reportError(token, 'style', 'Do not call system()', 'ENV33-C') + + # MSC24-C # Do not use deprecated or obsolescent functions def msc24(data): @@ -399,6 +409,7 @@ if __name__ == '__main__': str05(cfg) str07(cfg) str11(cfg) + env33(cfg) msc24(cfg) msc30(cfg) api01(cfg) diff --git a/addons/test/cert-test.c b/addons/test/cert-test.c index dd850c179..64c8b6ea7 100644 --- a/addons/test/cert-test.c +++ b/addons/test/cert-test.c @@ -21,12 +21,12 @@ void api01() } struct good_node_s { - struct good_node_s* next; + struct good_node_s* next; char name[String_Size]; } struct also_good_node_s { - struct also_good_node_s* next; + struct also_good_node_s* next; char *name; } } @@ -74,12 +74,18 @@ unsigned char int31(int x) x = (unsigned long long)-1; // cert-INT31-c } +void env33() +{ + system("chmod -x $(which chmod)"); // cert-ENV33-C + int system; +} + void msc24() { struct S { int x; int fopen; }; - + struct S s; time_t rawtime; struct tm *timeinfo;