win: base64 encode the username before appending to the pipe name

This commit is contained in:
Shuai Lin 2018-12-25 18:25:37 +08:00
parent dd49e4bc26
commit 3e724f5a89

View File

@ -4,6 +4,7 @@
#ifdef WIN32
#include <windows.h>
#include <wincrypt.h>
#endif
#include <unistd.h>
@ -283,6 +284,16 @@ register_rpc_service ()
searpc_signature_objlist__string_string_string_int());
}
#ifdef WIN32
char *b64encode(const char *input)
{
char buf[32767] = {0};
DWORD retlen = 32767;
CryptBinaryToString((BYTE*) input, strlen(input), CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF, buf, &retlen);
return strdup(buf);
}
#endif
static int
start_searpc_server ()
{
@ -297,7 +308,7 @@ start_searpc_server ()
return -1;
}
char *path = g_strdup_printf("\\\\.\\pipe\\seafile_%s", userNameBuf);
char *path = g_strdup_printf("\\\\.\\pipe\\seafile_%s", b64encode(userNameBuf));
#else
char *path = g_build_filename (seaf->seaf_dir, SEAFILE_SOCKET_NAME, NULL);
#endif