[nodiscard] Fix all winpr_RAND usages

* Check return value and act on it.
* Initialize arrays that were missed before.
This commit is contained in:
Armin Novak
2026-02-27 07:33:51 +01:00
parent 56d4139e6d
commit 89ab3c6c1b
50 changed files with 378 additions and 190 deletions

View File

@@ -842,7 +842,12 @@ char* freerdp_assistance_generate_pass_stub(WINPR_ATTR_UNUSED DWORD flags)
*
* Example: WB^6HsrIaFmEpi
*/
winpr_RAND(nums, sizeof(nums));
if (winpr_RAND(nums, sizeof(nums)) < 0)
{
free(passStub);
return nullptr;
}
passStub[0] = set1[nums[0] % sizeof(set1)]; /* character 0 */
passStub[1] = set2[nums[1] % sizeof(set2)]; /* character 1 */
passStub[2] = set3[nums[2] % sizeof(set3)]; /* character 2 */

View File

@@ -19,7 +19,8 @@ static BOOL test_alloc(void)
goto fail;
/* Test allocation without initializing arguments of random size > 0 */
winpr_RAND(&rng, sizeof(rng));
if (winpr_RAND(&rng, sizeof(rng)) < 0)
goto fail;
rng = abs(rng % 8192) + 1;
arg2 = freerdp_addin_argv_new(rng, nullptr);