From: Serge Petrenko <sergepetrenko@tarantool.org> To: vdavydov.dev@gmail.com, kostja@tarantool.org Cc: tarantool-patches@freelists.org, Serge Petrenko <sergepetrenko@tarantool.org> Subject: [PATCH v3 3/6] lua/pickle: fix a typo Date: Tue, 20 Aug 2019 20:10:01 +0300 [thread overview] Message-ID: <4ddad6d53cca6aa8901e919b513888eccb645299.1566320473.git.sergepetrenko@tarantool.org> (raw) In-Reply-To: <cover.1566320473.git.sergepetrenko@tarantool.org> Prior to this patch format checking was broken for 'i' (integer) and 'N' (big-endian integer). pickle.pack() rejected negative integers with these formats. Fix this --- src/lua/pickle.c | 4 ++-- test/app/pack.result | 8 ++++++++ test/app/pack.test.lua | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/lua/pickle.c b/src/lua/pickle.c index e47ac11b4..65208b5b3 100644 --- a/src/lua/pickle.c +++ b/src/lua/pickle.c @@ -109,14 +109,14 @@ lbox_pack(struct lua_State *L) case 'I': case 'i': /* signed and unsigned 32-bit integers */ - if (field.type != MP_UINT && field.ival != MP_INT) + if (field.type != MP_UINT && field.type != MP_INT) luaL_error(L, "pickle.pack: expected 32-bit int"); luaL_region_dup(L, buf, &field.ival, sizeof(uint32_t)); break; case 'N': /* signed and unsigned 32-bit big endian integers */ - if (field.type != MP_UINT && field.ival != MP_INT) + if (field.type != MP_UINT && field.type != MP_INT) luaL_error(L, "pickle.pack: expected 32-bit int"); field.ival = htonl(field.ival); diff --git a/test/app/pack.result b/test/app/pack.result index 8c1333abb..52f4be3cd 100644 --- a/test/app/pack.result +++ b/test/app/pack.result @@ -26,6 +26,14 @@ pickle.pack('s', 0x4d) --- - "M\0" ... +pickle.pack('i', -1) +--- +- !!binary /////w== +... +pickle.pack('N', -1) +--- +- !!binary /////w== +... pickle.pack('ssss', 25940, 29811, 28448, 11883) --- - Test ok. diff --git a/test/app/pack.test.lua b/test/app/pack.test.lua index 8f7a6a0f4..6ddd81cd4 100644 --- a/test/app/pack.test.lua +++ b/test/app/pack.test.lua @@ -7,6 +7,8 @@ pickle.pack('abc') pickle.pack('a', ' - hello') pickle.pack('Aa', ' - hello', ' world') pickle.pack('s', 0x4d) +pickle.pack('i', -1) +pickle.pack('N', -1) pickle.pack('ssss', 25940, 29811, 28448, 11883) pickle.pack('SSSS', 25940, 29811, 28448, 11883) pickle.pack('SSSSSSSS', 28493, 29550, 27680, 27497, 29541, 20512, 29285, 8556) -- 2.20.1 (Apple Git-117)
next prev parent reply other threads:[~2019-08-20 17:10 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-08-20 17:09 [PATCH v3 0/6] Decimal indices Serge Petrenko 2019-08-20 17:09 ` [PATCH v3 1/6] lua: fix decimal comparison with nil Serge Petrenko 2019-08-21 14:13 ` Vladimir Davydov 2019-08-20 17:10 ` [PATCH v3 2/6] decimal: fix encoding numbers with positive exponent Serge Petrenko 2019-08-21 14:13 ` Vladimir Davydov 2019-08-20 17:10 ` Serge Petrenko [this message] 2019-08-21 14:13 ` [PATCH v3 3/6] lua/pickle: fix a typo Vladimir Davydov 2019-08-20 17:10 ` [PATCH v3 4/6] decimal: allow to encode/decode decimals as MsgPack Serge Petrenko 2019-08-21 15:02 ` Vladimir Davydov 2019-08-20 17:10 ` [PATCH v3 5/6] decimal: add conversions to (u)int64_t Serge Petrenko 2019-08-21 15:02 ` Vladimir Davydov 2019-08-20 17:10 ` [PATCH v3 6/6] decimal: allow to index decimals Serge Petrenko 2019-08-21 15:02 ` Vladimir Davydov 2019-08-22 10:33 ` [tarantool-patches] " Kirill Yukhin
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=4ddad6d53cca6aa8901e919b513888eccb645299.1566320473.git.sergepetrenko@tarantool.org \ --to=sergepetrenko@tarantool.org \ --cc=kostja@tarantool.org \ --cc=tarantool-patches@freelists.org \ --cc=vdavydov.dev@gmail.com \ --subject='Re: [PATCH v3 3/6] lua/pickle: fix a typo' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox