diff --git a/include/pickle.h b/include/pickle.h index d42b130f1190c3bbe425970bfc6960184779b66a..92287cb3acf5ea03f061cdbd68bb92cdcfcf9736 100644 --- a/include/pickle.h +++ b/include/pickle.h @@ -77,7 +77,7 @@ load_varint32_s(void **data, size_t size) } if (unlikely(size < 3)) - tnt_raise(IllegalParams, :"varint is too short (expected 3+ bytes)"); + tnt_raise(IllegalParams, :"BER int is too short (expected 3+ bytes)"); if (!(b[2] & 0x80)) { *data += 3; @@ -85,7 +85,7 @@ load_varint32_s(void **data, size_t size) } if (unlikely(size < 4)) - tnt_raise(IllegalParams, :"varint is too short (expected 4+ bytes)"); + tnt_raise(IllegalParams, :"BER int is too short (expected 4+ bytes)"); if (!(b[3] & 0x80)) { *data += 4; @@ -94,7 +94,7 @@ load_varint32_s(void **data, size_t size) } if (unlikely(size < 5)) - tnt_raise(IllegalParams, :"varint is too short (expected 5+ bytes)"); + tnt_raise(IllegalParams, :"BER int is too short (expected 5+ bytes)"); if (!(b[4] & 0x80)) { *data += 5; @@ -102,7 +102,7 @@ load_varint32_s(void **data, size_t size) (b[2] & 0x7f) << 14 | (b[3] & 0x7f) << 7 | (b[4] & 0x7f); } - tnt_raise(IllegalParams, :"incorrect varint format"); + tnt_raise(IllegalParams, :"incorrect BER integer format"); } static inline u32 diff --git a/src/lua/init.m b/src/lua/init.m index 7606793855cbc6036165009d14fcd2bc156f05a1..c40226c6802a44243af71d4157b5df466fe7b769 100644 --- a/src/lua/init.m +++ b/src/lua/init.m @@ -373,10 +373,10 @@ lbox_unpack(struct lua_State *L) u16 u16buf; u32 u32buf; -#define CHECK_SIZE(cur) { if (unlikely((cur) >= end)) \ - luaL_error(L, "box.unpack('%c'): got %d bytes (expected: %d+)",\ - *f, (int) (end - str), (int) 1 + ((cur) - str));} - +#define CHECK_SIZE(cur) if (unlikely((cur) >= end)) { \ + luaL_error(L, "box.unpack('%c'): got %d bytes (expected: %d+)", \ + *f, (int) (end - str), (int) 1 + ((cur) - str)); \ +} while (*f) { switch (*f) { case 'b': @@ -404,16 +404,16 @@ lbox_unpack(struct lua_State *L) s += 8; break; case 'w': - /* exception is thrown on error */ + /* load_varint32_s throws exception on error. */ u32buf = load_varint32_s((void *)&s, end - s); lua_pushnumber(L, u32buf); break; case 'P': case 'p': - /* exception is thrown on error */ + /* load_varint32_s throws exception on error. */ u32buf = load_varint32_s((void *)&s, end - s); - CHECK_SIZE(s + u32buf-1); - lua_pushlstring (L, (const char *) s, u32buf); + CHECK_SIZE(s + u32buf - 1); + lua_pushlstring(L, (const char *) s, u32buf); s += u32buf; break; case '=': @@ -454,7 +454,7 @@ lbox_unpack(struct lua_State *L) s += 5; break; default: - luaL_error(L, "box.unpack: unsupported pack " + luaL_error(L, "box.unpack: unsupported " "format specifier '%c'", *f); } i++; @@ -465,7 +465,7 @@ lbox_unpack(struct lua_State *L) if (s != end) { luaL_error(L, "box.unpack('%s'): too many bytes: " - "unpacked %d, size %d", + "unpacked %d, total %d", format, s - str, str_size); } diff --git a/src/pickle.m b/src/pickle.m index fcc00d3600d2aad1dbe4f9176c21f2a1f6c7e25c..a4cc72d22486366471e8e68cab760c62aa9f1943 100644 --- a/src/pickle.m +++ b/src/pickle.m @@ -31,13 +31,11 @@ #include <fiber.h> #include <iproto.h> /* for err codes */ #include "say.h" -#include "exception.h" /* caller must ensure that there is space in target */ u8 * save_varint32(u8 *target, u32 value) { - if (value >= (1 << 7)) { if (value >= (1 << 14)) { if (value >= (1 << 21)) { diff --git a/test/box/lua.result b/test/box/lua.result index 439b4f01b90e2a4f0537ea8fa072a5015001429e..fa2d29fe1a6cfe2b29a0c657feae7da1e52ccfba 100644 --- a/test/box/lua.result +++ b/test/box/lua.result @@ -159,7 +159,7 @@ error: 'box.unpack(''i''): got 4 bytes (expected: 8+)' ... lua box.unpack('i', box.pack('ii', 1, 1)) --- -error: 'box.unpack(''i''): too many bytes: unpacked 4, size 8' +error: 'box.unpack(''i''): too many bytes: unpacked 4, total 8' ... lua box.unpack('+p', box.pack('=p', 1, '666')) ---