Mercurial > hg-old > index.cgi
diff lwlink/trunk/src/readfiles.c @ 124:4ac96c697ef0
Corrected errors with parsing script and object files
author | lost |
---|---|
date | Fri, 23 Jan 2009 04:03:37 +0000 |
parents | 36ce328df3c3 |
children | 269ef87192ad |
line wrap: on
line diff
--- a/lwlink/trunk/src/readfiles.c Thu Jan 22 02:14:52 2009 +0000 +++ b/lwlink/trunk/src/readfiles.c Fri Jan 23 04:03:37 2009 +0000 @@ -88,9 +88,9 @@ // this macro is used to bail out if we run off the end of the file data // while parsing - it keeps the code below cleaner -#define NEXTBYTE() do { cc++; if (cc >= fn -> filesize) { fprintf(stderr, "%s: invalid file format\n", fn -> filename); exit(1); } } while (0) +#define NEXTBYTE() do { cc++; if (cc > fn -> filesize) { fprintf(stderr, "%s: invalid file format\n", fn -> filename); exit(1); } } while (0) // this macro is used to refer to the current byte in the stream -#define CURBYTE() (fn -> filedata[cc]) +#define CURBYTE() (fn -> filedata[cc < fn -> filesize ? cc : fn -> filesize - 1]) // this one will leave the input pointer past the trailing NUL #define CURSTR() read_lwobj16v0_str(&cc, fn) unsigned char *read_lwobj16v0_str(long *cc1, fileinfo_t *fn) @@ -185,7 +185,9 @@ se -> sym = fp; se -> offset = val; } - + // skip terminating NUL + NEXTBYTE(); + // now parse the exported symbol table while (CURBYTE()) { @@ -205,6 +207,8 @@ se -> sym = fp; se -> offset = val; } + // skip terminating NUL + NEXTBYTE(); // now parse the incomplete references and make a list of // external references that need resolution @@ -269,7 +273,7 @@ lw_expr_term_free(term); } } - // skip the NUL terminatin + // skip the NUL terminating the relocations NEXTBYTE(); // now set code location and size and verify that the file