[nodiscard] mark more internal functions

This commit is contained in:
Armin Novak
2026-03-02 11:43:39 +01:00
parent be5c9bed64
commit 2b0637d629
4 changed files with 101 additions and 9 deletions

View File

@@ -77,6 +77,7 @@
#define FDServer 0x00000002 #define FDServer 0x00000002
#define FDOutProxy 0x00000003 #define FDOutProxy 0x00000003
WINPR_ATTR_NODISCARD
FREERDP_LOCAL BOOL rts_generate_cookie(BYTE* cookie); FREERDP_LOCAL BOOL rts_generate_cookie(BYTE* cookie);
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD

View File

@@ -220,11 +220,17 @@ struct rdp_license
wLog* log; wLog* log;
}; };
WINPR_ATTR_NODISCARD
static BOOL license_send_error_alert(rdpLicense* license, UINT32 dwErrorCode, static BOOL license_send_error_alert(rdpLicense* license, UINT32 dwErrorCode,
UINT32 dwStateTransition, const LICENSE_BLOB* info); UINT32 dwStateTransition, const LICENSE_BLOB* info);
WINPR_ATTR_NODISCARD
static BOOL license_set_state(rdpLicense* license, LICENSE_STATE state); static BOOL license_set_state(rdpLicense* license, LICENSE_STATE state);
WINPR_ATTR_NODISCARD
static const char* license_get_state_string(LICENSE_STATE state); static const char* license_get_state_string(LICENSE_STATE state);
WINPR_ATTR_NODISCARD
static const char* license_preferred_key_exchange_alg_string(UINT32 alg, char* buffer, size_t size) static const char* license_preferred_key_exchange_alg_string(UINT32 alg, char* buffer, size_t size)
{ {
const char* name = nullptr; const char* name = nullptr;
@@ -243,6 +249,7 @@ static const char* license_preferred_key_exchange_alg_string(UINT32 alg, char* b
return buffer; return buffer;
} }
WINPR_ATTR_NODISCARD
static const char* license_request_type_string(UINT32 type) static const char* license_request_type_string(UINT32 type)
{ {
switch (type) switch (type)
@@ -268,6 +275,7 @@ static const char* license_request_type_string(UINT32 type)
} }
} }
WINPR_ATTR_NODISCARD
static const char* licencse_blob_type_string(UINT16 type) static const char* licencse_blob_type_string(UINT16 type)
{ {
switch (type) switch (type)
@@ -296,54 +304,112 @@ static const char* licencse_blob_type_string(UINT16 type)
return "BB_UNKNOWN"; return "BB_UNKNOWN";
} }
} }
WINPR_ATTR_NODISCARD
static wStream* license_send_stream_init(rdpLicense* license, UINT16* sec_flags); static wStream* license_send_stream_init(rdpLicense* license, UINT16* sec_flags);
WINPR_ATTR_NODISCARD
static BOOL license_generate_randoms(rdpLicense* license); static BOOL license_generate_randoms(rdpLicense* license);
WINPR_ATTR_NODISCARD
static BOOL license_generate_keys(rdpLicense* license); static BOOL license_generate_keys(rdpLicense* license);
WINPR_ATTR_NODISCARD
static BOOL license_generate_hwid(rdpLicense* license); static BOOL license_generate_hwid(rdpLicense* license);
WINPR_ATTR_NODISCARD
static BOOL license_encrypt_premaster_secret(rdpLicense* license); static BOOL license_encrypt_premaster_secret(rdpLicense* license);
static LICENSE_PRODUCT_INFO* license_new_product_info(void);
static void license_free_product_info(LICENSE_PRODUCT_INFO* productInfo); static void license_free_product_info(LICENSE_PRODUCT_INFO* productInfo);
WINPR_ATTR_MALLOC(license_free_product_info, 1)
static LICENSE_PRODUCT_INFO* license_new_product_info(void);
WINPR_ATTR_NODISCARD
static BOOL license_read_product_info(wLog* log, wStream* s, LICENSE_PRODUCT_INFO* productInfo); static BOOL license_read_product_info(wLog* log, wStream* s, LICENSE_PRODUCT_INFO* productInfo);
static LICENSE_BLOB* license_new_binary_blob(UINT16 type);
static void license_free_binary_blob(LICENSE_BLOB* blob); static void license_free_binary_blob(LICENSE_BLOB* blob);
WINPR_ATTR_MALLOC(license_free_binary_blob, 1)
static LICENSE_BLOB* license_new_binary_blob(UINT16 type);
WINPR_ATTR_NODISCARD
static BOOL license_read_binary_blob_data(wLog* log, LICENSE_BLOB* blob, UINT16 type, static BOOL license_read_binary_blob_data(wLog* log, LICENSE_BLOB* blob, UINT16 type,
const void* data, size_t length); const void* data, size_t length);
WINPR_ATTR_NODISCARD
static BOOL license_read_binary_blob(wLog* log, wStream* s, LICENSE_BLOB* blob); static BOOL license_read_binary_blob(wLog* log, wStream* s, LICENSE_BLOB* blob);
WINPR_ATTR_NODISCARD
static BOOL license_write_binary_blob(wStream* s, const LICENSE_BLOB* blob); static BOOL license_write_binary_blob(wStream* s, const LICENSE_BLOB* blob);
static SCOPE_LIST* license_new_scope_list(void);
static BOOL license_scope_list_resize(SCOPE_LIST* scopeList, UINT32 count);
static void license_free_scope_list(SCOPE_LIST* scopeList); static void license_free_scope_list(SCOPE_LIST* scopeList);
WINPR_ATTR_MALLOC(license_free_scope_list, 1)
static SCOPE_LIST* license_new_scope_list(void);
WINPR_ATTR_NODISCARD
static BOOL license_scope_list_resize(SCOPE_LIST* scopeList, UINT32 count);
WINPR_ATTR_NODISCARD
static BOOL license_read_scope_list(wLog* log, wStream* s, SCOPE_LIST* scopeList); static BOOL license_read_scope_list(wLog* log, wStream* s, SCOPE_LIST* scopeList);
WINPR_ATTR_NODISCARD
static BOOL license_write_scope_list(wLog* log, wStream* s, const SCOPE_LIST* scopeList); static BOOL license_write_scope_list(wLog* log, wStream* s, const SCOPE_LIST* scopeList);
WINPR_ATTR_NODISCARD
static BOOL license_read_license_request_packet(rdpLicense* license, wStream* s); static BOOL license_read_license_request_packet(rdpLicense* license, wStream* s);
WINPR_ATTR_NODISCARD
static BOOL license_write_license_request_packet(const rdpLicense* license, wStream* s); static BOOL license_write_license_request_packet(const rdpLicense* license, wStream* s);
WINPR_ATTR_NODISCARD
static BOOL license_read_platform_challenge_packet(rdpLicense* license, wStream* s); static BOOL license_read_platform_challenge_packet(rdpLicense* license, wStream* s);
WINPR_ATTR_NODISCARD
static BOOL license_send_platform_challenge_packet(rdpLicense* license); static BOOL license_send_platform_challenge_packet(rdpLicense* license);
WINPR_ATTR_NODISCARD
static BOOL license_read_new_or_upgrade_license_packet(rdpLicense* license, wStream* s); static BOOL license_read_new_or_upgrade_license_packet(rdpLicense* license, wStream* s);
WINPR_ATTR_NODISCARD
static BOOL license_read_error_alert_packet(rdpLicense* license, wStream* s); static BOOL license_read_error_alert_packet(rdpLicense* license, wStream* s);
WINPR_ATTR_NODISCARD
static BOOL license_write_new_license_request_packet(const rdpLicense* license, wStream* s); static BOOL license_write_new_license_request_packet(const rdpLicense* license, wStream* s);
WINPR_ATTR_NODISCARD
static BOOL license_read_new_license_request_packet(rdpLicense* license, wStream* s); static BOOL license_read_new_license_request_packet(rdpLicense* license, wStream* s);
WINPR_ATTR_NODISCARD
static BOOL license_answer_license_request(rdpLicense* license); static BOOL license_answer_license_request(rdpLicense* license);
WINPR_ATTR_NODISCARD
static BOOL license_send_platform_challenge_response(rdpLicense* license); static BOOL license_send_platform_challenge_response(rdpLicense* license);
WINPR_ATTR_NODISCARD
static BOOL license_read_platform_challenge_response(rdpLicense* license); static BOOL license_read_platform_challenge_response(rdpLicense* license);
WINPR_ATTR_NODISCARD
static BOOL license_read_client_platform_challenge_response(rdpLicense* license, wStream* s); static BOOL license_read_client_platform_challenge_response(rdpLicense* license, wStream* s);
WINPR_ATTR_NODISCARD
static BOOL license_write_client_platform_challenge_response(rdpLicense* license, wStream* s); static BOOL license_write_client_platform_challenge_response(rdpLicense* license, wStream* s);
WINPR_ATTR_NODISCARD
static BOOL license_write_server_upgrade_license(const rdpLicense* license, wStream* s); static BOOL license_write_server_upgrade_license(const rdpLicense* license, wStream* s);
WINPR_ATTR_NODISCARD
static BOOL license_send_license_info(rdpLicense* license, const LICENSE_BLOB* calBlob, static BOOL license_send_license_info(rdpLicense* license, const LICENSE_BLOB* calBlob,
const BYTE* signature, size_t signature_length); const BYTE* signature, size_t signature_length);
WINPR_ATTR_NODISCARD
static BOOL license_read_license_info(rdpLicense* license, wStream* s); static BOOL license_read_license_info(rdpLicense* license, wStream* s);
WINPR_ATTR_NODISCARD
static state_run_t license_client_recv(rdpLicense* license, wStream* s); static state_run_t license_client_recv(rdpLicense* license, wStream* s);
WINPR_ATTR_NODISCARD
static state_run_t license_server_recv(rdpLicense* license, wStream* s); static state_run_t license_server_recv(rdpLicense* license, wStream* s);
#define PLATFORMID (CLIENT_OS_ID_WINNT_POST_52 | CLIENT_IMAGE_ID_MICROSOFT) #define PLATFORMID (CLIENT_OS_ID_WINNT_POST_52 | CLIENT_IMAGE_ID_MICROSOFT)
@@ -409,6 +475,7 @@ static void license_print_scope_list(wLog* log, const SCOPE_LIST* scopeList)
static const char licenseStore[] = "licenses"; static const char licenseStore[] = "licenses";
WINPR_ATTR_NODISCARD
static BOOL license_ensure_state(rdpLicense* license, LICENSE_STATE state, UINT32 msg) static BOOL license_ensure_state(rdpLicense* license, LICENSE_STATE state, UINT32 msg)
{ {
const LICENSE_STATE cstate = license_get_state(license); const LICENSE_STATE cstate = license_get_state(license);
@@ -441,6 +508,7 @@ state_run_t license_recv(rdpLicense* license, wStream* s)
return license_client_recv(license, s); return license_client_recv(license, s);
} }
WINPR_ATTR_NODISCARD
static BOOL license_check_stream_length(wLog* log, wStream* s, SSIZE_T expect, const char* where) static BOOL license_check_stream_length(wLog* log, wStream* s, SSIZE_T expect, const char* where)
{ {
const size_t remain = Stream_GetRemainingLength(s); const size_t remain = Stream_GetRemainingLength(s);
@@ -461,6 +529,7 @@ static BOOL license_check_stream_length(wLog* log, wStream* s, SSIZE_T expect, c
return TRUE; return TRUE;
} }
WINPR_ATTR_NODISCARD
static BOOL license_check_stream_capacity(wLog* log, wStream* s, size_t expect, const char* where) static BOOL license_check_stream_capacity(wLog* log, wStream* s, size_t expect, const char* where)
{ {
WINPR_ASSERT(where); WINPR_ASSERT(where);
@@ -470,6 +539,7 @@ static BOOL license_check_stream_capacity(wLog* log, wStream* s, size_t expect,
(size_t)__LINE__, where)); (size_t)__LINE__, where));
} }
WINPR_ATTR_NODISCARD
static BOOL computeCalHash(wLog* log, const char* hostname, char* hashStr, size_t len) static BOOL computeCalHash(wLog* log, const char* hostname, char* hashStr, size_t len)
{ {
WINPR_DIGEST_CTX* sha1 = nullptr; WINPR_DIGEST_CTX* sha1 = nullptr;
@@ -502,6 +572,7 @@ out:
return ret; return ret;
} }
WINPR_ATTR_NODISCARD
static BOOL saveCal(wLog* log, const rdpSettings* settings, const BYTE* data, size_t length, static BOOL saveCal(wLog* log, const rdpSettings* settings, const BYTE* data, size_t length,
const char* hostname) const char* hostname)
{ {
@@ -596,6 +667,7 @@ out:
return ret; return ret;
} }
WINPR_ATTR_MALLOC(free, 1)
static BYTE* loadCalFile(wLog* log, const rdpSettings* settings, const char* hostname, static BYTE* loadCalFile(wLog* log, const rdpSettings* settings, const char* hostname,
size_t* dataLen) size_t* dataLen)
{ {
@@ -674,7 +746,7 @@ error_path:
* @param wMsgSize message size * @param wMsgSize message size
* @return if the operation completed successfully * @return if the operation completed successfully
*/ */
WINPR_ATTR_NODISCARD
static BOOL license_read_preamble(wLog* log, wStream* s, BYTE* bMsgType, BYTE* flags, static BOOL license_read_preamble(wLog* log, wStream* s, BYTE* bMsgType, BYTE* flags,
UINT16* wMsgSize) UINT16* wMsgSize)
{ {
@@ -701,7 +773,7 @@ static BOOL license_read_preamble(wLog* log, wStream* s, BYTE* bMsgType, BYTE* f
* @param wMsgSize message size * @param wMsgSize message size
* @return if the operation completed successfully * @return if the operation completed successfully
*/ */
WINPR_ATTR_NODISCARD
static BOOL license_write_preamble(wStream* s, BYTE bMsgType, BYTE flags, UINT16 wMsgSize) static BOOL license_write_preamble(wStream* s, BYTE bMsgType, BYTE flags, UINT16 wMsgSize)
{ {
if (!Stream_EnsureRemainingCapacity(s, 4)) if (!Stream_EnsureRemainingCapacity(s, 4))
@@ -767,7 +839,7 @@ fail:
* @param license license module * @param license license module
* @param s stream * @param s stream
*/ */
WINPR_ATTR_NODISCARD
static BOOL license_send(rdpLicense* license, wStream* s, BYTE type, UINT16 sec_flags) static BOOL license_send(rdpLicense* license, wStream* s, BYTE type, UINT16 sec_flags)
{ {
WINPR_ASSERT(license); WINPR_ASSERT(license);
@@ -825,6 +897,7 @@ BOOL license_write_server_upgrade_license(const rdpLicense* license, wStream* s)
return TRUE; return TRUE;
} }
WINPR_ATTR_NODISCARD
static BOOL license_server_send_new_or_upgrade_license(rdpLicense* license, BOOL upgrade) static BOOL license_server_send_new_or_upgrade_license(rdpLicense* license, BOOL upgrade)
{ {
UINT16 sec_flags = 0; UINT16 sec_flags = 0;
@@ -851,7 +924,7 @@ fail:
* @param s stream * @param s stream
* @return if the operation completed successfully * @return if the operation completed successfully
*/ */
WINPR_ATTR_NODISCARD
static state_run_t license_client_recv_int(rdpLicense* license, wStream* s) static state_run_t license_client_recv_int(rdpLicense* license, wStream* s)
{ {
BYTE flags = 0; BYTE flags = 0;
@@ -1057,7 +1130,7 @@ BOOL license_generate_randoms(rdpLicense* license)
* Generate License Cryptographic Keys. * Generate License Cryptographic Keys.
* @param license license module * @param license license module
*/ */
WINPR_ATTR_NODISCARD
static BOOL license_generate_keys(rdpLicense* license) static BOOL license_generate_keys(rdpLicense* license)
{ {
WINPR_ASSERT(license); WINPR_ASSERT(license);
@@ -1157,6 +1230,7 @@ BOOL license_generate_hwid(rdpLicense* license)
WINPR_MD5_DIGEST_LENGTH); WINPR_MD5_DIGEST_LENGTH);
} }
WINPR_ATTR_NODISCARD
static BOOL license_get_server_rsa_public_key(rdpLicense* license) static BOOL license_get_server_rsa_public_key(rdpLicense* license)
{ {
rdpSettings* settings = nullptr; rdpSettings* settings = nullptr;
@@ -1232,6 +1306,7 @@ BOOL license_encrypt_premaster_secret(rdpLicense* license)
return TRUE; return TRUE;
} }
WINPR_ATTR_NODISCARD
static BOOL license_rc4_with_licenseKey(const rdpLicense* license, const BYTE* input, size_t len, static BOOL license_rc4_with_licenseKey(const rdpLicense* license, const BYTE* input, size_t len,
LICENSE_BLOB* target) LICENSE_BLOB* target)
{ {
@@ -1280,6 +1355,8 @@ error_buffer:
* @param mac the signature buffer (16 bytes) * @param mac the signature buffer (16 bytes)
* @return if the operation completed successfully * @return if the operation completed successfully
*/ */
WINPR_ATTR_NODISCARD
static BOOL license_encrypt_and_MAC(rdpLicense* license, const BYTE* input, size_t len, static BOOL license_encrypt_and_MAC(rdpLicense* license, const BYTE* input, size_t len,
LICENSE_BLOB* target, BYTE* mac, size_t mac_length) LICENSE_BLOB* target, BYTE* mac, size_t mac_length)
{ {
@@ -1300,6 +1377,7 @@ static BOOL license_encrypt_and_MAC(rdpLicense* license, const BYTE* input, size
* *
* @return if the operation completed successfully * @return if the operation completed successfully
*/ */
WINPR_ATTR_NODISCARD
static BOOL license_decrypt_and_check_MAC(rdpLicense* license, const BYTE* input, size_t len, static BOOL license_decrypt_and_check_MAC(rdpLicense* license, const BYTE* input, size_t len,
LICENSE_BLOB* target, const BYTE* packetMac) LICENSE_BLOB* target, const BYTE* packetMac)
{ {
@@ -1394,6 +1472,7 @@ out_fail:
return FALSE; return FALSE;
} }
WINPR_ATTR_NODISCARD
static BOOL license_write_product_info(wLog* log, wStream* s, static BOOL license_write_product_info(wLog* log, wStream* s,
const LICENSE_PRODUCT_INFO* productInfo) const LICENSE_PRODUCT_INFO* productInfo)
{ {
@@ -1565,6 +1644,7 @@ BOOL license_write_binary_blob(wStream* s, const LICENSE_BLOB* blob)
return TRUE; return TRUE;
} }
WINPR_ATTR_NODISCARD
static BOOL license_write_encrypted_premaster_secret_blob(wLog* log, wStream* s, static BOOL license_write_encrypted_premaster_secret_blob(wLog* log, wStream* s,
const LICENSE_BLOB* blob, const LICENSE_BLOB* blob,
UINT32 ModulusLength) UINT32 ModulusLength)
@@ -1592,6 +1672,7 @@ static BOOL license_write_encrypted_premaster_secret_blob(wLog* log, wStream* s,
return TRUE; return TRUE;
} }
WINPR_ATTR_NODISCARD
static BOOL license_read_encrypted_premaster_secret_blob(wLog* log, wStream* s, LICENSE_BLOB* blob, static BOOL license_read_encrypted_premaster_secret_blob(wLog* log, wStream* s, LICENSE_BLOB* blob,
UINT32* ModulusLength) UINT32* ModulusLength)
{ {
@@ -1809,6 +1890,7 @@ error:
return FALSE; return FALSE;
} }
WINPR_ATTR_NODISCARD
static BOOL license_check_preferred_alg(rdpLicense* license, UINT32 PreferredKeyExchangeAlg, static BOOL license_check_preferred_alg(rdpLicense* license, UINT32 PreferredKeyExchangeAlg,
const char* where) const char* where)
{ {
@@ -1975,6 +2057,7 @@ BOOL license_write_license_request_packet(const rdpLicense* license, wStream* s)
return TRUE; return TRUE;
} }
WINPR_ATTR_NODISCARD
static BOOL license_send_license_request_packet(rdpLicense* license) static BOOL license_send_license_request_packet(rdpLicense* license)
{ {
UINT16 sec_flags = 0; UINT16 sec_flags = 0;
@@ -2104,6 +2187,7 @@ fail:
return FALSE; return FALSE;
} }
WINPR_ATTR_NODISCARD
static BOOL license_read_encrypted_blob(const rdpLicense* license, wStream* s, LICENSE_BLOB* target) static BOOL license_read_encrypted_blob(const rdpLicense* license, wStream* s, LICENSE_BLOB* target)
{ {
UINT16 wBlobType = 0; UINT16 wBlobType = 0;
@@ -2900,6 +2984,7 @@ BOOL license_server_send_request(rdpLicense* license)
return license_set_state(license, LICENSE_STATE_REQUEST); return license_set_state(license, LICENSE_STATE_REQUEST);
} }
WINPR_ATTR_NODISCARD
static BOOL license_set_string(wLog* log, const char* what, const char* value, BYTE** bdst, static BOOL license_set_string(wLog* log, const char* what, const char* value, BYTE** bdst,
UINT32* dstLen) UINT32* dstLen)
{ {

View File

@@ -254,6 +254,7 @@ static void scard_handle_free(void* handle)
free(hdl); free(hdl);
} }
WINPR_ATTR_MALLOC(scard_handle_free, 1)
static SCardHandle* scard_handle_new(SmartcardEmulationContext* smartcard, SCARDCONTEXT context, static SCardHandle* scard_handle_new(SmartcardEmulationContext* smartcard, SCARDCONTEXT context,
const void* name, BOOL unicode) const void* name, BOOL unicode)
{ {
@@ -1589,6 +1590,7 @@ SCardHandle* find_reader(SmartcardEmulationContext* smartcard, const void* szRea
return hdl; return hdl;
} }
WINPR_ATTR_MALLOC(scard_handle_free, 1)
static SCardHandle* reader2handle(SmartcardEmulationContext* smartcard, SCARDCONTEXT hContext, static SCardHandle* reader2handle(SmartcardEmulationContext* smartcard, SCARDCONTEXT hContext,
const void* szReader, BOOL unicode, DWORD dwShareMode, const void* szReader, BOOL unicode, DWORD dwShareMode,
SCARDHANDLE* phCard, DWORD dwPreferredProtocols, SCARDHANDLE* phCard, DWORD dwPreferredProtocols,

View File

@@ -22,6 +22,7 @@
/* YUV to RGB conversion is lossy, so consider every value only /* YUV to RGB conversion is lossy, so consider every value only
* differing by less than 2 abs equal. */ * differing by less than 2 abs equal. */
WINPR_ATTR_NODISCARD
static BOOL similar(const BYTE* src, const BYTE* dst, size_t size) static BOOL similar(const BYTE* src, const BYTE* dst, size_t size)
{ {
for (size_t x = 0; x < size; x++) for (size_t x = 0; x < size; x++)
@@ -39,6 +40,7 @@ static BOOL similar(const BYTE* src, const BYTE* dst, size_t size)
return TRUE; return TRUE;
} }
WINPR_ATTR_NODISCARD
static BOOL similarRGB(size_t y, const BYTE* src, const BYTE* dst, size_t size, UINT32 format, static BOOL similarRGB(size_t y, const BYTE* src, const BYTE* dst, size_t size, UINT32 format,
BOOL use444) BOOL use444)
{ {
@@ -121,6 +123,7 @@ static BOOL similarRGB(size_t y, const BYTE* src, const BYTE* dst, size_t size,
return rc; return rc;
} }
WINPR_ATTR_NODISCARD
static BOOL get_size(BOOL large, UINT32* width, UINT32* height) static BOOL get_size(BOOL large, UINT32* width, UINT32* height)
{ {
UINT32 shift = large ? 8 : 1; UINT32 shift = large ? 8 : 1;
@@ -133,6 +136,7 @@ static BOOL get_size(BOOL large, UINT32* width, UINT32* height)
return TRUE; return TRUE;
} }
WINPR_ATTR_NODISCARD
static BOOL check_padding(const BYTE* psrc, size_t size, size_t padding, const char* buffer) static BOOL check_padding(const BYTE* psrc, size_t size, size_t padding, const char* buffer)
{ {
BOOL rc = TRUE; BOOL rc = TRUE;