Unifiy string append functions

This commit is contained in:
akallabeth 2022-06-03 10:25:30 +02:00 committed by akallabeth
parent aff8fdac26
commit f25261e271
15 changed files with 129 additions and 189 deletions

View File

@ -25,54 +25,33 @@
#include <freerdp/channels/ainput.h> #include <freerdp/channels/ainput.h>
static INLINE void ainput_append(char* buffer, size_t size, const char* what, BOOL separator)
{
size_t have;
size_t toadd;
WINPR_ASSERT(buffer || (size == 0));
WINPR_ASSERT(what);
have = strnlen(buffer, size);
toadd = strlen(what);
if (have > 0)
toadd += 1;
if (size - have < toadd + 1)
return;
if (have > 0)
strcat(buffer, separator ? "|" : " ");
strcat(buffer, what);
}
static INLINE const char* ainput_flags_to_string(UINT64 flags, char* buffer, size_t size) static INLINE const char* ainput_flags_to_string(UINT64 flags, char* buffer, size_t size)
{ {
char number[32] = { 0 }; char number[32] = { 0 };
if (flags & AINPUT_FLAGS_HAVE_REL) if (flags & AINPUT_FLAGS_HAVE_REL)
ainput_append(buffer, size, "AINPUT_FLAGS_HAVE_REL", TRUE); winpr_str_append("AINPUT_FLAGS_HAVE_REL", buffer, size, "|");
if (flags & AINPUT_FLAGS_WHEEL) if (flags & AINPUT_FLAGS_WHEEL)
ainput_append(buffer, size, "AINPUT_FLAGS_WHEEL", TRUE); winpr_str_append("AINPUT_FLAGS_WHEEL", buffer, size, "|");
if (flags & AINPUT_FLAGS_MOVE) if (flags & AINPUT_FLAGS_MOVE)
ainput_append(buffer, size, "AINPUT_FLAGS_MOVE", TRUE); winpr_str_append("AINPUT_FLAGS_MOVE", buffer, size, "|");
if (flags & AINPUT_FLAGS_DOWN) if (flags & AINPUT_FLAGS_DOWN)
ainput_append(buffer, size, "AINPUT_FLAGS_DOWN", TRUE); winpr_str_append("AINPUT_FLAGS_DOWN", buffer, size, "|");
if (flags & AINPUT_FLAGS_REL) if (flags & AINPUT_FLAGS_REL)
ainput_append(buffer, size, "AINPUT_FLAGS_REL", TRUE); winpr_str_append("AINPUT_FLAGS_REL", buffer, size, "|");
if (flags & AINPUT_FLAGS_BUTTON1) if (flags & AINPUT_FLAGS_BUTTON1)
ainput_append(buffer, size, "AINPUT_FLAGS_BUTTON1", TRUE); winpr_str_append("AINPUT_FLAGS_BUTTON1", buffer, size, "|");
if (flags & AINPUT_FLAGS_BUTTON2) if (flags & AINPUT_FLAGS_BUTTON2)
ainput_append(buffer, size, "AINPUT_FLAGS_BUTTON2", TRUE); winpr_str_append("AINPUT_FLAGS_BUTTON2", buffer, size, "|");
if (flags & AINPUT_FLAGS_BUTTON3) if (flags & AINPUT_FLAGS_BUTTON3)
ainput_append(buffer, size, "AINPUT_FLAGS_BUTTON3", TRUE); winpr_str_append("AINPUT_FLAGS_BUTTON3", buffer, size, "|");
if (flags & AINPUT_XFLAGS_BUTTON1) if (flags & AINPUT_XFLAGS_BUTTON1)
ainput_append(buffer, size, "AINPUT_XFLAGS_BUTTON1", TRUE); winpr_str_append("AINPUT_XFLAGS_BUTTON1", buffer, size, "|");
if (flags & AINPUT_XFLAGS_BUTTON2) if (flags & AINPUT_XFLAGS_BUTTON2)
ainput_append(buffer, size, "AINPUT_XFLAGS_BUTTON2", TRUE); winpr_str_append("AINPUT_XFLAGS_BUTTON2", buffer, size, "|");
_snprintf(number, sizeof(number), "[0x%08" PRIx64 "]", flags); _snprintf(number, sizeof(number), "[0x%08" PRIx64 "]", flags);
ainput_append(buffer, size, number, FALSE); winpr_str_append(number, buffer, size, " ");
return buffer; return buffer;
} }

