From 3feb702df8b362d3d3a4bdeda48313da1278ebe4 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 23 Nov 2015 09:31:21 -0200 Subject: ensure argument to 'string.format("%s")' does not contain zeros --- lstrlib.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lstrlib.c b/lstrlib.c index ff5cdd77..1bc26829 100644 --- a/lstrlib.c +++ b/lstrlib.c @@ -1,5 +1,5 @@ /* -** $Id: lstrlib.c,v 1.236 2015/10/28 17:56:51 roberto Exp roberto $ +** $Id: lstrlib.c,v 1.237 2015/10/29 15:11:41 roberto Exp roberto $ ** Standard library for string operations and pattern-matching ** See Copyright Notice in lua.h */ @@ -1031,6 +1031,7 @@ static int str_format (lua_State *L) { case 's': { size_t l; const char *s = luaL_tolstring(L, arg, &l); + luaL_argcheck(L, l == strlen(s), arg, "string cannot contain zeros"); if (!strchr(form, '.') && l >= 100) { /* no precision and string is too long to be formatted; keep original string */ -- cgit v1.2.3-55-g6feb