Patches sent by India based on Security review.

This commit is contained in:
Jim Norman 2006-04-06 20:09:26 +00:00
parent 861619e231
commit b2b5903126
7 changed files with 816 additions and 686 deletions

View File

@ -20,247 +20,253 @@
* *
***********************************************************************/ ***********************************************************************/
#include "sscs_ipc.h" #include "sscs_ipc.h"
#ifdef SSCS_WIN32_PLAT_F #ifdef SSCS_WIN32_PLAT_F
#include "windows.h" #include "windows.h"
#define XTIER_RPC_PIPE TEXT("\\\\.\\PIPE\\SS_RPC_PIPE") #define XTIER_RPC_PIPE TEXT("\\\\.\\PIPE\\SS_RPC_PIPE")
// global // global
int firstReadAfterWrite = 0; int firstReadAfterWrite = 0;
#endif #endif
/* /*
*/ */
#ifdef SSCS_LINUX_PLAT_F #ifdef SSCS_LINUX_PLAT_F
int ipc_unx_create() int ipc_unx_create()
{ {
int retVal = 0; int retVal = 0;
struct sockaddr_un servAddr; struct sockaddr_un servAddr;
char path[MAX_SOCKET_PATH_LEN]; char path[MAX_SOCKET_PATH_LEN];
int sockFd = 0; int sockFd = 0;
do do
{ {
sockFd = socket(AF_UNIX,SOCK_STREAM,0); sockFd = socket(AF_UNIX,SOCK_STREAM,0);
if( sockFd < 0 ) if( sockFd < 0 )
{ {
retVal = sockFd; retVal = sockFd;
break; break;
} }
memset(&servAddr,0,sizeof(servAddr)); memset(&servAddr,0,sizeof(servAddr));
servAddr.sun_family = AF_UNIX; servAddr.sun_family = AF_UNIX;
strcpy(servAddr.sun_path,"/tmp/.novellCASA"); strcpy(servAddr.sun_path,"/tmp/.novellCASA");
retVal = connect(sockFd,(struct sockaddr*)&servAddr, sizeof(servAddr)); retVal = connect(sockFd,(struct sockaddr*)&servAddr, sizeof(servAddr));
if(retVal < 0 ) if(retVal < 0 )
{ {
DMSG(("Connect fails : %s\n",strerror(errno))); DMSG(("Connect fails : %s\n",strerror(errno)));
DMSG(("Closing socket : %d\n",sockFd)); DMSG(("Closing socket : %d\n",sockFd));
close(sockFd); close(sockFd);
break; break;
} }
else else
retVal = sockFd; retVal = sockFd;
}while(0); }while(0);
return retVal; return retVal;
} }
#else #else
void * ipc_win_create() void * ipc_win_create()
{ {
//#ifdef SSCS_WIN32_PLAT_F //#ifdef SSCS_WIN32_PLAT_F
// connect to the named Pipe // connect to the named Pipe
HANDLE hPipe = NULL; HANDLE hPipe = NULL;
int rcode; int rcode;
DWORD mode = PIPE_READMODE_MESSAGE; DWORD mode = PIPE_READMODE_MESSAGE;
hPipe = CreateFile( hPipe = CreateFile(
XTIER_RPC_PIPE, XTIER_RPC_PIPE,
GENERIC_READ | GENERIC_WRITE, GENERIC_READ | GENERIC_WRITE,
0, 0,
NULL, //null, NULL, //null,
OPEN_EXISTING, OPEN_EXISTING,
0, 0,
0); 0);
if (hPipe == INVALID_HANDLE_VALUE) if (hPipe == INVALID_HANDLE_VALUE)
{ {
rcode = GetLastError(); rcode = GetLastError();
return 0; return 0;
} }
return hPipe; return hPipe;
} }
#endif #endif
#ifdef SSCS_LINUX_PLAT_F #ifdef SSCS_LINUX_PLAT_F
int ipc_unx_write(int fd, Byte *pData, int bytes) int ipc_unx_write(int fd, Byte *pData, int bytes)
{ {
int retVal = write(fd,pData,bytes); int retVal = write(fd,pData,bytes);
if( retVal < 0 ) if( retVal < 0 )
{ {
DMSG(("Write returns error : %d - %s\n",retVal, strerror(errno))); DMSG(("Write returns error : %d - %s\n",retVal, strerror(errno)));
} }
return retVal; return retVal;
//#endif //#endif
} }
#else #else
int ipc_win_write(HANDLE hPipe, LPCVOID lpBuffer, DWORD bytesToWrite) int ipc_win_write(HANDLE hPipe, LPCVOID lpBuffer, DWORD bytesToWrite)
{ {
//#ifdef SSCS_WIN32_PLAT_F //#ifdef SSCS_WIN32_PLAT_F
BOOL rcode; BOOL rcode;
int icode; int icode;
DWORD lpBytesWritten = 0; DWORD lpBytesWritten = 0;
//LPCVOID msgLen = malloc(4); //LPCVOID msgLen = malloc(4);
// rcode = WaitNamedPipe( // rcode = WaitNamedPipe(
// XTIER_RPC_PIPE, // XTIER_RPC_PIPE,
// NMPWAIT_WAIT_FOREVER); // NMPWAIT_WAIT_FOREVER);
// the server expects us to first write the number of bytes in the msg we're about to write. // the server expects us to first write the number of bytes in the msg we're about to write.
rcode = WriteFile( rcode = WriteFile(
hPipe, hPipe,
(LPCVOID)&bytesToWrite, (LPCVOID)&bytesToWrite,
4, 4,
&lpBytesWritten, &lpBytesWritten,
NULL); NULL);
if (!rcode) if (!rcode)
{ {
icode = GetLastError(); icode = GetLastError();
return 0; return 0;
} }
// rcode = WaitNamedPipe( // rcode = WaitNamedPipe(
// XTIER_RPC_PIPE, // XTIER_RPC_PIPE,
// NMPWAIT_WAIT_FOREVER); // NMPWAIT_WAIT_FOREVER);
rcode = WriteFile( rcode = WriteFile(
hPipe, hPipe,
lpBuffer, //LPCVOID lpBuffer, lpBuffer, //LPCVOID lpBuffer,
bytesToWrite, //DWORD nNumberOfBytesToWrite, bytesToWrite, //DWORD nNumberOfBytesToWrite,
&lpBytesWritten, // LPDWORD lpNumberOfBytesWritten, &lpBytesWritten, // LPDWORD lpNumberOfBytesWritten,
NULL); //LPOVERLAPPED lpOverlapped NULL); //LPOVERLAPPED lpOverlapped
if (!rcode) if (!rcode)
{ {
icode = GetLastError(); icode = GetLastError();
} }
firstReadAfterWrite = 1; firstReadAfterWrite = 1;
return lpBytesWritten; return lpBytesWritten;
} }
#endif #endif
/* /*
* *
*/ */
#ifdef SSCS_LINUX_PLAT_F #ifdef SSCS_LINUX_PLAT_F
int ipc_unx_read(int fd, Byte *pData, int bytes) int ipc_unx_read(int fd, Byte *pData, int bytes)
{ {
int bytesToRead = 0; // Keep track of number of bytes to read int bytesToRead = 0; // Keep track of number of bytes to read
int bytesRead = 0; // Number of bytes read int bytesRead = 0; // Number of bytes read
int retVal = 0; int retVal = 0;
for(bytesToRead = bytes; bytesToRead;) for(bytesToRead = bytes; bytesToRead;)
{ {
bytesRead = read(fd, pData, bytesToRead); if ((bytesRead = read(fd, pData, bytesToRead)) == 0)
if(bytesRead < 0) {
{ break;
return -1; }
} else
bytesToRead -= bytesRead; {
pData += bytesRead; if(bytesRead < 0)
} {
return bytesRead; return -1;
} }
//#endif bytesToRead -= bytesRead;
pData += bytesRead;
}
#else }
return bytesRead;
int ipc_win_read(HANDLE hPipe, LPVOID lpBuffer, DWORD numOfBytesToRead) }
{ //#endif
//#ifdef SSCS_WIN32_PLAT_F
BOOL rcode; #else
DWORD numBytesRead = 0;
LPVOID pMsgLen = malloc(4); int ipc_win_read(HANDLE hPipe, LPVOID lpBuffer, DWORD numOfBytesToRead)
int icode; {
//#ifdef SSCS_WIN32_PLAT_F
if (firstReadAfterWrite)
{ BOOL rcode;
firstReadAfterWrite = 0; DWORD numBytesRead = 0;
LPVOID pMsgLen = malloc(4);
// server first sends the number of bytes that gets sent. int icode;
rcode = ReadFile(
hPipe, //HANDLE hFile, if (firstReadAfterWrite)
pMsgLen, //LPVOID lpBuffer, {
4, //numOfBytesToRead, //DWORD nNumberOfBytesToRead, firstReadAfterWrite = 0;
&numBytesRead, //LPDWORD lpNumberOfBytesRead,
NULL); //LPOVERLAPPED lpOverlapped // server first sends the number of bytes that gets sent.
rcode = ReadFile(
if (!rcode) hPipe, //HANDLE hFile,
{ pMsgLen, //LPVOID lpBuffer,
icode = GetLastError(); 4, //numOfBytesToRead, //DWORD nNumberOfBytesToRead,
return 0; &numBytesRead, //LPDWORD lpNumberOfBytesRead,
} NULL); //LPOVERLAPPED lpOverlapped
} if (!rcode)
{
rcode = ReadFile( icode = GetLastError();
hPipe, //HANDLE hFile, return 0;
lpBuffer, //LPVOID lpBuffer, }
numOfBytesToRead, //DWORD nNumberOfBytesToRead,
&numBytesRead, //LPDWORD lpNumberOfBytesRead, }
NULL); //LPOVERLAPPED lpOverlapped
rcode = ReadFile(
hPipe, //HANDLE hFile,
if (pMsgLen) lpBuffer, //LPVOID lpBuffer,
free(pMsgLen); numOfBytesToRead, //DWORD nNumberOfBytesToRead,
&numBytesRead, //LPDWORD lpNumberOfBytesRead,
return numBytesRead; NULL); //LPOVERLAPPED lpOverlapped
}
#endif
if (pMsgLen)
free(pMsgLen);
#ifdef SSCS_LINUX_PLAT_F
int ipc_unx_close(int fd) return numBytesRead;
{ }
return close(fd); #endif
}
#else #ifdef SSCS_LINUX_PLAT_F
int ipc_unx_close(int fd)
{
int ipc_win_close(HANDLE hPipe) return close(fd);
{
//#ifdef SSCS_WIN32_PLAT_F }
#else
BOOL rcode;
rcode = DisconnectNamedPipe(hPipe); int ipc_win_close(HANDLE hPipe)
rcode = CloseHandle(hPipe); {
return 0; //#ifdef SSCS_WIN32_PLAT_F
}
BOOL rcode;
rcode = DisconnectNamedPipe(hPipe);
#endif rcode = CloseHandle(hPipe);
return 0;
}
#endif

View File

@ -21,133 +21,145 @@
***********************************************************************/ ***********************************************************************/
using System; using System;
using System.Net; using System.Net;
using System.Net.Sockets; using System.Net.Sockets;
using Mono.Unix.Native; using Mono.Unix;
using System.IO; using Mono.Unix.Native;
using System.Text; using System.IO;
using System.Threading; using System.Text;
using sscs.common; using System.Threading;
using sscs.constants; using sscs.common;
using sscs.constants;
namespace sscs.communication
{ namespace sscs.communication
{
/* Platform specific class which implements
* the 'Communication' interface. /* Platform specific class which implements
*/ * the 'Communication' interface.
*/
class UnixCommunication : Communication
{ class UnixCommunication : Communication
private Socket listeningSocket; {
private Socket connectedSocket; private Socket listeningSocket;
private string socketFileName = "/tmp/.novellCASA"; private Socket connectedSocket;
private Mono.Unix.UnixEndPoint sockEndPoint; private string socketFileName = "/tmp/.novellCASA";
private ManualResetEvent eventVar = null; private Mono.Unix.UnixEndPoint sockEndPoint;
private ManualResetEvent eventVar = null;
//Methods
internal UnixCommunication() //Methods
{ internal UnixCommunication()
CSSSLogger.ExecutionTrace(this); {
Syscall.umask(0); CSSSLogger.ExecutionTrace(this);
if(File.Exists(socketFileName)) Syscall.umask(0);
File.Delete(socketFileName); if(File.Exists(socketFileName))
listeningSocket = new Socket( AddressFamily.Unix, {
SocketType.Stream, File.Delete(socketFileName);
ProtocolType.IP ); }
sockEndPoint = new Mono.Unix.UnixEndPoint(socketFileName); listeningSocket = new Socket( AddressFamily.Unix,
eventVar = new ManualResetEvent(true); SocketType.Stream,
ProtocolType.IP );
} sockEndPoint = new Mono.Unix.UnixEndPoint(socketFileName);
eventVar = new ManualResetEvent(true);
~UnixCommunication()
{ }
CSSSLogger.ExecutionTrace(this);
eventVar.Close(); ~UnixCommunication()
CloseCommunicationEndPoint(); {
CSSSLogger.ExecutionTrace(this);
} eventVar.Close();
CloseCommunicationEndPoint();
// This code executes in the listening thread.
public void StartCommunicationEndPoint() }
{
CSSSLogger.ExecutionTrace(this); // This code executes in the listening thread.
try public void StartCommunicationEndPoint()
{ {
listeningSocket.Bind(sockEndPoint); CSSSLogger.ExecutionTrace(this);
listeningSocket.Listen(50); try
} {
catch(Exception e) UnixFileSystemInfo sockFileInfo = new UnixFileInfo(socketFileName);
{ UnixUserInfo sockFileOwner = sockFileInfo.OwnerUser;
CSSSLogger.ExpLog(e.ToString());
} // check if ROOT is the owner of the file: /tmp/.novellCASA
while(true) if (sockFileOwner.UserId != 0)
{ {
try File.Delete(socketFileName);
{ }
eventVar.Reset();
listeningSocket.BeginAccept(new AsyncCallback(ListenCb), listeningSocket.Bind(sockEndPoint);
listeningSocket); listeningSocket.Listen(50);
eventVar.WaitOne(); }
} catch(Exception e)
catch(Exception e) {
{ CSSSLogger.ExpLog(e.ToString());
CSSSLogger.ExpLog(e.ToString()); }
throw e; while(true)
} {
} try
} {
eventVar.Reset();
public void CloseCommunicationEndPoint() listeningSocket.BeginAccept(new AsyncCallback(ListenCb),
{ listeningSocket);
CSSSLogger.ExecutionTrace(this); eventVar.WaitOne();
listeningSocket.Close(); }
if(File.Exists( socketFileName )) catch(Exception e)
File.Delete(socketFileName); {
} CSSSLogger.ExpLog(e.ToString());
throw e;
// On receipt of a new client, this method is called. }
private void ListenCb (IAsyncResult state) }
{ }
try
{ public void CloseCommunicationEndPoint()
CSSSLogger.ExecutionTrace(this); {
connectedSocket = ((Socket)state.AsyncState).EndAccept (state); CSSSLogger.ExecutionTrace(this);
eventVar.Set(); listeningSocket.Close();
ServiceClient(); if(File.Exists( socketFileName ))
} File.Delete(socketFileName);
catch(Exception e) }
{
/* All resources would have been cleaned up before reaching // On receipt of a new client, this method is called.
* here. private void ListenCb (IAsyncResult state)
*/ {
CSSSLogger.ExpLog(e.ToString()); try
} {
/* End of thread function */ CSSSLogger.ExecutionTrace(this);
} connectedSocket = ((Socket)state.AsyncState).EndAccept (state);
eventVar.Set();
private void ServiceClient() ServiceClient();
{ }
CSSSLogger.ExecutionTrace(this); catch(Exception e)
IPCChannel ipcChannel = IPCChannel.Create(connectedSocket); {
AppHandler appHandler = new AppHandler(ipcChannel); /* All resources would have been cleaned up before reaching
* here.
try */
{ CSSSLogger.ExpLog(e.ToString());
int retVal = appHandler.ServiceApp(); }
if( retVal != RetCodes.SUCCESS ) /* End of thread function */
CSSSLogger.DbgLog("Servicing client failed."); }
}
catch( Exception e ) private void ServiceClient()
{ {
CSSSLogger.ExpLog(e.ToString()); CSSSLogger.ExecutionTrace(this);
} IPCChannel ipcChannel = IPCChannel.Create(connectedSocket);
finally AppHandler appHandler = new AppHandler(ipcChannel);
{
ipcChannel.Close(); try
} {
} int retVal = appHandler.ServiceApp();
} if( retVal != RetCodes.SUCCESS )
} CSSSLogger.DbgLog("Servicing client failed.");
}
catch( Exception e )
{
CSSSLogger.ExpLog(e.ToString());
}
finally
{
ipcChannel.Close();
}
}
}
}

View File

@ -20,205 +20,208 @@
* *
***********************************************************************/ ***********************************************************************/
using System; using System;
using System.IO; using System.IO;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Diagnostics; using System.Diagnostics;
using sscs.communication; using sscs.communication;
using sscs.constants; using sscs.constants;
using sscs.common; using sscs.common;
class SecretStoreClientService class SecretStoreClientService
{ {
private static Communication server = null; private static Communication server = null;
private static Thread listeningThread = null; private static Thread listeningThread = null;
public static void Main(string[] args) public static void Main(string[] args)
{ {
CSSSLogger.ExecutionTrace(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); CSSSLogger.ExecutionTrace(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
try try
{ {
/* If getting a lock fails, just exit. /* If getting a lock fails, just exit.
*/ */
if(!AcquireLock()) if(!AcquireLock())
{ {
Console.WriteLine("Another instance of micasad is already running"); Console.WriteLine("Another instance of micasad is already running");
Mono.Unix.Native.Syscall.exit(-1); Mono.Unix.Native.Syscall.exit(-1);
} }
RegisterSignals(); RegisterSignals();
Mono.Unix.Native.Syscall.umask( Mono.Unix.Native.FilePermissions.S_IRGRP |
CSSSLogger.DbgLog("Client Side SecretStore Service has started."); Mono.Unix.Native.FilePermissions.S_IWGRP |
Mono.Unix.Native.FilePermissions.S_IROTH |
server = CommunicationFactory.CreateCommunicationEndPoint(); Mono.Unix.Native.FilePermissions.S_IWOTH);
CSSSLogger.DbgLog("Client Side SecretStore Service has started.");
listeningThread = new Thread(new ThreadStart(StartServer));
listeningThread.Start(); server = CommunicationFactory.CreateCommunicationEndPoint();
listeningThread.Join();
} listeningThread = new Thread(new ThreadStart(StartServer));
catch(Exception e) listeningThread.Start();
{ listeningThread.Join();
Terminate(); }
} catch(Exception e)
} {
Terminate();
/* The thread which listens and spawns threads on every accept }
* starts its execution from this method. }
*/
private static void StartServer() /* The thread which listens and spawns threads on every accept
{ * starts its execution from this method.
try */
{ private static void StartServer()
CSSSLogger.ExecutionTrace(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); {
server.StartCommunicationEndPoint(); try
} {
catch(ThreadAbortException exp) CSSSLogger.ExecutionTrace(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
{ server.StartCommunicationEndPoint();
CSSSLogger.DbgLog("Listening thread of miCASAd is going down."); }
CSSSLogger.ExpLog(exp.ToString()); catch(ThreadAbortException exp)
} {
catch(Exception exp) CSSSLogger.DbgLog("Listening thread of miCASAd is going down.");
{ CSSSLogger.ExpLog(exp.ToString());
CSSSLogger.ExpLog(exp.ToString()); }
} catch(Exception exp)
CSSSLogger.DbgLog("Listening thread of miCASAd is going down."); {
} CSSSLogger.ExpLog(exp.ToString());
}
/* This ensures that there is only one instance of CSSSLogger.DbgLog("Listening thread of miCASAd is going down.");
* SSCS at any point. }
*/
private static bool AcquireLock() /* This ensures that there is only one instance of
{ * SSCS at any point.
CSSSLogger.ExecutionTrace(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); */
int platform = (int)Environment.OSVersion.Platform; private static bool AcquireLock()
if( (platform == 128) || (platform == 4) ) {
{ CSSSLogger.ExecutionTrace(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
if(File.Exists(ConstStrings.SSCS_LINUX_PIDFILE)) int platform = (int)Environment.OSVersion.Platform;
{ if( (platform == 128) || (platform == 4) )
if(CheckIfMiCASAdIsRunning()) {
{ if(File.Exists(ConstStrings.SSCS_LINUX_PIDFILE))
CSSSLogger.DbgLog("Acquiring lock failed. Terminating miCASAd."); {
return false; if(CheckIfMiCASAdIsRunning())
} {
else CSSSLogger.DbgLog("Acquiring lock failed. Terminating miCASAd.");
{ return false;
File.Delete(ConstStrings.SSCS_LINUX_PIDFILE); }
CreatePidFile(); else
return true; {
} File.Delete(ConstStrings.SSCS_LINUX_PIDFILE);
} CreatePidFile();
else return true;
{ }
CreatePidFile(); }
return true; else
} {
} CreatePidFile();
else return true;
return false; }
} }
private static void RegisterSignals() else
{ return false;
CSSSLogger.ExecutionTrace(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); }
if(( (int)Environment.OSVersion.Platform) == 128) private static void RegisterSignals()
{ {
//SIGTERM CSSSLogger.ExecutionTrace(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
Mono.Unix.Native.Stdlib.signal(Mono.Unix.Native.Signum.SIGTERM, new Mono.Unix.Native.SignalHandler(Terminate)); if(( (int)Environment.OSVersion.Platform) == 128)
//SIGINT {
Mono.Unix.Native.Stdlib.signal(Mono.Unix.Native.Signum.SIGINT, new Mono.Unix.Native.SignalHandler(Terminate)); //SIGTERM
//SIGHUP Mono.Unix.Native.Stdlib.signal(Mono.Unix.Native.Signum.SIGTERM, new Mono.Unix.Native.SignalHandler(Terminate));
Mono.Unix.Native.Stdlib.signal(Mono.Unix.Native.Signum.SIGHUP, new Mono.Unix.Native.SignalHandler(Terminate)); //SIGINT
} Mono.Unix.Native.Stdlib.signal(Mono.Unix.Native.Signum.SIGINT, new Mono.Unix.Native.SignalHandler(Terminate));
//SIGHUP
} Mono.Unix.Native.Stdlib.signal(Mono.Unix.Native.Signum.SIGHUP, new Mono.Unix.Native.SignalHandler(Terminate));
private static void Terminate(int sigNum) }
{
CSSSLogger.ExecutionTrace(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); }
Terminate(); private static void Terminate(int sigNum)
} {
private static void Terminate() CSSSLogger.ExecutionTrace(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
{ Terminate();
CSSSLogger.ExecutionTrace(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); }
CSSSLogger.DbgLog("Client Side SecretStore Service is now exiting."); private static void Terminate()
{
if( listeningThread != null ) CSSSLogger.ExecutionTrace(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
{ CSSSLogger.DbgLog("Client Side SecretStore Service is now exiting.");
listeningThread.Abort("Aborting listening thread");
} if( listeningThread != null )
int platform = (int)Environment.OSVersion.Platform; {
if( (platform == 128) || (platform == 4) ) listeningThread.Abort("Aborting listening thread");
{ }
if( File.Exists(ConstStrings.SSCS_LINUX_PIDFILE) ) int platform = (int)Environment.OSVersion.Platform;
{ if( (platform == 128) || (platform == 4) )
File.Delete(ConstStrings.SSCS_LINUX_PIDFILE); {
} if( File.Exists(ConstStrings.SSCS_LINUX_PIDFILE) )
Mono.Unix.Native.Syscall.exit(0); {
} File.Delete(ConstStrings.SSCS_LINUX_PIDFILE);
} }
private static void CreatePidFile() Mono.Unix.Native.Syscall.exit(0);
{ }
int pid = Mono.Unix.Native.Syscall.getpid(); }
string pidStr = String.Format("{0}",pid); private static void CreatePidFile()
{
FileInfo fInfo = new FileInfo(ConstStrings.SSCS_LINUX_PIDFILE); int pid = Mono.Unix.Native.Syscall.getpid();
FileStream fs = fInfo.Open(System.IO.FileMode.OpenOrCreate, FileAccess.ReadWrite); string pidStr = String.Format("{0}",pid);
StreamWriter w = new StreamWriter(fs);
w.Write(pidStr); FileInfo fInfo = new FileInfo(ConstStrings.SSCS_LINUX_PIDFILE);
w.Flush(); FileStream fs = fInfo.Open(System.IO.FileMode.OpenOrCreate, FileAccess.ReadWrite);
fs.Close(); StreamWriter w = new StreamWriter(fs);
} w.Write(pidStr);
private static bool CheckIfMiCASAdIsRunning() w.Flush();
{ fs.Close();
try }
{ private static bool CheckIfMiCASAdIsRunning()
StreamReader sr = new StreamReader(ConstStrings.SSCS_LINUX_PIDFILE); {
string line = sr.ReadLine(); try
if( line == null ) {
{ StreamReader sr = new StreamReader(ConstStrings.SSCS_LINUX_PIDFILE);
sr.Close(); string line = sr.ReadLine();
return false; if( line == null )
} {
sr.Close();
string procPath = "/proc/"+ line + "/cmdline"; return false;
}
/* If the file procPath itself does not exist,
* then another instance is surely not running. string procPath = "/proc/"+ line + "/cmdline";
*/
if( !File.Exists(procPath) ) /* If the file procPath itself does not exist,
{ * then another instance is surely not running.
return false; */
} if( !File.Exists(procPath) )
{
/* There is a possibility that the pid stored in return false;
* the pidfile has been reassigned to another process. }
* So, if procPath exists, check if the process is
* micasad.exe. /* There is a possibility that the pid stored in
*/ * the pidfile has been reassigned to another process.
* So, if procPath exists, check if the process is
StreamReader procReader = new StreamReader(procPath); * micasad.exe.
string cmdline = procReader.ReadLine(); */
/* StreamReader procReader = new StreamReader(procPath);
string assemblyName = (System.Reflection.MethodBase.GetCurrentMethod().DeclaringType).Assembly.FullName + ".exe\0"; string cmdline = procReader.ReadLine();
*/ /*
string assemblyName = "micasad.exe\0"; string assemblyName = (System.Reflection.MethodBase.GetCurrentMethod().DeclaringType).Assembly.FullName + ".exe\0";
if(cmdline.EndsWith(assemblyName)) */
{ string assemblyName = "micasad.exe\0";
return true;
} if(cmdline.EndsWith(assemblyName))
else {
{ return true;
return false; }
} else
{
} return false;
catch(Exception e) }
{
return false; }
} catch(Exception e)
{
} return false;
} }
}
}

View File

@ -48,9 +48,25 @@ namespace Novell.CASA.MiCasa.Communication
SocketType.Stream, SocketType.Stream,
ProtocolType.IP ); ProtocolType.IP );
if (mSocket == null) throw new Exception("could not get socket"); if (mSocket == null)
sockEndPoint = new UnixEndPoint(socketFileName); {
mSocket.Connect(sockEndPoint); throw new Exception("could not get socket");
}
sockEndPoint = new UnixEndPoint(socketFileName);
UnixFileSystemInfo sockFileInfo = new UnixFileInfo(socketFileName);
UnixUserInfo sockFileOwner = sockFileInfo.OwnerUser;
// root is the owner of the file "/tmp/.novellCASA"
if (sockFileOwner.UserId == 0)
{
mSocket.Connect(sockEndPoint);
}
else
{
throw new Exception("not a valid miCASA service");
}
} }
public int Read(byte[] buf) public int Read(byte[] buf)

View File

@ -24,6 +24,9 @@ using System;
using System.IO; using System.IO;
using System.Text; using System.Text;
using System.Security.Cryptography; using System.Security.Cryptography;
#if LINUX
using Mono.Unix;
#endif
using sscs.common; using sscs.common;
using sscs.constants; using sscs.constants;
@ -69,9 +72,7 @@ namespace sscs.crypto
//Encrypt the data to a file //Encrypt the data to a file
fsEncrypt = new FileStream(fileName, FileMode.Create); fsEncrypt = new FileStream(fileName, FileMode.Create);
#if LINUX
Mono.Unix.Native.Syscall.chmod(fileName,Mono.Unix.Native.FilePermissions.S_IRUSR | Mono.Unix.Native.FilePermissions.S_IWUSR);
#endif
// make hidden // make hidden
File.SetAttributes(fileName, FileAttributes.Hidden); File.SetAttributes(fileName, FileAttributes.Hidden);
@ -93,8 +94,8 @@ namespace sscs.crypto
CSSSLogger.ExpLog(e.ToString()); CSSSLogger.ExpLog(e.ToString());
CSSSLogger.DbgLog("Unable to store the generated key"); CSSSLogger.DbgLog("Unable to store the generated key");
bRet = false; bRet = false;
} }
if (csEncrypt != null) if (csEncrypt != null)
csEncrypt.Close(); csEncrypt.Close();
if( fsEncrypt != null ) if( fsEncrypt != null )
fsEncrypt.Close(); fsEncrypt.Close();
@ -107,9 +108,15 @@ namespace sscs.crypto
byte[] baSavedKey = null; byte[] baSavedKey = null;
FileStream fsDecrypt = null; FileStream fsDecrypt = null;
CryptoStream csDecrypt = null; CryptoStream csDecrypt = null;
try try
{ {
#if LINUX
UnixFileInfo fsTest = new UnixFileInfo (fileName);
if((fsTest == null) || !(fsTest.Exists) || fsTest.IsSymbolicLink)
#else
if(!File.Exists(fileName)) if(!File.Exists(fileName))
#endif
{ {
return null; return null;
} }
@ -138,7 +145,7 @@ namespace sscs.crypto
{ {
if(storedHash[i] != newHash[i]) if(storedHash[i] != newHash[i])
{ {
CSSSLogger.DbgLog("Hash doesnot match"); CSSSLogger.DbgLog("Hash doesnot match");
csDecrypt.Close(); csDecrypt.Close();
fsDecrypt.Close(); fsDecrypt.Close();
return null; return null;
@ -150,10 +157,10 @@ namespace sscs.crypto
CSSSLogger.ExpLog(e.ToString()); CSSSLogger.ExpLog(e.ToString());
CSSSLogger.DbgLog("Unable to get the stored key"); CSSSLogger.DbgLog("Unable to get the stored key");
baSavedKey = null; baSavedKey = null;
} }
if (csDecrypt != null) if (csDecrypt != null)
csDecrypt.Close(); csDecrypt.Close();
if ( fsDecrypt != null ) if ( fsDecrypt != null )
@ -180,9 +187,7 @@ namespace sscs.crypto
//Encrypt the data to a file //Encrypt the data to a file
fsEncrypt = new FileStream(fileName, FileMode.Create); fsEncrypt = new FileStream(fileName, FileMode.Create);
#if LINUX
Mono.Unix.Native.Syscall.chmod(fileName,Mono.Unix.Native.FilePermissions.S_IRUSR | Mono.Unix.Native.FilePermissions.S_IWUSR);
#endif
// make hidden // make hidden
File.SetAttributes(fileName, FileAttributes.Hidden); File.SetAttributes(fileName, FileAttributes.Hidden);
@ -203,8 +208,8 @@ namespace sscs.crypto
{ {
CSSSLogger.ExpLog(e.ToString()); CSSSLogger.ExpLog(e.ToString());
CSSSLogger.DbgLog("Encrypting and storing to file failed."); CSSSLogger.DbgLog("Encrypting and storing to file failed.");
} }
if (csEncrypt != null) if (csEncrypt != null)
csEncrypt.Close(); csEncrypt.Close();
if( fsEncrypt != null ) if( fsEncrypt != null )
fsEncrypt.Close(); fsEncrypt.Close();
@ -224,8 +229,13 @@ namespace sscs.crypto
//Get a decryptor that uses the same key and IV as the encryptor. //Get a decryptor that uses the same key and IV as the encryptor.
RijndaelManaged myRijndael = new RijndaelManaged(); RijndaelManaged myRijndael = new RijndaelManaged();
ICryptoTransform decryptor = myRijndael.CreateDecryptor(key, IV); ICryptoTransform decryptor = myRijndael.CreateDecryptor(key, IV);
if(!File.Exists(fileName)) #if LINUX
{ UnixFileInfo fsTest = new UnixFileInfo (fileName);
if((fsTest == null) || !(fsTest.Exists) || fsTest.IsSymbolicLink)
#else
if(!File.Exists(fileName))
#endif
{
return null; return null;
} }
@ -235,14 +245,15 @@ namespace sscs.crypto
fsDecrypt.Read(storedHash,0,storedHash.Length); fsDecrypt.Read(storedHash,0,storedHash.Length);
csDecrypt = new CryptoStream(fsDecrypt, decryptor, CryptoStreamMode.Read); csDecrypt = new CryptoStream(fsDecrypt, decryptor, CryptoStreamMode.Read);
if(fsDecrypt.Length < HASH_SIZE ) if(fsDecrypt.Length < HASH_SIZE )
{ {
csDecrypt.Close(); csDecrypt.Close();
fsDecrypt.Close(); fsDecrypt.Close();
return null; return null;
} }
ulong fileLen = (ulong)(fsDecrypt.Length - HASH_SIZE);
byte[] fromEncrypt = new byte[fileLen]; ulong fileLen = (ulong)(fsDecrypt.Length - HASH_SIZE);
byte[] fromEncrypt = new byte[fileLen];
//Read the data out of the crypto stream. //Read the data out of the crypto stream.
int bytesRead = csDecrypt.Read(fromEncrypt, 0, fromEncrypt.Length); int bytesRead = csDecrypt.Read(fromEncrypt, 0, fromEncrypt.Length);
@ -257,13 +268,13 @@ namespace sscs.crypto
{ {
if(storedHash[i] != newHash[i]) if(storedHash[i] != newHash[i])
{ {
CSSSLogger.DbgLog("Hash doesnot match"); CSSSLogger.DbgLog("Hash doesnot match");
csDecrypt.Close(); csDecrypt.Close();
fsDecrypt.Close(); fsDecrypt.Close();
return null; return null;
} }
} }
csDecrypt.Close(); csDecrypt.Close();
fsDecrypt.Close(); fsDecrypt.Close();
return tmpEncrypt; return tmpEncrypt;
@ -271,10 +282,10 @@ namespace sscs.crypto
catch(Exception e) catch(Exception e)
{ {
Console.WriteLine(e.ToString()); Console.WriteLine(e.ToString());
} }
if (csDecrypt != null) if (csDecrypt != null)
{ {
csDecrypt.Close(); csDecrypt.Close();
} }
if( fsDecrypt != null ) if( fsDecrypt != null )
{ {
@ -393,9 +404,7 @@ namespace sscs.crypto
//Encrypt the data to a file //Encrypt the data to a file
fsEncrypt = new FileStream(fileName,FileMode.Create); fsEncrypt = new FileStream(fileName,FileMode.Create);
#if LINUX
Mono.Unix.Native.Syscall.chmod(fileName,Mono.Unix.Native.FilePermissions.S_IRUSR | Mono.Unix.Native.FilePermissions.S_IWUSR);
#endif
// make hidden // make hidden
File.SetAttributes(fileName, FileAttributes.Hidden); File.SetAttributes(fileName, FileAttributes.Hidden);
@ -405,17 +414,17 @@ namespace sscs.crypto
//Write all data to the crypto stream and flush it. //Write all data to the crypto stream and flush it.
csEncrypt.Write(baMasterPasscode, 0, baMasterPasscode.Length); csEncrypt.Write(baMasterPasscode, 0, baMasterPasscode.Length);
csEncrypt.FlushFinalBlock(); csEncrypt.FlushFinalBlock();
csEncrypt.Close(); csEncrypt.Close();
fsEncrypt.Close(); fsEncrypt.Close();
} }
catch(Exception e) catch(Exception e)
{ {
CSSSLogger.ExpLog(e.ToString()); CSSSLogger.ExpLog(e.ToString());
} }
if (csEncrypt != null) if (csEncrypt != null)
{ {
csEncrypt.Close(); csEncrypt.Close();
} }
if( fsEncrypt != null ) if( fsEncrypt != null )
{ {
@ -437,10 +446,20 @@ namespace sscs.crypto
/* Get a decryptor that uses the same key and /* Get a decryptor that uses the same key and
* IV as the encryptor. * IV as the encryptor.
*/ */
RijndaelManaged myRijndael = new RijndaelManaged(); RijndaelManaged myRijndael = new RijndaelManaged();
ICryptoTransform decryptor = myRijndael.CreateDecryptor(baKey, ICryptoTransform decryptor = myRijndael.CreateDecryptor(baKey,
baKey); baKey);
//Now decrypt //Now decrypt
#if LINUX
UnixFileInfo fsTest = new UnixFileInfo (fileName);
if((fsTest == null) || !(fsTest.Exists) || fsTest.IsSymbolicLink)
#else
if(!File.Exists(fileName))
#endif
{
return null;
}
fsDecrypt = new FileStream(fileName, FileMode.Open); fsDecrypt = new FileStream(fileName, FileMode.Open);
csDecrypt = new CryptoStream(fsDecrypt, decryptor, csDecrypt = new CryptoStream(fsDecrypt, decryptor,
CryptoStreamMode.Read); CryptoStreamMode.Read);
@ -584,11 +603,11 @@ namespace sscs.crypto
} }
catch(Exception e) catch(Exception e)
{ {
CSSSLogger.ExpLog(e.ToString()); CSSSLogger.ExpLog(e.ToString());
CSSSLogger.DbgLog("Validation of passcode failed."); CSSSLogger.DbgLog("Validation of passcode failed.");
} }
return false; return false;
} }
} }
} }

View File

@ -27,6 +27,9 @@ using System.Collections;
using System.Threading; using System.Threading;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Xml; using System.Xml;
#if LINUX
using Mono.Unix.Native;
#endif
using sscs.cache; using sscs.cache;
using sscs.crypto; using sscs.crypto;
using sscs.common; using sscs.common;
@ -60,7 +63,12 @@ namespace sscs.lss
private SecretStore userStore = null; private SecretStore userStore = null;
private int persistThreadSleepTime = 1000 * 60 * 5; //1000 * 30; private int persistThreadSleepTime = 1000 * 60 * 5; //1000 * 30;
private Thread persistThread = null; private Thread persistThread = null;
#if LINUX
Mono.Unix.UnixFileSystemInfo sockFileInfo;
Mono.Unix.UnixUserInfo sockFileOwner;
#endif
private static string LINUXID = "Unix"; private static string LINUXID = "Unix";
@ -120,23 +128,59 @@ namespace sscs.lss
} }
return true; return true;
} }
public bool IsOwnedByRoot(string fileName)
{
#if LINUX
sockFileInfo = new Mono.Unix.UnixFileInfo(fileName);
sockFileOwner = sockFileInfo.OwnerUser;
if(0==sockFileOwner.UserId)
return true;
else
return false;
#else
return true;
#endif
}
private string GetDecryptedXml() private string GetDecryptedXml()
{ {
try try
{ {
string fileName = userStore.GetPersistenceFilePath(); string fileName = userStore.GetPersistenceFilePath();
if(!File.Exists(fileName)) string tempFile = fileName;
{ int count = 0;
// check for tmp file if(!File.Exists(fileName))
if (File.Exists(fileName+".tmp")) {
File.Move(fileName+".tmp", fileName); while(true)
else {
return null; // check for tmp file
if (File.Exists(tempFile+".tmp"))
{
if(IsOwnedByRoot(tempFile+".tmp"))
{
File.Move(tempFile+".tmp", fileName);
break;
}
else
{
count++;
tempFile = fileName + count.ToString();
}
}
else
return null;
}
// delete tmp file if there
if (File.Exists(tempFile+".tmp"))
{
if(IsOwnedByRoot(tempFile+".tmp"))
File.Delete(tempFile+".tmp");
}
} }
// delete tmp file if there
if (File.Exists(fileName+".tmp"))
File.Delete(fileName+".tmp");
byte[] baPasscode = null; byte[] baPasscode = null;
if (null != m_baGeneratedKey) if (null != m_baGeneratedKey)
@ -235,7 +279,7 @@ namespace sscs.lss
{ {
attrColl = keyNode.Attributes; attrColl = keyNode.Attributes;
string key; string key;
try try
{ {
key = (attrColl[XmlConsts.idAttr]).Value; key = (attrColl[XmlConsts.idAttr]).Value;
} }
@ -427,28 +471,46 @@ namespace sscs.lss
byte[] key = CASACrypto.GetKeySetFromFile(m_baGeneratedKey, userStore.GetKeyFilePath()); byte[] key = CASACrypto.GetKeySetFromFile(m_baGeneratedKey, userStore.GetKeyFilePath());
string fileName = userStore.GetPersistenceFilePath(); string fileName = userStore.GetPersistenceFilePath();
string tempFile = fileName;
// rename existing file int count=0;
if(File.Exists(fileName))
{ // rename existing file
if (File.Exists(fileName+".tmp")) if(File.Exists(fileName))
File.Delete(fileName+".tmp"); {
while(true)
File.Move(fileName, fileName+".tmp"); {
} if (File.Exists(tempFile+".tmp"))
{
CASACrypto.EncryptDataAndWriteToFile(ms1.ToArray(),key,fileName); if(IsOwnedByRoot(tempFile+".tmp"))
{
//remove temp File.Delete(tempFile+".tmp");
if(File.Exists(fileName+".tmp")) break;
{ }
File.Delete(fileName+".tmp"); else
} {
} count++;
catch(Exception e) tempFile = fileName + count.ToString();
{ }
CSSSLogger.ExpLog(e.ToString()); }
} else
break;
}
File.Move(fileName, tempFile+".tmp");
}
CASACrypto.EncryptDataAndWriteToFile(ms1.ToArray(),key,fileName);
//remove temp
if(File.Exists(tempFile+".tmp"))
{
if(IsOwnedByRoot(tempFile+".tmp"))
File.Delete(tempFile+".tmp");
}
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
}
} }
} }
} }

