Fixed util.encodings.base64.decode to not truncate results when encountering an '=' before the end of the given input.
authorWaqas Hussain <waqas20@gmail.com>
Mon, 08 Dec 2008 03:19:11 +0500
changeset 601 6cb908ef01c8
parent 600 2255a2e84ddc
child 602 a977227aa9e6
Fixed util.encodings.base64.decode to not truncate results when encountering an '=' before the end of the given input.
util-src/encodings.c
--- a/util-src/encodings.c	Sun Dec 07 19:18:50 2008 +0000
+++ b/util-src/encodings.c	Mon Dec 08 03:19:11 2008 +0500
@@ -90,7 +90,7 @@
 	luaL_buffinit(L,&b);
 	for (;;)
 	{
-		int c=*s++;
+		int c=*s++;
 		switch (c)
 		{
 			const char *p;
@@ -108,8 +108,10 @@
 				{
 					case 1: base64_decode(&b,t[0],0,0,0,1);		break;
 					case 2: base64_decode(&b,t[0],t[1],0,0,2);	break;
-					case 3: base64_decode(&b,t[0],t[1],t[2],0,3);	break;
-				}
+					case 3: base64_decode(&b,t[0],t[1],t[2],0,3);	break;
+				}
+				n=0;
+				break;
 			case 0:
 				luaL_pushresult(&b);
 				return 1;