Skip to content

Commit a10b502

Browse files
committed
fix tests, it is not fixed 100%
1 parent 87b6495 commit a10b502

3 files changed

Lines changed: 21 additions & 18 deletions

File tree

cpp/ql/src/experimental/query-tests/Security/CWE/CWE-409/DecompressionBomb.qll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
import cpp
22
import semmle.code.cpp.ir.dataflow.TaintTracking
3+
import MiniZip
4+
import ZlibGzopen
5+
import ZlibInflator
6+
import ZlibUncompress
7+
import LibArchive
8+
import LibMiniz
9+
import XZ
10+
import ZSTD
11+
import Bzip2
12+
import Brotli
313

414
/**
515
* The Decompression Sink instances, extend this class to define new decompression sinks.

cpp/ql/src/experimental/query-tests/Security/CWE/CWE-409/DecompressionBombs.ql

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ import cpp
1515
import semmle.code.cpp.ir.dataflow.TaintTracking
1616
import semmle.code.cpp.security.FlowSources
1717
import semmle.code.cpp.commons.File
18-
import MiniZip
19-
import ZlibGzopen
2018
import DecompressionBomb
2119

2220
module DecompressionTaintConfig implements DataFlow::ConfigSig {

cpp/ql/test/experimental/query-tests/Security/CWE/CWE-409/zlibTest.cpp

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,12 @@ namespace std {
5050
extern ostream cout;
5151
}
5252

53-
int UnsafeInflate(int argc, char *argv[]) {
54-
// original string len = 36
55-
char a[50] = "Hello Hello Hello Hello Hello Hello!";
53+
int UnsafeInflate(char *a) {
5654
// placeholder for the compressed (deflated) version of "a"
5755
char b[50];
5856
// placeholder for the Uncompressed (inflated) version of "b"
5957
char c[50];
6058

61-
6259
// STEP 1.
6360
// zlib struct
6461
z_stream defstream;
@@ -117,12 +114,7 @@ void gzclose(gzFile gz_file);
117114
std::ostream operator<<(const std::ostream &lhs, unsigned char rhs);
118115

119116

120-
int send(int, const void *, int, int);
121-
122-
123-
int UnsafeGzread(char **argv) {
124-
char *fileName;
125-
send(0, fileName, 0, 0);
117+
int UnsafeGzread(char *fileName) {
126118
gzFile inFileZ = gzopen(fileName, "rb");
127119
if (&inFileZ == nullptr) {
128120
exit(0);
@@ -143,9 +135,7 @@ int UnsafeGzread(char **argv) {
143135

144136
bool gzfread(char *str, int i, int i1, gzFile gz_file);
145137

146-
int UnsafeGzfread(char **argv) {
147-
char *fileName;
148-
send(0, fileName, 0, 0);
138+
int UnsafeGzfread(char *fileName) {
149139
gzFile inFileZ = gzopen(fileName, "rb");
150140
if (&inFileZ == nullptr) {
151141
exit(0);
@@ -162,9 +152,7 @@ int UnsafeGzfread(char **argv) {
162152

163153
char *gzgets(gzFile gz_file, char *buffer, int i);
164154

165-
int UnsafeGzgets(char **argv) {
166-
char *fileName;
167-
send(0, fileName, 0, 0);
155+
int UnsafeGzgets(char *fileName) {
168156
gzFile inFileZ = gzopen(fileName, "rb");
169157
if (&inFileZ == nullptr) {
170158
exit(0);
@@ -180,3 +168,10 @@ int UnsafeGzgets(char **argv) {
180168
}
181169
return 0;
182170
}
171+
172+
int main(int argc, char **argv) {
173+
UnsafeGzfread(argv[2]);
174+
UnsafeGzgets(argv[2]);
175+
UnsafeInflate(argv[2]);
176+
UnsafeGzread(argv[2]);
177+
}

0 commit comments

Comments
 (0)