| 118 | }; |
| 119 | |
| 120 | static std::vector<CIntegrityFileLine> ReadIntegrityFile(const char *pFilename) |
| 121 | { |
| 122 | CLineReader LineReader; |
| 123 | if(!LineReader.OpenFile(io_open(pFilename, IOFLAG_READ))) |
| 124 | { |
| 125 | return {}; |
| 126 | } |
| 127 | |
| 128 | std::vector<CIntegrityFileLine> vLines; |
| 129 | while(const char *pReadLine = LineReader.Get()) |
| 130 | { |
| 131 | const char *pSpaceInLine = str_rchr(pReadLine, ' '); |
| 132 | CIntegrityFileLine Line; |
| 133 | char aSha256[SHA256_MAXSTRSIZE]; |
| 134 | if(pSpaceInLine == nullptr) |
| 135 | { |
| 136 | if(!vLines.empty()) |
| 137 | { |
| 138 | // Only the first line is allowed to not contain a filename |
| 139 | log_error("android", "Failed to parse line %" PRIzu " of '%s': line does not contain space", vLines.size() + 1, pFilename); |
| 140 | return {}; |
| 141 | } |
| 142 | Line.m_aFilename[0] = '\0'; |
| 143 | str_copy(aSha256, pReadLine); |
| 144 | } |
| 145 | else |
| 146 | { |
| 147 | str_truncate(Line.m_aFilename, sizeof(Line.m_aFilename), pReadLine, pSpaceInLine - pReadLine); |
| 148 | str_copy(aSha256, pSpaceInLine + 1); |
| 149 | } |
| 150 | if(sha256_from_str(&Line.m_Sha256, aSha256) != 0) |
| 151 | { |
| 152 | log_error("android", "Failed to parse line %" PRIzu " of '%s': invalid SHA256 string", vLines.size() + 1, pFilename); |
| 153 | return {}; |
| 154 | } |
| 155 | vLines.emplace_back(std::move(Line)); |
| 156 | } |
| 157 | |
| 158 | return vLines; |
| 159 | } |
| 160 | |
| 161 | const char *InitAndroid() |
| 162 | { |
no test coverage detected