Coverage Report

Created: 2026-09-14 06:32

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/FreeRDP/client/common/test/TestFuzzClientRdpFile.c
Line
Count
Source
1
/**
2
 * FreeRDP: A Remote Desktop Protocol Implementation
3
 * libFuzzer harness for .rdp connection file parsing
4
 *
5
 * A .rdp file is untrusted input: they are mailed around, published for
6
 * download and shared between users, and opening one is the ordinary way a
7
 * client gets configured. client/common/file.c parses that key/value format,
8
 * and freerdp_client_populate_settings_from_rdp_file() then converts and range
9
 * checks every option on its way into the settings store.
10
 *
11
 * Neither is otherwise fuzzed. The existing assistance harness covers the
12
 * unrelated Remote Assistance (.msrcIncident) file format.
13
 *
14
 * Both the checked and the unchecked populate path run on every input, so a
15
 * mutation always means a different file rather than a different code path.
16
 */
17
18
#include <stddef.h>
19
#include <stdint.h>
20
21
#include <freerdp/client/file.h>
22
#include <freerdp/settings.h>
23
24
static void populate_settings(const rdpFile* file, BOOL unchecked)
25
0
{
26
0
  rdpSettings* settings = freerdp_settings_new(0);
27
0
  if (!settings)
28
0
    return;
29
30
0
  if (unchecked)
31
0
    (void)freerdp_client_populate_settings_from_rdp_file_unchecked(file, settings);
32
0
  else
33
0
    (void)freerdp_client_populate_settings_from_rdp_file(file, settings);
34
35
0
  freerdp_settings_free(settings);
36
0
}
37
38
int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size)
39
{
40
  rdpFile* file = freerdp_client_rdp_file_new();
41
  if (!file)
42
    return 0;
43
44
  char* buf = calloc(Size + 1, sizeof(char));
45
  if (buf == nullptr)
46
    goto err;
47
  memcpy(buf, Data, Size);
48
  buf[Size] = '\0';
49
50
  if (freerdp_client_parse_rdp_file_buffer(file, (const BYTE*)buf, Size + 1))
51
  {
52
    populate_settings(file, FALSE);
53
    populate_settings(file, TRUE);
54
  }
55
56
err:
57
  freerdp_client_rdp_file_free(file);
58
  free(buf);
59
60
  return 0;
61
}