View File

@ -1929,7 +1929,7 @@ static UINT rdpdr_server_drive_query_directory_callback1(RdpdrServerContext* con
irp->Callback = rdpdr_server_drive_query_directory_callback2; irp->Callback = rdpdr_server_drive_query_directory_callback2;
irp->DeviceId = deviceId; irp->DeviceId = deviceId;
irp->FileId = fileId; irp->FileId = fileId;
strcat(irp->PathName, "\\*.*"); winpr_str_append("\\*.*", irp->PathName, ARRAYSIZE(irp->PathName), NULL);
if (!rdpdr_server_enqueue_irp(context, irp)) if (!rdpdr_server_enqueue_irp(context, irp))
{ {

View File

@ -507,12 +507,7 @@ static BOOL filter_by_class(uint8_t bDeviceClass, uint8_t bDeviceSubClass)
static BOOL append(char* dst, size_t length, const char* src) static BOOL append(char* dst, size_t length, const char* src)
{ {
size_t slen = strlen(src); return winpr_str_append(src, dst, length, NULL);
size_t dlen = strnlen(dst, length);
if (dlen + slen >= length)
return FALSE;
strcat(dst, src);
return TRUE;
} }
static BOOL device_is_filtered(struct libusb_device* dev, static BOOL device_is_filtered(struct libusb_device* dev,

View File

@ -28,6 +28,8 @@
#include <winpr/assert.h> #include <winpr/assert.h>
#include <winpr/collections.h> #include <winpr/collections.h>
#include <freerdp/utils/string.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include <X11/keysym.h> #include <X11/keysym.h>
@ -474,18 +476,19 @@ static int xf_keyboard_execute_action_script(xfContext* xfc, XF_MODIFIER_KEYS* m
} }
if (mod->Shift) if (mod->Shift)
strcat(combination, "Shift+"); winpr_str_append("Shift", combination, sizeof(combination), "+");
if (mod->Ctrl) if (mod->Ctrl)
strcat(combination, "Ctrl+"); winpr_str_append("Ctrl", combination, sizeof(combination), "+");
if (mod->Alt) if (mod->Alt)
strcat(combination, "Alt+"); winpr_str_append("Alt", combination, sizeof(combination), "+");
if (mod->Super) if (mod->Super)
strcat(combination, "Super+"); winpr_str_append("Super", combination, sizeof(combination), "+");
winpr_str_append(keyStr, combination, sizeof(combination), NULL);
strcat(combination, keyStr);
count = ArrayList_Count(xfc->keyCombinations); count = ArrayList_Count(xfc->keyCombinations);
for (index = 0; index < count; index++) for (index = 0; index < count; index++)

View File

@ -216,6 +216,7 @@ static BOOL copy_value(const char* value, char** dst)
static BOOL append_value(const char* value, char** dst) static BOOL append_value(const char* value, char** dst)
{ {
size_t x = 0, y; size_t x = 0, y;
size_t size;
char* tmp; char* tmp;
if (!dst || !value) if (!dst || !value)
return FALSE; return FALSE;
@ -223,14 +224,16 @@ static BOOL append_value(const char* value, char** dst)
if (*dst) if (*dst)
x = strlen(*dst); x = strlen(*dst);
y = strlen(value); y = strlen(value);
tmp = realloc(*dst, x + y + 2);
size = x + y + 2;
tmp = realloc(*dst, size);
if (!tmp) if (!tmp)
return FALSE; return FALSE;
if (x == 0) if (x == 0)
tmp[0] = '\0'; tmp[0] = '\0';
else else
strcat(tmp, ","); winpr_str_append(",", tmp, size, NULL);
strcat(tmp, value); winpr_str_append(value, tmp, size, NULL);
*dst = tmp; *dst = tmp;
return TRUE; return TRUE;
} }

View File

@ -256,20 +256,18 @@ static const char* flags_to_string(UINT32 flags, const t_flag_mapping* map, size
{ {
size_t x = 0; size_t x = 0;
static char buffer[1024] = { 0 }; static char buffer[1024] = { 0 };
char fields[12]; char fields[12] = { 0 };
memset(buffer, 0, sizeof(buffer));
for (x = 0; x < elements; x++) for (x = 0; x < elements; x++)
{ {
if (buffer[0] != '\0') const t_flag_mapping* cur = &map[x];
strcat(buffer, "|");
if ((map[x].code & flags) != 0) if ((cur->code & flags) != 0)
strcat(buffer, map[x].name); winpr_str_append(cur->name, buffer, sizeof(buffer), "|");
} }
sprintf_s(fields, ARRAYSIZE(fields), " [%04" PRIx32 "]", flags); sprintf_s(fields, ARRAYSIZE(fields), " [%04" PRIx32 "]", flags);
strcat(buffer, fields); winpr_str_append(fields, buffer, sizeof(buffer), NULL);
return buffer; return buffer;
} }

View File

@ -45,11 +45,13 @@ static const char* const INFO_TYPE_LOGON_STRINGS[4] = { "Logon Info V1", "Logon
/* This define limits the length of the strings in the label field. */ /* This define limits the length of the strings in the label field. */
#define MAX_LABEL_LENGTH 40 #define MAX_LABEL_LENGTH 40
static struct struct info_flags_t
{ {
UINT32 flag; UINT32 flag;
const char* label; const char* label;
} const info_flags[] = { };
static const struct info_flags_t info_flags[] = {
{ INFO_MOUSE, "INFO_MOUSE" }, { INFO_MOUSE, "INFO_MOUSE" },
{ INFO_DISABLECTRLALTDEL, "INFO_DISABLECTRLALTDEL" }, { INFO_DISABLECTRLALTDEL, "INFO_DISABLECTRLALTDEL" },
{ INFO_AUTOLOGON, "INFO_AUTOLOGON" }, { INFO_AUTOLOGON, "INFO_AUTOLOGON" },
@ -122,12 +124,8 @@ static BOOL rdp_read_info_null_string(UINT32 flags, wStream* s, size_t cbLen, CH
static char* rdp_info_package_flags_description(UINT32 flags) static char* rdp_info_package_flags_description(UINT32 flags)
{ {
char* result; char* result;
size_t maximum_size = 1; /* Reserve space for the terminating '\0' by strcat if all flags set */ size_t maximum_size = 1 + MAX_LABEL_LENGTH * ARRAYSIZE(info_flags);
size_t i; size_t i;
size_t size;
for (i = 0; i < ARRAYSIZE(info_flags); i++)
maximum_size += strnlen(info_flags[i].label, MAX_LABEL_LENGTH) + 1;
result = calloc(maximum_size, sizeof(char)); result = calloc(maximum_size, sizeof(char));
@ -136,18 +134,13 @@ static char* rdp_info_package_flags_description(UINT32 flags)
for (i = 0; i < ARRAYSIZE(info_flags); i++) for (i = 0; i < ARRAYSIZE(info_flags); i++)
{ {
if (info_flags[i].flag & flags) const struct info_flags_t* cur = &info_flags[i];
if (cur->flag & flags)
{ {
strcat(result, info_flags[i].label); winpr_str_append(cur->label, result, maximum_size, "|");
strcat(result, "|");
} }
} }
size = strnlen(result, maximum_size);
if (size > 0)
result[size - 1] = '\0'; /* remove last "|" */
return result; return result;
} }

View File

@ -1090,36 +1090,26 @@ BOOL nego_process_negotiation_request(rdpNego* nego, wStream* s)
* @param nego * @param nego
* @param s * @param s
*/ */
static void pipecat(char* buffer, BOOL* first, const char* what)
{
WINPR_ASSERT(first);
if (!*first)
strcat(buffer, "|");
*first = FALSE;
strcat(buffer, what);
}
static const char* nego_rdp_neg_rsp_flags_str(UINT32 flags) static const char* nego_rdp_neg_rsp_flags_str(UINT32 flags)
{ {
BOOL first = TRUE;
static char buffer[1024] = { 0 }; static char buffer[1024] = { 0 };
_snprintf(buffer, ARRAYSIZE(buffer), "[0x%02" PRIx32 "] ", flags); _snprintf(buffer, ARRAYSIZE(buffer), "[0x%02" PRIx32 "] ", flags);
if (flags & EXTENDED_CLIENT_DATA_SUPPORTED) if (flags & EXTENDED_CLIENT_DATA_SUPPORTED)
pipecat(buffer, &first, "EXTENDED_CLIENT_DATA_SUPPORTED"); winpr_str_append("EXTENDED_CLIENT_DATA_SUPPORTED", buffer, sizeof(buffer), "|");
if (flags & DYNVC_GFX_PROTOCOL_SUPPORTED) if (flags & DYNVC_GFX_PROTOCOL_SUPPORTED)
pipecat(buffer, &first, "DYNVC_GFX_PROTOCOL_SUPPORTED"); winpr_str_append("DYNVC_GFX_PROTOCOL_SUPPORTED", buffer, sizeof(buffer), "|");
if (flags & RDP_NEGRSP_RESERVED) if (flags & RDP_NEGRSP_RESERVED)
pipecat(buffer, &first, "RDP_NEGRSP_RESERVED"); winpr_str_append("RDP_NEGRSP_RESERVED", buffer, sizeof(buffer), "|");
if (flags & RESTRICTED_ADMIN_MODE_SUPPORTED) if (flags & RESTRICTED_ADMIN_MODE_SUPPORTED)
pipecat(buffer, &first, "RESTRICTED_ADMIN_MODE_SUPPORTED"); winpr_str_append("RESTRICTED_ADMIN_MODE_SUPPORTED", buffer, sizeof(buffer), "|");
if (flags & REDIRECTED_AUTHENTICATION_MODE_SUPPORTED) if (flags & REDIRECTED_AUTHENTICATION_MODE_SUPPORTED)
pipecat(buffer, &first, "REDIRECTED_AUTHENTICATION_MODE_SUPPORTED"); winpr_str_append("REDIRECTED_AUTHENTICATION_MODE_SUPPORTED", buffer, sizeof(buffer), "|");
if ((flags & if ((flags &
~(EXTENDED_CLIENT_DATA_SUPPORTED | DYNVC_GFX_PROTOCOL_SUPPORTED | RDP_NEGRSP_RESERVED | ~(EXTENDED_CLIENT_DATA_SUPPORTED | DYNVC_GFX_PROTOCOL_SUPPORTED | RDP_NEGRSP_RESERVED |
RESTRICTED_ADMIN_MODE_SUPPORTED | REDIRECTED_AUTHENTICATION_MODE_SUPPORTED))) RESTRICTED_ADMIN_MODE_SUPPORTED | REDIRECTED_AUTHENTICATION_MODE_SUPPORTED)))
pipecat(buffer, &first, "UNKNOWN"); winpr_str_append("UNKNOWN", buffer, sizeof(buffer), "|");
return buffer; return buffer;
} }

View File

@ -31,6 +31,13 @@
#include "../core/rdp.h" #include "../core/rdp.h"
char* utils_str_append(char* buffer, size_t size, const char* what)
{
if (!winpr_str_append(what, buffer, size, "|"))
return NULL;
return buffer;
}
BOOL utils_str_copy(const char* value, char** dst) BOOL utils_str_copy(const char* value, char** dst)
{ {
WINPR_ASSERT(dst); WINPR_ASSERT(dst);
@ -59,8 +66,9 @@ auth_status utils_authenticate_gateway(freerdp* instance, rdp_auth_reason reason
if (freerdp_shall_disconnect_context(instance->context)) if (freerdp_shall_disconnect_context(instance->context))
return AUTH_FAILED; return AUTH_FAILED;
if (!settings->GatewayPassword || !settings->GatewayUsername || if (utils_str_is_empty(freerdp_settings_get_string(settings, FreeRDP_GatewayPassword)))
!strlen(settings->GatewayPassword) || !strlen(settings->GatewayUsername)) prompt = TRUE;
if (utils_str_is_empty(freerdp_settings_get_string(settings, FreeRDP_GatewayUsername)))
prompt = TRUE; prompt = TRUE;
if (!prompt) if (!prompt)
@ -102,7 +110,7 @@ auth_status utils_authenticate(freerdp* instance, rdp_auth_reason reason, BOOL o
return AUTH_FAILED; return AUTH_FAILED;
/* Ask for auth data if no or an empty username was specified or no password was given */ /* Ask for auth data if no or an empty username was specified or no password was given */
if (utils_str_is_empty(settings->Username) || if (utils_str_is_empty(freerdp_settings_get_string(settings, FreeRDP_Username)) ||
(settings->Password == NULL && settings->RedirectionPassword == NULL)) (settings->Password == NULL && settings->RedirectionPassword == NULL))
prompt = TRUE; prompt = TRUE;

View File

@ -31,6 +31,9 @@ extern "C"
{ {
#endif #endif
WINPR_API BOOL winpr_str_append(const char* what, char* buffer, size_t size,
const char* separator);
#ifndef _WIN32 #ifndef _WIN32
#define CSTR_LESS_THAN 1 #define CSTR_LESS_THAN 1

View File

@ -348,7 +348,8 @@ static void* clipboard_synthesize_html_format(wClipboard* clipboard, UINT32 form
if (formatId == ClipboardGetFormatId(clipboard, "text/html")) if (formatId == ClipboardGetFormatId(clipboard, "text/html"))
{ {
INT64 SrcSize = (INT64)*pSize; const INT64 SrcSize = (INT64)*pSize;
const size_t DstSize = SrcSize + 200;
char* body; char* body;
char num[20] = { 0 }; char num[20] = { 0 };
@ -378,12 +379,12 @@ static void* clipboard_synthesize_html_format(wClipboard* clipboard, UINT32 form
} }
} }
pDstData = (char*)calloc(1, SrcSize + 200); pDstData = (char*)calloc(1, DstSize);
if (!pDstData) if (!pDstData)
goto fail; goto fail;
sprintf_s(pDstData, SrcSize + 200, sprintf_s(pDstData, DstSize,
"Version:0.9\r\n" "Version:0.9\r\n"
"StartHTML:0000000000\r\n" "StartHTML:0000000000\r\n"
"EndHTML:0000000000\r\n" "EndHTML:0000000000\r\n"
@ -395,29 +396,42 @@ static void* clipboard_synthesize_html_format(wClipboard* clipboard, UINT32 form
body = strstr(pSrcData.cpc, "<BODY"); body = strstr(pSrcData.cpc, "<BODY");
/* StartHTML */ /* StartHTML */
sprintf_s(num, sizeof(num), "%010" PRIuz "", strnlen(pDstData, SrcSize + 200)); sprintf_s(num, sizeof(num), "%010" PRIuz "", strnlen(pDstData, DstSize));
CopyMemory(&pDstData[23], num, 10); CopyMemory(&pDstData[23], num, 10);
if (!body) if (!body)
strcat(pDstData, "<HTML><BODY>"); {
if (!winpr_str_append("<HTML><BODY>", pDstData, DstSize, NULL))
goto fail;
}
if (!winpr_str_append("<!--StartFragment-->", pDstData, DstSize, NULL))
goto fail;
strcat(pDstData, "<!--StartFragment-->");
/* StartFragment */ /* StartFragment */
sprintf_s(num, sizeof(num), "%010" PRIuz "", strnlen(pDstData, SrcSize + 200)); sprintf_s(num, sizeof(num), "%010" PRIuz "", strnlen(pDstData, SrcSize + 200));
CopyMemory(&pDstData[69], num, 10); CopyMemory(&pDstData[69], num, 10);
strcat(pDstData, pSrcData.cpc);
if (!winpr_str_append(pSrcData.cpc, pDstData, DstSize, NULL))
goto fail;
/* EndFragment */ /* EndFragment */
sprintf_s(num, sizeof(num), "%010" PRIuz "", strnlen(pDstData, SrcSize + 200)); sprintf_s(num, sizeof(num), "%010" PRIuz "", strnlen(pDstData, SrcSize + 200));
CopyMemory(&pDstData[93], num, 10); CopyMemory(&pDstData[93], num, 10);
strcat(pDstData, "<!--EndFragment-->");
if (!winpr_str_append("<!--EndFragment-->", pDstData, DstSize, NULL))
goto fail;
if (!body) if (!body)
strcat(pDstData, "</BODY></HTML>"); {
if (!winpr_str_append("</BODY></HTML>", pDstData, DstSize, NULL))
goto fail;
}
/* EndHTML */ /* EndHTML */
sprintf_s(num, sizeof(num), "%010" PRIuz "", strnlen(pDstData, SrcSize + 200)); sprintf_s(num, sizeof(num), "%010" PRIuz "", strnlen(pDstData, DstSize));
CopyMemory(&pDstData[43], num, 10); CopyMemory(&pDstData[43], num, 10);
*pSize = (UINT32)strlen(pDstData) + 1; *pSize = (UINT32)strnlen(pDstData, DstSize) + 1;
} }
fail: fail:
free(pSrcData.pv); free(pSrcData.pv);

View File

@ -33,6 +33,23 @@
#include "../log.h" #include "../log.h"
#define TAG WINPR_TAG("crt") #define TAG WINPR_TAG("crt")
BOOL winpr_str_append(const char* what, char* buffer, size_t size, const char* separator)
{
const size_t used = strnlen(buffer, size);
const size_t add = strnlen(what, size);
const size_t sep_len = separator ? strnlen(separator, size) : 0;
const size_t sep = (used > 0) ? sep_len : 0;
if (used + add + sep >= size)
return FALSE;
if ((used > 0) && (sep_len > 0))
strncat(buffer, separator, sep_len);
strncat(buffer, what, add);
return TRUE;
}
#ifndef _WIN32 #ifndef _WIN32
char* _strdup(const char* strSource) char* _strdup(const char* strSource)

View File

@ -22,6 +22,7 @@
#include <winpr/config.h> #include <winpr/config.h>
#include <winpr/crt.h> #include <winpr/crt.h>
#include <winpr/string.h>
#include <winpr/path.h> #include <winpr/path.h>
#include <winpr/file.h> #include <winpr/file.h>
@ -555,15 +556,7 @@ BOOL GetFileInformationByHandle(HANDLE hFile, LPBY_HANDLE_FILE_INFORMATION lpFil
static char* append(char* buffer, size_t size, const char* append) static char* append(char* buffer, size_t size, const char* append)
{ {
const size_t len = strnlen(buffer, size); winpr_str_append(append, buffer, size, "|");
if (len == 0)
_snprintf(buffer, size, "%s", append);
else
{
strcat(buffer, "|");
strcat(buffer, append);
}
return buffer; return buffer;
} }
@ -602,7 +595,7 @@ static const char* flagsToStr(char* buffer, size_t size, DWORD flags)
append(buffer, size, "FILE_ATTRIBUTE_VIRTUAL"); append(buffer, size, "FILE_ATTRIBUTE_VIRTUAL");
_snprintf(strflags, sizeof(strflags), " [0x%08" PRIx32 "]", flags); _snprintf(strflags, sizeof(strflags), " [0x%08" PRIx32 "]", flags);
strcat(buffer, strflags); winpr_str_append(strflags, buffer, size, NULL);
return buffer; return buffer;
} }

View File

@ -1057,103 +1057,47 @@ WINSCARDAPI const char* WINAPI SCardGetCardStateString(DWORD dwCardState)
WINSCARDAPI char* WINAPI SCardGetReaderStateString(DWORD dwReaderState) WINSCARDAPI char* WINAPI SCardGetReaderStateString(DWORD dwReaderState)
{ {
char* szReaderState = malloc(512); const size_t size = 512;
char* buffer = calloc(size, sizeof(char));
if (!szReaderState) if (!buffer)
return NULL; return NULL;
szReaderState[0] = '\0';
if (dwReaderState & SCARD_STATE_IGNORE) if (dwReaderState & SCARD_STATE_IGNORE)
{ winpr_str_append("SCARD_STATE_IGNORE", buffer, size, "|");
if (szReaderState[0])
strcat(szReaderState, " | ");
strcat(szReaderState, "SCARD_STATE_IGNORE");
}
if (dwReaderState & SCARD_STATE_CHANGED) if (dwReaderState & SCARD_STATE_CHANGED)
{ winpr_str_append("SCARD_STATE_CHANGED", buffer, size, "|");
if (szReaderState[0])
strcat(szReaderState, " | ");
strcat(szReaderState, "SCARD_STATE_CHANGED");
}
if (dwReaderState & SCARD_STATE_UNKNOWN) if (dwReaderState & SCARD_STATE_UNKNOWN)
{ winpr_str_append("SCARD_STATE_UNKNOWN", buffer, size, "|");
if (szReaderState[0])
strcat(szReaderState, " | ");
strcat(szReaderState, "SCARD_STATE_UNKNOWN");
}
if (dwReaderState & SCARD_STATE_UNAVAILABLE) if (dwReaderState & SCARD_STATE_UNAVAILABLE)
{ winpr_str_append("SCARD_STATE_UNAVAILABLE", buffer, size, "|");
if (szReaderState[0])
strcat(szReaderState, " | ");
strcat(szReaderState, "SCARD_STATE_UNAVAILABLE");
}
if (dwReaderState & SCARD_STATE_EMPTY) if (dwReaderState & SCARD_STATE_EMPTY)
{ winpr_str_append("SCARD_STATE_EMPTY", buffer, size, "|");
if (szReaderState[0])
strcat(szReaderState, " | ");
strcat(szReaderState, "SCARD_STATE_EMPTY");
}
if (dwReaderState & SCARD_STATE_PRESENT) if (dwReaderState & SCARD_STATE_PRESENT)
{ winpr_str_append("SCARD_STATE_PRESENT", buffer, size, "|");
if (szReaderState[0])
strcat(szReaderState, " | ");
strcat(szReaderState, "SCARD_STATE_PRESENT");
}
if (dwReaderState & SCARD_STATE_ATRMATCH) if (dwReaderState & SCARD_STATE_ATRMATCH)
{ winpr_str_append("SCARD_STATE_ATRMATCH", buffer, size, "|");
if (szReaderState[0])
strcat(szReaderState, " | ");
strcat(szReaderState, "SCARD_STATE_ATRMATCH");
}
if (dwReaderState & SCARD_STATE_EXCLUSIVE) if (dwReaderState & SCARD_STATE_EXCLUSIVE)
{ winpr_str_append("SCARD_STATE_EXCLUSIVE", buffer, size, "|");
if (szReaderState[0])
strcat(szReaderState, " | ");
strcat(szReaderState, "SCARD_STATE_EXCLUSIVE");
}
if (dwReaderState & SCARD_STATE_INUSE) if (dwReaderState & SCARD_STATE_INUSE)
{ winpr_str_append("SCARD_STATE_INUSE", buffer, size, "|");
if (szReaderState[0])
strcat(szReaderState, " | ");
strcat(szReaderState, "SCARD_STATE_INUSE");
}
if (dwReaderState & SCARD_STATE_MUTE) if (dwReaderState & SCARD_STATE_MUTE)
{ winpr_str_append("SCARD_STATE_MUTE", buffer, size, "|");
if (szReaderState[0])
strcat(szReaderState, " | ");
strcat(szReaderState, "SCARD_STATE_MUTE");
}
if (dwReaderState & SCARD_STATE_UNPOWERED) if (dwReaderState & SCARD_STATE_UNPOWERED)
{ winpr_str_append("SCARD_STATE_UNPOWERED", buffer, size, "|");
if (szReaderState[0])
strcat(szReaderState, " | ");
strcat(szReaderState, "SCARD_STATE_UNPOWERED"); if (!buffer[0])
} winpr_str_append("SCARD_STATE_UNAWARE", buffer, size, "|");
if (!szReaderState[0]) return buffer;
strcat(szReaderState, "SCARD_STATE_UNAWARE");
return szReaderState;
} }

View File

@ -1313,13 +1313,13 @@ char* ntlm_negotiate_flags_string(char* buffer, size_t size, UINT32 flags)
{ {
if (size - len < 1) if (size - len < 1)
break; break;
strcat(buffer, "|"); winpr_str_append("|", buffer, size, NULL);
len++; len++;
} }
if (size - len < flen) if (size - len < flen)
break; break;
strcat(buffer, str); winpr_str_append(str, buffer, size, NULL);
} }
} }