From: AKhatskevich <avkhatskevich@tarantool.org>
To: kyukhin@tarantool.org, tarantool-patches@freelists.org
Subject: [tarantool-patches] [PATCH 1/2] lua-yaml: fix read garbage bug
Date: Thu, 4 Oct 2018 17:36:13 +0300 [thread overview]
Message-ID: <a6efa3d8af83abee3ceea350e55a4f5df1d24acf.1538663611.git.avkhatskevich@tarantool.org> (raw)
In-Reply-To: <cover.1538663611.git.avkhatskevich@tarantool.org>
In-Reply-To: <cover.1538663611.git.avkhatskevich@tarantool.org>
Add argc check for yaml encode and decode functions.
---
third_party/lua-yaml/lyaml.cc | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/third_party/lua-yaml/lyaml.cc b/third_party/lua-yaml/lyaml.cc
index c6d118a79..9b07992d8 100644
--- a/third_party/lua-yaml/lyaml.cc
+++ b/third_party/lua-yaml/lyaml.cc
@@ -400,7 +400,8 @@ static void load(struct lua_yaml_loader *loader) {
*/
static int l_load(lua_State *L) {
struct lua_yaml_loader loader;
- if (! lua_isstring(L, 1)) {
+ int top = lua_gettop(L);
+ if (!(top == 1 || top == 2) || !lua_isstring(L, 1)) {
usage_error:
return luaL_error(L, "Usage: yaml.decode(document, "\
"[{tag_only = boolean}])");
@@ -416,7 +417,7 @@ usage_error:
return luaL_error(L, OOM_ERRMSG);
yaml_parser_set_input_string(&loader.parser, (yaml_char_t *) document, len);
bool tag_only;
- if (lua_gettop(L) > 1) {
+ if (lua_gettop(L) == 2) {
if (! lua_istable(L, 2))
goto usage_error;
lua_getfield(L, 2, "tag_only");
@@ -794,7 +795,7 @@ error:
static int l_dump(lua_State *L) {
struct luaL_serializer *serializer = luaL_checkserializer(L);
int top = lua_gettop(L);
- if (top > 2) {
+ if (!(top == 1 || top == 2)) {
usage_error:
return luaL_error(L, "Usage: encode(object, {tag_prefix = <string>, "\
"tag_handle = <string>})");
--
2.14.1
next prev parent reply other threads:[~2018-10-04 14:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-04 14:36 [tarantool-patches] [PATCH 0/2] fix yaml encode/decode AKhatskevich
2018-10-04 14:36 ` AKhatskevich [this message]
2018-10-04 14:36 ` [tarantool-patches] [PATCH 2/2] lua-yaml: fix yaml encode/decode type inferring AKhatskevich
2019-01-22 2:08 ` [tarantool-patches] " Alexander Turenko
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=a6efa3d8af83abee3ceea350e55a4f5df1d24acf.1538663611.git.avkhatskevich@tarantool.org \
--to=avkhatskevich@tarantool.org \
--cc=kyukhin@tarantool.org \
--cc=tarantool-patches@freelists.org \
--subject='Re: [tarantool-patches] [PATCH 1/2] lua-yaml: fix read garbage bug' \
/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