Changeset 80883
- Timestamp:
- 07/19/11 21:18:40 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/gsoc11-post-destroot/base/src/pextlib1.0/macho.c
r80618 r80883 9 9 #include <sys/mman.h> 10 10 11 #include <err.h>12 11 #include <string.h> 13 12 … … 30 29 static const void *macho_read (macho_input_t *input, const void *address, size_t length) { 31 30 if ((((uint8_t *) address) - ((uint8_t *) input->data)) + length > input->length) { 32 warnx("Short read parsing Mach-O input");33 31 return NULL; 34 32 } … … 120 118 121 119 default: 122 warnx("Unknown Mach-O magic: 0x%" PRIx32 "", *magic); 123 return false; 120 return TCL_ERROR; 124 121 } 125 122 … … 158 155 cmd = macho_offset(input, header, header_size, sizeof(struct load_command)); 159 156 if (cmd == NULL) 160 return false;157 return TCL_ERROR; 161 158 ncmds = swap32(header->ncmds); 162 159 … … 167 164 cmd = macho_read(input, cmd, cmdsize); 168 165 if (cmd == NULL) 169 return false;166 return TCL_ERROR; 170 167 171 168 /* Handle known types */ … … 175 172 /* Fetch the path */ 176 173 if (cmdsize < sizeof(struct rpath_command)) { 177 warnx("Incorrect cmd size"); 178 return false; 174 return TCL_ERROR; 179 175 } 180 176 … … 182 178 const void *pathptr = macho_offset(input, cmd, sizeof(struct rpath_command), pathlen); 183 179 if (pathptr == NULL) 184 return false;180 return TCL_ERROR; 185 181 186 182 char *path = malloc(pathlen); … … 198 194 /* Extract the install name */ 199 195 if (cmdsize < sizeof(struct dylib_command)) { 200 warnx("Incorrect name size"); 201 return false; 196 return TCL_ERROR; 202 197 } 203 198 … … 205 200 const void *nameptr = macho_offset(input, cmd, sizeof(struct dylib_command), namelen); 206 201 if (nameptr == NULL) 207 return false;202 return TCL_ERROR; 208 203 209 204 char *name = malloc(namelen); … … 286 281 287 282 default: 288 warnx("Unknown Mach-O magic: 0x%" PRIx32 "", *magic);289 283 return TCL_ERROR; 290 284 } … … 354 348 void *data = mmap(NULL, stbuf.st_size, PROT_READ, MAP_FILE|MAP_PRIVATE, fd, 0); 355 349 if (data == MAP_FAILED) 356 err(1, "mmap()");350 return TCL_ERROR; 357 351 358 352 /* Parse */ … … 394 388 void *data = mmap(NULL, stbuf.st_size, PROT_READ, MAP_FILE|MAP_PRIVATE, fd, 0); 395 389 if (data == MAP_FAILED) 396 err(1, "mmap()");390 return TCL_ERROR; 397 391 398 392 /* Parse */
Note: See TracChangeset
for help on using the changeset viewer.

