mirror of
https://gitee.com/TarsCloud/TarsCpp.git
synced 2024-12-22 22:16:38 +08:00
fix tars proto, overflow bug
This commit is contained in:
parent
b7e9be5a5b
commit
ee17821a2e
@ -627,6 +627,12 @@ namespace tars
|
|||||||
*/
|
*/
|
||||||
bool hasEnd()
|
bool hasEnd()
|
||||||
{
|
{
|
||||||
|
if(_cur > _buf_len)
|
||||||
|
{
|
||||||
|
char s[64];
|
||||||
|
snprintf(s, sizeof(s), "buffer overflow when skip, over %u.", (uint32_t)_buf_len);
|
||||||
|
throw TarsDecodeException(s);
|
||||||
|
}
|
||||||
return _cur >= _buf_len;
|
return _cur >= _buf_len;
|
||||||
}
|
}
|
||||||
size_t tellp() const
|
size_t tellp() const
|
||||||
@ -991,7 +997,7 @@ namespace tars
|
|||||||
break;
|
break;
|
||||||
case TarsHeadeMap:
|
case TarsHeadeMap:
|
||||||
{
|
{
|
||||||
Int32 size = 0;
|
UInt32 size = 0;
|
||||||
read(size, 0);
|
read(size, 0);
|
||||||
for (Int32 i = 0; i < size * 2; ++i)
|
for (Int32 i = 0; i < size * 2; ++i)
|
||||||
skipField();
|
skipField();
|
||||||
@ -999,7 +1005,7 @@ namespace tars
|
|||||||
break;
|
break;
|
||||||
case TarsHeadeList:
|
case TarsHeadeList:
|
||||||
{
|
{
|
||||||
Int32 size = 0;
|
UInt32 size = 0;
|
||||||
read(size, 0);
|
read(size, 0);
|
||||||
for (Int32 i = 0; i < size; ++i)
|
for (Int32 i = 0; i < size; ++i)
|
||||||
skipField();
|
skipField();
|
||||||
@ -1015,7 +1021,7 @@ namespace tars
|
|||||||
snprintf(s, sizeof(s), "skipField with invalid type, type value: %d, %d, %d.", type, headType, headTag);
|
snprintf(s, sizeof(s), "skipField with invalid type, type value: %d, %d, %d.", type, headType, headTag);
|
||||||
throw TarsDecodeMismatch(s);
|
throw TarsDecodeMismatch(s);
|
||||||
}
|
}
|
||||||
Int32 size = 0;
|
UInt32 size = 0;
|
||||||
read(size, 0);
|
read(size, 0);
|
||||||
TarsReadHeadSkip(*this, size);
|
TarsReadHeadSkip(*this, size);
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -513,7 +513,7 @@ int yy_flex_debug = 0;
|
|||||||
#define YY_MORE_ADJ 0
|
#define YY_MORE_ADJ 0
|
||||||
#define YY_RESTORE_YY_MORE_OFFSET
|
#define YY_RESTORE_YY_MORE_OFFSET
|
||||||
char *yytext;
|
char *yytext;
|
||||||
#line 1 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
|
#line 1 "/Users/jarod/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
|
||||||
/**
|
/**
|
||||||
* Tencent is pleased to support the open source community by making Tars available.
|
* Tencent is pleased to support the open source community by making Tars available.
|
||||||
*
|
*
|
||||||
@ -529,7 +529,7 @@ char *yytext;
|
|||||||
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations under the License.
|
* specific language governing permissions and limitations under the License.
|
||||||
*/
|
*/
|
||||||
#line 20 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
|
#line 20 "/Users/jarod/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@ -742,7 +742,7 @@ YY_DECL
|
|||||||
register char *yy_cp, *yy_bp;
|
register char *yy_cp, *yy_bp;
|
||||||
register int yy_act;
|
register int yy_act;
|
||||||
|
|
||||||
#line 67 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
|
#line 67 "/Users/jarod/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
|
||||||
|
|
||||||
|
|
||||||
#line 749 "tars.lex.cpp"
|
#line 749 "tars.lex.cpp"
|
||||||
@ -840,12 +840,12 @@ do_action: /* This label is used only to access EOF actions. */
|
|||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 69 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
|
#line 69 "/Users/jarod/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
|
||||||
{ BEGIN(INCL); }
|
{ BEGIN(INCL); }
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 2:
|
case 2:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 71 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
|
#line 71 "/Users/jarod/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
|
||||||
{
|
{
|
||||||
if ( include_file_stack_ptr >= MAX_INCLUDE_DEPTH )
|
if ( include_file_stack_ptr >= MAX_INCLUDE_DEPTH )
|
||||||
{
|
{
|
||||||
@ -878,7 +878,7 @@ YY_RULE_SETUP
|
|||||||
YY_BREAK
|
YY_BREAK
|
||||||
case YY_STATE_EOF(INITIAL):
|
case YY_STATE_EOF(INITIAL):
|
||||||
case YY_STATE_EOF(INCL):
|
case YY_STATE_EOF(INCL):
|
||||||
#line 101 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
|
#line 101 "/Users/jarod/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
|
||||||
{
|
{
|
||||||
--include_file_stack_ptr;
|
--include_file_stack_ptr;
|
||||||
if ( include_file_stack_ptr < 0 )
|
if ( include_file_stack_ptr < 0 )
|
||||||
@ -897,14 +897,14 @@ case YY_STATE_EOF(INCL):
|
|||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 3:
|
case 3:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 117 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
|
#line 117 "/Users/jarod/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
|
||||||
{
|
{
|
||||||
return TARS_SCOPE_DELIMITER;
|
return TARS_SCOPE_DELIMITER;
|
||||||
}
|
}
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 4:
|
case 4:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 121 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
|
#line 121 "/Users/jarod/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
|
||||||
{
|
{
|
||||||
// C++ comment
|
// C++ comment
|
||||||
bool e = false;
|
bool e = false;
|
||||||
@ -925,7 +925,7 @@ YY_RULE_SETUP
|
|||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 5:
|
case 5:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 139 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
|
#line 139 "/Users/jarod/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
|
||||||
{
|
{
|
||||||
// C comment
|
// C comment
|
||||||
bool e = false;
|
bool e = false;
|
||||||
@ -976,7 +976,7 @@ YY_RULE_SETUP
|
|||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 6:
|
case 6:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 187 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
|
#line 187 "/Users/jarod/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
|
||||||
{
|
{
|
||||||
StringGrammarPtr ident = new StringGrammar;
|
StringGrammarPtr ident = new StringGrammar;
|
||||||
ident->v = yytext;
|
ident->v = yytext;
|
||||||
@ -987,7 +987,7 @@ YY_RULE_SETUP
|
|||||||
case 7:
|
case 7:
|
||||||
/* rule 7 can match eol */
|
/* rule 7 can match eol */
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 194 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
|
#line 194 "/Users/jarod/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
|
||||||
{
|
{
|
||||||
StringGrammarPtr ident = new StringGrammar;
|
StringGrammarPtr ident = new StringGrammar;
|
||||||
ident->v = yytext;
|
ident->v = yytext;
|
||||||
@ -1000,7 +1000,7 @@ YY_RULE_SETUP
|
|||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 8:
|
case 8:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 204 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
|
#line 204 "/Users/jarod/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
|
||||||
{
|
{
|
||||||
StringGrammarPtr str = new StringGrammar;
|
StringGrammarPtr str = new StringGrammar;
|
||||||
bool e = false;
|
bool e = false;
|
||||||
@ -1115,7 +1115,7 @@ YY_RULE_SETUP
|
|||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 9:
|
case 9:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 316 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
|
#line 316 "/Users/jarod/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
|
||||||
{
|
{
|
||||||
errno = 0;
|
errno = 0;
|
||||||
IntergerGrammarPtr ptr = new IntergerGrammar;
|
IntergerGrammarPtr ptr = new IntergerGrammar;
|
||||||
@ -1140,7 +1140,7 @@ YY_RULE_SETUP
|
|||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 10:
|
case 10:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 338 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
|
#line 338 "/Users/jarod/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
|
||||||
{
|
{
|
||||||
errno = 0;
|
errno = 0;
|
||||||
FloatGrammarPtr ptr = new FloatGrammar;
|
FloatGrammarPtr ptr = new FloatGrammar;
|
||||||
@ -1175,7 +1175,7 @@ YY_RULE_SETUP
|
|||||||
case 11:
|
case 11:
|
||||||
/* rule 11 can match eol */
|
/* rule 11 can match eol */
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 369 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
|
#line 369 "/Users/jarod/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
|
||||||
{
|
{
|
||||||
if(yytext[0] == '\n')
|
if(yytext[0] == '\n')
|
||||||
{
|
{
|
||||||
@ -1185,7 +1185,7 @@ YY_RULE_SETUP
|
|||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 12:
|
case 12:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 376 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
|
#line 376 "/Users/jarod/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
|
||||||
{
|
{
|
||||||
if(yytext[0] < 32 || yytext[0] > 126)
|
if(yytext[0] < 32 || yytext[0] > 126)
|
||||||
{
|
{
|
||||||
@ -1204,7 +1204,7 @@ YY_RULE_SETUP
|
|||||||
YY_BREAK
|
YY_BREAK
|
||||||
case 13:
|
case 13:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 392 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
|
#line 392 "/Users/jarod/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
|
||||||
ECHO;
|
ECHO;
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
#line 1211 "tars.lex.cpp"
|
#line 1211 "tars.lex.cpp"
|
||||||
@ -2214,7 +2214,7 @@ void yyfree (void * ptr )
|
|||||||
|
|
||||||
#define YYTABLES_NAME "yytables"
|
#define YYTABLES_NAME "yytables"
|
||||||
|
|
||||||
#line 392 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
|
#line 392 "/Users/jarod/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user