diff options
author | Matthew Wild <mwild1@gmail.com> | 2008-11-27 17:12:05 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2008-11-27 17:12:05 +0000 |
commit | e6297e237d1407a5a5cf83f312cfbea1e2371e6e (patch) | |
tree | 15b0e3e298cf7bd60a37e4bc15f3b7fa5e2d15de /util-src/encodings.c | |
parent | 6953a3a15ec57e841daaa340dc31754301dc951c (diff) | |
parent | f33e9646043c0a00f6d6f03fcdde9726d7123581 (diff) | |
download | prosody-e6297e237d1407a5a5cf83f312cfbea1e2371e6e.tar.gz prosody-e6297e237d1407a5a5cf83f312cfbea1e2371e6e.zip |
Merge from waqas
Diffstat (limited to 'util-src/encodings.c')
-rw-r--r-- | util-src/encodings.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/util-src/encodings.c b/util-src/encodings.c index 27955601..ac24ebcf 100644 --- a/util-src/encodings.c +++ b/util-src/encodings.c @@ -3,7 +3,11 @@ * Lua library for base64, stringprep and idna encodings
*/
+// Newer MSVC compilers deprecate strcpy as unsafe, but we use it in a safe way
+#define _CRT_SECURE_NO_DEPRECATE
+
#include <string.h>
+#include <malloc.h>
#include "lua.h"
#include "lauxlib.h"
@@ -51,9 +55,9 @@ static void base64_decode(luaL_Buffer *b, int c1, int c2, int c3, int c4, int n) char s[3];
switch (--n)
{
- case 3: s[2]=tuple;
- case 2: s[1]=tuple >> 8;
- case 1: s[0]=tuple >> 16;
+ case 3: s[2]=(char) tuple;
+ case 2: s[1]=(char) (tuple >> 8);
+ case 1: s[0]=(char) (tuple >> 16);
}
luaL_addlstring(b,s,n);
}
@@ -74,7 +78,7 @@ static int Lbase64_decode(lua_State *L) /** decode(s) */ const char *p;
default:
p=strchr(code,c); if (p==NULL) return 0;
- t[n++]= p-code;
+ t[n++]= (char) (p-code);
if (n==4)
{
base64_decode(&b,t[0],t[1],t[2],t[3],4);
|