From 8b471e7e7961f0a2c898a009d053eb13822a2113 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 28 Jun 2017 15:01:35 +0000 Subject: [PATCH] Faster parser stack overflow detection. FossilOrigin-Name: 36e54cd8b1fb374fd41e3e09b34b86e34327bf07c9e4bfec58382163c5c5d279 --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/lempar.c | 6 ++++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 4370c5292a..d205da7170 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Minor\stweak\sto\sthe\sSQL\sgrammar\sto\smake\sthe\sparser\stables\sa\sfew\sbytes\ssmaller. -D 2017-06-28T14:26:37.622 +C Faster\sparser\sstack\soverflow\sdetection. +D 2017-06-28T15:01:35.715 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 8eeb80162074004e906b53d7340a12a14c471a83743aab975947e95ce061efcc @@ -1510,7 +1510,7 @@ F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce F tool/kvtest-speed.sh 4761a9c4b3530907562314d7757995787f7aef8f F tool/lemon.c 5a04dff28578a67415cea5bf981b893c50cebfdd4388fb21254d1892525edfd8 -F tool/lempar.c 1653b07079a7b4c0eabe6cde5e354013da3cf4de30947d0dc00d045be1e2c9a1 +F tool/lempar.c f0dc07c2838febff4c34244651a6932fceb523065e6fe79bacfaa93019cc8cca F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca @@ -1584,7 +1584,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P b362f0d8ed34839bf3b29d10ed0853ab94245fba135ccd28e619caa6ee6992d5 -R 47fe456950b93480334e354c250c0848 +P cc4810b23e683e8c359f7c1a562338ec8501e43cac3475b2be002568fca5e6a4 +R aecb52c4ffe19d7ddc13e13ae7717a64 U drh -Z 983cf2b86c0c77a70c157e39be586b00 +Z deaa1ad68fb12d39469a0630e4b55aa7 diff --git a/manifest.uuid b/manifest.uuid index ff73f3fd14..f6a85fd8bf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cc4810b23e683e8c359f7c1a562338ec8501e43cac3475b2be002568fca5e6a4 \ No newline at end of file +36e54cd8b1fb374fd41e3e09b34b86e34327bf07c9e4bfec58382163c5c5d279 \ No newline at end of file diff --git a/tool/lempar.c b/tool/lempar.c index 51adf672b3..4a98d23700 100644 --- a/tool/lempar.c +++ b/tool/lempar.c @@ -221,6 +221,7 @@ struct yyParser { yyStackEntry yystk0; /* First stack entry */ #else yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */ + yyStackEntry *yystackEnd; /* Last entry in the stack */ #endif }; typedef struct yyParser yyParser; @@ -338,6 +339,7 @@ void ParseInit(void *yypParser){ pParser->yytos = pParser->yystack; pParser->yystack[0].stateno = 0; pParser->yystack[0].major = 0; + pParser->yystackEnd = &pParser->yystack[YYSTACKDEPTH-1]; } #ifndef Parse_ENGINEALWAYSONSTACK @@ -607,7 +609,7 @@ static void yy_shift( } #endif #if YYSTACKDEPTH>0 - if( yypParser->yytos>=&yypParser->yystack[YYSTACKDEPTH] ){ + if( yypParser->yytos>yypParser->yystackEnd ){ yypParser->yytos--; yyStackOverflow(yypParser); return; @@ -676,7 +678,7 @@ static void yy_reduce( } #endif #if YYSTACKDEPTH>0 - if( yypParser->yytos>=&yypParser->yystack[YYSTACKDEPTH-1] ){ + if( yypParser->yytos>=yypParser->yystackEnd ){ yyStackOverflow(yypParser); return; }