[tarantool-patches] sql: assertion fault on VALUES (#3888)

Stanislav Zudin szudin at tarantool.org
Tue Jan 22 16:42:21 MSK 2019


Branch: https://github.com/tarantool/tarantool/tree/2.1
Issue: https://github.com/tarantool/tarantool/issues/3888

 From ff49a389a68488b13a0e3093fce9f51ac4c186bf Mon Sep 17 00:00:00 2001
From: Stanislav Zudin <szudin at tarantool.org>
Date: Tue, 22 Jan 2019 15:41:26 +0300
Subject: [PATCH] sql: if a keyword 'blob' is used as an ID treat it as error

Closes #3888
---
  src/box/sql/expr.c | 18 ++++++++++++++++--
  1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/box/sql/expr.c b/src/box/sql/expr.c
index b67b22c23..3eea7f4a3 100644
--- a/src/box/sql/expr.c
+++ b/src/box/sql/expr.c
@@ -3751,10 +3751,24 @@ sqlite3ExprCodeTarget(Parse * pParse, Expr * 
pExpr, int target)
          }
  #ifndef SQLITE_OMIT_BLOB_LITERAL
      case TK_BLOB:{
-            int n;
-            const char *z;
+            int n = sqlite3Strlen30(pExpr->u.zToken);
+            const char *z = pExpr->u.zToken;
              char *zBlob;
+
              assert(!ExprHasProperty(pExpr, EP_IntValue));
+
+            if ((n < 3) ||    /* 'X' + opening ' + closing ' == 3 */
+                (z[0] != 'x' && z[0] != 'X') ||
+                (z[1] != '\'') || (z[n - 1] != '\'')) {
+                /* It's definitely not a blob, report an error. */
+                sqlite3ErrorMsg(pParse,
+                            "Unexpected keyword '%s' within request",
+                            z);
+                sqlite3MayAbort(pParse);
+                return 0;
+            }
+
+            /* ---------------------------------------------- */
              assert(pExpr->u.zToken[0] == 'x'
                     || pExpr->u.zToken[0] == 'X');
              assert(pExpr->u.zToken[1] == '\'');

-- 
2.17.1





More information about the Tarantool-patches mailing list