Skip to content

Commit d8a70d8

Browse files
committed
C++: Add test annotations
1 parent 751e7e6 commit d8a70d8

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ namespace std {
2525

2626
int brotli_test(int argc, const char **argv) {
2727
uint8_t *output = nullptr;
28-
BrotliDecoderDecompress(1024 * 1024, (uint8_t *) argv[2],
28+
BrotliDecoderDecompress(1024 * 1024, (uint8_t *) argv[2], // BAD
2929
reinterpret_cast<size_t *>(1024 * 1024 * 1024), output);
3030
uint8_t **output2 = nullptr;
3131
const uint8_t **input2 = nullptr;
3232
std::strncpy(reinterpret_cast<char *>(input2), argv[2], 32);
3333
BrotliDecoderDecompressStream(0, reinterpret_cast<size_t *>(1024 * 1024),
34-
input2, reinterpret_cast<size_t *>(1024 * 1024 * 1024),
34+
input2, reinterpret_cast<size_t *>(1024 * 1024 * 1024), // BAD
3535
output2,
3636
reinterpret_cast<size_t *>(1024 * 1024 * 1024));
3737
return 0;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static int copy_data(struct archive *ar, struct archive *aw) {
5353
la_int64_t offset;
5454

5555
for (;;) {
56-
archive_read_data_block(ar, &buff, &size, &offset);
56+
archive_read_data_block(ar, &buff, &size, &offset); // BAD
5757
if (r == ARCHIVE_EOF)
5858
return (ARCHIVE_OK);
5959
if (r < ARCHIVE_OK)

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ int minizip_test(int argc, const char **argv) {
3737
int32_t err;
3838
char buf[4096];
3939
do {
40-
bytes_read = mz_zip_entry_read(zip_handle, (char *) argv[1], sizeof(buf));
40+
bytes_read = mz_zip_entry_read(zip_handle, (char *) argv[1], sizeof(buf)); // BAD
4141
if (bytes_read < 0) {
4242
err = bytes_read;
4343
}
@@ -55,7 +55,7 @@ int minizip_test(int argc, const char **argv) {
5555
mz_stream_os_open(entry_stream, entry_path, 1);
5656
int file_stream;
5757
int mz_stream_os_write;
58-
mz_zip_reader_entry_save(zip_reader, file_stream, mz_stream_os_write);
58+
mz_zip_reader_entry_save(zip_reader, file_stream, mz_stream_os_write); // BAD
5959
// the above sink is same as "mz_zip_reader_entry_save", "mz_zip_reader_entry_read", "mz_zip_reader_entry_save_process",
6060
// "mz_zip_reader_entry_save_file", "mz_zip_reader_entry_save_buffer", "mz_zip_reader_save_all" and "mz_zip_entry_read" functions
6161
mz_stream_os_close(entry_stream);
@@ -64,7 +64,7 @@ int minizip_test(int argc, const char **argv) {
6464
mz_zip_reader_delete(&zip_reader);
6565

6666

67-
UnzOpen(argv[3]);
67+
UnzOpen(argv[3]); // BAD
6868
return 0;
6969
}
7070

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ int UnsafeInflate(char *a) {
6767
// uLong total_out; /* total number of bytes output so far */
6868
// the actual DE-compression work.
6969
inflateInit(&infstream);
70-
inflate(&infstream, Z_NO_FLUSH);
70+
inflate(&infstream, Z_NO_FLUSH); // BAD
7171
inflateEnd(&infstream);
7272

7373

@@ -98,7 +98,7 @@ int UnsafeGzread(char *fileName) {
9898
unsigned char unzipBuffer[8192];
9999
unsigned int unzippedBytes;
100100
while (true) {
101-
unzippedBytes = gzread(inFileZ, unzipBuffer, 8192);
101+
unzippedBytes = gzread(inFileZ, unzipBuffer, 8192); // BAD
102102
if (unzippedBytes > 0) {
103103
std::cout << unzippedBytes;
104104
} else {
@@ -118,7 +118,7 @@ int UnsafeGzfread(char *fileName) {
118118
}
119119
while (true) {
120120
char buffer[1000];
121-
if (!gzfread(buffer, 999, 1, inFileZ)) {
121+
if (!gzfread(buffer, 999, 1, inFileZ)) { // BAD
122122
break;
123123
}
124124
}
@@ -136,7 +136,7 @@ int UnsafeGzgets(char *fileName) {
136136
char *buffer = new char[4000000000];
137137
char *result;
138138
while (true) {
139-
result = gzgets(inFileZ, buffer, 1000000000);
139+
result = gzgets(inFileZ, buffer, 1000000000); // BAD
140140
if (result == nullptr) {
141141
break;
142142
}
@@ -160,7 +160,7 @@ bool InflateString(const unsigned char *input, const unsigned char *output, size
160160
destination_length = (uLong) output_length;
161161

162162
int result = uncompress((Bytef *) output, &destination_length,
163-
(Bytef *) input, source_length);
163+
(Bytef *) input, source_length); // BAD
164164

165165
return result == Z_OK;
166166
}

0 commit comments

Comments
 (0)