Merge pull request #10606 from akallabeth/warn-fix

Warn fix
This commit is contained in:
akallabeth 2024-09-14 21:44:34 +02:00 committed by GitHub
commit ca1791cfe8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
46 changed files with 162 additions and 99 deletions

View File

@ -292,7 +292,7 @@ static DWORD WINAPI ainput_server_thread_func(LPVOID arg)
}
}
WTSVirtualChannelClose(ainput->ainput_channel);
(void)WTSVirtualChannelClose(ainput->ainput_channel);
ainput->ainput_channel = NULL;
if (error && ainput->context.rdpcontext)
@ -369,7 +369,7 @@ static UINT ainput_server_close(ainput_server_context* context)
{
if (ainput->state != AINPUT_INITIAL)
{
WTSVirtualChannelClose(ainput->ainput_channel);
(void)WTSVirtualChannelClose(ainput->ainput_channel);
ainput->ainput_channel = NULL;
ainput->state = AINPUT_INITIAL;
}

View File

@ -430,7 +430,7 @@ static DWORD WINAPI audin_server_thread_func(LPVOID arg)
out_capacity:
Stream_Free(s, TRUE);
out:
WTSVirtualChannelClose(audin->audin_channel);
(void)WTSVirtualChannelClose(audin->audin_channel);
audin->audin_channel = NULL;
if (error && audin->context.rdpcontext)
@ -533,7 +533,7 @@ static BOOL audin_server_close(audin_server_context* context)
if (audin->audin_channel)
{
WTSVirtualChannelClose(audin->audin_channel);
(void)WTSVirtualChannelClose(audin->audin_channel);
audin->audin_channel = NULL;
}

View File

@ -1355,7 +1355,7 @@ static UINT cliprdr_server_close(CliprdrServerContext* context)
if (cliprdr->ChannelHandle)
{
WTSVirtualChannelClose(cliprdr->ChannelHandle);
(void)WTSVirtualChannelClose(cliprdr->ChannelHandle);
cliprdr->ChannelHandle = NULL;
}

View File

@ -474,7 +474,7 @@ static UINT disp_server_open(DispServerContext* context)
return CHANNEL_RC_OK;
out_close:
WTSVirtualChannelClose(priv->disp_channel);
(void)WTSVirtualChannelClose(priv->disp_channel);
priv->disp_channel = NULL;
priv->channelEvent = NULL;
return rc;
@ -567,7 +567,7 @@ static UINT disp_server_close(DispServerContext* context)
if (priv->disp_channel)
{
WTSVirtualChannelClose(priv->disp_channel);
(void)WTSVirtualChannelClose(priv->disp_channel);
priv->disp_channel = NULL;
}

View File

@ -219,7 +219,7 @@ static DWORD WINAPI echo_server_thread_func(LPVOID arg)
if (!s)
{
WLog_ERR(TAG, "Stream_New failed!");
WTSVirtualChannelClose(echo->echo_channel);
(void)WTSVirtualChannelClose(echo->echo_channel);
ExitThread(ERROR_NOT_ENOUGH_MEMORY);
return ERROR_NOT_ENOUGH_MEMORY;
}
@ -239,7 +239,12 @@ static DWORD WINAPI echo_server_thread_func(LPVOID arg)
break;
Stream_SetPosition(s, 0);
WTSVirtualChannelRead(echo->echo_channel, 0, NULL, 0, &BytesReturned);
if (!WTSVirtualChannelRead(echo->echo_channel, 0, NULL, 0, &BytesReturned))
{
WLog_ERR(TAG, "WTSVirtualChannelRead failed!");
error = ERROR_INTERNAL_ERROR;
break;
}
if (BytesReturned < 1)
continue;
@ -270,7 +275,7 @@ static DWORD WINAPI echo_server_thread_func(LPVOID arg)
}
Stream_Free(s, TRUE);
WTSVirtualChannelClose(echo->echo_channel);
(void)WTSVirtualChannelClose(echo->echo_channel);
echo->echo_channel = NULL;
out:

View File

