aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip <pipcet@gmail.com>2015-04-30 21:31:32 +0000
committerPhilip <pipcet@gmail.com>2015-04-30 21:35:21 +0000
commit951a43ea6c77436209c3dc974d8b18e5b2e87936 (patch)
tree41e47cb9200a64397409a5b18447a571f7593573
parent2e04fa8872f38aea4eb96fd3424c3d6762b5262d (diff)
downloadtinycc-951a43ea6c77436209c3dc974d8b18e5b2e87936.tar.gz
tinycc-951a43ea6c77436209c3dc974d8b18e5b2e87936.tar.bz2
fix a potential end-of-buffer issue in tccelf.c
also read characters one at a time when PARSE_DEBUG is set; after this patch, things seem to work with that.
-rw-r--r--tccelf.c7
-rw-r--r--tccpp.c2
2 files changed, 6 insertions, 3 deletions
diff --git a/tccelf.c b/tccelf.c
index 552a39f..581ebef 100644
--- a/tccelf.c
+++ b/tccelf.c
@@ -3275,6 +3275,11 @@ static int ld_next(TCCState *s1, char *name, int name_size)
goto parse_name;
}
break;
+ case '\\':
+ ch = handle_eob();
+ if (ch != '\\')
+ goto redo;
+ /* fall through */
/* case 'a' ... 'z': */
case 'a':
case 'b':
@@ -3330,7 +3335,6 @@ static int ld_next(TCCState *s1, char *name, int name_size)
case 'Y':
case 'Z':
case '_':
- case '\\':
case '.':
case '$':
case '~':
@@ -3462,7 +3466,6 @@ ST_FUNC int tcc_load_ldscript(TCCState *s1)
char filename[1024];
int t, ret;
- ch = file->buf_ptr[0];
ch = handle_eob();
for(;;) {
t = ld_next(s1, cmd, sizeof(cmd));
diff --git a/tccpp.c b/tccpp.c
index b44296d..0a99832 100644
--- a/tccpp.c
+++ b/tccpp.c
@@ -386,7 +386,7 @@ static int tcc_peekc_slow(BufferedFile *bf)
if (bf->buf_ptr >= bf->buf_end) {
if (bf->fd != -1) {
#if defined(PARSE_DEBUG)
- len = 8;
+ len = 1;
#else
len = IO_BUF_SIZE;
#endif