From 5291dc65440d02ac4556281a0f0fe22e0b5efe36 Mon Sep 17 00:00:00 2001 From: robocop Date: Sun, 12 Dec 2004 01:57:19 +0000 Subject: [PATCH] Restore checks for length. We don't need tokens bigger than 1KB. --- src/dsql/preparse.cpp | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/src/dsql/preparse.cpp b/src/dsql/preparse.cpp index 10c7b4c309..2bca989e44 100644 --- a/src/dsql/preparse.cpp +++ b/src/dsql/preparse.cpp @@ -404,15 +404,11 @@ static SSHORT get_next_token( token += *s++; } *stmt = s; -/* CVC: Will adjust this check. - if (p >= token_end) { + if (token.length() > MAX_TOKEN_SIZE) { // '=' used as then there is no place for null termination - - *token_length = MAX_TOKEN_SIZE; - token[MAX_TOKEN_SIZE] = '\0'; + token.erase(MAX_TOKEN_SIZE); return TOKEN_TOO_LONG; } -*/ return STRING; } @@ -422,14 +418,10 @@ static SSHORT get_next_token( for (; s < stmt_end && (classes[c = *s] & CHR_DIGIT); ++s); // empty body const ptrdiff_t length = (s - start_of_token); *stmt = s; -/* CVC: Will adjust this check. if (length > MAX_TOKEN_SIZE) { - memcpy(token, start_of_token, MAX_TOKEN_SIZE); - token[MAX_TOKEN_SIZE] = '\0'; - *token_length = MAX_TOKEN_SIZE; + token.assign(start_of_token, MAX_TOKEN_SIZE); return TOKEN_TOO_LONG; } -*/ token.assign(start_of_token, length); return NUMERIC; } @@ -443,13 +435,10 @@ static SSHORT get_next_token( } *stmt = s; -/* CVC: Will adjust this check. - if (p >= token_end) { - *token_length = MAX_TOKEN_SIZE; - token[MAX_TOKEN_SIZE] = '\0'; + if (token.length() > MAX_TOKEN_SIZE) { + token.erase(MAX_TOKEN_SIZE); return TOKEN_TOO_LONG; } -*/ return SYMBOL; }