| 162 | }; |
| 163 | |
| 164 | bool cmMachOHeaderAndLoadCommands::read_load_commands(uint32_t ncmds, |
| 165 | uint32_t sizeofcmds, |
| 166 | cmsys::ifstream& fin) |
| 167 | { |
| 168 | uint32_t size_read = 0; |
| 169 | this->LoadCommands.resize(ncmds); |
| 170 | for (uint32_t i = 0; i < ncmds; i++) { |
| 171 | load_command lc; |
| 172 | if (!peek(fin, lc)) { |
| 173 | return false; |
| 174 | } |
| 175 | lc.cmd = swap(lc.cmd); |
| 176 | lc.cmdsize = swap(lc.cmdsize); |
| 177 | size_read += lc.cmdsize; |
| 178 | |
| 179 | RawLoadCommand& c = this->LoadCommands[i]; |
| 180 | c.LoadCommand.resize(lc.cmdsize); |
| 181 | if (!read(fin, c.LoadCommand)) { |
| 182 | return false; |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | if (size_read != sizeofcmds) { |
| 187 | this->LoadCommands.clear(); |
| 188 | return false; |
| 189 | } |
| 190 | |
| 191 | return true; |
| 192 | } |
| 193 | |
| 194 | class cmMachOInternal |
| 195 | { |