Datasets:
Download raw/cpp/cwe_119_4_secure_translate.cpp from amazon/AutoSUIT: direct link, hf CLI and curl.
- Browser
- Download file 598 Bytes
-
https://huggingface.co/datasets/amazon/AutoSUIT/resolve/main/raw/cpp/cwe_119_4_secure_translate.cpp
- Command line
-
hf download hf://datasets/amazon/AutoSUIT/raw/cpp/cwe_119_4_secure_translate.cpp
-
curl -L -o cwe_119_4_secure_translate.cpp https://huggingface.co/datasets/amazon/AutoSUIT/resolve/main/raw/cpp/cwe_119_4_secure_translate.cpp
598 Bytes
| // Function prototype | |
| bool isIndexValid(int index, int len); | |
| // Function to check array index validity | |
| bool isIndexValid(int index, int len) { | |
| // check that the array index is within the correct range of values for the array | |
| return (index >= 0 && index < len); | |
| } | |
| int main() { | |
| int index = 5; // Example value | |
| int len = 10; // Example value | |
| if (isIndexValid(index, len)) { | |
| std::cout << "Index is within range." << std::endl; | |
| } else { | |
| std::cout << "Index is out of range." << std::endl; | |
| } | |
| return 0; | |
| } | |