diff options
| author | Diego Nehab <diego@fresnel.local> | 2012-08-01 03:06:09 -0300 |
|---|---|---|
| committer | Diego Nehab <diego@fresnel.local> | 2012-08-01 03:06:09 -0300 |
| commit | f329aae724573b87bd2a814f4858d29ca894600b (patch) | |
| tree | 31bbbce37e8e4f03e44a556943298d1136579caf | |
| parent | 54ffcd483f8357f7916225ab775f1773452bfe42 (diff) | |
| download | luasocket-f329aae724573b87bd2a814f4858d29ca894600b.tar.gz luasocket-f329aae724573b87bd2a814f4858d29ca894600b.tar.bz2 luasocket-f329aae724573b87bd2a814f4858d29ca894600b.zip | |
Fix HORRIBLE but in b64/qp code.
Bug was caught by user moteus.
Code was checking if arguments was nil after using
luaL_Buffer code, which messes with the stack.
Simple to fix, though.
| -rw-r--r-- | src/makefile | 2 | ||||
| -rw-r--r-- | src/mime.c | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/src/makefile b/src/makefile index 1363bc0..7e5f2e2 100644 --- a/src/makefile +++ b/src/makefile | |||
| @@ -29,7 +29,7 @@ DEBUG?=NODEBUG | |||
| 29 | # LUAINC_macosx: | 29 | # LUAINC_macosx: |
| 30 | # /opt/local/include | 30 | # /opt/local/include |
| 31 | LUAINC_macosx_base?=/opt/local/include | 31 | LUAINC_macosx_base?=/opt/local/include |
| 32 | LUAINC_macosx?=$(LUAINC_macosx_base)$(LUAV) | 32 | LUAINC_macosx?=$(LUAINC_macosx_base)/lua$(LUAV) |
| 33 | # FIXME default should this default to fink or to macports? | 33 | # FIXME default should this default to fink or to macports? |
| 34 | # What happens when more than one Lua version is installed? | 34 | # What happens when more than one Lua version is installed? |
| 35 | LUAPREFIX_macosx?=/opt/local/ | 35 | LUAPREFIX_macosx?=/opt/local/ |
| @@ -263,6 +263,8 @@ static int mime_global_b64(lua_State *L) | |||
| 263 | lua_pushnil(L); | 263 | lua_pushnil(L); |
| 264 | return 2; | 264 | return 2; |
| 265 | } | 265 | } |
| 266 | /* make sure we don't confuse buffer stuff with arguments */ | ||
| 267 | lua_settop(L, 2); | ||
| 266 | /* process first part of the input */ | 268 | /* process first part of the input */ |
| 267 | luaL_buffinit(L, &buffer); | 269 | luaL_buffinit(L, &buffer); |
| 268 | while (input < last) | 270 | while (input < last) |
| @@ -307,6 +309,8 @@ static int mime_global_unb64(lua_State *L) | |||
| 307 | lua_pushnil(L); | 309 | lua_pushnil(L); |
| 308 | return 2; | 310 | return 2; |
| 309 | } | 311 | } |
| 312 | /* make sure we don't confuse buffer stuff with arguments */ | ||
| 313 | lua_settop(L, 2); | ||
| 310 | /* process first part of the input */ | 314 | /* process first part of the input */ |
| 311 | luaL_buffinit(L, &buffer); | 315 | luaL_buffinit(L, &buffer); |
| 312 | while (input < last) | 316 | while (input < last) |
| @@ -458,6 +462,8 @@ static int mime_global_qp(lua_State *L) | |||
| 458 | lua_pushnil(L); | 462 | lua_pushnil(L); |
| 459 | return 2; | 463 | return 2; |
| 460 | } | 464 | } |
| 465 | /* make sure we don't confuse buffer stuff with arguments */ | ||
| 466 | lua_settop(L, 3); | ||
| 461 | /* process first part of input */ | 467 | /* process first part of input */ |
| 462 | luaL_buffinit(L, &buffer); | 468 | luaL_buffinit(L, &buffer); |
| 463 | while (input < last) | 469 | while (input < last) |
| @@ -531,6 +537,8 @@ static int mime_global_unqp(lua_State *L) | |||
| 531 | lua_pushnil(L); | 537 | lua_pushnil(L); |
| 532 | return 2; | 538 | return 2; |
| 533 | } | 539 | } |
| 540 | /* make sure we don't confuse buffer stuff with arguments */ | ||
| 541 | lua_settop(L, 2); | ||
| 534 | /* process first part of input */ | 542 | /* process first part of input */ |
| 535 | luaL_buffinit(L, &buffer); | 543 | luaL_buffinit(L, &buffer); |
| 536 | while (input < last) | 544 | while (input < last) |