@ -232,7 +232,12 @@ static DWORD WINAPI encomsp_server_thread(LPVOID arg)
break;
}
WTSVirtualChannelRead(context->priv->ChannelHandle, 0, NULL, 0, &BytesReturned);
if (!WTSVirtualChannelRead(context->priv->ChannelHandle, 0, NULL, 0, &BytesReturned))
{
WLog_ERR(TAG, "WTSVirtualChannelRead failed!");
error = ERROR_INTERNAL_ERROR;
break;
}
if (BytesReturned < 1)
continue;
@ -364,7 +369,7 @@ void encomsp_server_context_free(EncomspServerContext* context)
if (context)
{
if (context->priv->ChannelHandle != INVALID_HANDLE_VALUE)
WTSVirtualChannelClose(context->priv->ChannelHandle);
(void)WTSVirtualChannelClose(context->priv->ChannelHandle);
free(context->priv);
free(context);

View File

@ -426,7 +426,7 @@ static DWORD WINAPI location_server_thread_func(LPVOID arg)
}
}
WTSVirtualChannelClose(location->location_channel);
(void)WTSVirtualChannelClose(location->location_channel);
location->location_channel = NULL;
if (error && location->context.rdpcontext)
@ -493,7 +493,7 @@ static UINT location_server_close(LocationServerContext* context)
{
if (location->state != LOCATION_INITIAL)
{
WTSVirtualChannelClose(location->location_channel);
(void)WTSVirtualChannelClose(location->location_channel);
location->location_channel = NULL;
location->state = LOCATION_INITIAL;
}

View File

@ -1462,7 +1462,7 @@ out_stop_event:
CloseHandle(context->priv->stopEvent);
context->priv->stopEvent = NULL;
out_close:
WTSVirtualChannelClose(context->priv->rail_channel);
(void)WTSVirtualChannelClose(context->priv->rail_channel);
context->priv->rail_channel = NULL;
return error;
}
@ -1489,7 +1489,7 @@ static BOOL rail_server_stop(RailServerContext* context)
if (priv->rail_channel)
{
WTSVirtualChannelClose(priv->rail_channel);
(void)WTSVirtualChannelClose(priv->rail_channel);
priv->rail_channel = NULL;
}

View File

@ -2186,7 +2186,7 @@ static UINT rdpdr_server_stop(RdpdrServerContext* context)
if (context->priv->ChannelHandle)
{
WTSVirtualChannelClose(context->priv->ChannelHandle);
(void)WTSVirtualChannelClose(context->priv->ChannelHandle);
context->priv->ChannelHandle = NULL;
}
return CHANNEL_RC_OK;

View File

@ -35,4 +35,4 @@ if (NOT IOS AND NOT WIN32 AND NOT ANDROID)
# add_channel_server(${MODULE_PREFIX} ${CHANNEL_NAME})
#endif()
endif()
endif()
endif()

View File

@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <krb5/krb5.h>
#include <krb5.h>
#include <errno.h>
#include <winpr/assert.h>

View File

