aboutsummaryrefslogtreecommitdiff
path: root/src/lj_lex.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lj_lex.c')
-rw-r--r--src/lj_lex.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/lj_lex.c b/src/lj_lex.c
index d87a49dc..669d2dfe 100644
--- a/src/lj_lex.c
+++ b/src/lj_lex.c
@@ -411,6 +411,7 @@ static int llex(LexState *ls, TValue *tv)
411/* Setup lexer state. */ 411/* Setup lexer state. */
412int lj_lex_setup(lua_State *L, LexState *ls) 412int lj_lex_setup(lua_State *L, LexState *ls)
413{ 413{
414 int header = 0;
414 ls->L = L; 415 ls->L = L;
415 ls->fs = NULL; 416 ls->fs = NULL;
416 ls->n = 0; 417 ls->n = 0;
@@ -430,6 +431,7 @@ int lj_lex_setup(lua_State *L, LexState *ls)
430 ls->n -= 2; 431 ls->n -= 2;
431 ls->p += 2; 432 ls->p += 2;
432 next(ls); 433 next(ls);
434 header = 1;
433 } 435 }
434 if (ls->current == '#') { /* Skip POSIX #! header line. */ 436 if (ls->current == '#') { /* Skip POSIX #! header line. */
435 do { 437 do {
@@ -437,8 +439,22 @@ int lj_lex_setup(lua_State *L, LexState *ls)
437 if (ls->current == END_OF_STREAM) return 0; 439 if (ls->current == END_OF_STREAM) return 0;
438 } while (!currIsNewline(ls)); 440 } while (!currIsNewline(ls));
439 inclinenumber(ls); 441 inclinenumber(ls);
442 header = 1;
440 } 443 }
441 return (ls->current == LUA_SIGNATURE[0]); /* Bytecode dump? */ 444 if (ls->current == LUA_SIGNATURE[0]) { /* Bytecode dump. */
445 if (header) {
446 /*
447 ** Loading bytecode with an extra header is disabled for security
448 ** reasons. This may circumvent the usual check for bytecode vs.
449 ** Lua code by looking at the first char. Since this is a potential
450 ** security violation no attempt is made to echo the chunkname either.
451 */
452 setstrV(L, L->top++, lj_err_str(L, LJ_ERR_BCHEAD));
453 lj_err_throw(L, LUA_ERRSYNTAX);
454 }
455 return 1;
456 }
457 return 0;
442} 458}
443 459
444/* Cleanup lexer state. */ 460/* Cleanup lexer state. */