Skip to content

Commit 92d748e

Browse files
committed
C++: Fix ODR/dbcheck issue in test.
1 parent 46f3f28 commit 92d748e

File tree

3 files changed

+55
-30
lines changed

3 files changed

+55
-30
lines changed

cpp/ql/test/query-tests/Security/CWE/CWE-497/semmle/tests/tests.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
// library functions etc
44

5-
typedef unsigned long size_t;
5+
#include "tests.h"
6+
7+
68
typedef struct {} FILE;
79
FILE *stdout;
810

@@ -13,29 +15,27 @@ int snprintf(char *s, size_t n, const char *format, ...);
1315
size_t strlen(const char *s);
1416
char *getenv(const char *name);
1517

16-
namespace std
17-
{
18-
typedef size_t streamsize;
18+
extern std::ostream someotherostream;
19+
20+
21+
22+
23+
24+
25+
26+
27+
28+
29+
30+
31+
32+
33+
1934

20-
template<class charT> struct char_traits;
2135

22-
template <class charT, class traits = char_traits<charT> >
23-
class basic_ostream /*: virtual public basic_ios<charT,traits> - not needed for this test */ {
24-
public:
25-
typedef charT char_type;
26-
basic_ostream<charT,traits>& write(const char_type* s, streamsize n);
2736

28-
basic_ostream<charT, traits>& operator<<(int n);
29-
};
30-
template<class charT, class traits> basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&, const charT*);
3137

32-
typedef basic_ostream<char> ostream;
3338

34-
extern ostream cout;
35-
extern ostream cerr;
36-
extern ostream clog;
37-
}
38-
extern std::ostream someotherostream;
3939

4040
#define NULL (0)
4141

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
typedef unsigned long size_t;
3+
4+
namespace std
5+
{
6+
typedef size_t streamsize;
7+
8+
template<class charT> struct char_traits;
9+
10+
template <class charT, class traits = char_traits<charT> >
11+
class basic_ostream /*: virtual public basic_ios<charT,traits> - not needed for this test */ {
12+
public:
13+
typedef charT char_type;
14+
basic_ostream<charT,traits>& write(const char_type* s, streamsize n);
15+
16+
basic_ostream<charT, traits>& operator<<(int n);
17+
};
18+
template<class charT, class traits> basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&, const charT*);
19+
20+
typedef basic_ostream<char> ostream;
21+
22+
extern ostream cout;
23+
extern ostream cerr;
24+
extern ostream clog;
25+
}

cpp/ql/test/query-tests/Security/CWE/CWE-497/semmle/tests/tests2.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@
22

33
// library functions etc
44

5+
#include "tests.h"
6+
57
char *getenv(const char *name);
68
char *strcpy(char *s1, const char *s2);
79

8-
namespace std
9-
{
10-
template<class charT> struct char_traits;
1110

12-
template <class charT, class traits = char_traits<charT> >
13-
class basic_ostream /*: virtual public basic_ios<charT,traits> - not needed for this test */ {
14-
public:
15-
};
1611

17-
template<class charT, class traits> basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&, const charT*);
1812

19-
typedef basic_ostream<char> ostream;
2013

21-
extern ostream cout;
22-
}
14+
15+
16+
17+
18+
19+
20+
21+
22+
2323

2424
int socket(int p1, int p2, int p3);
2525
void send(int sock, const char *buffer, int p3, int p4);

0 commit comments

Comments
 (0)