View File

@ -221,42 +221,50 @@ static int32_t sscsshs_GetNextSHSEntry
* Internal function that escapes delimited characters in a string. * Internal function that escapes delimited characters in a string.
* *
*/ */
static void sscsshs_ChkEscapeString(SS_UTF8_T *entryBuf) static void sscsshs_ChkEscapeString(SS_UTF8_T **entryBuf)
{ /* beginning of the call */ { /* beginning of the call */
/* ########################## DECLARATIONS START HERE ######################### */ /* ########################## DECLARATIONS START HERE ######################### */
int len = 0, i, k = 0; int len = 0, i, k = 0, tmplen = 0, escaped = 0;
SS_UTF8_T *tempBuf = NULL; SS_UTF8_T *tempBuf = NULL;
/* ############################## CODE STARTS HERE ############################ */ /* ############################## CODE STARTS HERE ############################ */
if(!(tempBuf = (SS_UTF8_T *)malloc(NSSCS_MAX_SECRET_BUF_LEN - SSCS_CRED_SET_LEN))) len = sscs_Utf8Strlen(*entryBuf) + 1;
if (len > (NSSCS_MAX_SECRET_BUF_LEN - SSCS_CRED_SET_LEN))
return;
/* We assume that all the chars in entryBuf might need escaping */
if(!(tempBuf = (SS_UTF8_T *)malloc(2 * (NSSCS_MAX_SECRET_BUF_LEN - SSCS_CRED_SET_LEN))))
{ {
return; return;
} }
memset(tempBuf, 0, NSSCS_MAX_SECRET_BUF_LEN - SSCS_CRED_SET_LEN); memset(tempBuf, 0, 2 * (NSSCS_MAX_SECRET_BUF_LEN - SSCS_CRED_SET_LEN));
len = sscs_Utf8Strlen(entryBuf) + 1;
for(i = 0; i < len; i++) for(i = 0; i < len; i++)
{ {
SS_UTF8_T c = entryBuf[i]; SS_UTF8_T c = *((*entryBuf)+i);
switch(c) switch(c)
{ {
case (SS_UTF8_T)'\\': case (SS_UTF8_T)'\\':
tempBuf[k++] = (SS_UTF8_T)'\\'; tempBuf[k++] = (SS_UTF8_T)'\\';
tempBuf[k++] = (SS_UTF8_T)'\\'; tempBuf[k++] = (SS_UTF8_T)'\\';
escaped = 1;
break; break;
case (SS_UTF8_T)':': case (SS_UTF8_T)':':
tempBuf[k++] = (SS_UTF8_T)'\\'; tempBuf[k++] = (SS_UTF8_T)'\\';
tempBuf[k++] = (SS_UTF8_T)':'; tempBuf[k++] = (SS_UTF8_T)':';
escaped = 1;
break; break;
case (SS_UTF8_T)'=': case (SS_UTF8_T)'=':
tempBuf[k++] = (SS_UTF8_T)'\\'; tempBuf[k++] = (SS_UTF8_T)'\\';
tempBuf[k++] = (SS_UTF8_T)'='; tempBuf[k++] = (SS_UTF8_T)'=';
escaped = 1;
break; break;
default: default:
@ -264,7 +272,11 @@ static void sscsshs_ChkEscapeString(SS_UTF8_T *entryBuf)
} }
} }
sscs_Utf8Strcpy(entryBuf, tempBuf); if (escaped) {
free (*entryBuf);
*entryBuf = tempBuf;
return;
}
/* ############################### CODE EXITS HERE ############################# */ /* ############################### CODE EXITS HERE ############################# */
@ -310,7 +322,7 @@ static int32_t sscsshs_PopulateSecretBuf
retBuffer[sscs_Utf8Strlen(retBuffer)] = (SS_UTF8_T)0x0A; // add a line feed delimiter retBuffer[sscs_Utf8Strlen(retBuffer)] = (SS_UTF8_T)0x0A; // add a line feed delimiter
} }
sscsshs_ChkEscapeString(key); sscsshs_ChkEscapeString(&key);
if(sscs_Utf8Strcmp(key, SSCS_CRED_SET)) if(sscs_Utf8Strcmp(key, SSCS_CRED_SET))
{ {
@ -328,7 +340,7 @@ static int32_t sscsshs_PopulateSecretBuf
sscs_Utf8Strcat(retBuffer, APP_DELIMITER); sscs_Utf8Strcat(retBuffer, APP_DELIMITER);
} }
sscsshs_ChkEscapeString(val); sscsshs_ChkEscapeString(&val);
if((*bufLen + (sscs_Utf8StrSize(val))) < NSSCS_MAX_SECRET_BUF_LEN) if((*bufLen + (sscs_Utf8StrSize(val))) < NSSCS_MAX_SECRET_BUF_LEN)
{ {
sscs_Utf8Strcat(retBuffer, val); sscs_Utf8Strcat(retBuffer, val);
@ -385,7 +397,7 @@ static int32_t sscsshs_PopulateBinarySecretBuf
return(NSSCS_E_PARSER_FAILURE); // create error stating non-binary buffer return(NSSCS_E_PARSER_FAILURE); // create error stating non-binary buffer
} }
sscsshs_ChkEscapeString(key); sscsshs_ChkEscapeString(&key);
sscs_Utf8Strcpy((SS_UTF8_T *)retBuffer, key); sscs_Utf8Strcpy((SS_UTF8_T *)retBuffer, key);
sscs_Utf8Strcat((SS_UTF8_T *)retBuffer, BINARY_DELIMITER); sscs_Utf8Strcat((SS_UTF8_T *)retBuffer, BINARY_DELIMITER);
len = sscs_Utf8StrSize((SS_UTF8_T *)retBuffer); len = sscs_Utf8StrSize((SS_UTF8_T *)retBuffer);
@ -1057,7 +1069,7 @@ miCASAReadSecret
// escape delimited characters // escape delimited characters
memcpy(escapedSHSName, sharedSecretID->name, sscs_Utf8StrSize((SS_UTF8_T *)sharedSecretID->name)); memcpy(escapedSHSName, sharedSecretID->name, sscs_Utf8StrSize((SS_UTF8_T *)sharedSecretID->name));
sscsshs_ChkEscapeString(escapedSHSName); sscsshs_ChkEscapeString(&escapedSHSName);
if((escNameLen = sscs_Utf8Strlen((SS_UTF8_T *)escapedSHSName)) < 1) if((escNameLen = sscs_Utf8Strlen((SS_UTF8_T *)escapedSHSName)) < 1)
{ {
@ -1227,7 +1239,7 @@ miCASARemoveSecret
// escape delimited characters // escape delimited characters
memcpy(escapedSHSName, sharedSecretID->name, sscs_Utf8StrSize((SS_UTF8_T *)sharedSecretID->name)); memcpy(escapedSHSName, sharedSecretID->name, sscs_Utf8StrSize((SS_UTF8_T *)sharedSecretID->name));
sscsshs_ChkEscapeString(escapedSHSName); sscsshs_ChkEscapeString(&escapedSHSName);
if((escNameLen = sscs_Utf8Strlen((SS_UTF8_T *)escapedSHSName)) < 1) if((escNameLen = sscs_Utf8Strlen((SS_UTF8_T *)escapedSHSName)) < 1)
{ {
@ -1373,7 +1385,7 @@ miCASAWriteSecret
// escape delimited characters // escape delimited characters
memcpy(escapedSHSName, sharedSecretID->name, sscs_Utf8StrSize((SS_UTF8_T *)sharedSecretID->name)); memcpy(escapedSHSName, sharedSecretID->name, sscs_Utf8StrSize((SS_UTF8_T *)sharedSecretID->name));
sscsshs_ChkEscapeString(escapedSHSName); sscsshs_ChkEscapeString(&escapedSHSName);
if((escNameLen = sscs_Utf8Strlen((SS_UTF8_T *)escapedSHSName)) < 1) if((escNameLen = sscs_Utf8Strlen((SS_UTF8_T *)escapedSHSName)) < 1)
{ {
@ -1575,13 +1587,13 @@ miCASAWriteKey
// escape delimited characters // escape delimited characters
memcpy(escapedSHSName, sharedSecretID->id, sscs_Utf8StrSize((SS_UTF8_T *)sharedSecretID->id)); memcpy(escapedSHSName, sharedSecretID->id, sscs_Utf8StrSize((SS_UTF8_T *)sharedSecretID->id));
sscsshs_ChkEscapeString(escapedSHSName); sscsshs_ChkEscapeString(&escapedSHSName);
memcpy(escapedSHSKey, key, keyLen); memcpy(escapedSHSKey, key, keyLen);
sscsshs_ChkEscapeString(escapedSHSKey); sscsshs_ChkEscapeString(&escapedSHSKey);
memcpy(escapedSHSValue, val, valLen); memcpy(escapedSHSValue, val, valLen);
sscsshs_ChkEscapeString(escapedSHSValue); sscsshs_ChkEscapeString(&escapedSHSValue);
if((escNameLen = sscs_Utf8Strlen((SS_UTF8_T *)escapedSHSName)) < 1) if((escNameLen = sscs_Utf8Strlen((SS_UTF8_T *)escapedSHSName)) < 1)
{ {
@ -1701,10 +1713,10 @@ miCASAWriteBinaryKey
// escape delimited characters // escape delimited characters
memcpy(escapedSHSName, sharedSecretID->id, sscs_Utf8StrSize((SS_UTF8_T *)sharedSecretID->id)); memcpy(escapedSHSName, sharedSecretID->id, sscs_Utf8StrSize((SS_UTF8_T *)sharedSecretID->id));
sscsshs_ChkEscapeString(escapedSHSName); sscsshs_ChkEscapeString(&escapedSHSName);
memcpy(escapedSHSKey, key, keyLen); memcpy(escapedSHSKey, key, keyLen);
sscsshs_ChkEscapeString(escapedSHSKey); sscsshs_ChkEscapeString(&escapedSHSKey);
if((escNameLen = sscs_Utf8Strlen((SS_UTF8_T *)escapedSHSName)) < 1) if((escNameLen = sscs_Utf8Strlen((SS_UTF8_T *)escapedSHSName)) < 1)
{ {
@ -1821,10 +1833,10 @@ miCASAReadKey
// escape delimited characters // escape delimited characters
memcpy(escapedSHSName, sharedSecretID->id, sscs_Utf8StrSize((SS_UTF8_T *)sharedSecretID->id)); memcpy(escapedSHSName, sharedSecretID->id, sscs_Utf8StrSize((SS_UTF8_T *)sharedSecretID->id));
sscsshs_ChkEscapeString(escapedSHSName); sscsshs_ChkEscapeString(&escapedSHSName);
memcpy(escapedSHSKey, key, keyLen); memcpy(escapedSHSKey, key, keyLen);
sscsshs_ChkEscapeString(escapedSHSKey); sscsshs_ChkEscapeString(&escapedSHSKey);
if((escNameLen = sscs_Utf8Strlen((SS_UTF8_T *)escapedSHSName)) < 1) if((escNameLen = sscs_Utf8Strlen((SS_UTF8_T *)escapedSHSName)) < 1)
{ {
@ -1939,10 +1951,10 @@ miCASAReadBinaryKey
// escape delimited characters // escape delimited characters
memcpy(escapedSHSName, sharedSecretID->id, sscs_Utf8StrSize((SS_UTF8_T *)sharedSecretID->id)); memcpy(escapedSHSName, sharedSecretID->id, sscs_Utf8StrSize((SS_UTF8_T *)sharedSecretID->id));
sscsshs_ChkEscapeString(escapedSHSName); sscsshs_ChkEscapeString(&escapedSHSName);
memcpy(escapedSHSKey, key, keyLen); memcpy(escapedSHSKey, key, keyLen);
sscsshs_ChkEscapeString(escapedSHSKey); sscsshs_ChkEscapeString(&escapedSHSKey);
if((escNameLen = sscs_Utf8Strlen((SS_UTF8_T *)escapedSHSName)) < 1) if((escNameLen = sscs_Utf8Strlen((SS_UTF8_T *)escapedSHSName)) < 1)
{ {