FREERDP_ADDIN** freerdp_channels_list_client_static_addins(LPSTR pszName, LPSTR pszSubsystem,
LPSTR pszType, DWORD dwFlags)
{
- int i, j;
+ size_t i, j;
DWORD nAddins;
- FREERDP_ADDIN* pAddin = NULL;
FREERDP_ADDIN** ppAddins = NULL;
STATIC_SUBSYSTEM_ENTRY* subsystems;
nAddins = 0;
for (i = 0; CLIENT_STATIC_ADDIN_TABLE[i].name != NULL; i++)
{
- pAddin = (FREERDP_ADDIN*) calloc(1, sizeof(FREERDP_ADDIN));
+ FREERDP_ADDIN* pAddin = (FREERDP_ADDIN*) calloc(1, sizeof(FREERDP_ADDIN));
if (!pAddin)
{
goto error_out;
}
- strcpy(pAddin->cName, CLIENT_STATIC_ADDIN_TABLE[i].name);
+ sprintf_s(pAddin->cName, ARRAYSIZE(pAddin->cName), "%s", CLIENT_STATIC_ADDIN_TABLE[i].name);
pAddin->dwFlags = FREERDP_ADDIN_CLIENT;
pAddin->dwFlags |= FREERDP_ADDIN_STATIC;
pAddin->dwFlags |= FREERDP_ADDIN_NAME;
goto error_out;
}
- strcpy(pAddin->cName, CLIENT_STATIC_ADDIN_TABLE[i].name);
- strcpy(pAddin->cSubsystem, subsystems[j].name);
+ sprintf_s(pAddin->cName, ARRAYSIZE(pAddin->cName), "%s", CLIENT_STATIC_ADDIN_TABLE[i].name);
+ _snprintf(pAddin->cSubsystem, ARRAYSIZE(pAddin->cSubsystem), "%s", subsystems[j].name);
pAddin->dwFlags = FREERDP_ADDIN_CLIENT;
pAddin->dwFlags |= FREERDP_ADDIN_STATIC;
pAddin->dwFlags |= FREERDP_ADDIN_NAME;
CHANNEL_OPTION_ENCRYPT_RDP |
CHANNEL_OPTION_COMPRESS_RDP |
CHANNEL_OPTION_SHOW_PROTOCOL;
- strcpy(cliprdr->channelDef.name, "cliprdr");
+ sprintf_s(cliprdr->channelDef.name, ARRAYSIZE(cliprdr->channelDef.name), "cliprdr");
pEntryPointsEx = (CHANNEL_ENTRY_POINTS_FREERDP_EX*) pEntryPoints;
if ((pEntryPointsEx->cbSize >= sizeof(CHANNEL_ENTRY_POINTS_FREERDP_EX)) &&
CHANNEL_OPTION_INITIALIZED |
CHANNEL_OPTION_ENCRYPT_RDP |
CHANNEL_OPTION_COMPRESS_RDP;
- strcpy(drdynvc->channelDef.name, "drdynvc");
+ sprintf_s(drdynvc->channelDef.name, ARRAYSIZE(drdynvc->channelDef.name), "drdynvc");
drdynvc->state = DRDYNVC_STATE_INITIAL;
pEntryPointsEx = (CHANNEL_ENTRY_POINTS_FREERDP_EX*) pEntryPoints;
CHANNEL_OPTION_ENCRYPT_RDP |
CHANNEL_OPTION_COMPRESS_RDP |
CHANNEL_OPTION_SHOW_PROTOCOL;
- strcpy(encomsp->channelDef.name, "encomsp");
+ sprintf_s(encomsp->channelDef.name, ARRAYSIZE(encomsp->channelDef.name), "encomsp");
pEntryPointsEx = (CHANNEL_ENTRY_POINTS_FREERDP_EX*) pEntryPoints;
if ((pEntryPointsEx->cbSize >= sizeof(CHANNEL_ENTRY_POINTS_FREERDP_EX)) &&
CHANNEL_OPTION_ENCRYPT_RDP |
CHANNEL_OPTION_COMPRESS_RDP |
CHANNEL_OPTION_SHOW_PROTOCOL;
- strcpy(rail->channelDef.name, "rail");
+ sprintf_s(rail->channelDef.name, ARRAYSIZE(rail->channelDef.name), "rail");
pEntryPointsEx = (CHANNEL_ENTRY_POINTS_FREERDP_EX*) pEntryPoints;
if ((pEntryPointsEx->cbSize >= sizeof(CHANNEL_ENTRY_POINTS_FREERDP_EX)) &&
CHANNEL_OPTION_INITIALIZED |
CHANNEL_OPTION_ENCRYPT_RDP |
CHANNEL_OPTION_COMPRESS_RDP;
- strcpy(rdpdr->channelDef.name, "rdpdr");
+ sprintf_s(rdpdr->channelDef.name, ARRAYSIZE(rdpdr->channelDef.name), "rdpdr");
rdpdr->sequenceId = 0;
pEntryPointsEx = (CHANNEL_ENTRY_POINTS_FREERDP_EX*) pEntryPoints;
rdpsnd->channelDef.options =
CHANNEL_OPTION_INITIALIZED |
CHANNEL_OPTION_ENCRYPT_RDP;
- strcpy(rdpsnd->channelDef.name, "rdpsnd");
+ sprintf_s(rdpsnd->channelDef.name, ARRAYSIZE(rdpsnd->channelDef.name), "rdpsnd");
pEntryPointsEx = (CHANNEL_ENTRY_POINTS_FREERDP_EX*) pEntryPoints;
if ((pEntryPointsEx->cbSize >= sizeof(CHANNEL_ENTRY_POINTS_FREERDP_EX)) &&
UINT32 msgType, UINT32 msgSize)
{
ctlHeader->msgType = msgType;
- strcpy(ctlHeader->ChannelName, REMDESK_CHANNEL_CTL_NAME);
+ sprintf_s(ctlHeader->ChannelName, ARRAYSIZE(ctlHeader->ChannelName), REMDESK_CHANNEL_CTL_NAME);
ctlHeader->DataLength = 4 + msgSize;
return CHANNEL_RC_OK;
}
CHANNEL_OPTION_ENCRYPT_RDP |
CHANNEL_OPTION_COMPRESS_RDP |
CHANNEL_OPTION_SHOW_PROTOCOL;
- strcpy(remdesk->channelDef.name, "remdesk");
+ sprintf_s(remdesk->channelDef.name, ARRAYSIZE(remdesk->channelDef.name), "remdesk");
remdesk->Version = 2;
pEntryPointsEx = (CHANNEL_ENTRY_POINTS_FREERDP_EX*) pEntryPoints;
UINT32 msgType, UINT32 msgSize)
{
ctlHeader->msgType = msgType;
- strcpy(ctlHeader->ChannelName, REMDESK_CHANNEL_CTL_NAME);
+ sprintf_s(ctlHeader->ChannelName, ARRAYSIZE(ctlHeader->ChannelName), REMDESK_CHANNEL_CTL_NAME);
ctlHeader->DataLength = 4 + msgSize;
return CHANNEL_RC_OK;
}
RemdeskServerContext* context;
UINT error;
context = (RemdeskServerContext*) arg;
-
buffer = NULL;
BytesReturned = 0;
ChannelEvent = NULL;
}
if (!(context->priv->Thread = CreateThread(NULL, 0,
- remdesk_server_thread, (void*) context, 0, NULL)))
+ remdesk_server_thread, (void*) context, 0, NULL)))
{
WLog_ERR(TAG, "CreateThread failed!");
CloseHandle(context->priv->StopEvent);
{
if (context->priv->ChannelHandle != INVALID_HANDLE_VALUE)
WTSVirtualChannelClose(context->priv->ChannelHandle);
-
+
free(context->priv);
free(context);
}
}
while (p1 != NULL);
- memset(pdev->path, 0, 17);
- strcpy(pdev->path, p2);
+ _snprintf(pdev->path, ARRAYSIZE(pdev->path), "%s", p2);
WLog_DBG(TAG, " DevPath: %s", pdev->path);
/* query parent hub info */
dev = udev_device_get_parent(dev);
dev_number = 0;
idVendor = 0;
idProduct = 0;
- strcpy(hardware_id, token);
+ _snprintf(hardware_id, ARRAYSIZE(hardware_id), "%s", token);
token = strtok(NULL, "#");
if (udevman->flags & UDEVMAN_FLAG_ADD_BY_VID_PID)
idProduct = (UINT16)pdev->query_device_descriptor(pdev, ID_PRODUCT);
bcdDevice = (UINT16)pdev->query_device_descriptor(pdev, BCD_DEVICE);
sprintf_s(str, sizeof(str), "USB\\VID_%04"PRIX16"&PID_%04"PRIX16"", idVendor, idProduct);
- strcpy(HardwareIds[1], str);
+ strncpy(HardwareIds[1], str, DEVICE_HARDWARE_ID_SIZE);
sprintf_s(str, sizeof(str), "%s&REV_%04"PRIX16"", HardwareIds[1], bcdDevice);
- strcpy(HardwareIds[0], str);
+ strncpy(HardwareIds[0], str, DEVICE_HARDWARE_ID_SIZE);
return 0;
}
if (!(pdev->isCompositeDevice(pdev)))
{
sprintf_s(str, sizeof(str), "USB\\Class_%02"PRIX8"", bDeviceClass);
- strcpy(CompatibilityIds[2], str);
+ strncpy(CompatibilityIds[2], str, DEVICE_COMPATIBILITY_ID_SIZE);
sprintf_s(str, sizeof(str), "%s&SubClass_%02"PRIX8"", CompatibilityIds[2], bDeviceSubClass);
- strcpy(CompatibilityIds[1], str);
+ strncpy(CompatibilityIds[1], str, DEVICE_COMPATIBILITY_ID_SIZE);
sprintf_s(str, sizeof(str), "%s&Prot_%02"PRIX8"", CompatibilityIds[1], bDeviceProtocol);
- strcpy(CompatibilityIds[0], str);
+ strncpy(CompatibilityIds[0], str, DEVICE_COMPATIBILITY_ID_SIZE);
}
else
{
sprintf_s(str, sizeof(str), "USB\\DevClass_00");
- strcpy(CompatibilityIds[2], str);
+ strncpy(CompatibilityIds[2], str, DEVICE_COMPATIBILITY_ID_SIZE);
sprintf_s(str, sizeof(str), "%s&SubClass_00", CompatibilityIds[2]);
- strcpy(CompatibilityIds[1], str);
+ strncpy(CompatibilityIds[1], str, DEVICE_COMPATIBILITY_ID_SIZE);
sprintf_s(str, sizeof(str), "%s&Prot_00", CompatibilityIds[1]);
- strcpy(CompatibilityIds[0], str);
+ strncpy(CompatibilityIds[0], str, DEVICE_COMPATIBILITY_ID_SIZE);
}
return 0;
if (ok)
{
+ size_t ulen, plen, dlen;
const char* submittedUsername = [dialog.username cStringUsingEncoding:
NSUTF8StringEncoding];
- *username = malloc((strlen(submittedUsername) + 1) * sizeof(char));
- strcpy(*username, submittedUsername);
+ ulen = (strlen(submittedUsername) + 1) * sizeof(char);
+ *username = malloc(ulen);
+
+ if (!(*username))
+ return FALSE;
+
+ sprintf_s(*username, ulen, "%s", submittedUsername);
const char* submittedPassword = [dialog.password cStringUsingEncoding:
NSUTF8StringEncoding];
- *password = malloc((strlen(submittedPassword) + 1) * sizeof(char));
- strcpy(*password, submittedPassword);
+ plen = (strlen(submittedPassword) + 1) * sizeof(char);
+ *password = malloc(plen);
+
+ if (!(*password))
+ return FALSE;
+
+ sprintf_s(*password, plen, "%s", submittedPassword);
const char* submittedDomain = [dialog.domain cStringUsingEncoding:
NSUTF8StringEncoding];
- *domain = malloc((strlen(submittedDomain) + 1) * sizeof(char));
- strcpy(*domain, submittedDomain);
+ dlen = (strlen(submittedDomain) + 1) * sizeof(char);
+ *domain = malloc(dlen);
+
+ if (!(*domain))
+ return FALSE;
+
+ sprintf_s(*domain, dlen, "%s", submittedDomain);
}
return ok;
length = (int)([str length] + 1);
cptr = (char*) malloc(length);
- strcpy(cptr, [str UTF8String]);
+ sprintf_s(cptr, length, "%s", [str UTF8String]);
context->argv[i++] = cptr;
}
BOOL match = FALSE;
char* keyCombination;
char buffer[1024] = { 0 };
- char command[1024] = { 0 };
+ char command[2048] = { 0 };
char combination[1024] = { 0 };
if (!xfc->actionScriptExists)
if (name)
{
size_t len = strlen(name);
- p = (char**) calloc(1UL + len, sizeof(char*));
+ p = (char**) calloc(2UL + len, sizeof(char*));
if (p)
{
char* dst = (char*)&p[1];
p[0] = dst;
- strncpy(dst, name, len);
+ sprintf_s(dst, len, "%s", name);
*count = 1;
return p;
}
#include <winpr/crt.h>
#include <winpr/path.h>
+#include <winpr/string.h>
#include <winpr/library.h>
#include <freerdp/addin.h>
break;
case AF_UNIX:
- strcpy(ipAddress, "127.0.0.1");
+ sprintf_s(ipAddress, ARRAYSIZE(ipAddress), "127.0.0.1");
break;
default:
#include <errno.h>
#include <winpr/crt.h>
+#include <winpr/string.h>
#include <winpr/sspi.h>
#include <winpr/ssl.h>
ChannelBindings->dwApplicationDataOffset = sizeof(SEC_CHANNEL_BINDINGS);
ChannelBindingToken = &((BYTE*)
ChannelBindings)[ChannelBindings->dwApplicationDataOffset];
- strcpy((char*) ChannelBindingToken, TLS_SERVER_END_POINT);
- CopyMemory(&ChannelBindingToken[PrefixLength], CertificateHash,
- CertificateHashLength);
+ sprintf_s((char*) ChannelBindingToken,
+ ContextBindings->BindingsLength - ChannelBindings->dwApplicationDataOffset, "%s%s",
+ TLS_SERVER_END_POINT, CertificateHash);
return ContextBindings;
out_free:
free(ContextBindings);
if (!fontImageFile)
goto cleanup;
- strcpy(fontImageFile, fontBaseFile);
- strcpy(&fontImageFile[length], ".png");
+ sprintf_s(fontImageFile, length + 8, "%s.png", fontBaseFile);
fontDescriptorFile = (char*) malloc(length + 8);
if (!fontDescriptorFile)
goto cleanup;
- strcpy(fontDescriptorFile, fontBaseFile);
- strcpy(&fontDescriptorFile[length], ".xml");
+ sprintf_s(fontDescriptorFile, length + 8, "%s.xml", fontBaseFile);
if (!PathFileExistsA(fontImageFile))
goto cleanup;
#include <fcntl.h>
#include <errno.h>
#include <stdlib.h>
+#include <stdio.h>
#include <string.h>
#include <sys/epoll.h>
return -1;
flags = fcntl(fd, F_GETFD);
+
if (flags == -1)
goto err;
goto err;
return fd;
-
err:
close(fd);
return -1;
int uwac_os_socket_cloexec(int domain, int type, int protocol)
{
int fd;
-
fd = socket(domain, type | SOCK_CLOEXEC, protocol);
+
if (fd >= 0)
return fd;
+
if (errno != EINVAL)
return -1;
int uwac_os_dupfd_cloexec(int fd, long minfd)
{
int newfd;
-
newfd = fcntl(fd, F_DUPFD_CLOEXEC, minfd);
+
if (newfd >= 0)
return newfd;
+
if (errno != EINVAL)
return -1;
return set_cloexec_or_close(newfd);
}
-static ssize_t recvmsg_cloexec_fallback(int sockfd, struct msghdr *msg, int flags)
+static ssize_t recvmsg_cloexec_fallback(int sockfd, struct msghdr* msg, int flags)
{
ssize_t len;
- struct cmsghdr *cmsg;
- unsigned char *data;
- int *fd;
- int *end;
-
+ struct cmsghdr* cmsg;
+ unsigned char* data;
+ int* fd;
+ int* end;
len = recvmsg(sockfd, msg, flags);
+
if (len == -1)
return -1;
return len;
cmsg = CMSG_FIRSTHDR(msg);
- for (; cmsg != NULL; cmsg = CMSG_NXTHDR(msg, cmsg)) {
+
+ for (; cmsg != NULL; cmsg = CMSG_NXTHDR(msg, cmsg))
+ {
if (cmsg->cmsg_level != SOL_SOCKET ||
cmsg->cmsg_type != SCM_RIGHTS)
continue;
data = CMSG_DATA(cmsg);
- end = (int *)(data + cmsg->cmsg_len - CMSG_LEN(0));
- for (fd = (int *)data; fd < end; ++fd)
+ end = (int*)(data + cmsg->cmsg_len - CMSG_LEN(0));
+
+ for (fd = (int*)data; fd < end; ++fd)
*fd = set_cloexec_or_close(*fd);
}
return len;
}
-ssize_t uwac_os_recvmsg_cloexec(int sockfd, struct msghdr *msg, int flags)
+ssize_t uwac_os_recvmsg_cloexec(int sockfd, struct msghdr* msg, int flags)
{
ssize_t len;
-
len = recvmsg(sockfd, msg, flags | MSG_CMSG_CLOEXEC);
+
if (len >= 0)
return len;
+
if (errno != EINVAL)
return -1;
int uwac_os_epoll_create_cloexec(void)
{
int fd;
-
#ifdef EPOLL_CLOEXEC
fd = epoll_create1(EPOLL_CLOEXEC);
+
if (fd >= 0)
return fd;
+
if (errno != EINVAL)
return -1;
-#endif
+#endif
fd = epoll_create(1);
return set_cloexec_or_close(fd);
}
-static int create_tmpfile_cloexec(char *tmpname)
+static int create_tmpfile_cloexec(char* tmpname)
{
int fd;
-
#ifdef USE_SHM
fd = shm_open(SHM_ANON, O_CREAT | O_RDWR, 0600);
#elif defined(HAVE_MKOSTEMP)
fd = mkostemp(tmpname, O_CLOEXEC);
+
if (fd >= 0)
unlink(tmpname);
+
#else
fd = mkstemp(tmpname);
- if (fd >= 0) {
+
+ if (fd >= 0)
+ {
fd = set_cloexec_or_close(fd);
unlink(tmpname);
}
-#endif
+#endif
return fd;
}
int uwac_create_anonymous_file(off_t size)
{
static const char template[] = "/weston-shared-XXXXXX";
- const char *path;
- char *name;
+ const char* path;
+ char* name;
int fd;
int ret;
-
+ size_t length;
path = getenv("XDG_RUNTIME_DIR");
- if (!path) {
+
+ if (!path)
+ {
errno = ENOENT;
return -1;
}
- name = malloc(strlen(path) + sizeof(template));
+ length = strlen(path) + sizeof(template);
+ name = malloc(length);
+
if (!name)
return -1;
- strcpy(name, path);
- strcat(name, template);
-
+ snprintf(name, length, "%s%s", path, template);
fd = create_tmpfile_cloexec(name);
-
free(name);
if (fd < 0)
#ifdef HAVE_POSIX_FALLOCATE
ret = posix_fallocate(fd, 0, size);
- if (ret != 0) {
+
+ if (ret != 0)
+ {
close(fd);
errno = ret;
return -1;
}
+
#else
ret = ftruncate(fd, size);
- if (ret < 0) {
+
+ if (ret < 0)
+ {
close(fd);
return -1;
}
-#endif
+#endif
return fd;
}
{
char* body;
BYTE bom[2];
- char num[11];
+ char num[20];
WCHAR* wstr;
if (SrcSize > 2)
return NULL;
}
- strcpy(pDstData,
- "Version:0.9\r\n"
- "StartHTML:0000000000\r\n"
- "EndHTML:0000000000\r\n"
- "StartFragment:0000000000\r\n"
- "EndFragment:0000000000\r\n");
+ sprintf_s(pDstData, SrcSize + 200,
+ "Version:0.9\r\n"
+ "StartHTML:0000000000\r\n"
+ "EndHTML:0000000000\r\n"
+ "StartFragment:0000000000\r\n"
+ "EndFragment:0000000000\r\n");
body = strstr(pSrcData, "<body");
if (!body)
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
+
return TRUE;
}
{
WINPR_NAMED_PIPE* pNamedPipe = (WINPR_NAMED_PIPE*) handle;
-
if (!NamedPipeClientIsHandled(handle))
return FALSE;
free(pNamedPipe->lpFilePath);
free(pNamedPipe->name);
free(pNamedPipe);
-
return TRUE;
}
static int NamedPipeClientGetFd(HANDLE handle)
{
- WINPR_NAMED_PIPE *file = (WINPR_NAMED_PIPE *)handle;
+ WINPR_NAMED_PIPE* file = (WINPR_NAMED_PIPE*)handle;
if (!NamedPipeClientIsHandled(handle))
return -1;
return file->clientfd;
}
-static HANDLE_OPS ops = {
- NamedPipeClientIsHandled,
- NamedPipeClientCloseHandle,
- NamedPipeClientGetFd,
- NULL, /* CleanupHandle */
- NamedPipeRead,
- NULL, /* FileReadEx */
- NULL, /* FileReadScatter */
- NamedPipeWrite,
- NULL, /* FileWriteEx */
- NULL, /* FileWriteGather */
- NULL, /* FileGetFileSize */
- NULL, /* FlushFileBuffers */
- NULL, /* FileSetEndOfFile */
- NULL, /* FileSetFilePointer */
- NULL, /* SetFilePointerEx */
- NULL, /* FileLockFile */
- NULL, /* FileLockFileEx */
- NULL, /* FileUnlockFile */
- NULL, /* FileUnlockFileEx */
- NULL /* SetFileTime */
+static HANDLE_OPS ops =
+{
+ NamedPipeClientIsHandled,
+ NamedPipeClientCloseHandle,
+ NamedPipeClientGetFd,
+ NULL, /* CleanupHandle */
+ NamedPipeRead,
+ NULL, /* FileReadEx */
+ NULL, /* FileReadScatter */
+ NamedPipeWrite,
+ NULL, /* FileWriteEx */
+ NULL, /* FileWriteGather */
+ NULL, /* FileGetFileSize */
+ NULL, /* FlushFileBuffers */
+ NULL, /* FileSetEndOfFile */
+ NULL, /* FileSetFilePointer */
+ NULL, /* SetFilePointerEx */
+ NULL, /* FileLockFile */
+ NULL, /* FileLockFileEx */
+ NULL, /* FileUnlockFile */
+ NULL, /* FileUnlockFileEx */
+ NULL /* SetFileTime */
};
-static HANDLE NamedPipeClientCreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes,
- DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
+static HANDLE NamedPipeClientCreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess,
+ DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes,
+ DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
{
char* name;
int status;
free(name);
pNamedPipe = (WINPR_NAMED_PIPE*) calloc(1, sizeof(WINPR_NAMED_PIPE));
+
if (!pNamedPipe)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
hNamedPipe = (HANDLE) pNamedPipe;
WINPR_HANDLE_SET_TYPE_AND_MODE(pNamedPipe, HANDLE_TYPE_NAMED_PIPE, WINPR_FD_READ);
pNamedPipe->name = _strdup(lpFileName);
+
if (!pNamedPipe->name)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
free(pNamedPipe);
return INVALID_HANDLE_VALUE;
}
+
pNamedPipe->dwOpenMode = 0;
pNamedPipe->dwPipeMode = 0;
pNamedPipe->nMaxInstances = 0;
pNamedPipe->nDefaultTimeOut = 0;
pNamedPipe->dwFlagsAndAttributes = dwFlagsAndAttributes;
pNamedPipe->lpFileName = GetNamedPipeNameWithoutPrefixA(lpFileName);
+
if (!pNamedPipe->lpFileName)
{
- free((void *)pNamedPipe->name);
+ free((void*)pNamedPipe->name);
free(pNamedPipe);
return INVALID_HANDLE_VALUE;
-
}
+
pNamedPipe->lpFilePath = GetNamedPipeUnixDomainSocketFilePathA(lpFileName);
+
if (!pNamedPipe->lpFilePath)
{
- free((void *)pNamedPipe->lpFileName);
- free((void *)pNamedPipe->name);
+ free((void*)pNamedPipe->lpFileName);
+ free((void*)pNamedPipe->name);
free(pNamedPipe);
return INVALID_HANDLE_VALUE;
-
}
+
pNamedPipe->clientfd = socket(PF_LOCAL, SOCK_STREAM, 0);
pNamedPipe->serverfd = -1;
pNamedPipe->ServerMode = FALSE;
ZeroMemory(&s, sizeof(struct sockaddr_un));
s.sun_family = AF_UNIX;
- strcpy(s.sun_path, pNamedPipe->lpFilePath);
+ sprintf_s(s.sun_path, ARRAYSIZE(s.sun_path), "%s", pNamedPipe->lpFilePath);
status = connect(pNamedPipe->clientfd, (struct sockaddr*) &s, sizeof(struct sockaddr_un));
-
pNamedPipe->ops = &ops;
if (status != 0)
return hNamedPipe;
}
-HANDLE_CREATOR *GetNamedPipeClientHandleCreator(void)
+HANDLE_CREATOR* GetNamedPipeClientHandleCreator(void)
{
_NamedPipeClientHandleCreator.IsHandled = IsNamedPipeFileNameA;
_NamedPipeClientHandleCreator.CreateFileA = NamedPipeClientCreateFileA;
char* lpTempPath;
char* lpPipePath;
lpTempPath = GetKnownPath(KNOWN_PATH_TEMP);
+
if (!lpTempPath)
return NULL;
+
lpPipePath = GetCombinedPath(lpTempPath, ".pipe");
free(lpTempPath);
return lpPipePath;
ZeroMemory(&s, sizeof(struct sockaddr_un));
s.sun_family = AF_UNIX;
- strcpy(s.sun_path, pNamedPipe->lpFilePath);
+ sprintf_s(s.sun_path, ARRAYSIZE(s.sun_path), "%s", pNamedPipe->lpFilePath);
if (bind(serverfd, (struct sockaddr*) &s, sizeof(struct sockaddr_un)) == -1)
{
struct passwd pwd;
struct passwd* pw = NULL;
WINPR_ACCESS_TOKEN* token;
-
token = (WINPR_ACCESS_TOKEN*) hToken;
if (!token || (token->Type != HANDLE_TYPE_ACCESS_TOKEN) || !lpcchSize)
if ((status != 0) || !pw)
{
SetLastError(ERROR_INVALID_PARAMETER);
- free (buf);
+ free(buf);
return FALSE;
}
}
ZeroMemory(lpProfileDir, *lpcchSize);
- strcpy(lpProfileDir, pw->pw_dir);
+ sprintf_s(lpProfileDir, *lpcchSize, "%s", pw->pw_dir);
*lpcchSize = cchDirSize;
free(buf);
-
return TRUE;
}
}
*lpcchSize = cchSizeA;
-
return bStatus;
}
int offset;
char* filename = NULL;
char* fullpath = NULL;
+ char* ext;
int ret = -1;
BIO* bio = NULL;
BYTE* x509_str = NULL;
if (!filename)
return -1;
- strcpy(filename, context->output_file);
-
if (context->crtFormat)
- strcpy(&filename[length], ".crt");
+ ext = "crt";
else if (context->pemFormat)
- strcpy(&filename[length], ".pem");
+ ext = "pem";
else if (context->pfxFormat)
- strcpy(&filename[length], ".pfx");
+ ext = "pfx";
+ else
+ return -1;
+
+ sprintf_s(filename, length + 8, "%s.%s", context->output_file, ext);
if (path)
fullpath = GetCombinedPath(path, filename);
if (!filename)
return -1;
- strcpy(filename, context->output_file);
- strcpy(&filename[length], ".key");
+ sprintf_s(filename, length + 8, "%s.key", context->output_file);
if (path)
fullpath = GetCombinedPath(path, filename);