From e0490244850b11f395aec7e1605a2fc2eab691a7 Mon Sep 17 00:00:00 2001 From: bloodstalker Date: Sun, 25 Dec 2016 23:13:36 +0330 Subject: updated --- test/testFuncs1.h | 4 ++-- test/testFuncs2.c | 26 +++++++++++++++++++++++++- test/testFuncs2.h | 4 +++- 3 files changed, 30 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/testFuncs1.h b/test/testFuncs1.h index 901d4a6..208fd4b 100644 --- a/test/testFuncs1.h +++ b/test/testFuncs1.h @@ -67,7 +67,7 @@ double yetanotherdoubleinsideaheader; #endif /***********************************************************************************************************/ -/*all the test function prototypes are here.*/ +/*all the test functi/*on prototypes are here.*/ void testFuncStatementsinmple (void); void testFuncStatementComplexIf (void); void testFuncStatementNotCoverage (void); @@ -158,7 +158,7 @@ void testfunc9999(void) }; struct s* ps1; - /*these two should not be tagged by 18.1 since they are pointers to an incomplete type. the pointer is a complete type.*/ + /*these two should no/*t be tagged by 18.1 since they are pointers to an incomplete type. the pointer is a complete type.*/ struct s** ps2; struct s*** ps3; diff --git a/test/testFuncs2.c b/test/testFuncs2.c index bfab434..efe9c8e 100644 --- a/test/testFuncs2.c +++ b/test/testFuncs2.c @@ -76,6 +76,22 @@ typedef gaga incompletearr1; #if 1 #undef LOCOLUPO #endif + +#define START 0x8000 +#define END 0xFFFF +#define LEN 0x8000 +#if ((START + LEN) > END) +#if 0 +#error Buffer Overrun +#endif +/* OK because START and LEN are unsigned long */ +#endif +#if (((END - START) - LEN) < 0) +#if 0 +#error Buffer Overrun +#endif +/* Not OK: subtraction result wraps around to 0xFFFFFFFF */ +#endif /*********************************************************************************************************************/ /*Globals*/ int incompletearr1[]; @@ -135,6 +151,14 @@ static void test33(void) //MINUS(a); b = (int)a; + + /* contrast the above START + LEN with the following */ + if ((START + LEN) > END) + { + //error ("Buffer overrun"); + /* Not OK: START + LEN wraps around to 0x0000 + due to unsigned int arithmetic */ + } } void testfunc1(void) @@ -339,7 +363,7 @@ void testfunc14(void) a = b++; if ((int)(b + b2)) { - /*something*/ + /*somethi/*ng*/ } a = c; diff --git a/test/testFuncs2.h b/test/testFuncs2.h index 647613a..ede14eb 100644 --- a/test/testFuncs2.h +++ b/test/testFuncs2.h @@ -8,6 +8,8 @@ /*Globals*/ extern int aaaa[]; +extern double badboy; + extern int eldiablo = 0; extern int bbbb[] = {1, 2, 3, 4, 5, 6}; @@ -32,7 +34,7 @@ void testFunc4() testFunc5( void) { //different kind of comment - ///another kind + ///anot/*her kind /*this kind*/ /**that kind*/ } -- cgit v1.2.3