| /* | |
| * Copyright (C) 2025 The Android Open Source Project | |
| * | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | |
| * | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * | |
| * Unless required by applicable law or agreed to in writing, software | |
| * distributed under the License is distributed on an "AS IS" BASIS, | |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| * See the License for the specific language governing permissions and | |
| * limitations under the License. | |
| */ | |
| #include <iostream> | |
| #include <fstream> | |
| #define EXIT_SUCCESS 0 | |
| #define EXIT_FAILURE 1 | |
| #define EXIT_VULNERABLE 113 | |
| int main(int argc, char *argv[]) { | |
| if (argc != 3) { | |
| std::cout << "unknown commands" << std::endl; | |
| return EXIT_FAILURE; | |
| } | |
| std::ifstream f(argv[1]); | |
| if (f.is_open()) { | |
| // the host test can either check exit code or stdout | |
| std::cout << "Hello " << f.rdbuf() << "! " << argv[2] << std::endl; | |
| // please don't use a test-controlled value in a security report | |
| std::string expected = "secure"; | |
| if (expected.compare(argv[2]) != 0) { | |
| return EXIT_VULNERABLE; | |
| } else { | |
| return EXIT_SUCCESS; | |
| } | |
| } else { | |
| std::cout << "could not open file" << std::endl; | |
| return EXIT_FAILURE; | |
| } | |
| } |