From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id A6C926EC40; Thu, 3 Jun 2021 18:54:08 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org A6C926EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1622735648; bh=vc2/TSarqQBt0uZH9DYNq0XyuG8cttHC+vSMhgb7dCk=; h=To:Cc:Date:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=xGSPYDB9DrZpKHAEXKWPC8FBxOuyN01/EWLBkXAlj1XP3GaNknbBBb8ZpcwxD7nIi 9pKiYytf9LUecLP8lG8Ps3eePoF3ElabQQMpaQdFD+siGT6MYR9EehDsoNozdQqzhC 2OTcRJ5Y92FjV9ZnGU4hVgoG/8IAzZfml4VFxcRc= Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [94.100.179.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 9B9EB6EC40 for ; Thu, 3 Jun 2021 18:54:07 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 9B9EB6EC40 Received: by smtpng2.m.smailru.net with esmtpa (envelope-from ) id 1lopfa-0004nt-KV; Thu, 03 Jun 2021 18:54:07 +0300 To: sergepetrenko@tarantool.org Cc: tarantool-patches@dev.tarantool.org Date: Thu, 3 Jun 2021 18:54:06 +0300 Message-Id: <4fef21459158c16b993e0f72db337674129834df.1622735576.git.imeevma@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9D5B0DA836B685C543EF5F9E25E4001B3518B676B8BE4A4C7182A05F538085040F40797B9FAF620DCFD5565DF11F480038564B51B19AE44ADB47121A2D350F408 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE76A312A092B0E1E4AEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006374A24022C550661178638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8BC2775868D18224E927AC1D79B8FDD29117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC3A703B70628EAD7BA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735201E561CDFBCA1751F28451B159A507268D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B62CFFCC7B69C47339089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975CDBB9428EB2128D6729AFCFC892185BC0F2CDB1BF3E47B8719C2B6934AE262D3EE7EAB7254005DCED0E6F8C16B49E17FC1E0A4E2319210D9B64D260DF9561598F01A9E91200F654B0CCA28C6D779E2CD78E8E86DC7131B365E7726E8460B7C23C X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D344E332383F80D58BB628CA521E85E59490EAF48EF909B7CFC5221089AC20EC56F9593E0BAFE314FF71D7E09C32AA3244C8BC83006FF5934060A5D2A1554E89470F2F5F14F68F1805B729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojNbQUdF9mq4GqsO+DKB2i8Q== X-Mailru-Sender: 689FA8AB762F73936BC43F508A06382238D7CD0BA6D723F7D048B679DDC8F90383D72C36FC87018B9F80AB2734326CD2FB559BB5D741EB96352A0ABBE4FDA4210A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: [Tarantool-patches] [PATCH v1 1/1] box: check STRING length when it is cast to UUID X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Mergen Imeev via Tarantool-patches Reply-To: imeevma@tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" After this patch, the tt_uuid_from_strl() function will check the length of the given string before converting it to a UUID. Follow up #5886 --- https://github.com/tarantool/tarantool/issues/5886 https://github.com/tarantool/tarantool/tree/imeevma/gh-5886-follow-up src/lib/uuid/tt_uuid.c | 2 ++ test/sql-tap/uuid.test.lua | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/lib/uuid/tt_uuid.c b/src/lib/uuid/tt_uuid.c index 8bc9bc7af..6bdf2014a 100644 --- a/src/lib/uuid/tt_uuid.c +++ b/src/lib/uuid/tt_uuid.c @@ -98,6 +98,8 @@ tt_uuid_str(const struct tt_uuid *uu) int tt_uuid_from_strl(const char *in, size_t len, struct tt_uuid *uu) { + if (len != UUID_STR_LEN) + return -1; char buf[UUID_STR_LEN + 1]; snprintf(buf, sizeof(buf), "%.*s", (int) len, in); return tt_uuid_from_string(buf, uu); diff --git a/test/sql-tap/uuid.test.lua b/test/sql-tap/uuid.test.lua index 83fcc3d0e..77ba06c2d 100755 --- a/test/sql-tap/uuid.test.lua +++ b/test/sql-tap/uuid.test.lua @@ -3,7 +3,7 @@ local build_path = os.getenv("BUILDDIR") package.cpath = build_path..'/test/sql-tap/?.so;'..build_path..'/test/sql-tap/?.dylib;'..package.cpath local test = require("sqltester") -test:plan(145) +test:plan(147) local uuid = require("uuid") local uuid1 = uuid.fromstr("11111111-1111-1111-1111-111111111111") @@ -1316,6 +1316,23 @@ test:do_execsql_test( true }) +-- Make sure STRING of wrong length cannot be cast to UUID. +test:do_catchsql_test( + "uuid-17.1", + [[ + SELECT CAST('11111111-1111-1111-1111-111111111111111222222222' AS UUID); + ]], { + 1, "Type mismatch: can not convert 11111111-1111-1111-1111-111111111111111222222222 to uuid" + }) + +test:do_catchsql_test( + "uuid-17.2", + [[ + SELECT CAST('11111111-1111-1111-1111-11111' AS UUID); + ]], { + 1, "Type mismatch: can not convert 11111111-1111-1111-1111-11111 to uuid" + }) + test:execsql([[ DROP TRIGGER t; DROP VIEW v; -- 2.25.1