@ -26,10 +26,25 @@ add_library(rdpear-common-obj OBJECT
)
target_include_directories(rdpear-common
INTERFACE ${KRB5_INCLUDE_DIRS})
target_include_directories(rdpear-common-obj
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${KRB5_INCLUDE_DIRS})
SYSTEM
INTERFACE ${KRB5_INCLUDE_DIRS}
)
target_compile_options(rdpear-common
INTERFACE
${KRB5_CFLAGS}
)
target_link_options(rdpear-common
INTERFACE
${KRB5_LDFLAGS}
)
target_include_directories(rdpear-common-obj
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
)
target_include_directories(rdpear-common-obj
SYSTEM
PRIVATE ${KRB5_INCLUDE_DIRS}
)
target_link_directories(rdpear-common INTERFACE ${KRB5_LIBRARY_DIRS})
target_link_libraries(rdpear-common INTERFACE
${KRB5_LIBRARIES}

View File

@ -418,7 +418,7 @@ static DWORD WINAPI enumerator_server_thread_func(LPVOID arg)
}
}
WTSVirtualChannelClose(enumerator->enumerator_channel);
(void)WTSVirtualChannelClose(enumerator->enumerator_channel);
enumerator->enumerator_channel = NULL;
if (error && enumerator->context.rdpcontext)
@ -486,7 +486,7 @@ static UINT enumerator_server_close(CamDevEnumServerContext* context)
{
if (enumerator->state != ENUMERATOR_INITIAL)
{
WTSVirtualChannelClose(enumerator->enumerator_channel);
(void)WTSVirtualChannelClose(enumerator->enumerator_channel);
enumerator->enumerator_channel = NULL;
enumerator->state = ENUMERATOR_INITIAL;
}

View File

@ -571,7 +571,7 @@ static DWORD WINAPI device_server_thread_func(LPVOID arg)
}
}
WTSVirtualChannelClose(device->device_channel);
(void)WTSVirtualChannelClose(device->device_channel);
device->device_channel = NULL;
if (error && device->context.rdpcontext)
@ -638,7 +638,7 @@ static UINT device_server_close(CameraDeviceServerContext* context)
{
if (device->state != CAMERA_DEVICE_INITIAL)
{
WTSVirtualChannelClose(device->device_channel);
(void)WTSVirtualChannelClose(device->device_channel);
device->device_channel = NULL;
device->state = CAMERA_DEVICE_INITIAL;
}

View File

@ -136,7 +136,7 @@ UINT rdpei_server_init(RdpeiServerContext* context)
return CHANNEL_RC_OK;
out_close:
WTSVirtualChannelClose(priv->channelHandle);
(void)WTSVirtualChannelClose(priv->channelHandle);
return CHANNEL_RC_INITIALIZATION_ERROR;
}
@ -161,7 +161,7 @@ void rdpei_server_context_free(RdpeiServerContext* context)
if (priv)
{
if (priv->channelHandle != INVALID_HANDLE_VALUE)
WTSVirtualChannelClose(priv->channelHandle);
(void)WTSVirtualChannelClose(priv->channelHandle);
Stream_Free(priv->inputStream, TRUE);
}
free(priv);

View File

@ -375,7 +375,7 @@ static DWORD WINAPI mouse_cursor_server_thread_func(LPVOID arg)
}
}
WTSVirtualChannelClose(mouse_cursor->mouse_cursor_channel);
(void)WTSVirtualChannelClose(mouse_cursor->mouse_cursor_channel);
mouse_cursor->mouse_cursor_channel = NULL;
if (error && mouse_cursor->context.rdpcontext)
@ -443,7 +443,7 @@ static UINT mouse_cursor_server_close(MouseCursorServerContext* context)
{
if (mouse_cursor->state != MOUSE_CURSOR_INITIAL)
{
WTSVirtualChannelClose(mouse_cursor->mouse_cursor_channel);
(void)WTSVirtualChannelClose(mouse_cursor->mouse_cursor_channel);
mouse_cursor->mouse_cursor_channel = NULL;
mouse_cursor->state = MOUSE_CURSOR_INITIAL;
}

View File

@ -1649,7 +1649,7 @@ BOOL rdpgfx_server_close(RdpgfxServerContext* context)
if (priv->rdpgfx_channel)
{
WTSVirtualChannelClose(priv->rdpgfx_channel);
(void)WTSVirtualChannelClose(priv->rdpgfx_channel);
priv->rdpgfx_channel = NULL;
}

View File

@ -965,7 +965,7 @@ out_pdu:
Stream_Free(context->priv->rdpsnd_pdu, TRUE);
context->priv->rdpsnd_pdu = NULL;
out_close:
WTSVirtualChannelClose(context->priv->ChannelHandle);
(void)WTSVirtualChannelClose(context->priv->ChannelHandle);
context->priv->ChannelHandle = NULL;
return error;
}
@ -1015,7 +1015,7 @@ static UINT rdpsnd_server_stop(RdpsndServerContext* context)
if (context->priv->ChannelHandle)
{
WTSVirtualChannelClose(context->priv->ChannelHandle);
(void)WTSVirtualChannelClose(context->priv->ChannelHandle);
context->priv->ChannelHandle = NULL;
}

View File

@ -728,7 +728,7 @@ void remdesk_server_context_free(RemdeskServerContext* context)
if (context)
{
if (context->priv->ChannelHandle != INVALID_HANDLE_VALUE)
WTSVirtualChannelClose(context->priv->ChannelHandle);
(void)WTSVirtualChannelClose(context->priv->ChannelHandle);
free(context->priv);
free(context);

View File

@ -295,7 +295,7 @@ static DWORD WINAPI telemetry_server_thread_func(LPVOID arg)
}
}
WTSVirtualChannelClose(telemetry->telemetry_channel);
(void)WTSVirtualChannelClose(telemetry->telemetry_channel);
telemetry->telemetry_channel = NULL;
if (error && telemetry->context.rdpcontext)
@ -362,7 +362,7 @@ static UINT telemetry_server_close(TelemetryServerContext* context)
{
if (telemetry->state != TELEMETRY_INITIAL)
{
WTSVirtualChannelClose(telemetry->telemetry_channel);
(void)WTSVirtualChannelClose(telemetry->telemetry_channel);
telemetry->telemetry_channel = NULL;
telemetry->state = TELEMETRY_INITIAL;
}

View File

@ -434,15 +434,16 @@ static size_t print_description(const char* text, size_t start_offset, size_t cu
char* str = _strdup(text);
char* cur = str;
do
{
while (cur != NULL)
cur = print_token(cur, start_offset, &current, limit, " ", "\r\n");
} while (cur != NULL);
free(str);
const int rc = printf("\n");
if (rc >= 0)
{
WINPR_ASSERT(SIZE_MAX - rc >= current);
current += (size_t)rc;
}
return current;
}

View File

@ -1021,9 +1021,9 @@ BOOL freerdp_client_parse_rdp_file_ex(rdpFile* file, const char* name, rdp_file_
return FALSE;
}
_fseeki64(fp, 0, SEEK_END);
(void)_fseeki64(fp, 0, SEEK_END);
file_size = _ftelli64(fp);
_fseeki64(fp, 0, SEEK_SET);
(void)_fseeki64(fp, 0, SEEK_SET);
if (file_size < 1)
{

View File

@ -201,14 +201,14 @@ else()
GET_KRB5_BY_CONFIG("${KRB5_ROOT_CONFIG}")
endif()
#message("using KRB5_FOUND ${KRB5_FOUND} ")
#message("using KRB5_VERSION ${KRB5_VERSION} ")
#message("using KRB5_FLAVOUR ${KRB5_FLAVOUR} ")
#message("using KRB5_CFLAGS ${KRB5_CFLAGS} ")
#message("using KRB5_LDFLAGS ${KRB5_LDFLAGS} ")
#message("using KRB5_INCLUDEDIR ${KRB5_INCLUDEDIR} ")
#message("using KRB5_INCLUDE_DIRS ${KRB5_INCLUDEDIR} ")
#message("using KRB5_LIBRARIES ${KRB5_LIBRARIES} ")
message("using KRB5_FOUND ${KRB5_FOUND} ")
message("using KRB5_VERSION ${KRB5_VERSION} ")
message("using KRB5_FLAVOUR ${KRB5_FLAVOUR} ")
message("using KRB5_CFLAGS ${KRB5_CFLAGS} ")
message("using KRB5_LDFLAGS ${KRB5_LDFLAGS} ")
message("using KRB5_INCLUDEDIR ${KRB5_INCLUDEDIR} ")
message("using KRB5_INCLUDE_DIRS ${KRB5_INCLUDE_DIRS} ")
message("using KRB5_LIBRARIES ${KRB5_LIBRARIES} ")
include(FindPackageHandleStandardArgs)

View File

@ -286,12 +286,12 @@ static BYTE* test_progressive_load_file(const char* path, const char* file, size
if (!fp)
return NULL;
_fseeki64(fp, 0, SEEK_END);
(void)_fseeki64(fp, 0, SEEK_END);
const INT64 pos = _ftelli64(fp);
WINPR_ASSERT(pos >= 0);
WINPR_ASSERT(pos <= SIZE_MAX);
*size = (size_t)pos;
_fseeki64(fp, 0, SEEK_SET);
(void)_fseeki64(fp, 0, SEEK_SET);
BYTE* buffer = (BYTE*)malloc(*size);
if (!buffer)

View File

@ -1246,9 +1246,9 @@ int freerdp_assistance_parse_file(rdpAssistanceFile* file, const char* name, con
return -1;
}
_fseeki64(fp, 0, SEEK_END);
(void)_fseeki64(fp, 0, SEEK_END);
fileSize.i64 = _ftelli64(fp);
_fseeki64(fp, 0, SEEK_SET);
(void)_fseeki64(fp, 0, SEEK_SET);
if (fileSize.i64 < 1)
{

View File

@ -624,9 +624,11 @@ static BYTE* loadCalFile(const rdpSettings* settings, const char* hostname, size
if (!fp)
goto error_open;
_fseeki64(fp, 0, SEEK_END);
if (_fseeki64(fp, 0, SEEK_END) != 0)
goto error_malloc;
length = _ftelli64(fp);
_fseeki64(fp, 0, SEEK_SET);
if (_fseeki64(fp, 0, SEEK_SET) != 0)
goto error_malloc;
if (length < 0)
goto error_malloc;

View File

@ -85,7 +85,7 @@ state_run_t multitransport_recv_request(rdpMultitransport* multi, wStream* s)
WLog_WARN(TAG,
"reserved is %" PRIu16 " instead of 0, skipping %" PRIuz "bytes of unknown data",
reserved, Stream_GetRemainingLength(s));
Stream_SafeSeek(s, Stream_GetRemainingLength(s));
(void)Stream_SafeSeek(s, Stream_GetRemainingLength(s));
}
WINPR_ASSERT(multi->MtRequest);

View File

@ -1198,6 +1198,7 @@ static BOOL nla_read_KERB_TICKET_LOGON(rdpNla* nla, wStream* s, KERB_TICKET_LOGO
/** @brief kind of RCG credentials */
typedef enum
{
RCG_TYPE_NONE,
RCG_TYPE_KERB,
RCG_TYPE_NTLM
} RemoteGuardPackageCredType;
@ -1211,17 +1212,24 @@ static BOOL nla_read_TSRemoteGuardPackageCred(rdpNla* nla, WinPrAsn1Decoder* dec
BOOL error = FALSE;
char packageNameStr[100] = { 0 };
WINPR_ASSERT(nla);
WINPR_ASSERT(dec);
WINPR_ASSERT(credsType);
WINPR_ASSERT(payload);
*credsType = RCG_TYPE_NONE;
/* packageName [0] OCTET STRING */
if (!WinPrAsn1DecReadContextualOctetString(dec, 0, &error, &packageName, FALSE) || error)
return TRUE;
return FALSE;
ConvertMszWCharNToUtf8((WCHAR*)packageName.data, packageName.len / sizeof(WCHAR),
packageNameStr, 100);
packageNameStr, sizeof(packageNameStr));
WLog_DBG(TAG, "TSRemoteGuardPackageCred(%s)", packageNameStr);
/* credBuffer [1] OCTET STRING, */
if (!WinPrAsn1DecReadContextualOctetString(dec, 1, &error, &credBuffer, FALSE) || error)
return TRUE;
return FALSE;
if (_stricmp(packageNameStr, "Kerberos") == 0)
{
@ -1345,7 +1353,7 @@ static BOOL nla_read_ts_credentials(rdpNla* nla, SecBuffer* data)
if (!WinPrAsn1DecReadContextualSequence(&dec2, 0, &error, &logonCredsSeq) || error)
return FALSE;
RemoteGuardPackageCredType logonCredsType = { 0 };
RemoteGuardPackageCredType logonCredsType = RCG_TYPE_NONE;
wStream logonPayload = { 0 };
if (!nla_read_TSRemoteGuardPackageCred(nla, &logonCredsSeq, &logonCredsType,
&logonPayload))

View File

@ -1066,7 +1066,7 @@ VOID WINAPI FreeRDP_WTSCloseServer(HANDLE hServer)
if (vcm->drdynvc_channel)
{
WTSVirtualChannelClose(vcm->drdynvc_channel);
(void)WTSVirtualChannelClose(vcm->drdynvc_channel);
vcm->drdynvc_channel = NULL;
}

View File

@ -57,7 +57,7 @@ static void delete_file(char* path)
int rs = _fseeki64(fp, 0, SEEK_END);
if (rs == 0)
size = _ftelli64(fp);
_fseeki64(fp, 0, SEEK_SET);
(void)_fseeki64(fp, 0, SEEK_SET);
for (INT64 x = 0; x < size; x += sizeof(buffer))
{

View File

@ -80,7 +80,7 @@ static
return FALSE;
if (pOffset)
_fseeki64(fp, *pOffset, SEEK_SET);
(void)_fseeki64(fp, *pOffset, SEEK_SET);
r = fread(&ts, 1, sizeof(ts), fp);
if (r != sizeof(ts))

View File

@ -221,9 +221,9 @@ static long transport_bio_simple_ctrl(BIO* bio, int cmd, long arg1, void* arg2)
return 0;
if (arg1)
fcntl((int)ptr->socket, F_SETFL, flags | O_NONBLOCK);
(void)fcntl((int)ptr->socket, F_SETFL, flags | O_NONBLOCK);
else
fcntl((int)ptr->socket, F_SETFL, flags & ~(O_NONBLOCK));
(void)fcntl((int)ptr->socket, F_SETFL, flags & ~(O_NONBLOCK));
#else
/* the internal socket is always non-blocking */

View File

@ -401,7 +401,8 @@ static BOOL vgids_ef_read_do(vgidsEF* ef, UINT16 doID, BYTE** data, DWORD* dataS
else
{
/* Skip DO */
Stream_SafeSeek(ef->data, doSize);
if (!Stream_SafeSeek(ef->data, doSize))
return FALSE;
}
}

View File

@ -252,7 +252,7 @@ int freerdp_interruptible_getc(rdpContext* context, FILE* f)
const int fd = fileno(f);
const int orig = fcntl(fd, F_GETFL);
fcntl(fd, F_SETFL, orig | O_NONBLOCK);
(void)fcntl(fd, F_SETFL, orig | O_NONBLOCK);
do
{
const int res = wait_for_fd(fd, 10);
@ -266,7 +266,7 @@ int freerdp_interruptible_getc(rdpContext* context, FILE* f)
}
} while (!freerdp_shall_disconnect_context(context));
fcntl(fd, F_SETFL, orig);
(void)fcntl(fd, F_SETFL, orig);
return rc;
}

View File

@ -225,9 +225,9 @@ rdpPcap* pcap_open(const char* name, BOOL write)
}
else
{
_fseeki64(pcap->fp, 0, SEEK_END);
(void)_fseeki64(pcap->fp, 0, SEEK_END);
pcap->file_size = _ftelli64(pcap->fp);
_fseeki64(pcap->fp, 0, SEEK_SET);
(void)_fseeki64(pcap->fp, 0, SEEK_SET);
if (!pcap_read_header(pcap, &pcap->header))
goto fail;
}

View File

@ -93,7 +93,7 @@ static void test_peer_context_free(freerdp_peer* client, rdpContext* ctx)
nsc_context_free(context->nsc_context);
if (context->debug_channel)
WTSVirtualChannelClose(context->debug_channel);
(void)WTSVirtualChannelClose(context->debug_channel);
sf_peer_audin_uninit(context);
@ -610,7 +610,6 @@ fail:
static DWORD WINAPI tf_debug_channel_thread_func(LPVOID arg)
{
void* fd = NULL;
wStream* s = NULL;
void* buffer = NULL;
DWORD BytesReturned = 0;
ULONG written = 0;
@ -627,8 +626,12 @@ static DWORD WINAPI tf_debug_channel_thread_func(LPVOID arg)
return 0;
}
s = Stream_New(NULL, 4096);
WTSVirtualChannelWrite(context->debug_channel, (PCHAR) "test1", 5, &written);
wStream* s = Stream_New(NULL, 4096);
if (!s)
goto fail;
if (!WTSVirtualChannelWrite(context->debug_channel, (PCHAR) "test1", 5, &written))
goto fail;
while (1)
{
@ -892,7 +895,8 @@ static BOOL tf_peer_keyboard_event(rdpInput* input, UINT16 flags, UINT8 code)
if (tcontext->debug_channel)
{
ULONG written = 0;
WTSVirtualChannelWrite(tcontext->debug_channel, (PCHAR) "test2", 5, &written);
if (!WTSVirtualChannelWrite(tcontext->debug_channel, (PCHAR) "test2", 5, &written))
return FALSE;
}
}
else if (((flags & KBD_FLAGS_RELEASE) == 0) && code == RDP_SCANCODE_KEY_X) /* 'x' key */

View File

@ -129,15 +129,19 @@ extern "C"
{
#endif
WINPR_ATTR_MALLOC(free, 1)
WINPR_API LPCH MergeEnvironmentStrings(PCSTR original, PCSTR merge);
WINPR_API DWORD GetEnvironmentVariableEBA(LPCSTR envBlock, LPCSTR lpName, LPSTR lpBuffer,
DWORD nSize);
WINPR_API BOOL SetEnvironmentVariableEBA(LPSTR* envBlock, LPCSTR lpName, LPCSTR lpValue);
WINPR_ATTR_MALLOC(free, 1)
WINPR_API char** EnvironmentBlockToEnvpA(LPCH lpszEnvironmentBlock);
WINPR_API DWORD GetEnvironmentVariableX(const char* lpName, char* lpBuffer, DWORD nSize);
WINPR_ATTR_MALLOC(free, 1)
WINPR_API char* GetEnvAlloc(LPCSTR lpName);
#ifdef __cplusplus

View File

@ -306,10 +306,20 @@ extern "C"
#endif
WINPR_API const char* GetKnownPathIdString(int id);
WINPR_ATTR_MALLOC(free, 1)
WINPR_API char* GetKnownPath(int id);
WINPR_ATTR_MALLOC(free, 1)
WINPR_API char* GetKnownSubPath(int id, const char* path);
WINPR_ATTR_MALLOC(free, 1)
WINPR_API char* GetEnvironmentPath(char* name);
WINPR_ATTR_MALLOC(free, 1)
WINPR_API char* GetEnvironmentSubPath(char* name, const char* path);
WINPR_ATTR_MALLOC(free, 1)
WINPR_API char* GetCombinedPath(const char* basePath, const char* subPath);
WINPR_API BOOL PathMakePathA(LPCSTR path, LPSECURITY_ATTRIBUTES lpAttributes);

View File

@ -1074,14 +1074,16 @@ extern "C"
WINPR_API BOOL WINAPI WTSWaitSystemEvent(HANDLE hServer, DWORD EventMask, DWORD* pEventFlags);
WINPR_API BOOL WINAPI WTSVirtualChannelClose(HANDLE hChannelHandle);
WINPR_ATTR_MALLOC(WTSVirtualChannelClose, 1)
WINPR_API HANDLE WINAPI WTSVirtualChannelOpen(HANDLE hServer, DWORD SessionId,
LPSTR pVirtualName);
WINPR_ATTR_MALLOC(WTSVirtualChannelClose, 1)
WINPR_API HANDLE WINAPI WTSVirtualChannelOpenEx(DWORD SessionId, LPSTR pVirtualName,
DWORD flags);
WINPR_API BOOL WINAPI WTSVirtualChannelClose(HANDLE hChannelHandle);
WINPR_API BOOL WINAPI WTSVirtualChannelRead(HANDLE hChannelHandle, ULONG TimeOut, PCHAR Buffer,
ULONG BufferSize, PULONG pBytesRead);

View File

@ -106,28 +106,25 @@ out:
return result;
}
static const BYTE* TEST_RC4_KEY = (BYTE*)"Key";
static const char* TEST_RC4_PLAINTEXT = "Plaintext";
static const BYTE* TEST_RC4_CIPHERTEXT = (BYTE*)"\xBB\xF3\x16\xE8\xD9\x40\xAF\x0A\xD3";
static const char TEST_RC4_KEY[] = "Key";
static const char TEST_RC4_PLAINTEXT[] = "Plaintext";
static const char TEST_RC4_CIPHERTEXT[] = "\xBB\xF3\x16\xE8\xD9\x40\xAF\x0A\xD3";
static BOOL test_crypto_cipher_rc4(void)
{
size_t len = 0;
BOOL rc = FALSE;
BYTE* text = NULL;
WINPR_RC4_CTX* ctx = NULL;
len = strnlen(TEST_RC4_PLAINTEXT, sizeof(TEST_RC4_PLAINTEXT));
if (!(text = (BYTE*)calloc(1, len)))
const size_t len = strnlen(TEST_RC4_PLAINTEXT, sizeof(TEST_RC4_PLAINTEXT));
BYTE* text = (BYTE*)calloc(1, len);
if (!text)
{
(void)fprintf(stderr, "%s: failed to allocate text buffer (len=%" PRIuz ")\n", __func__,
len);
goto out;
}
if ((ctx = winpr_RC4_New(TEST_RC4_KEY,
strnlen((const char*)TEST_RC4_KEY, sizeof(TEST_RC4_KEY)))) == NULL)
if ((ctx = winpr_RC4_New(TEST_RC4_KEY, strnlen(TEST_RC4_KEY, sizeof(TEST_RC4_KEY)))) == NULL)
{
(void)fprintf(stderr, "%s: winpr_RC4_New failed\n", __func__);
goto out;

View File

@ -301,6 +301,8 @@ BOOL FreeEnvironmentStringsA(LPCH lpszEnvironmentBlock)
BOOL FreeEnvironmentStringsW(LPWCH lpszEnvironmentBlock)
{
free(lpszEnvironmentBlock);
return TRUE;
}

View File

@ -217,7 +217,7 @@ static HANDLE NamedPipeClientCreateFileA(LPCSTR lpFileName, DWORD dwDesiredAcces
int flags = fcntl(pNamedPipe->clientfd, F_GETFL);
if (flags != -1)
fcntl(pNamedPipe->clientfd, F_SETFL, flags | O_NONBLOCK);
(void)fcntl(pNamedPipe->clientfd, F_SETFL, flags | O_NONBLOCK);
#endif
}

View File

@ -95,9 +95,11 @@ static BOOL reg_load_start(Reg* reg)
WINPR_ASSERT(reg);
WINPR_ASSERT(reg->fp);
_fseeki64(reg->fp, 0, SEEK_END);
if (_fseeki64(reg->fp, 0, SEEK_END) != 0)
return FALSE;
file_size = _ftelli64(reg->fp);
_fseeki64(reg->fp, 0, SEEK_SET);
if (_fseeki64(reg->fp, 0, SEEK_SET) != 0)
return FALSE;
reg->line = NULL;
reg->next_line = NULL;

View File

@ -139,9 +139,11 @@ static BOOL SamLookupStart(WINPR_SAM* sam)
if (!sam || !sam->fp)
return FALSE;
_fseeki64(sam->fp, 0, SEEK_END);
if (_fseeki64(sam->fp, 0, SEEK_END) != 0)
return FALSE;
fileSize = _ftelli64(sam->fp);
_fseeki64(sam->fp, 0, SEEK_SET);
if (_fseeki64(sam->fp, 0, SEEK_SET) != 0)
return FALSE;
if (fileSize < 1)
return FALSE;

View File

@ -99,11 +99,14 @@ static BOOL WLog_UdpAppender_WriteMessage(wLog* log, wLogAppender* appender, wLo
udpAppender = (wLogUdpAppender*)appender;
message->PrefixString = prefix;
WLog_Layout_GetMessagePrefix(log, appender->Layout, message);
_sendto(udpAppender->sock, message->PrefixString, (int)strnlen(message->PrefixString, INT_MAX),
0, &udpAppender->targetAddr, udpAppender->targetAddrLen);
_sendto(udpAppender->sock, message->TextString, (int)strnlen(message->TextString, INT_MAX), 0,
&udpAppender->targetAddr, udpAppender->targetAddrLen);
_sendto(udpAppender->sock, "\n", 1, 0, &udpAppender->targetAddr, udpAppender->targetAddrLen);
(void)_sendto(udpAppender->sock, message->PrefixString,
(int)strnlen(message->PrefixString, INT_MAX), 0, &udpAppender->targetAddr,
udpAppender->targetAddrLen);
(void)_sendto(udpAppender->sock, message->TextString,
(int)strnlen(message->TextString, INT_MAX), 0, &udpAppender->targetAddr,
udpAppender->targetAddrLen);
(void)_sendto(udpAppender->sock, "\n", 1, 0, &udpAppender->targetAddr,
udpAppender->targetAddrLen);
return TRUE;
}

View File

@ -1060,9 +1060,9 @@ int _ioctlsocket(SOCKET s, long cmd, u_long* argp)
return SOCKET_ERROR;
if (*argp)
fcntl(fd, F_SETFL, flags | O_NONBLOCK);
(void)fcntl(fd, F_SETFL, flags | O_NONBLOCK);
else
fcntl(fd, F_SETFL, flags & ~(O_NONBLOCK));
(void)fcntl(fd, F_SETFL, flags & ~(O_NONBLOCK));
}
return 0;