idx int64 | func_before string | Vulnerability Classification string | vul int64 | func_after string | patch string | CWE ID string | lines_before string | lines_after string |
|---|---|---|---|---|---|---|---|---|
13,900 | init_seconds_var ()
{
SHELL_VAR *v;
v = find_variable ("SECONDS");
if (v)
{
if (legal_number (value_cell(v), &seconds_value_assigned) == 0)
seconds_value_assigned = 0;
}
INIT_DYNAMIC_VAR ("SECONDS", (v ? value_cell (v) : (char *)NULL), get_seconds, assign_seconds);
return v;
}
| Exec Code Overflow | 0 | init_seconds_var ()
{
SHELL_VAR *v;
v = find_variable ("SECONDS");
if (v)
{
if (legal_number (value_cell(v), &seconds_value_assigned) == 0)
seconds_value_assigned = 0;
}
INIT_DYNAMIC_VAR ("SECONDS", (v ? value_cell (v) : (char *)NULL), get_seconds, assign_seconds);
return v;
}
| @@ -4666,12 +4666,18 @@ sv_locale (name)
char *name;
{
char *v;
+ int r;
v = get_string_value (name);
if (name[0] == 'L' && name[1] == 'A') /* LANG */
- set_lang (name, v);
+ r = set_lang (name, v);
else
- set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */
+ r = set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */
+
+#if 1
+ if (r == 0 && posixly_correct)
+ last_command_exit_value = 1;
+#endif
}
#if defined (ARRAY_VARS) | CWE-119 | null | null |
13,901 | initialize_dynamic_variables ()
{
SHELL_VAR *v;
v = init_seconds_var ();
INIT_DYNAMIC_VAR ("BASH_COMMAND", (char *)NULL, get_bash_command, (sh_var_assign_func_t *)NULL);
INIT_DYNAMIC_VAR ("BASH_SUBSHELL", (char *)NULL, get_subshell, assign_subshell);
INIT_DYNAMIC_VAR ("RANDOM", (char *)NULL, get_random, assign_random);
VSETATTR (v, att_integer);
INIT_DYNAMIC_VAR ("LINENO", (char *)NULL, get_lineno, assign_lineno);
VSETATTR (v, att_integer);
INIT_DYNAMIC_VAR ("BASHPID", (char *)NULL, get_bashpid, null_assign);
VSETATTR (v, att_integer|att_readonly);
#if defined (HISTORY)
INIT_DYNAMIC_VAR ("HISTCMD", (char *)NULL, get_histcmd, (sh_var_assign_func_t *)NULL);
VSETATTR (v, att_integer);
#endif
#if defined (READLINE)
INIT_DYNAMIC_VAR ("COMP_WORDBREAKS", (char *)NULL, get_comp_wordbreaks, assign_comp_wordbreaks);
#endif
#if defined (PUSHD_AND_POPD) && defined (ARRAY_VARS)
v = init_dynamic_array_var ("DIRSTACK", get_dirstack, assign_dirstack, 0);
#endif /* PUSHD_AND_POPD && ARRAY_VARS */
#if defined (ARRAY_VARS)
v = init_dynamic_array_var ("GROUPS", get_groupset, null_array_assign, att_noassign);
# if defined (DEBUGGER)
v = init_dynamic_array_var ("BASH_ARGC", get_self, null_array_assign, att_noassign|att_nounset);
v = init_dynamic_array_var ("BASH_ARGV", get_self, null_array_assign, att_noassign|att_nounset);
# endif /* DEBUGGER */
v = init_dynamic_array_var ("BASH_SOURCE", get_self, null_array_assign, att_noassign|att_nounset);
v = init_dynamic_array_var ("BASH_LINENO", get_self, null_array_assign, att_noassign|att_nounset);
v = init_dynamic_assoc_var ("BASH_CMDS", get_hashcmd, assign_hashcmd, att_nofree);
# if defined (ALIAS)
v = init_dynamic_assoc_var ("BASH_ALIASES", get_aliasvar, assign_aliasvar, att_nofree);
# endif
#endif
v = init_funcname_var ();
}
| Exec Code Overflow | 0 | initialize_dynamic_variables ()
{
SHELL_VAR *v;
v = init_seconds_var ();
INIT_DYNAMIC_VAR ("BASH_COMMAND", (char *)NULL, get_bash_command, (sh_var_assign_func_t *)NULL);
INIT_DYNAMIC_VAR ("BASH_SUBSHELL", (char *)NULL, get_subshell, assign_subshell);
INIT_DYNAMIC_VAR ("RANDOM", (char *)NULL, get_random, assign_random);
VSETATTR (v, att_integer);
INIT_DYNAMIC_VAR ("LINENO", (char *)NULL, get_lineno, assign_lineno);
VSETATTR (v, att_integer);
INIT_DYNAMIC_VAR ("BASHPID", (char *)NULL, get_bashpid, null_assign);
VSETATTR (v, att_integer|att_readonly);
#if defined (HISTORY)
INIT_DYNAMIC_VAR ("HISTCMD", (char *)NULL, get_histcmd, (sh_var_assign_func_t *)NULL);
VSETATTR (v, att_integer);
#endif
#if defined (READLINE)
INIT_DYNAMIC_VAR ("COMP_WORDBREAKS", (char *)NULL, get_comp_wordbreaks, assign_comp_wordbreaks);
#endif
#if defined (PUSHD_AND_POPD) && defined (ARRAY_VARS)
v = init_dynamic_array_var ("DIRSTACK", get_dirstack, assign_dirstack, 0);
#endif /* PUSHD_AND_POPD && ARRAY_VARS */
#if defined (ARRAY_VARS)
v = init_dynamic_array_var ("GROUPS", get_groupset, null_array_assign, att_noassign);
# if defined (DEBUGGER)
v = init_dynamic_array_var ("BASH_ARGC", get_self, null_array_assign, att_noassign|att_nounset);
v = init_dynamic_array_var ("BASH_ARGV", get_self, null_array_assign, att_noassign|att_nounset);
# endif /* DEBUGGER */
v = init_dynamic_array_var ("BASH_SOURCE", get_self, null_array_assign, att_noassign|att_nounset);
v = init_dynamic_array_var ("BASH_LINENO", get_self, null_array_assign, att_noassign|att_nounset);
v = init_dynamic_assoc_var ("BASH_CMDS", get_hashcmd, assign_hashcmd, att_nofree);
# if defined (ALIAS)
v = init_dynamic_assoc_var ("BASH_ALIASES", get_aliasvar, assign_aliasvar, att_nofree);
# endif
#endif
v = init_funcname_var ();
}
| @@ -4666,12 +4666,18 @@ sv_locale (name)
char *name;
{
char *v;
+ int r;
v = get_string_value (name);
if (name[0] == 'L' && name[1] == 'A') /* LANG */
- set_lang (name, v);
+ r = set_lang (name, v);
else
- set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */
+ r = set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */
+
+#if 1
+ if (r == 0 && posixly_correct)
+ last_command_exit_value = 1;
+#endif
}
#if defined (ARRAY_VARS) | CWE-119 | null | null |
13,902 | initialize_shell_level ()
{
adjust_shell_level (1);
}
| Exec Code Overflow | 0 | initialize_shell_level ()
{
adjust_shell_level (1);
}
| @@ -4666,12 +4666,18 @@ sv_locale (name)
char *name;
{
char *v;
+ int r;
v = get_string_value (name);
if (name[0] == 'L' && name[1] == 'A') /* LANG */
- set_lang (name, v);
+ r = set_lang (name, v);
else
- set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */
+ r = set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */
+
+#if 1
+ if (r == 0 && posixly_correct)
+ last_command_exit_value = 1;
+#endif
}
#if defined (ARRAY_VARS) | CWE-119 | null | null |
13,903 | local_exported_variables ()
{
return (vapply (local_and_exported));
}
| Exec Code Overflow | 0 | local_exported_variables ()
{
return (vapply (local_and_exported));
}
| @@ -4666,12 +4666,18 @@ sv_locale (name)
char *name;
{
char *v;
+ int r;
v = get_string_value (name);
if (name[0] == 'L' && name[1] == 'A') /* LANG */
- set_lang (name, v);
+ r = set_lang (name, v);
else
- set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */
+ r = set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */
+
+#if 1
+ if (r == 0 && posixly_correct)
+ last_command_exit_value = 1;
+#endif
}
#if defined (ARRAY_VARS) | CWE-119 | null | null |
13,904 | make_vers_array ()
{
SHELL_VAR *vv;
ARRAY *av;
char *s, d[32], b[INT_STRLEN_BOUND(int) + 1];
unbind_variable ("BASH_VERSINFO");
vv = make_new_array_variable ("BASH_VERSINFO");
av = array_cell (vv);
strcpy (d, dist_version);
s = strchr (d, '.');
if (s)
*s++ = '\0';
array_insert (av, 0, d);
array_insert (av, 1, s);
s = inttostr (patch_level, b, sizeof (b));
array_insert (av, 2, s);
s = inttostr (build_version, b, sizeof (b));
array_insert (av, 3, s);
array_insert (av, 4, release_status);
array_insert (av, 5, MACHTYPE);
VSETATTR (vv, att_readonly);
}
| Exec Code Overflow | 0 | make_vers_array ()
{
SHELL_VAR *vv;
ARRAY *av;
char *s, d[32], b[INT_STRLEN_BOUND(int) + 1];
unbind_variable ("BASH_VERSINFO");
vv = make_new_array_variable ("BASH_VERSINFO");
av = array_cell (vv);
strcpy (d, dist_version);
s = strchr (d, '.');
if (s)
*s++ = '\0';
array_insert (av, 0, d);
array_insert (av, 1, s);
s = inttostr (patch_level, b, sizeof (b));
array_insert (av, 2, s);
s = inttostr (build_version, b, sizeof (b));
array_insert (av, 3, s);
array_insert (av, 4, release_status);
array_insert (av, 5, MACHTYPE);
VSETATTR (vv, att_readonly);
}
| @@ -4666,12 +4666,18 @@ sv_locale (name)
char *name;
{
char *v;
+ int r;
v = get_string_value (name);
if (name[0] == 'L' && name[1] == 'A') /* LANG */
- set_lang (name, v);
+ r = set_lang (name, v);
else
- set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */
+ r = set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */
+
+#if 1
+ if (r == 0 && posixly_correct)
+ last_command_exit_value = 1;
+#endif
}
#if defined (ARRAY_VARS) | CWE-119 | null | null |
13,905 | maybe_make_export_env ()
{
register char **temp_array;
int new_size;
VAR_CONTEXT *tcxt;
if (array_needs_making)
{
if (export_env)
strvec_flush (export_env);
/* Make a guess based on how many shell variables and functions we
have. Since there will always be array variables, and array
variables are not (yet) exported, this will always be big enough
for the exported variables and functions. */
new_size = n_shell_variables () + HASH_ENTRIES (shell_functions) + 1 +
HASH_ENTRIES (temporary_env);
if (new_size > export_env_size)
{
export_env_size = new_size;
export_env = strvec_resize (export_env, export_env_size);
environ = export_env;
}
export_env[export_env_index = 0] = (char *)NULL;
/* Make a dummy variable context from the temporary_env, stick it on
the front of shell_variables, call make_var_export_array on the
whole thing to flatten it, and convert the list of SHELL_VAR *s
to the form needed by the environment. */
if (temporary_env)
{
tcxt = new_var_context ((char *)NULL, 0);
tcxt->table = temporary_env;
tcxt->down = shell_variables;
}
else
tcxt = shell_variables;
temp_array = make_var_export_array (tcxt);
if (temp_array)
add_temp_array_to_env (temp_array, 0, 0);
if (tcxt != shell_variables)
free (tcxt);
#if defined (RESTRICTED_SHELL)
/* Restricted shells may not export shell functions. */
temp_array = restricted ? (char **)0 : make_func_export_array ();
#else
temp_array = make_func_export_array ();
#endif
if (temp_array)
add_temp_array_to_env (temp_array, 0, 0);
array_needs_making = 0;
}
}
| Exec Code Overflow | 0 | maybe_make_export_env ()
{
register char **temp_array;
int new_size;
VAR_CONTEXT *tcxt;
if (array_needs_making)
{
if (export_env)
strvec_flush (export_env);
/* Make a guess based on how many shell variables and functions we
have. Since there will always be array variables, and array
variables are not (yet) exported, this will always be big enough
for the exported variables and functions. */
new_size = n_shell_variables () + HASH_ENTRIES (shell_functions) + 1 +
HASH_ENTRIES (temporary_env);
if (new_size > export_env_size)
{
export_env_size = new_size;
export_env = strvec_resize (export_env, export_env_size);
environ = export_env;
}
export_env[export_env_index = 0] = (char *)NULL;
/* Make a dummy variable context from the temporary_env, stick it on
the front of shell_variables, call make_var_export_array on the
whole thing to flatten it, and convert the list of SHELL_VAR *s
to the form needed by the environment. */
if (temporary_env)
{
tcxt = new_var_context ((char *)NULL, 0);
tcxt->table = temporary_env;
tcxt->down = shell_variables;
}
else
tcxt = shell_variables;
temp_array = make_var_export_array (tcxt);
if (temp_array)
add_temp_array_to_env (temp_array, 0, 0);
if (tcxt != shell_variables)
free (tcxt);
#if defined (RESTRICTED_SHELL)
/* Restricted shells may not export shell functions. */
temp_array = restricted ? (char **)0 : make_func_export_array ();
#else
temp_array = make_func_export_array ();
#endif
if (temp_array)
add_temp_array_to_env (temp_array, 0, 0);
array_needs_making = 0;
}
}
| @@ -4666,12 +4666,18 @@ sv_locale (name)
char *name;
{
char *v;
+ int r;
v = get_string_value (name);
if (name[0] == 'L' && name[1] == 'A') /* LANG */
- set_lang (name, v);
+ r = set_lang (name, v);
else
- set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */
+ r = set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */
+
+#if 1
+ if (r == 0 && posixly_correct)
+ last_command_exit_value = 1;
+#endif
}
#if defined (ARRAY_VARS) | CWE-119 | null | null |
13,906 | merge_temporary_env ()
{
if (temporary_env)
dispose_temporary_env (push_temp_var);
}
| Exec Code Overflow | 0 | merge_temporary_env ()
{
if (temporary_env)
dispose_temporary_env (push_temp_var);
}
| @@ -4666,12 +4666,18 @@ sv_locale (name)
char *name;
{
char *v;
+ int r;
v = get_string_value (name);
if (name[0] == 'L' && name[1] == 'A') /* LANG */
- set_lang (name, v);
+ r = set_lang (name, v);
else
- set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */
+ r = set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */
+
+#if 1
+ if (r == 0 && posixly_correct)
+ last_command_exit_value = 1;
+#endif
}
#if defined (ARRAY_VARS) | CWE-119 | null | null |
13,907 | n_shell_variables ()
{
VAR_CONTEXT *vc;
int n;
for (n = 0, vc = shell_variables; vc; vc = vc->down)
n += HASH_ENTRIES (vc->table);
return n;
}
| Exec Code Overflow | 0 | n_shell_variables ()
{
VAR_CONTEXT *vc;
int n;
for (n = 0, vc = shell_variables; vc; vc = vc->down)
n += HASH_ENTRIES (vc->table);
return n;
}
| @@ -4666,12 +4666,18 @@ sv_locale (name)
char *name;
{
char *v;
+ int r;
v = get_string_value (name);
if (name[0] == 'L' && name[1] == 'A') /* LANG */
- set_lang (name, v);
+ r = set_lang (name, v);
else
- set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */
+ r = set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */
+
+#if 1
+ if (r == 0 && posixly_correct)
+ last_command_exit_value = 1;
+#endif
}
#if defined (ARRAY_VARS) | CWE-119 | null | null |
13,908 | pop_context ()
{
pop_dollar_vars ();
variable_context--;
pop_var_context ();
sv_ifs ("IFS"); /* XXX here for now */
}
| Exec Code Overflow | 0 | pop_context ()
{
pop_dollar_vars ();
variable_context--;
pop_var_context ();
sv_ifs ("IFS"); /* XXX here for now */
}
| @@ -4666,12 +4666,18 @@ sv_locale (name)
char *name;
{
char *v;
+ int r;
v = get_string_value (name);
if (name[0] == 'L' && name[1] == 'A') /* LANG */
- set_lang (name, v);
+ r = set_lang (name, v);
else
- set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */
+ r = set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */
+
+#if 1
+ if (r == 0 && posixly_correct)
+ last_command_exit_value = 1;
+#endif
}
#if defined (ARRAY_VARS) | CWE-119 | null | null |
13,909 | pop_var_context ()
{
VAR_CONTEXT *ret, *vcxt;
vcxt = shell_variables;
if (vc_isfuncenv (vcxt) == 0)
{
internal_error (_("pop_var_context: head of shell_variables not a function context"));
return;
}
if (ret = vcxt->down)
{
ret->up = (VAR_CONTEXT *)NULL;
shell_variables = ret;
if (vcxt->table)
hash_flush (vcxt->table, push_func_var);
dispose_var_context (vcxt);
}
else
internal_error (_("pop_var_context: no global_variables context"));
}
| Exec Code Overflow | 0 | pop_var_context ()
{
VAR_CONTEXT *ret, *vcxt;
vcxt = shell_variables;
if (vc_isfuncenv (vcxt) == 0)
{
internal_error (_("pop_var_context: head of shell_variables not a function context"));
return;
}
if (ret = vcxt->down)
{
ret->up = (VAR_CONTEXT *)NULL;
shell_variables = ret;
if (vcxt->table)
hash_flush (vcxt->table, push_func_var);
dispose_var_context (vcxt);
}
else
internal_error (_("pop_var_context: no global_variables context"));
}
| @@ -4666,12 +4666,18 @@ sv_locale (name)
char *name;
{
char *v;
+ int r;
v = get_string_value (name);
if (name[0] == 'L' && name[1] == 'A') /* LANG */
- set_lang (name, v);
+ r = set_lang (name, v);
else
- set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */
+ r = set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */
+
+#if 1
+ if (r == 0 && posixly_correct)
+ last_command_exit_value = 1;
+#endif
}
#if defined (ARRAY_VARS) | CWE-119 | null | null |
13,910 | push_dollar_vars ()
{
if (dollar_arg_stack_index + 2 > dollar_arg_stack_slots)
{
dollar_arg_stack = (WORD_LIST **)
xrealloc (dollar_arg_stack, (dollar_arg_stack_slots += 10)
* sizeof (WORD_LIST *));
}
dollar_arg_stack[dollar_arg_stack_index++] = list_rest_of_args ();
dollar_arg_stack[dollar_arg_stack_index] = (WORD_LIST *)NULL;
}
| Exec Code Overflow | 0 | push_dollar_vars ()
{
if (dollar_arg_stack_index + 2 > dollar_arg_stack_slots)
{
dollar_arg_stack = (WORD_LIST **)
xrealloc (dollar_arg_stack, (dollar_arg_stack_slots += 10)
* sizeof (WORD_LIST *));
}
dollar_arg_stack[dollar_arg_stack_index++] = list_rest_of_args ();
dollar_arg_stack[dollar_arg_stack_index] = (WORD_LIST *)NULL;
}
| @@ -4666,12 +4666,18 @@ sv_locale (name)
char *name;
{
char *v;
+ int r;
v = get_string_value (name);
if (name[0] == 'L' && name[1] == 'A') /* LANG */
- set_lang (name, v);
+ r = set_lang (name, v);
else
- set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */
+ r = set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */
+
+#if 1
+ if (r == 0 && posixly_correct)
+ last_command_exit_value = 1;
+#endif
}
#if defined (ARRAY_VARS) | CWE-119 | null | null |
13,911 | seedrand ()
{
struct timeval tv;
gettimeofday (&tv, NULL);
sbrand (tv.tv_sec ^ tv.tv_usec ^ getpid ());
}
| Exec Code Overflow | 0 | seedrand ()
{
struct timeval tv;
gettimeofday (&tv, NULL);
sbrand (tv.tv_sec ^ tv.tv_usec ^ getpid ());
}
| @@ -4666,12 +4666,18 @@ sv_locale (name)
char *name;
{
char *v;
+ int r;
v = get_string_value (name);
if (name[0] == 'L' && name[1] == 'A') /* LANG */
- set_lang (name, v);
+ r = set_lang (name, v);
else
- set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */
+ r = set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */
+
+#if 1
+ if (r == 0 && posixly_correct)
+ last_command_exit_value = 1;
+#endif
}
#if defined (ARRAY_VARS) | CWE-119 | null | null |
13,912 | set_home_var ()
{
SHELL_VAR *temp_var;
temp_var = find_variable ("HOME");
if (temp_var == 0)
temp_var = bind_variable ("HOME", sh_get_home_dir (), 0);
#if 0
VSETATTR (temp_var, att_exported);
#endif
}
| Exec Code Overflow | 0 | set_home_var ()
{
SHELL_VAR *temp_var;
temp_var = find_variable ("HOME");
if (temp_var == 0)
temp_var = bind_variable ("HOME", sh_get_home_dir (), 0);
#if 0
VSETATTR (temp_var, att_exported);
#endif
}
| @@ -4666,12 +4666,18 @@ sv_locale (name)
char *name;
{
char *v;
+ int r;
v = get_string_value (name);
if (name[0] == 'L' && name[1] == 'A') /* LANG */
- set_lang (name, v);
+ r = set_lang (name, v);
else
- set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */
+ r = set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */
+
+#if 1
+ if (r == 0 && posixly_correct)
+ last_command_exit_value = 1;
+#endif
}
#if defined (ARRAY_VARS) | CWE-119 | null | null |
13,913 | set_ppid ()
{
char namebuf[INT_STRLEN_BOUND(pid_t) + 1], *name;
SHELL_VAR *temp_var;
name = inttostr (getppid (), namebuf, sizeof(namebuf));
temp_var = find_variable ("PPID");
if (temp_var)
VUNSETATTR (temp_var, (att_readonly | att_exported));
temp_var = bind_variable ("PPID", name, 0);
VSETATTR (temp_var, (att_readonly | att_integer));
}
| Exec Code Overflow | 0 | set_ppid ()
{
char namebuf[INT_STRLEN_BOUND(pid_t) + 1], *name;
SHELL_VAR *temp_var;
name = inttostr (getppid (), namebuf, sizeof(namebuf));
temp_var = find_variable ("PPID");
if (temp_var)
VUNSETATTR (temp_var, (att_readonly | att_exported));
temp_var = bind_variable ("PPID", name, 0);
VSETATTR (temp_var, (att_readonly | att_integer));
}
| @@ -4666,12 +4666,18 @@ sv_locale (name)
char *name;
{
char *v;
+ int r;
v = get_string_value (name);
if (name[0] == 'L' && name[1] == 'A') /* LANG */
- set_lang (name, v);
+ r = set_lang (name, v);
else
- set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */
+ r = set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */
+
+#if 1
+ if (r == 0 && posixly_correct)
+ last_command_exit_value = 1;
+#endif
}
#if defined (ARRAY_VARS) | CWE-119 | null | null |
13,914 | set_pwd ()
{
SHELL_VAR *temp_var, *home_var;
char *temp_string, *home_string;
home_var = find_variable ("HOME");
home_string = home_var ? value_cell (home_var) : (char *)NULL;
temp_var = find_variable ("PWD");
if (temp_var && imported_p (temp_var) &&
(temp_string = value_cell (temp_var)) &&
same_file (temp_string, ".", (struct stat *)NULL, (struct stat *)NULL))
set_working_directory (temp_string);
else if (home_string && interactive_shell && login_shell &&
same_file (home_string, ".", (struct stat *)NULL, (struct stat *)NULL))
{
set_working_directory (home_string);
temp_var = bind_variable ("PWD", home_string, 0);
set_auto_export (temp_var);
}
else
{
temp_string = get_working_directory ("shell-init");
if (temp_string)
{
temp_var = bind_variable ("PWD", temp_string, 0);
set_auto_export (temp_var);
free (temp_string);
}
}
/* According to the Single Unix Specification, v2, $OLDPWD is an
`environment variable' and therefore should be auto-exported.
Make a dummy invisible variable for OLDPWD, and mark it as exported. */
temp_var = bind_variable ("OLDPWD", (char *)NULL, 0);
VSETATTR (temp_var, (att_exported | att_invisible));
}
| Exec Code Overflow | 0 | set_pwd ()
{
SHELL_VAR *temp_var, *home_var;
char *temp_string, *home_string;
home_var = find_variable ("HOME");
home_string = home_var ? value_cell (home_var) : (char *)NULL;
temp_var = find_variable ("PWD");
if (temp_var && imported_p (temp_var) &&
(temp_string = value_cell (temp_var)) &&
same_file (temp_string, ".", (struct stat *)NULL, (struct stat *)NULL))
set_working_directory (temp_string);
else if (home_string && interactive_shell && login_shell &&
same_file (home_string, ".", (struct stat *)NULL, (struct stat *)NULL))
{
set_working_directory (home_string);
temp_var = bind_variable ("PWD", home_string, 0);
set_auto_export (temp_var);
}
else
{
temp_string = get_working_directory ("shell-init");
if (temp_string)
{
temp_var = bind_variable ("PWD", temp_string, 0);
set_auto_export (temp_var);
free (temp_string);
}
}
/* According to the Single Unix Specification, v2, $OLDPWD is an
`environment variable' and therefore should be auto-exported.
Make a dummy invisible variable for OLDPWD, and mark it as exported. */
temp_var = bind_variable ("OLDPWD", (char *)NULL, 0);
VSETATTR (temp_var, (att_exported | att_invisible));
}
| @@ -4666,12 +4666,18 @@ sv_locale (name)
char *name;
{
char *v;
+ int r;
v = get_string_value (name);
if (name[0] == 'L' && name[1] == 'A') /* LANG */
- set_lang (name, v);
+ r = set_lang (name, v);
else
- set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */
+ r = set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */
+
+#if 1
+ if (r == 0 && posixly_correct)
+ last_command_exit_value = 1;
+#endif
}
#if defined (ARRAY_VARS) | CWE-119 | null | null |
13,915 | set_shell_var ()
{
SHELL_VAR *temp_var;
temp_var = find_variable ("SHELL");
if (temp_var == 0)
{
if (current_user.shell == 0)
get_current_user_info ();
temp_var = bind_variable ("SHELL", current_user.shell, 0);
}
#if 0
VSETATTR (temp_var, att_exported);
#endif
}
| Exec Code Overflow | 0 | set_shell_var ()
{
SHELL_VAR *temp_var;
temp_var = find_variable ("SHELL");
if (temp_var == 0)
{
if (current_user.shell == 0)
get_current_user_info ();
temp_var = bind_variable ("SHELL", current_user.shell, 0);
}
#if 0
VSETATTR (temp_var, att_exported);
#endif
}
| @@ -4666,12 +4666,18 @@ sv_locale (name)
char *name;
{
char *v;
+ int r;
v = get_string_value (name);
if (name[0] == 'L' && name[1] == 'A') /* LANG */
- set_lang (name, v);
+ r = set_lang (name, v);
else
- set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */
+ r = set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */
+
+#if 1
+ if (r == 0 && posixly_correct)
+ last_command_exit_value = 1;
+#endif
}
#if defined (ARRAY_VARS) | CWE-119 | null | null |
13,916 | sh_get_home_dir ()
{
if (current_user.home_dir == 0)
get_current_user_info ();
return current_user.home_dir;
}
| Exec Code Overflow | 0 | sh_get_home_dir ()
{
if (current_user.home_dir == 0)
get_current_user_info ();
return current_user.home_dir;
}
| @@ -4666,12 +4666,18 @@ sv_locale (name)
char *name;
{
char *v;
+ int r;
v = get_string_value (name);
if (name[0] == 'L' && name[1] == 'A') /* LANG */
- set_lang (name, v);
+ r = set_lang (name, v);
else
- set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */
+ r = set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */
+
+#if 1
+ if (r == 0 && posixly_correct)
+ last_command_exit_value = 1;
+#endif
}
#if defined (ARRAY_VARS) | CWE-119 | null | null |
13,917 | uidset ()
{
char buff[INT_STRLEN_BOUND(uid_t) + 1], *b;
register SHELL_VAR *v;
b = inttostr (current_user.uid, buff, sizeof (buff));
v = find_variable ("UID");
if (v == 0)
{
v = bind_variable ("UID", b, 0);
VSETATTR (v, (att_readonly | att_integer));
}
if (current_user.euid != current_user.uid)
b = inttostr (current_user.euid, buff, sizeof (buff));
v = find_variable ("EUID");
if (v == 0)
{
v = bind_variable ("EUID", b, 0);
VSETATTR (v, (att_readonly | att_integer));
}
}
| Exec Code Overflow | 0 | uidset ()
{
char buff[INT_STRLEN_BOUND(uid_t) + 1], *b;
register SHELL_VAR *v;
b = inttostr (current_user.uid, buff, sizeof (buff));
v = find_variable ("UID");
if (v == 0)
{
v = bind_variable ("UID", b, 0);
VSETATTR (v, (att_readonly | att_integer));
}
if (current_user.euid != current_user.uid)
b = inttostr (current_user.euid, buff, sizeof (buff));
v = find_variable ("EUID");
if (v == 0)
{
v = bind_variable ("EUID", b, 0);
VSETATTR (v, (att_readonly | att_integer));
}
}
| @@ -4666,12 +4666,18 @@ sv_locale (name)
char *name;
{
char *v;
+ int r;
v = get_string_value (name);
if (name[0] == 'L' && name[1] == 'A') /* LANG */
- set_lang (name, v);
+ r = set_lang (name, v);
else
- set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */
+ r = set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */
+
+#if 1
+ if (r == 0 && posixly_correct)
+ last_command_exit_value = 1;
+#endif
}
#if defined (ARRAY_VARS) | CWE-119 | null | null |
13,918 | PanoramiXExtensionInit(void)
{
int i;
Bool success = FALSE;
ExtensionEntry *extEntry;
ScreenPtr pScreen = screenInfo.screens[0];
PanoramiXScreenPtr pScreenPriv;
if (noPanoramiXExtension)
return;
if (!dixRegisterPrivateKey(&PanoramiXScreenKeyRec, PRIVATE_SCREEN, 0)) {
noPanoramiXExtension = TRUE;
return;
}
if (!dixRegisterPrivateKey
(&PanoramiXGCKeyRec, PRIVATE_GC, sizeof(PanoramiXGCRec))) {
noPanoramiXExtension = TRUE;
return;
}
PanoramiXNumScreens = screenInfo.numScreens;
if (PanoramiXNumScreens == 1) { /* Only 1 screen */
noPanoramiXExtension = TRUE;
return;
}
while (panoramiXGeneration != serverGeneration) {
extEntry = AddExtension(PANORAMIX_PROTOCOL_NAME, 0, 0,
ProcPanoramiXDispatch,
SProcPanoramiXDispatch, PanoramiXResetProc,
StandardMinorOpcode);
if (!extEntry)
break;
/*
* First make sure all the basic allocations succeed. If not,
* run in non-PanoramiXeen mode.
*/
FOR_NSCREENS(i) {
pScreen = screenInfo.screens[i];
pScreenPriv = malloc(sizeof(PanoramiXScreenRec));
dixSetPrivate(&pScreen->devPrivates, PanoramiXScreenKey,
pScreenPriv);
if (!pScreenPriv) {
noPanoramiXExtension = TRUE;
return;
}
pScreenPriv->CreateGC = pScreen->CreateGC;
pScreenPriv->CloseScreen = pScreen->CloseScreen;
pScreen->CreateGC = XineramaCreateGC;
pScreen->CloseScreen = XineramaCloseScreen;
}
XRC_DRAWABLE = CreateNewResourceClass();
XRT_WINDOW = CreateNewResourceType(XineramaDeleteResource,
"XineramaWindow");
if (XRT_WINDOW)
XRT_WINDOW |= XRC_DRAWABLE;
XRT_PIXMAP = CreateNewResourceType(XineramaDeleteResource,
"XineramaPixmap");
if (XRT_PIXMAP)
XRT_PIXMAP |= XRC_DRAWABLE;
XRT_GC = CreateNewResourceType(XineramaDeleteResource, "XineramaGC");
XRT_COLORMAP = CreateNewResourceType(XineramaDeleteResource,
"XineramaColormap");
if (XRT_WINDOW && XRT_PIXMAP && XRT_GC && XRT_COLORMAP) {
panoramiXGeneration = serverGeneration;
success = TRUE;
}
SetResourceTypeErrorValue(XRT_WINDOW, BadWindow);
SetResourceTypeErrorValue(XRT_PIXMAP, BadPixmap);
SetResourceTypeErrorValue(XRT_GC, BadGC);
SetResourceTypeErrorValue(XRT_COLORMAP, BadColor);
}
if (!success) {
noPanoramiXExtension = TRUE;
ErrorF(PANORAMIX_PROTOCOL_NAME " extension failed to initialize\n");
return;
}
XineramaInitData();
/*
* Put our processes into the ProcVector
*/
for (i = 256; i--;)
SavedProcVector[i] = ProcVector[i];
ProcVector[X_CreateWindow] = PanoramiXCreateWindow;
ProcVector[X_ChangeWindowAttributes] = PanoramiXChangeWindowAttributes;
ProcVector[X_DestroyWindow] = PanoramiXDestroyWindow;
ProcVector[X_DestroySubwindows] = PanoramiXDestroySubwindows;
ProcVector[X_ChangeSaveSet] = PanoramiXChangeSaveSet;
ProcVector[X_ReparentWindow] = PanoramiXReparentWindow;
ProcVector[X_MapWindow] = PanoramiXMapWindow;
ProcVector[X_MapSubwindows] = PanoramiXMapSubwindows;
ProcVector[X_UnmapWindow] = PanoramiXUnmapWindow;
ProcVector[X_UnmapSubwindows] = PanoramiXUnmapSubwindows;
ProcVector[X_ConfigureWindow] = PanoramiXConfigureWindow;
ProcVector[X_CirculateWindow] = PanoramiXCirculateWindow;
ProcVector[X_GetGeometry] = PanoramiXGetGeometry;
ProcVector[X_TranslateCoords] = PanoramiXTranslateCoords;
ProcVector[X_CreatePixmap] = PanoramiXCreatePixmap;
ProcVector[X_FreePixmap] = PanoramiXFreePixmap;
ProcVector[X_CreateGC] = PanoramiXCreateGC;
ProcVector[X_ChangeGC] = PanoramiXChangeGC;
ProcVector[X_CopyGC] = PanoramiXCopyGC;
ProcVector[X_SetDashes] = PanoramiXSetDashes;
ProcVector[X_SetClipRectangles] = PanoramiXSetClipRectangles;
ProcVector[X_FreeGC] = PanoramiXFreeGC;
ProcVector[X_ClearArea] = PanoramiXClearToBackground;
ProcVector[X_CopyArea] = PanoramiXCopyArea;
ProcVector[X_CopyPlane] = PanoramiXCopyPlane;
ProcVector[X_PolyPoint] = PanoramiXPolyPoint;
ProcVector[X_PolyLine] = PanoramiXPolyLine;
ProcVector[X_PolySegment] = PanoramiXPolySegment;
ProcVector[X_PolyRectangle] = PanoramiXPolyRectangle;
ProcVector[X_PolyArc] = PanoramiXPolyArc;
ProcVector[X_FillPoly] = PanoramiXFillPoly;
ProcVector[X_PolyFillRectangle] = PanoramiXPolyFillRectangle;
ProcVector[X_PolyFillArc] = PanoramiXPolyFillArc;
ProcVector[X_PutImage] = PanoramiXPutImage;
ProcVector[X_GetImage] = PanoramiXGetImage;
ProcVector[X_PolyText8] = PanoramiXPolyText8;
ProcVector[X_PolyText16] = PanoramiXPolyText16;
ProcVector[X_ImageText8] = PanoramiXImageText8;
ProcVector[X_ImageText16] = PanoramiXImageText16;
ProcVector[X_CreateColormap] = PanoramiXCreateColormap;
ProcVector[X_FreeColormap] = PanoramiXFreeColormap;
ProcVector[X_CopyColormapAndFree] = PanoramiXCopyColormapAndFree;
ProcVector[X_InstallColormap] = PanoramiXInstallColormap;
ProcVector[X_UninstallColormap] = PanoramiXUninstallColormap;
ProcVector[X_AllocColor] = PanoramiXAllocColor;
ProcVector[X_AllocNamedColor] = PanoramiXAllocNamedColor;
ProcVector[X_AllocColorCells] = PanoramiXAllocColorCells;
ProcVector[X_AllocColorPlanes] = PanoramiXAllocColorPlanes;
ProcVector[X_FreeColors] = PanoramiXFreeColors;
ProcVector[X_StoreColors] = PanoramiXStoreColors;
ProcVector[X_StoreNamedColor] = PanoramiXStoreNamedColor;
PanoramiXRenderInit();
PanoramiXFixesInit();
PanoramiXDamageInit();
#ifdef COMPOSITE
PanoramiXCompositeInit();
#endif
}
| Exec Code | 0 | PanoramiXExtensionInit(void)
{
int i;
Bool success = FALSE;
ExtensionEntry *extEntry;
ScreenPtr pScreen = screenInfo.screens[0];
PanoramiXScreenPtr pScreenPriv;
if (noPanoramiXExtension)
return;
if (!dixRegisterPrivateKey(&PanoramiXScreenKeyRec, PRIVATE_SCREEN, 0)) {
noPanoramiXExtension = TRUE;
return;
}
if (!dixRegisterPrivateKey
(&PanoramiXGCKeyRec, PRIVATE_GC, sizeof(PanoramiXGCRec))) {
noPanoramiXExtension = TRUE;
return;
}
PanoramiXNumScreens = screenInfo.numScreens;
if (PanoramiXNumScreens == 1) { /* Only 1 screen */
noPanoramiXExtension = TRUE;
return;
}
while (panoramiXGeneration != serverGeneration) {
extEntry = AddExtension(PANORAMIX_PROTOCOL_NAME, 0, 0,
ProcPanoramiXDispatch,
SProcPanoramiXDispatch, PanoramiXResetProc,
StandardMinorOpcode);
if (!extEntry)
break;
/*
* First make sure all the basic allocations succeed. If not,
* run in non-PanoramiXeen mode.
*/
FOR_NSCREENS(i) {
pScreen = screenInfo.screens[i];
pScreenPriv = malloc(sizeof(PanoramiXScreenRec));
dixSetPrivate(&pScreen->devPrivates, PanoramiXScreenKey,
pScreenPriv);
if (!pScreenPriv) {
noPanoramiXExtension = TRUE;
return;
}
pScreenPriv->CreateGC = pScreen->CreateGC;
pScreenPriv->CloseScreen = pScreen->CloseScreen;
pScreen->CreateGC = XineramaCreateGC;
pScreen->CloseScreen = XineramaCloseScreen;
}
XRC_DRAWABLE = CreateNewResourceClass();
XRT_WINDOW = CreateNewResourceType(XineramaDeleteResource,
"XineramaWindow");
if (XRT_WINDOW)
XRT_WINDOW |= XRC_DRAWABLE;
XRT_PIXMAP = CreateNewResourceType(XineramaDeleteResource,
"XineramaPixmap");
if (XRT_PIXMAP)
XRT_PIXMAP |= XRC_DRAWABLE;
XRT_GC = CreateNewResourceType(XineramaDeleteResource, "XineramaGC");
XRT_COLORMAP = CreateNewResourceType(XineramaDeleteResource,
"XineramaColormap");
if (XRT_WINDOW && XRT_PIXMAP && XRT_GC && XRT_COLORMAP) {
panoramiXGeneration = serverGeneration;
success = TRUE;
}
SetResourceTypeErrorValue(XRT_WINDOW, BadWindow);
SetResourceTypeErrorValue(XRT_PIXMAP, BadPixmap);
SetResourceTypeErrorValue(XRT_GC, BadGC);
SetResourceTypeErrorValue(XRT_COLORMAP, BadColor);
}
if (!success) {
noPanoramiXExtension = TRUE;
ErrorF(PANORAMIX_PROTOCOL_NAME " extension failed to initialize\n");
return;
}
XineramaInitData();
/*
* Put our processes into the ProcVector
*/
for (i = 256; i--;)
SavedProcVector[i] = ProcVector[i];
ProcVector[X_CreateWindow] = PanoramiXCreateWindow;
ProcVector[X_ChangeWindowAttributes] = PanoramiXChangeWindowAttributes;
ProcVector[X_DestroyWindow] = PanoramiXDestroyWindow;
ProcVector[X_DestroySubwindows] = PanoramiXDestroySubwindows;
ProcVector[X_ChangeSaveSet] = PanoramiXChangeSaveSet;
ProcVector[X_ReparentWindow] = PanoramiXReparentWindow;
ProcVector[X_MapWindow] = PanoramiXMapWindow;
ProcVector[X_MapSubwindows] = PanoramiXMapSubwindows;
ProcVector[X_UnmapWindow] = PanoramiXUnmapWindow;
ProcVector[X_UnmapSubwindows] = PanoramiXUnmapSubwindows;
ProcVector[X_ConfigureWindow] = PanoramiXConfigureWindow;
ProcVector[X_CirculateWindow] = PanoramiXCirculateWindow;
ProcVector[X_GetGeometry] = PanoramiXGetGeometry;
ProcVector[X_TranslateCoords] = PanoramiXTranslateCoords;
ProcVector[X_CreatePixmap] = PanoramiXCreatePixmap;
ProcVector[X_FreePixmap] = PanoramiXFreePixmap;
ProcVector[X_CreateGC] = PanoramiXCreateGC;
ProcVector[X_ChangeGC] = PanoramiXChangeGC;
ProcVector[X_CopyGC] = PanoramiXCopyGC;
ProcVector[X_SetDashes] = PanoramiXSetDashes;
ProcVector[X_SetClipRectangles] = PanoramiXSetClipRectangles;
ProcVector[X_FreeGC] = PanoramiXFreeGC;
ProcVector[X_ClearArea] = PanoramiXClearToBackground;
ProcVector[X_CopyArea] = PanoramiXCopyArea;
ProcVector[X_CopyPlane] = PanoramiXCopyPlane;
ProcVector[X_PolyPoint] = PanoramiXPolyPoint;
ProcVector[X_PolyLine] = PanoramiXPolyLine;
ProcVector[X_PolySegment] = PanoramiXPolySegment;
ProcVector[X_PolyRectangle] = PanoramiXPolyRectangle;
ProcVector[X_PolyArc] = PanoramiXPolyArc;
ProcVector[X_FillPoly] = PanoramiXFillPoly;
ProcVector[X_PolyFillRectangle] = PanoramiXPolyFillRectangle;
ProcVector[X_PolyFillArc] = PanoramiXPolyFillArc;
ProcVector[X_PutImage] = PanoramiXPutImage;
ProcVector[X_GetImage] = PanoramiXGetImage;
ProcVector[X_PolyText8] = PanoramiXPolyText8;
ProcVector[X_PolyText16] = PanoramiXPolyText16;
ProcVector[X_ImageText8] = PanoramiXImageText8;
ProcVector[X_ImageText16] = PanoramiXImageText16;
ProcVector[X_CreateColormap] = PanoramiXCreateColormap;
ProcVector[X_FreeColormap] = PanoramiXFreeColormap;
ProcVector[X_CopyColormapAndFree] = PanoramiXCopyColormapAndFree;
ProcVector[X_InstallColormap] = PanoramiXInstallColormap;
ProcVector[X_UninstallColormap] = PanoramiXUninstallColormap;
ProcVector[X_AllocColor] = PanoramiXAllocColor;
ProcVector[X_AllocNamedColor] = PanoramiXAllocNamedColor;
ProcVector[X_AllocColorCells] = PanoramiXAllocColorCells;
ProcVector[X_AllocColorPlanes] = PanoramiXAllocColorPlanes;
ProcVector[X_FreeColors] = PanoramiXFreeColors;
ProcVector[X_StoreColors] = PanoramiXStoreColors;
ProcVector[X_StoreNamedColor] = PanoramiXStoreNamedColor;
PanoramiXRenderInit();
PanoramiXFixesInit();
PanoramiXDamageInit();
#ifdef COMPOSITE
PanoramiXCompositeInit();
#endif
}
| @@ -988,10 +988,11 @@ ProcPanoramiXGetScreenSize(ClientPtr client)
xPanoramiXGetScreenSizeReply rep;
int rc;
+ REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
+
if (stuff->screen >= PanoramiXNumScreens)
return BadMatch;
- REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc; | CWE-20 | null | null |
13,919 | PanoramiXFindIDByScrnum(RESTYPE type, XID id, int screen)
{
PanoramiXSearchData data;
void *val;
if (!screen) {
dixLookupResourceByType(&val, id, type, serverClient, DixReadAccess);
return val;
}
data.screen = screen;
data.id = id;
return LookupClientResourceComplex(clients[CLIENT_ID(id)], type,
XineramaFindIDByScrnum, &data);
}
| Exec Code | 0 | PanoramiXFindIDByScrnum(RESTYPE type, XID id, int screen)
{
PanoramiXSearchData data;
void *val;
if (!screen) {
dixLookupResourceByType(&val, id, type, serverClient, DixReadAccess);
return val;
}
data.screen = screen;
data.id = id;
return LookupClientResourceComplex(clients[CLIENT_ID(id)], type,
XineramaFindIDByScrnum, &data);
}
| @@ -988,10 +988,11 @@ ProcPanoramiXGetScreenSize(ClientPtr client)
xPanoramiXGetScreenSizeReply rep;
int rc;
+ REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
+
if (stuff->screen >= PanoramiXNumScreens)
return BadMatch;
- REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc; | CWE-20 | null | null |
13,920 | PanoramiXMaybeAddDepth(DepthPtr pDepth)
{
ScreenPtr pScreen;
int j, k;
Bool found = FALSE;
FOR_NSCREENS_FORWARD_SKIP(j) {
pScreen = screenInfo.screens[j];
for (k = 0; k < pScreen->numDepths; k++) {
if (pScreen->allowedDepths[k].depth == pDepth->depth) {
found = TRUE;
break;
}
}
}
if (!found)
return;
j = PanoramiXNumDepths;
PanoramiXNumDepths++;
PanoramiXDepths = reallocarray(PanoramiXDepths,
PanoramiXNumDepths, sizeof(DepthRec));
PanoramiXDepths[j].depth = pDepth->depth;
PanoramiXDepths[j].numVids = 0;
/* XXX suboptimal, should grow these dynamically */
if (pDepth->numVids)
PanoramiXDepths[j].vids = xallocarray(pDepth->numVids, sizeof(VisualID));
else
PanoramiXDepths[j].vids = NULL;
}
| Exec Code | 0 | PanoramiXMaybeAddDepth(DepthPtr pDepth)
{
ScreenPtr pScreen;
int j, k;
Bool found = FALSE;
FOR_NSCREENS_FORWARD_SKIP(j) {
pScreen = screenInfo.screens[j];
for (k = 0; k < pScreen->numDepths; k++) {
if (pScreen->allowedDepths[k].depth == pDepth->depth) {
found = TRUE;
break;
}
}
}
if (!found)
return;
j = PanoramiXNumDepths;
PanoramiXNumDepths++;
PanoramiXDepths = reallocarray(PanoramiXDepths,
PanoramiXNumDepths, sizeof(DepthRec));
PanoramiXDepths[j].depth = pDepth->depth;
PanoramiXDepths[j].numVids = 0;
/* XXX suboptimal, should grow these dynamically */
if (pDepth->numVids)
PanoramiXDepths[j].vids = xallocarray(pDepth->numVids, sizeof(VisualID));
else
PanoramiXDepths[j].vids = NULL;
}
| @@ -988,10 +988,11 @@ ProcPanoramiXGetScreenSize(ClientPtr client)
xPanoramiXGetScreenSizeReply rep;
int rc;
+ REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
+
if (stuff->screen >= PanoramiXNumScreens)
return BadMatch;
- REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc; | CWE-20 | null | null |
13,921 | PanoramiXMaybeAddVisual(VisualPtr pVisual)
{
ScreenPtr pScreen;
int j, k;
Bool found = FALSE;
FOR_NSCREENS_FORWARD_SKIP(j) {
pScreen = screenInfo.screens[j];
found = FALSE;
for (k = 0; k < pScreen->numVisuals; k++) {
VisualPtr candidate = &pScreen->visuals[k];
if ((*XineramaVisualsEqualPtr) (pVisual, pScreen, candidate)
#ifdef GLXPROXY
&& glxMatchVisual(screenInfo.screens[0], pVisual, pScreen)
#endif
) {
found = TRUE;
break;
}
}
if (!found)
return;
}
/* found a matching visual on all screens, add it to the subset list */
j = PanoramiXNumVisuals;
PanoramiXNumVisuals++;
PanoramiXVisuals = reallocarray(PanoramiXVisuals,
PanoramiXNumVisuals, sizeof(VisualRec));
memcpy(&PanoramiXVisuals[j], pVisual, sizeof(VisualRec));
for (k = 0; k < PanoramiXNumDepths; k++) {
if (PanoramiXDepths[k].depth == pVisual->nplanes) {
PanoramiXDepths[k].vids[PanoramiXDepths[k].numVids] = pVisual->vid;
PanoramiXDepths[k].numVids++;
break;
}
}
}
| Exec Code | 0 | PanoramiXMaybeAddVisual(VisualPtr pVisual)
{
ScreenPtr pScreen;
int j, k;
Bool found = FALSE;
FOR_NSCREENS_FORWARD_SKIP(j) {
pScreen = screenInfo.screens[j];
found = FALSE;
for (k = 0; k < pScreen->numVisuals; k++) {
VisualPtr candidate = &pScreen->visuals[k];
if ((*XineramaVisualsEqualPtr) (pVisual, pScreen, candidate)
#ifdef GLXPROXY
&& glxMatchVisual(screenInfo.screens[0], pVisual, pScreen)
#endif
) {
found = TRUE;
break;
}
}
if (!found)
return;
}
/* found a matching visual on all screens, add it to the subset list */
j = PanoramiXNumVisuals;
PanoramiXNumVisuals++;
PanoramiXVisuals = reallocarray(PanoramiXVisuals,
PanoramiXNumVisuals, sizeof(VisualRec));
memcpy(&PanoramiXVisuals[j], pVisual, sizeof(VisualRec));
for (k = 0; k < PanoramiXNumDepths; k++) {
if (PanoramiXDepths[k].depth == pVisual->nplanes) {
PanoramiXDepths[k].vids[PanoramiXDepths[k].numVids] = pVisual->vid;
PanoramiXDepths[k].numVids++;
break;
}
}
}
| @@ -988,10 +988,11 @@ ProcPanoramiXGetScreenSize(ClientPtr client)
xPanoramiXGetScreenSizeReply rep;
int rc;
+ REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
+
if (stuff->screen >= PanoramiXNumScreens)
return BadMatch;
- REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc; | CWE-20 | null | null |
13,922 | ProcPanoramiXDispatch(ClientPtr client)
{
REQUEST(xReq);
switch (stuff->data) {
case X_PanoramiXQueryVersion:
return ProcPanoramiXQueryVersion(client);
case X_PanoramiXGetState:
return ProcPanoramiXGetState(client);
case X_PanoramiXGetScreenCount:
return ProcPanoramiXGetScreenCount(client);
case X_PanoramiXGetScreenSize:
return ProcPanoramiXGetScreenSize(client);
case X_XineramaIsActive:
return ProcXineramaIsActive(client);
case X_XineramaQueryScreens:
return ProcXineramaQueryScreens(client);
}
return BadRequest;
}
| Exec Code | 0 | ProcPanoramiXDispatch(ClientPtr client)
{
REQUEST(xReq);
switch (stuff->data) {
case X_PanoramiXQueryVersion:
return ProcPanoramiXQueryVersion(client);
case X_PanoramiXGetState:
return ProcPanoramiXGetState(client);
case X_PanoramiXGetScreenCount:
return ProcPanoramiXGetScreenCount(client);
case X_PanoramiXGetScreenSize:
return ProcPanoramiXGetScreenSize(client);
case X_XineramaIsActive:
return ProcXineramaIsActive(client);
case X_XineramaQueryScreens:
return ProcXineramaQueryScreens(client);
}
return BadRequest;
}
| @@ -988,10 +988,11 @@ ProcPanoramiXGetScreenSize(ClientPtr client)
xPanoramiXGetScreenSizeReply rep;
int rc;
+ REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
+
if (stuff->screen >= PanoramiXNumScreens)
return BadMatch;
- REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc; | CWE-20 | null | null |
13,923 | ProcPanoramiXGetState(ClientPtr client)
{
REQUEST(xPanoramiXGetStateReq);
WindowPtr pWin;
xPanoramiXGetStateReply rep;
int rc;
REQUEST_SIZE_MATCH(xPanoramiXGetStateReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc;
rep = (xPanoramiXGetStateReply) {
.type = X_Reply,
.state = !noPanoramiXExtension,
.sequenceNumber = client->sequence,
.length = 0,
.window = stuff->window
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.window);
}
WriteToClient(client, sizeof(xPanoramiXGetStateReply), &rep);
return Success;
}
| Exec Code | 0 | ProcPanoramiXGetState(ClientPtr client)
{
REQUEST(xPanoramiXGetStateReq);
WindowPtr pWin;
xPanoramiXGetStateReply rep;
int rc;
REQUEST_SIZE_MATCH(xPanoramiXGetStateReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc;
rep = (xPanoramiXGetStateReply) {
.type = X_Reply,
.state = !noPanoramiXExtension,
.sequenceNumber = client->sequence,
.length = 0,
.window = stuff->window
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.window);
}
WriteToClient(client, sizeof(xPanoramiXGetStateReply), &rep);
return Success;
}
| @@ -988,10 +988,11 @@ ProcPanoramiXGetScreenSize(ClientPtr client)
xPanoramiXGetScreenSizeReply rep;
int rc;
+ REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
+
if (stuff->screen >= PanoramiXNumScreens)
return BadMatch;
- REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc; | CWE-20 | null | null |
13,924 | ProcXineramaIsActive(ClientPtr client)
{
/* REQUEST(xXineramaIsActiveReq); */
xXineramaIsActiveReply rep;
REQUEST_SIZE_MATCH(xXineramaIsActiveReq);
rep = (xXineramaIsActiveReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
#if 1
/* The following hack fools clients into thinking that Xinerama
* is disabled even though it is not. */
.state = !noPanoramiXExtension && !PanoramiXExtensionDisabledHack
#else
.state = !noPanoramiXExtension;
#endif
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.state);
}
WriteToClient(client, sizeof(xXineramaIsActiveReply), &rep);
return Success;
}
| Exec Code | 0 | ProcXineramaIsActive(ClientPtr client)
{
/* REQUEST(xXineramaIsActiveReq); */
xXineramaIsActiveReply rep;
REQUEST_SIZE_MATCH(xXineramaIsActiveReq);
rep = (xXineramaIsActiveReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
#if 1
/* The following hack fools clients into thinking that Xinerama
* is disabled even though it is not. */
.state = !noPanoramiXExtension && !PanoramiXExtensionDisabledHack
#else
.state = !noPanoramiXExtension;
#endif
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.state);
}
WriteToClient(client, sizeof(xXineramaIsActiveReply), &rep);
return Success;
}
| @@ -988,10 +988,11 @@ ProcPanoramiXGetScreenSize(ClientPtr client)
xPanoramiXGetScreenSizeReply rep;
int rc;
+ REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
+
if (stuff->screen >= PanoramiXNumScreens)
return BadMatch;
- REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc; | CWE-20 | null | null |
13,925 | ProcXineramaQueryScreens(ClientPtr client)
{
/* REQUEST(xXineramaQueryScreensReq); */
CARD32 number = (noPanoramiXExtension) ? 0 : PanoramiXNumScreens;
xXineramaQueryScreensReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(number * sz_XineramaScreenInfo),
.number = number
};
REQUEST_SIZE_MATCH(xXineramaQueryScreensReq);
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.number);
}
WriteToClient(client, sizeof(xXineramaQueryScreensReply), &rep);
if (!noPanoramiXExtension) {
xXineramaScreenInfo scratch;
int i;
FOR_NSCREENS(i) {
scratch.x_org = screenInfo.screens[i]->x;
scratch.y_org = screenInfo.screens[i]->y;
scratch.width = screenInfo.screens[i]->width;
scratch.height = screenInfo.screens[i]->height;
if (client->swapped) {
swaps(&scratch.x_org);
swaps(&scratch.y_org);
swaps(&scratch.width);
swaps(&scratch.height);
}
WriteToClient(client, sz_XineramaScreenInfo, &scratch);
}
}
return Success;
}
| Exec Code | 0 | ProcXineramaQueryScreens(ClientPtr client)
{
/* REQUEST(xXineramaQueryScreensReq); */
CARD32 number = (noPanoramiXExtension) ? 0 : PanoramiXNumScreens;
xXineramaQueryScreensReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(number * sz_XineramaScreenInfo),
.number = number
};
REQUEST_SIZE_MATCH(xXineramaQueryScreensReq);
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.number);
}
WriteToClient(client, sizeof(xXineramaQueryScreensReply), &rep);
if (!noPanoramiXExtension) {
xXineramaScreenInfo scratch;
int i;
FOR_NSCREENS(i) {
scratch.x_org = screenInfo.screens[i]->x;
scratch.y_org = screenInfo.screens[i]->y;
scratch.width = screenInfo.screens[i]->width;
scratch.height = screenInfo.screens[i]->height;
if (client->swapped) {
swaps(&scratch.x_org);
swaps(&scratch.y_org);
swaps(&scratch.width);
swaps(&scratch.height);
}
WriteToClient(client, sz_XineramaScreenInfo, &scratch);
}
}
return Success;
}
| @@ -988,10 +988,11 @@ ProcPanoramiXGetScreenSize(ClientPtr client)
xPanoramiXGetScreenSizeReply rep;
int rc;
+ REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
+
if (stuff->screen >= PanoramiXNumScreens)
return BadMatch;
- REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc; | CWE-20 | null | null |
13,926 | XineramaChangeClip(GCPtr pGC, int type, void *pvalue, int nrects)
{
Xinerama_GC_FUNC_PROLOGUE(pGC);
(*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects);
Xinerama_GC_FUNC_EPILOGUE(pGC);
}
| Exec Code | 0 | XineramaChangeClip(GCPtr pGC, int type, void *pvalue, int nrects)
{
Xinerama_GC_FUNC_PROLOGUE(pGC);
(*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects);
Xinerama_GC_FUNC_EPILOGUE(pGC);
}
| @@ -988,10 +988,11 @@ ProcPanoramiXGetScreenSize(ClientPtr client)
xPanoramiXGetScreenSizeReply rep;
int rc;
+ REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
+
if (stuff->screen >= PanoramiXNumScreens)
return BadMatch;
- REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc; | CWE-20 | null | null |
13,927 | XineramaChangeGC(GCPtr pGC, unsigned long mask)
{
Xinerama_GC_FUNC_PROLOGUE(pGC);
if (mask & GCTileStipXOrigin)
pGCPriv->patOrg.x = pGC->patOrg.x;
if (mask & GCTileStipYOrigin)
pGCPriv->patOrg.y = pGC->patOrg.y;
if (mask & GCClipXOrigin)
pGCPriv->clipOrg.x = pGC->clipOrg.x;
if (mask & GCClipYOrigin)
pGCPriv->clipOrg.y = pGC->clipOrg.y;
(*pGC->funcs->ChangeGC) (pGC, mask);
Xinerama_GC_FUNC_EPILOGUE(pGC);
}
| Exec Code | 0 | XineramaChangeGC(GCPtr pGC, unsigned long mask)
{
Xinerama_GC_FUNC_PROLOGUE(pGC);
if (mask & GCTileStipXOrigin)
pGCPriv->patOrg.x = pGC->patOrg.x;
if (mask & GCTileStipYOrigin)
pGCPriv->patOrg.y = pGC->patOrg.y;
if (mask & GCClipXOrigin)
pGCPriv->clipOrg.x = pGC->clipOrg.x;
if (mask & GCClipYOrigin)
pGCPriv->clipOrg.y = pGC->clipOrg.y;
(*pGC->funcs->ChangeGC) (pGC, mask);
Xinerama_GC_FUNC_EPILOGUE(pGC);
}
| @@ -988,10 +988,11 @@ ProcPanoramiXGetScreenSize(ClientPtr client)
xPanoramiXGetScreenSizeReply rep;
int rc;
+ REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
+
if (stuff->screen >= PanoramiXNumScreens)
return BadMatch;
- REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc; | CWE-20 | null | null |
13,928 | XineramaCloseScreen(ScreenPtr pScreen)
{
PanoramiXScreenPtr pScreenPriv = (PanoramiXScreenPtr)
dixLookupPrivate(&pScreen->devPrivates, PanoramiXScreenKey);
pScreen->CloseScreen = pScreenPriv->CloseScreen;
pScreen->CreateGC = pScreenPriv->CreateGC;
if (pScreen->myNum == 0)
RegionUninit(&PanoramiXScreenRegion);
free(pScreenPriv);
return (*pScreen->CloseScreen) (pScreen);
}
| Exec Code | 0 | XineramaCloseScreen(ScreenPtr pScreen)
{
PanoramiXScreenPtr pScreenPriv = (PanoramiXScreenPtr)
dixLookupPrivate(&pScreen->devPrivates, PanoramiXScreenKey);
pScreen->CloseScreen = pScreenPriv->CloseScreen;
pScreen->CreateGC = pScreenPriv->CreateGC;
if (pScreen->myNum == 0)
RegionUninit(&PanoramiXScreenRegion);
free(pScreenPriv);
return (*pScreen->CloseScreen) (pScreen);
}
| @@ -988,10 +988,11 @@ ProcPanoramiXGetScreenSize(ClientPtr client)
xPanoramiXGetScreenSizeReply rep;
int rc;
+ REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
+
if (stuff->screen >= PanoramiXNumScreens)
return BadMatch;
- REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc; | CWE-20 | null | null |
13,929 | XineramaCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
{
Xinerama_GC_FUNC_PROLOGUE(pgcDst);
(*pgcDst->funcs->CopyClip) (pgcDst, pgcSrc);
Xinerama_GC_FUNC_EPILOGUE(pgcDst);
}
| Exec Code | 0 | XineramaCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
{
Xinerama_GC_FUNC_PROLOGUE(pgcDst);
(*pgcDst->funcs->CopyClip) (pgcDst, pgcSrc);
Xinerama_GC_FUNC_EPILOGUE(pgcDst);
}
| @@ -988,10 +988,11 @@ ProcPanoramiXGetScreenSize(ClientPtr client)
xPanoramiXGetScreenSizeReply rep;
int rc;
+ REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
+
if (stuff->screen >= PanoramiXNumScreens)
return BadMatch;
- REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc; | CWE-20 | null | null |
13,930 | XineramaCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst)
{
PanoramiXGCPtr pSrcPriv = (PanoramiXGCPtr)
dixLookupPrivate(&pGCSrc->devPrivates, PanoramiXGCKey);
Xinerama_GC_FUNC_PROLOGUE(pGCDst);
if (mask & GCTileStipXOrigin)
pGCPriv->patOrg.x = pSrcPriv->patOrg.x;
if (mask & GCTileStipYOrigin)
pGCPriv->patOrg.y = pSrcPriv->patOrg.y;
if (mask & GCClipXOrigin)
pGCPriv->clipOrg.x = pSrcPriv->clipOrg.x;
if (mask & GCClipYOrigin)
pGCPriv->clipOrg.y = pSrcPriv->clipOrg.y;
(*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst);
Xinerama_GC_FUNC_EPILOGUE(pGCDst);
}
| Exec Code | 0 | XineramaCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst)
{
PanoramiXGCPtr pSrcPriv = (PanoramiXGCPtr)
dixLookupPrivate(&pGCSrc->devPrivates, PanoramiXGCKey);
Xinerama_GC_FUNC_PROLOGUE(pGCDst);
if (mask & GCTileStipXOrigin)
pGCPriv->patOrg.x = pSrcPriv->patOrg.x;
if (mask & GCTileStipYOrigin)
pGCPriv->patOrg.y = pSrcPriv->patOrg.y;
if (mask & GCClipXOrigin)
pGCPriv->clipOrg.x = pSrcPriv->clipOrg.x;
if (mask & GCClipYOrigin)
pGCPriv->clipOrg.y = pSrcPriv->clipOrg.y;
(*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst);
Xinerama_GC_FUNC_EPILOGUE(pGCDst);
}
| @@ -988,10 +988,11 @@ ProcPanoramiXGetScreenSize(ClientPtr client)
xPanoramiXGetScreenSizeReply rep;
int rc;
+ REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
+
if (stuff->screen >= PanoramiXNumScreens)
return BadMatch;
- REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc; | CWE-20 | null | null |
13,931 | XineramaCreateGC(GCPtr pGC)
{
ScreenPtr pScreen = pGC->pScreen;
PanoramiXScreenPtr pScreenPriv = (PanoramiXScreenPtr)
dixLookupPrivate(&pScreen->devPrivates, PanoramiXScreenKey);
Bool ret;
pScreen->CreateGC = pScreenPriv->CreateGC;
if ((ret = (*pScreen->CreateGC) (pGC))) {
PanoramiXGCPtr pGCPriv = (PanoramiXGCPtr)
dixLookupPrivate(&pGC->devPrivates, PanoramiXGCKey);
pGCPriv->wrapFuncs = pGC->funcs;
pGC->funcs = &XineramaGCFuncs;
pGCPriv->clipOrg.x = pGC->clipOrg.x;
pGCPriv->clipOrg.y = pGC->clipOrg.y;
pGCPriv->patOrg.x = pGC->patOrg.x;
pGCPriv->patOrg.y = pGC->patOrg.y;
}
pScreen->CreateGC = XineramaCreateGC;
return ret;
}
| Exec Code | 0 | XineramaCreateGC(GCPtr pGC)
{
ScreenPtr pScreen = pGC->pScreen;
PanoramiXScreenPtr pScreenPriv = (PanoramiXScreenPtr)
dixLookupPrivate(&pScreen->devPrivates, PanoramiXScreenKey);
Bool ret;
pScreen->CreateGC = pScreenPriv->CreateGC;
if ((ret = (*pScreen->CreateGC) (pGC))) {
PanoramiXGCPtr pGCPriv = (PanoramiXGCPtr)
dixLookupPrivate(&pGC->devPrivates, PanoramiXGCKey);
pGCPriv->wrapFuncs = pGC->funcs;
pGC->funcs = &XineramaGCFuncs;
pGCPriv->clipOrg.x = pGC->clipOrg.x;
pGCPriv->clipOrg.y = pGC->clipOrg.y;
pGCPriv->patOrg.x = pGC->patOrg.x;
pGCPriv->patOrg.y = pGC->patOrg.y;
}
pScreen->CreateGC = XineramaCreateGC;
return ret;
}
| @@ -988,10 +988,11 @@ ProcPanoramiXGetScreenSize(ClientPtr client)
xPanoramiXGetScreenSizeReply rep;
int rc;
+ REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
+
if (stuff->screen >= PanoramiXNumScreens)
return BadMatch;
- REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc; | CWE-20 | null | null |
13,932 | XineramaDestroyClip(GCPtr pGC)
{
Xinerama_GC_FUNC_PROLOGUE(pGC);
(*pGC->funcs->DestroyClip) (pGC);
Xinerama_GC_FUNC_EPILOGUE(pGC);
}
| Exec Code | 0 | XineramaDestroyClip(GCPtr pGC)
{
Xinerama_GC_FUNC_PROLOGUE(pGC);
(*pGC->funcs->DestroyClip) (pGC);
Xinerama_GC_FUNC_EPILOGUE(pGC);
}
| @@ -988,10 +988,11 @@ ProcPanoramiXGetScreenSize(ClientPtr client)
xPanoramiXGetScreenSizeReply rep;
int rc;
+ REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
+
if (stuff->screen >= PanoramiXNumScreens)
return BadMatch;
- REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc; | CWE-20 | null | null |
13,933 | XineramaDestroyGC(GCPtr pGC)
{
Xinerama_GC_FUNC_PROLOGUE(pGC);
(*pGC->funcs->DestroyGC) (pGC);
Xinerama_GC_FUNC_EPILOGUE(pGC);
}
| Exec Code | 0 | XineramaDestroyGC(GCPtr pGC)
{
Xinerama_GC_FUNC_PROLOGUE(pGC);
(*pGC->funcs->DestroyGC) (pGC);
Xinerama_GC_FUNC_EPILOGUE(pGC);
}
| @@ -988,10 +988,11 @@ ProcPanoramiXGetScreenSize(ClientPtr client)
xPanoramiXGetScreenSizeReply rep;
int rc;
+ REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
+
if (stuff->screen >= PanoramiXNumScreens)
return BadMatch;
- REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc; | CWE-20 | null | null |
13,934 | XineramaFindIDByScrnum(void *resource, XID id, void *privdata)
{
PanoramiXRes *res = (PanoramiXRes *) resource;
PanoramiXSearchData *data = (PanoramiXSearchData *) privdata;
return res->info[data->screen].id == data->id;
}
| Exec Code | 0 | XineramaFindIDByScrnum(void *resource, XID id, void *privdata)
{
PanoramiXRes *res = (PanoramiXRes *) resource;
PanoramiXSearchData *data = (PanoramiXSearchData *) privdata;
return res->info[data->screen].id == data->id;
}
| @@ -988,10 +988,11 @@ ProcPanoramiXGetScreenSize(ClientPtr client)
xPanoramiXGetScreenSizeReply rep;
int rc;
+ REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
+
if (stuff->screen >= PanoramiXNumScreens)
return BadMatch;
- REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc; | CWE-20 | null | null |
13,935 | XineramaGetImageData(DrawablePtr *pDrawables,
int left,
int top,
int width,
int height,
unsigned int format,
unsigned long planemask,
char *data, int pitch, Bool isRoot)
{
RegionRec SrcRegion, ScreenRegion, GrabRegion;
BoxRec SrcBox, *pbox;
int x, y, w, h, i, j, nbox, size, sizeNeeded, ScratchPitch, inOut, depth;
DrawablePtr pDraw = pDrawables[0];
char *ScratchMem = NULL;
size = 0;
/* find box in logical screen space */
SrcBox.x1 = left;
SrcBox.y1 = top;
if (!isRoot) {
SrcBox.x1 += pDraw->x + screenInfo.screens[0]->x;
SrcBox.y1 += pDraw->y + screenInfo.screens[0]->y;
}
SrcBox.x2 = SrcBox.x1 + width;
SrcBox.y2 = SrcBox.y1 + height;
RegionInit(&SrcRegion, &SrcBox, 1);
RegionNull(&GrabRegion);
depth = (format == XYPixmap) ? 1 : pDraw->depth;
FOR_NSCREENS(i) {
BoxRec TheBox;
ScreenPtr pScreen;
pDraw = pDrawables[i];
pScreen = pDraw->pScreen;
TheBox.x1 = pScreen->x;
TheBox.x2 = TheBox.x1 + pScreen->width;
TheBox.y1 = pScreen->y;
TheBox.y2 = TheBox.y1 + pScreen->height;
RegionInit(&ScreenRegion, &TheBox, 1);
inOut = RegionContainsRect(&ScreenRegion, &SrcBox);
if (inOut == rgnPART)
RegionIntersect(&GrabRegion, &SrcRegion, &ScreenRegion);
RegionUninit(&ScreenRegion);
if (inOut == rgnIN) {
(*pScreen->GetImage) (pDraw,
SrcBox.x1 - pDraw->x -
screenInfo.screens[i]->x,
SrcBox.y1 - pDraw->y -
screenInfo.screens[i]->y, width, height,
format, planemask, data);
break;
}
else if (inOut == rgnOUT)
continue;
nbox = RegionNumRects(&GrabRegion);
if (nbox) {
pbox = RegionRects(&GrabRegion);
while (nbox--) {
w = pbox->x2 - pbox->x1;
h = pbox->y2 - pbox->y1;
ScratchPitch = PixmapBytePad(w, depth);
sizeNeeded = ScratchPitch * h;
if (sizeNeeded > size) {
char *tmpdata = ScratchMem;
ScratchMem = realloc(ScratchMem, sizeNeeded);
if (ScratchMem)
size = sizeNeeded;
else {
ScratchMem = tmpdata;
break;
}
}
x = pbox->x1 - pDraw->x - screenInfo.screens[i]->x;
y = pbox->y1 - pDraw->y - screenInfo.screens[i]->y;
(*pScreen->GetImage) (pDraw, x, y, w, h,
format, planemask, ScratchMem);
/* copy the memory over */
if (depth == 1) {
int k, shift, leftover, index, index2;
x = pbox->x1 - SrcBox.x1;
y = pbox->y1 - SrcBox.y1;
shift = x & 7;
x >>= 3;
leftover = w & 7;
w >>= 3;
/* clean up the edge */
if (leftover) {
int mask = (1 << leftover) - 1;
for (j = h, k = w; j--; k += ScratchPitch)
ScratchMem[k] &= mask;
}
for (j = 0, index = (pitch * y) + x, index2 = 0; j < h;
j++, index += pitch, index2 += ScratchPitch) {
if (w) {
if (!shift)
memcpy(data + index, ScratchMem + index2, w);
else
CopyBits(data + index, shift,
ScratchMem + index2, w);
}
if (leftover) {
data[index + w] |=
SHIFT_L(ScratchMem[index2 + w], shift);
if ((shift + leftover) > 8)
data[index + w + 1] |=
SHIFT_R(ScratchMem[index2 + w],
(8 - shift));
}
}
}
else {
j = BitsPerPixel(depth) >> 3;
x = (pbox->x1 - SrcBox.x1) * j;
y = pbox->y1 - SrcBox.y1;
w *= j;
for (j = 0; j < h; j++) {
memcpy(data + (pitch * (y + j)) + x,
ScratchMem + (ScratchPitch * j), w);
}
}
pbox++;
}
RegionSubtract(&SrcRegion, &SrcRegion, &GrabRegion);
if (!RegionNotEmpty(&SrcRegion))
break;
}
}
free(ScratchMem);
RegionUninit(&SrcRegion);
RegionUninit(&GrabRegion);
}
| Exec Code | 0 | XineramaGetImageData(DrawablePtr *pDrawables,
int left,
int top,
int width,
int height,
unsigned int format,
unsigned long planemask,
char *data, int pitch, Bool isRoot)
{
RegionRec SrcRegion, ScreenRegion, GrabRegion;
BoxRec SrcBox, *pbox;
int x, y, w, h, i, j, nbox, size, sizeNeeded, ScratchPitch, inOut, depth;
DrawablePtr pDraw = pDrawables[0];
char *ScratchMem = NULL;
size = 0;
/* find box in logical screen space */
SrcBox.x1 = left;
SrcBox.y1 = top;
if (!isRoot) {
SrcBox.x1 += pDraw->x + screenInfo.screens[0]->x;
SrcBox.y1 += pDraw->y + screenInfo.screens[0]->y;
}
SrcBox.x2 = SrcBox.x1 + width;
SrcBox.y2 = SrcBox.y1 + height;
RegionInit(&SrcRegion, &SrcBox, 1);
RegionNull(&GrabRegion);
depth = (format == XYPixmap) ? 1 : pDraw->depth;
FOR_NSCREENS(i) {
BoxRec TheBox;
ScreenPtr pScreen;
pDraw = pDrawables[i];
pScreen = pDraw->pScreen;
TheBox.x1 = pScreen->x;
TheBox.x2 = TheBox.x1 + pScreen->width;
TheBox.y1 = pScreen->y;
TheBox.y2 = TheBox.y1 + pScreen->height;
RegionInit(&ScreenRegion, &TheBox, 1);
inOut = RegionContainsRect(&ScreenRegion, &SrcBox);
if (inOut == rgnPART)
RegionIntersect(&GrabRegion, &SrcRegion, &ScreenRegion);
RegionUninit(&ScreenRegion);
if (inOut == rgnIN) {
(*pScreen->GetImage) (pDraw,
SrcBox.x1 - pDraw->x -
screenInfo.screens[i]->x,
SrcBox.y1 - pDraw->y -
screenInfo.screens[i]->y, width, height,
format, planemask, data);
break;
}
else if (inOut == rgnOUT)
continue;
nbox = RegionNumRects(&GrabRegion);
if (nbox) {
pbox = RegionRects(&GrabRegion);
while (nbox--) {
w = pbox->x2 - pbox->x1;
h = pbox->y2 - pbox->y1;
ScratchPitch = PixmapBytePad(w, depth);
sizeNeeded = ScratchPitch * h;
if (sizeNeeded > size) {
char *tmpdata = ScratchMem;
ScratchMem = realloc(ScratchMem, sizeNeeded);
if (ScratchMem)
size = sizeNeeded;
else {
ScratchMem = tmpdata;
break;
}
}
x = pbox->x1 - pDraw->x - screenInfo.screens[i]->x;
y = pbox->y1 - pDraw->y - screenInfo.screens[i]->y;
(*pScreen->GetImage) (pDraw, x, y, w, h,
format, planemask, ScratchMem);
/* copy the memory over */
if (depth == 1) {
int k, shift, leftover, index, index2;
x = pbox->x1 - SrcBox.x1;
y = pbox->y1 - SrcBox.y1;
shift = x & 7;
x >>= 3;
leftover = w & 7;
w >>= 3;
/* clean up the edge */
if (leftover) {
int mask = (1 << leftover) - 1;
for (j = h, k = w; j--; k += ScratchPitch)
ScratchMem[k] &= mask;
}
for (j = 0, index = (pitch * y) + x, index2 = 0; j < h;
j++, index += pitch, index2 += ScratchPitch) {
if (w) {
if (!shift)
memcpy(data + index, ScratchMem + index2, w);
else
CopyBits(data + index, shift,
ScratchMem + index2, w);
}
if (leftover) {
data[index + w] |=
SHIFT_L(ScratchMem[index2 + w], shift);
if ((shift + leftover) > 8)
data[index + w + 1] |=
SHIFT_R(ScratchMem[index2 + w],
(8 - shift));
}
}
}
else {
j = BitsPerPixel(depth) >> 3;
x = (pbox->x1 - SrcBox.x1) * j;
y = pbox->y1 - SrcBox.y1;
w *= j;
for (j = 0; j < h; j++) {
memcpy(data + (pitch * (y + j)) + x,
ScratchMem + (ScratchPitch * j), w);
}
}
pbox++;
}
RegionSubtract(&SrcRegion, &SrcRegion, &GrabRegion);
if (!RegionNotEmpty(&SrcRegion))
break;
}
}
free(ScratchMem);
RegionUninit(&SrcRegion);
RegionUninit(&GrabRegion);
}
| @@ -988,10 +988,11 @@ ProcPanoramiXGetScreenSize(ClientPtr client)
xPanoramiXGetScreenSizeReply rep;
int rc;
+ REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
+
if (stuff->screen >= PanoramiXNumScreens)
return BadMatch;
- REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc; | CWE-20 | null | null |
13,936 | XineramaRegisterConnectionBlockCallback(void (*func) (void))
{
XineramaConnectionCallbackList *newlist;
if (!(newlist = malloc(sizeof(XineramaConnectionCallbackList))))
return FALSE;
newlist->next = ConnectionCallbackList;
newlist->func = func;
ConnectionCallbackList = newlist;
return TRUE;
}
| Exec Code | 0 | XineramaRegisterConnectionBlockCallback(void (*func) (void))
{
XineramaConnectionCallbackList *newlist;
if (!(newlist = malloc(sizeof(XineramaConnectionCallbackList))))
return FALSE;
newlist->next = ConnectionCallbackList;
newlist->func = func;
ConnectionCallbackList = newlist;
return TRUE;
}
| @@ -988,10 +988,11 @@ ProcPanoramiXGetScreenSize(ClientPtr client)
xPanoramiXGetScreenSizeReply rep;
int rc;
+ REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
+
if (stuff->screen >= PanoramiXNumScreens)
return BadMatch;
- REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc; | CWE-20 | null | null |
13,937 | XineramaReinitData(void)
{
RegionUninit(&PanoramiXScreenRegion);
XineramaInitData();
}
| Exec Code | 0 | XineramaReinitData(void)
{
RegionUninit(&PanoramiXScreenRegion);
XineramaInitData();
}
| @@ -988,10 +988,11 @@ ProcPanoramiXGetScreenSize(ClientPtr client)
xPanoramiXGetScreenSizeReply rep;
int rc;
+ REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
+
if (stuff->screen >= PanoramiXNumScreens)
return BadMatch;
- REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc; | CWE-20 | null | null |
13,938 | XineramaValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDraw)
{
Xinerama_GC_FUNC_PROLOGUE(pGC);
if ((pDraw->type == DRAWABLE_WINDOW) && !(((WindowPtr) pDraw)->parent)) {
/* the root window */
int x_off = pGC->pScreen->x;
int y_off = pGC->pScreen->y;
int new_val;
new_val = pGCPriv->clipOrg.x - x_off;
if (pGC->clipOrg.x != new_val) {
pGC->clipOrg.x = new_val;
changes |= GCClipXOrigin;
}
new_val = pGCPriv->clipOrg.y - y_off;
if (pGC->clipOrg.y != new_val) {
pGC->clipOrg.y = new_val;
changes |= GCClipYOrigin;
}
new_val = pGCPriv->patOrg.x - x_off;
if (pGC->patOrg.x != new_val) {
pGC->patOrg.x = new_val;
changes |= GCTileStipXOrigin;
}
new_val = pGCPriv->patOrg.y - y_off;
if (pGC->patOrg.y != new_val) {
pGC->patOrg.y = new_val;
changes |= GCTileStipYOrigin;
}
}
else {
if (pGC->clipOrg.x != pGCPriv->clipOrg.x) {
pGC->clipOrg.x = pGCPriv->clipOrg.x;
changes |= GCClipXOrigin;
}
if (pGC->clipOrg.y != pGCPriv->clipOrg.y) {
pGC->clipOrg.y = pGCPriv->clipOrg.y;
changes |= GCClipYOrigin;
}
if (pGC->patOrg.x != pGCPriv->patOrg.x) {
pGC->patOrg.x = pGCPriv->patOrg.x;
changes |= GCTileStipXOrigin;
}
if (pGC->patOrg.y != pGCPriv->patOrg.y) {
pGC->patOrg.y = pGCPriv->patOrg.y;
changes |= GCTileStipYOrigin;
}
}
(*pGC->funcs->ValidateGC) (pGC, changes, pDraw);
Xinerama_GC_FUNC_EPILOGUE(pGC);
}
| Exec Code | 0 | XineramaValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDraw)
{
Xinerama_GC_FUNC_PROLOGUE(pGC);
if ((pDraw->type == DRAWABLE_WINDOW) && !(((WindowPtr) pDraw)->parent)) {
/* the root window */
int x_off = pGC->pScreen->x;
int y_off = pGC->pScreen->y;
int new_val;
new_val = pGCPriv->clipOrg.x - x_off;
if (pGC->clipOrg.x != new_val) {
pGC->clipOrg.x = new_val;
changes |= GCClipXOrigin;
}
new_val = pGCPriv->clipOrg.y - y_off;
if (pGC->clipOrg.y != new_val) {
pGC->clipOrg.y = new_val;
changes |= GCClipYOrigin;
}
new_val = pGCPriv->patOrg.x - x_off;
if (pGC->patOrg.x != new_val) {
pGC->patOrg.x = new_val;
changes |= GCTileStipXOrigin;
}
new_val = pGCPriv->patOrg.y - y_off;
if (pGC->patOrg.y != new_val) {
pGC->patOrg.y = new_val;
changes |= GCTileStipYOrigin;
}
}
else {
if (pGC->clipOrg.x != pGCPriv->clipOrg.x) {
pGC->clipOrg.x = pGCPriv->clipOrg.x;
changes |= GCClipXOrigin;
}
if (pGC->clipOrg.y != pGCPriv->clipOrg.y) {
pGC->clipOrg.y = pGCPriv->clipOrg.y;
changes |= GCClipYOrigin;
}
if (pGC->patOrg.x != pGCPriv->patOrg.x) {
pGC->patOrg.x = pGCPriv->patOrg.x;
changes |= GCTileStipXOrigin;
}
if (pGC->patOrg.y != pGCPriv->patOrg.y) {
pGC->patOrg.y = pGCPriv->patOrg.y;
changes |= GCTileStipYOrigin;
}
}
(*pGC->funcs->ValidateGC) (pGC, changes, pDraw);
Xinerama_GC_FUNC_EPILOGUE(pGC);
}
| @@ -988,10 +988,11 @@ ProcPanoramiXGetScreenSize(ClientPtr client)
xPanoramiXGetScreenSizeReply rep;
int rc;
+ REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
+
if (stuff->screen >= PanoramiXNumScreens)
return BadMatch;
- REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc; | CWE-20 | null | null |
13,939 | CheckScreenPrivate(ScreenPtr pScreen)
{
SetupScreen(pScreen);
if (!pPriv)
return;
if (!pPriv->attr && !pPriv->events &&
!pPriv->hasWindow && pPriv->installedMap == None) {
free(pPriv);
SetScreenPrivate(pScreen, NULL);
pScreen->screensaver.ExternalScreenSaver = NULL;
}
}
| Exec Code | 0 | CheckScreenPrivate(ScreenPtr pScreen)
{
SetupScreen(pScreen);
if (!pPriv)
return;
if (!pPriv->attr && !pPriv->events &&
!pPriv->hasWindow && pPriv->installedMap == None) {
free(pPriv);
SetScreenPrivate(pScreen, NULL);
pScreen->screensaver.ExternalScreenSaver = NULL;
}
}
| @@ -1186,6 +1186,8 @@ ProcScreenSaverUnsetAttributes(ClientPtr client)
PanoramiXRes *draw;
int rc, i;
+ REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq);
+
rc = dixLookupResourceByClass((void **) &draw, stuff->drawable,
XRC_DRAWABLE, client, DixWriteAccess);
if (rc != Success) | CWE-20 | null | null |
13,940 | CreateSaverWindow(ScreenPtr pScreen)
{
SetupScreen(pScreen);
ScreenSaverStuffPtr pSaver;
ScreenSaverAttrPtr pAttr;
WindowPtr pWin;
int result;
unsigned long mask;
Colormap wantMap;
ColormapPtr pCmap;
pSaver = &pScreen->screensaver;
if (pSaver->pWindow) {
pSaver->pWindow = NullWindow;
FreeResource(pSaver->wid, RT_NONE);
if (pPriv) {
UninstallSaverColormap(pScreen);
pPriv->hasWindow = FALSE;
CheckScreenPrivate(pScreen);
}
}
if (!pPriv || !(pAttr = pPriv->attr))
return FALSE;
pPriv->installedMap = None;
if (GrabInProgress && GrabInProgress != pAttr->client->index)
return FALSE;
pWin = CreateWindow(pSaver->wid, pScreen->root,
pAttr->x, pAttr->y, pAttr->width, pAttr->height,
pAttr->borderWidth, pAttr->class,
pAttr->mask, (XID *) pAttr->values,
pAttr->depth, serverClient, pAttr->visual, &result);
if (!pWin)
return FALSE;
if (!AddResource(pWin->drawable.id, RT_WINDOW, pWin))
return FALSE;
mask = 0;
if (pAttr->pBackgroundPixmap) {
pWin->backgroundState = BackgroundPixmap;
pWin->background.pixmap = pAttr->pBackgroundPixmap;
pAttr->pBackgroundPixmap->refcnt++;
mask |= CWBackPixmap;
}
if (pAttr->pBorderPixmap) {
pWin->borderIsPixel = FALSE;
pWin->border.pixmap = pAttr->pBorderPixmap;
pAttr->pBorderPixmap->refcnt++;
mask |= CWBorderPixmap;
}
if (pAttr->pCursor) {
CursorPtr cursor;
if (!pWin->optional)
if (!MakeWindowOptional(pWin)) {
FreeResource(pWin->drawable.id, RT_NONE);
return FALSE;
}
cursor = RefCursor(pAttr->pCursor);
if (pWin->optional->cursor)
FreeCursor(pWin->optional->cursor, (Cursor) 0);
pWin->optional->cursor = cursor;
pWin->cursorIsNone = FALSE;
CheckWindowOptionalNeed(pWin);
mask |= CWCursor;
}
if (mask)
(*pScreen->ChangeWindowAttributes) (pWin, mask);
if (pAttr->colormap != None)
(void) ChangeWindowAttributes(pWin, CWColormap, &pAttr->colormap,
serverClient);
MapWindow(pWin, serverClient);
pPriv->hasWindow = TRUE;
pSaver->pWindow = pWin;
/* check and install our own colormap if it isn't installed now */
wantMap = wColormap(pWin);
if (wantMap == None || IsMapInstalled(wantMap, pWin))
return TRUE;
result = dixLookupResourceByType((void **) &pCmap, wantMap, RT_COLORMAP,
serverClient, DixInstallAccess);
if (result != Success)
return TRUE;
pPriv->installedMap = wantMap;
(*pCmap->pScreen->InstallColormap) (pCmap);
return TRUE;
}
| Exec Code | 0 | CreateSaverWindow(ScreenPtr pScreen)
{
SetupScreen(pScreen);
ScreenSaverStuffPtr pSaver;
ScreenSaverAttrPtr pAttr;
WindowPtr pWin;
int result;
unsigned long mask;
Colormap wantMap;
ColormapPtr pCmap;
pSaver = &pScreen->screensaver;
if (pSaver->pWindow) {
pSaver->pWindow = NullWindow;
FreeResource(pSaver->wid, RT_NONE);
if (pPriv) {
UninstallSaverColormap(pScreen);
pPriv->hasWindow = FALSE;
CheckScreenPrivate(pScreen);
}
}
if (!pPriv || !(pAttr = pPriv->attr))
return FALSE;
pPriv->installedMap = None;
if (GrabInProgress && GrabInProgress != pAttr->client->index)
return FALSE;
pWin = CreateWindow(pSaver->wid, pScreen->root,
pAttr->x, pAttr->y, pAttr->width, pAttr->height,
pAttr->borderWidth, pAttr->class,
pAttr->mask, (XID *) pAttr->values,
pAttr->depth, serverClient, pAttr->visual, &result);
if (!pWin)
return FALSE;
if (!AddResource(pWin->drawable.id, RT_WINDOW, pWin))
return FALSE;
mask = 0;
if (pAttr->pBackgroundPixmap) {
pWin->backgroundState = BackgroundPixmap;
pWin->background.pixmap = pAttr->pBackgroundPixmap;
pAttr->pBackgroundPixmap->refcnt++;
mask |= CWBackPixmap;
}
if (pAttr->pBorderPixmap) {
pWin->borderIsPixel = FALSE;
pWin->border.pixmap = pAttr->pBorderPixmap;
pAttr->pBorderPixmap->refcnt++;
mask |= CWBorderPixmap;
}
if (pAttr->pCursor) {
CursorPtr cursor;
if (!pWin->optional)
if (!MakeWindowOptional(pWin)) {
FreeResource(pWin->drawable.id, RT_NONE);
return FALSE;
}
cursor = RefCursor(pAttr->pCursor);
if (pWin->optional->cursor)
FreeCursor(pWin->optional->cursor, (Cursor) 0);
pWin->optional->cursor = cursor;
pWin->cursorIsNone = FALSE;
CheckWindowOptionalNeed(pWin);
mask |= CWCursor;
}
if (mask)
(*pScreen->ChangeWindowAttributes) (pWin, mask);
if (pAttr->colormap != None)
(void) ChangeWindowAttributes(pWin, CWColormap, &pAttr->colormap,
serverClient);
MapWindow(pWin, serverClient);
pPriv->hasWindow = TRUE;
pSaver->pWindow = pWin;
/* check and install our own colormap if it isn't installed now */
wantMap = wColormap(pWin);
if (wantMap == None || IsMapInstalled(wantMap, pWin))
return TRUE;
result = dixLookupResourceByType((void **) &pCmap, wantMap, RT_COLORMAP,
serverClient, DixInstallAccess);
if (result != Success)
return TRUE;
pPriv->installedMap = wantMap;
(*pCmap->pScreen->InstallColormap) (pCmap);
return TRUE;
}
| @@ -1186,6 +1186,8 @@ ProcScreenSaverUnsetAttributes(ClientPtr client)
PanoramiXRes *draw;
int rc, i;
+ REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq);
+
rc = dixLookupResourceByClass((void **) &draw, stuff->drawable,
XRC_DRAWABLE, client, DixWriteAccess);
if (rc != Success) | CWE-20 | null | null |
13,941 | DestroySaverWindow(ScreenPtr pScreen)
{
SetupScreen(pScreen);
ScreenSaverStuffPtr pSaver;
if (!pPriv || !pPriv->hasWindow)
return FALSE;
pSaver = &pScreen->screensaver;
if (pSaver->pWindow) {
pSaver->pWindow = NullWindow;
FreeResource(pSaver->wid, RT_NONE);
}
pPriv->hasWindow = FALSE;
CheckScreenPrivate(pScreen);
UninstallSaverColormap(pScreen);
return TRUE;
}
| Exec Code | 0 | DestroySaverWindow(ScreenPtr pScreen)
{
SetupScreen(pScreen);
ScreenSaverStuffPtr pSaver;
if (!pPriv || !pPriv->hasWindow)
return FALSE;
pSaver = &pScreen->screensaver;
if (pSaver->pWindow) {
pSaver->pWindow = NullWindow;
FreeResource(pSaver->wid, RT_NONE);
}
pPriv->hasWindow = FALSE;
CheckScreenPrivate(pScreen);
UninstallSaverColormap(pScreen);
return TRUE;
}
| @@ -1186,6 +1186,8 @@ ProcScreenSaverUnsetAttributes(ClientPtr client)
PanoramiXRes *draw;
int rc, i;
+ REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq);
+
rc = dixLookupResourceByClass((void **) &draw, stuff->drawable,
XRC_DRAWABLE, client, DixWriteAccess);
if (rc != Success) | CWE-20 | null | null |
13,942 | FreeAttrs(ScreenSaverAttrPtr pAttr)
{
PixmapPtr pPixmap;
CursorPtr pCursor;
if ((pPixmap = pAttr->pBackgroundPixmap) != 0)
(*pPixmap->drawable.pScreen->DestroyPixmap) (pPixmap);
if ((pPixmap = pAttr->pBorderPixmap) != 0)
(*pPixmap->drawable.pScreen->DestroyPixmap) (pPixmap);
if ((pCursor = pAttr->pCursor) != 0)
FreeCursor(pCursor, (Cursor) 0);
}
| Exec Code | 0 | FreeAttrs(ScreenSaverAttrPtr pAttr)
{
PixmapPtr pPixmap;
CursorPtr pCursor;
if ((pPixmap = pAttr->pBackgroundPixmap) != 0)
(*pPixmap->drawable.pScreen->DestroyPixmap) (pPixmap);
if ((pPixmap = pAttr->pBorderPixmap) != 0)
(*pPixmap->drawable.pScreen->DestroyPixmap) (pPixmap);
if ((pCursor = pAttr->pCursor) != 0)
FreeCursor(pCursor, (Cursor) 0);
}
| @@ -1186,6 +1186,8 @@ ProcScreenSaverUnsetAttributes(ClientPtr client)
PanoramiXRes *draw;
int rc, i;
+ REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq);
+
rc = dixLookupResourceByClass((void **) &draw, stuff->drawable,
XRC_DRAWABLE, client, DixWriteAccess);
if (rc != Success) | CWE-20 | null | null |
13,943 | MakeScreenPrivate(ScreenPtr pScreen)
{
SetupScreen(pScreen);
if (pPriv)
return pPriv;
pPriv = New(ScreenSaverScreenPrivateRec);
if (!pPriv)
return 0;
pPriv->events = 0;
pPriv->attr = 0;
pPriv->hasWindow = FALSE;
pPriv->installedMap = None;
SetScreenPrivate(pScreen, pPriv);
pScreen->screensaver.ExternalScreenSaver = ScreenSaverHandle;
return pPriv;
}
| Exec Code | 0 | MakeScreenPrivate(ScreenPtr pScreen)
{
SetupScreen(pScreen);
if (pPriv)
return pPriv;
pPriv = New(ScreenSaverScreenPrivateRec);
if (!pPriv)
return 0;
pPriv->events = 0;
pPriv->attr = 0;
pPriv->hasWindow = FALSE;
pPriv->installedMap = None;
SetScreenPrivate(pScreen, pPriv);
pScreen->screensaver.ExternalScreenSaver = ScreenSaverHandle;
return pPriv;
}
| @@ -1186,6 +1186,8 @@ ProcScreenSaverUnsetAttributes(ClientPtr client)
PanoramiXRes *draw;
int rc, i;
+ REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq);
+
rc = dixLookupResourceByClass((void **) &draw, stuff->drawable,
XRC_DRAWABLE, client, DixWriteAccess);
if (rc != Success) | CWE-20 | null | null |
13,944 | ProcScreenSaverDispatch(ClientPtr client)
{
REQUEST(xReq);
if (stuff->data < NUM_REQUESTS)
return (*NormalVector[stuff->data]) (client);
return BadRequest;
}
| Exec Code | 0 | ProcScreenSaverDispatch(ClientPtr client)
{
REQUEST(xReq);
if (stuff->data < NUM_REQUESTS)
return (*NormalVector[stuff->data]) (client);
return BadRequest;
}
| @@ -1186,6 +1186,8 @@ ProcScreenSaverUnsetAttributes(ClientPtr client)
PanoramiXRes *draw;
int rc, i;
+ REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq);
+
rc = dixLookupResourceByClass((void **) &draw, stuff->drawable,
XRC_DRAWABLE, client, DixWriteAccess);
if (rc != Success) | CWE-20 | null | null |
13,945 | ProcScreenSaverQueryInfo(ClientPtr client)
{
REQUEST(xScreenSaverQueryInfoReq);
xScreenSaverQueryInfoReply rep;
int rc;
ScreenSaverStuffPtr pSaver;
DrawablePtr pDraw;
CARD32 lastInput;
ScreenSaverScreenPrivatePtr pPriv;
REQUEST_SIZE_MATCH(xScreenSaverQueryInfoReq);
rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0,
DixGetAttrAccess);
if (rc != Success)
return rc;
rc = XaceHook(XACE_SCREENSAVER_ACCESS, client, pDraw->pScreen,
DixGetAttrAccess);
if (rc != Success)
return rc;
pSaver = &pDraw->pScreen->screensaver;
pPriv = GetScreenPrivate(pDraw->pScreen);
UpdateCurrentTime();
lastInput = GetTimeInMillis() - LastEventTime(XIAllDevices).milliseconds;
rep = (xScreenSaverQueryInfoReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.window = pSaver->wid
};
if (screenIsSaved != SCREEN_SAVER_OFF) {
rep.state = ScreenSaverOn;
if (ScreenSaverTime)
rep.tilOrSince = lastInput - ScreenSaverTime;
else
rep.tilOrSince = 0;
}
else {
if (ScreenSaverTime) {
rep.state = ScreenSaverOff;
if (ScreenSaverTime < lastInput)
rep.tilOrSince = 0;
else
rep.tilOrSince = ScreenSaverTime - lastInput;
}
else {
rep.state = ScreenSaverDisabled;
rep.tilOrSince = 0;
}
}
rep.idle = lastInput;
rep.eventMask = getEventMask(pDraw->pScreen, client);
if (pPriv && pPriv->attr)
rep.kind = ScreenSaverExternal;
else if (ScreenSaverBlanking != DontPreferBlanking)
rep.kind = ScreenSaverBlanked;
else
rep.kind = ScreenSaverInternal;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.window);
swapl(&rep.tilOrSince);
swapl(&rep.idle);
swapl(&rep.eventMask);
}
WriteToClient(client, sizeof(xScreenSaverQueryInfoReply), &rep);
return Success;
}
| Exec Code | 0 | ProcScreenSaverQueryInfo(ClientPtr client)
{
REQUEST(xScreenSaverQueryInfoReq);
xScreenSaverQueryInfoReply rep;
int rc;
ScreenSaverStuffPtr pSaver;
DrawablePtr pDraw;
CARD32 lastInput;
ScreenSaverScreenPrivatePtr pPriv;
REQUEST_SIZE_MATCH(xScreenSaverQueryInfoReq);
rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0,
DixGetAttrAccess);
if (rc != Success)
return rc;
rc = XaceHook(XACE_SCREENSAVER_ACCESS, client, pDraw->pScreen,
DixGetAttrAccess);
if (rc != Success)
return rc;
pSaver = &pDraw->pScreen->screensaver;
pPriv = GetScreenPrivate(pDraw->pScreen);
UpdateCurrentTime();
lastInput = GetTimeInMillis() - LastEventTime(XIAllDevices).milliseconds;
rep = (xScreenSaverQueryInfoReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.window = pSaver->wid
};
if (screenIsSaved != SCREEN_SAVER_OFF) {
rep.state = ScreenSaverOn;
if (ScreenSaverTime)
rep.tilOrSince = lastInput - ScreenSaverTime;
else
rep.tilOrSince = 0;
}
else {
if (ScreenSaverTime) {
rep.state = ScreenSaverOff;
if (ScreenSaverTime < lastInput)
rep.tilOrSince = 0;
else
rep.tilOrSince = ScreenSaverTime - lastInput;
}
else {
rep.state = ScreenSaverDisabled;
rep.tilOrSince = 0;
}
}
rep.idle = lastInput;
rep.eventMask = getEventMask(pDraw->pScreen, client);
if (pPriv && pPriv->attr)
rep.kind = ScreenSaverExternal;
else if (ScreenSaverBlanking != DontPreferBlanking)
rep.kind = ScreenSaverBlanked;
else
rep.kind = ScreenSaverInternal;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.window);
swapl(&rep.tilOrSince);
swapl(&rep.idle);
swapl(&rep.eventMask);
}
WriteToClient(client, sizeof(xScreenSaverQueryInfoReply), &rep);
return Success;
}
| @@ -1186,6 +1186,8 @@ ProcScreenSaverUnsetAttributes(ClientPtr client)
PanoramiXRes *draw;
int rc, i;
+ REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq);
+
rc = dixLookupResourceByClass((void **) &draw, stuff->drawable,
XRC_DRAWABLE, client, DixWriteAccess);
if (rc != Success) | CWE-20 | null | null |
13,946 | ProcScreenSaverSelectInput(ClientPtr client)
{
REQUEST(xScreenSaverSelectInputReq);
DrawablePtr pDraw;
int rc;
REQUEST_SIZE_MATCH(xScreenSaverSelectInputReq);
rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0,
DixGetAttrAccess);
if (rc != Success)
return rc;
rc = XaceHook(XACE_SCREENSAVER_ACCESS, client, pDraw->pScreen,
DixSetAttrAccess);
if (rc != Success)
return rc;
if (!setEventMask(pDraw->pScreen, client, stuff->eventMask))
return BadAlloc;
return Success;
}
| Exec Code | 0 | ProcScreenSaverSelectInput(ClientPtr client)
{
REQUEST(xScreenSaverSelectInputReq);
DrawablePtr pDraw;
int rc;
REQUEST_SIZE_MATCH(xScreenSaverSelectInputReq);
rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0,
DixGetAttrAccess);
if (rc != Success)
return rc;
rc = XaceHook(XACE_SCREENSAVER_ACCESS, client, pDraw->pScreen,
DixSetAttrAccess);
if (rc != Success)
return rc;
if (!setEventMask(pDraw->pScreen, client, stuff->eventMask))
return BadAlloc;
return Success;
}
| @@ -1186,6 +1186,8 @@ ProcScreenSaverUnsetAttributes(ClientPtr client)
PanoramiXRes *draw;
int rc, i;
+ REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq);
+
rc = dixLookupResourceByClass((void **) &draw, stuff->drawable,
XRC_DRAWABLE, client, DixWriteAccess);
if (rc != Success) | CWE-20 | null | null |
13,947 | ProcScreenSaverSetAttributes(ClientPtr client)
{
#ifdef PANORAMIX
if (!noPanoramiXExtension) {
REQUEST(xScreenSaverSetAttributesReq);
PanoramiXRes *draw;
PanoramiXRes *backPix = NULL;
PanoramiXRes *bordPix = NULL;
PanoramiXRes *cmap = NULL;
int i, status, len;
int pback_offset = 0, pbord_offset = 0, cmap_offset = 0;
XID orig_visual, tmp;
REQUEST_AT_LEAST_SIZE(xScreenSaverSetAttributesReq);
status = dixLookupResourceByClass((void **) &draw, stuff->drawable,
XRC_DRAWABLE, client, DixWriteAccess);
if (status != Success)
return (status == BadValue) ? BadDrawable : status;
len =
stuff->length -
bytes_to_int32(sizeof(xScreenSaverSetAttributesReq));
if (Ones(stuff->mask) != len)
return BadLength;
if ((Mask) stuff->mask & CWBackPixmap) {
pback_offset = Ones((Mask) stuff->mask & (CWBackPixmap - 1));
tmp = *((CARD32 *) &stuff[1] + pback_offset);
if ((tmp != None) && (tmp != ParentRelative)) {
status = dixLookupResourceByType((void **) &backPix, tmp,
XRT_PIXMAP, client,
DixReadAccess);
if (status != Success)
return status;
}
}
if ((Mask) stuff->mask & CWBorderPixmap) {
pbord_offset = Ones((Mask) stuff->mask & (CWBorderPixmap - 1));
tmp = *((CARD32 *) &stuff[1] + pbord_offset);
if (tmp != CopyFromParent) {
status = dixLookupResourceByType((void **) &bordPix, tmp,
XRT_PIXMAP, client,
DixReadAccess);
if (status != Success)
return status;
}
}
if ((Mask) stuff->mask & CWColormap) {
cmap_offset = Ones((Mask) stuff->mask & (CWColormap - 1));
tmp = *((CARD32 *) &stuff[1] + cmap_offset);
if (tmp != CopyFromParent) {
status = dixLookupResourceByType((void **) &cmap, tmp,
XRT_COLORMAP, client,
DixReadAccess);
if (status != Success)
return status;
}
}
orig_visual = stuff->visualID;
FOR_NSCREENS_BACKWARD(i) {
stuff->drawable = draw->info[i].id;
if (backPix)
*((CARD32 *) &stuff[1] + pback_offset) = backPix->info[i].id;
if (bordPix)
*((CARD32 *) &stuff[1] + pbord_offset) = bordPix->info[i].id;
if (cmap)
*((CARD32 *) &stuff[1] + cmap_offset) = cmap->info[i].id;
if (orig_visual != CopyFromParent)
stuff->visualID = PanoramiXTranslateVisualID(i, orig_visual);
status = ScreenSaverSetAttributes(client);
}
return status;
}
#endif
return ScreenSaverSetAttributes(client);
}
| Exec Code | 0 | ProcScreenSaverSetAttributes(ClientPtr client)
{
#ifdef PANORAMIX
if (!noPanoramiXExtension) {
REQUEST(xScreenSaverSetAttributesReq);
PanoramiXRes *draw;
PanoramiXRes *backPix = NULL;
PanoramiXRes *bordPix = NULL;
PanoramiXRes *cmap = NULL;
int i, status, len;
int pback_offset = 0, pbord_offset = 0, cmap_offset = 0;
XID orig_visual, tmp;
REQUEST_AT_LEAST_SIZE(xScreenSaverSetAttributesReq);
status = dixLookupResourceByClass((void **) &draw, stuff->drawable,
XRC_DRAWABLE, client, DixWriteAccess);
if (status != Success)
return (status == BadValue) ? BadDrawable : status;
len =
stuff->length -
bytes_to_int32(sizeof(xScreenSaverSetAttributesReq));
if (Ones(stuff->mask) != len)
return BadLength;
if ((Mask) stuff->mask & CWBackPixmap) {
pback_offset = Ones((Mask) stuff->mask & (CWBackPixmap - 1));
tmp = *((CARD32 *) &stuff[1] + pback_offset);
if ((tmp != None) && (tmp != ParentRelative)) {
status = dixLookupResourceByType((void **) &backPix, tmp,
XRT_PIXMAP, client,
DixReadAccess);
if (status != Success)
return status;
}
}
if ((Mask) stuff->mask & CWBorderPixmap) {
pbord_offset = Ones((Mask) stuff->mask & (CWBorderPixmap - 1));
tmp = *((CARD32 *) &stuff[1] + pbord_offset);
if (tmp != CopyFromParent) {
status = dixLookupResourceByType((void **) &bordPix, tmp,
XRT_PIXMAP, client,
DixReadAccess);
if (status != Success)
return status;
}
}
if ((Mask) stuff->mask & CWColormap) {
cmap_offset = Ones((Mask) stuff->mask & (CWColormap - 1));
tmp = *((CARD32 *) &stuff[1] + cmap_offset);
if (tmp != CopyFromParent) {
status = dixLookupResourceByType((void **) &cmap, tmp,
XRT_COLORMAP, client,
DixReadAccess);
if (status != Success)
return status;
}
}
orig_visual = stuff->visualID;
FOR_NSCREENS_BACKWARD(i) {
stuff->drawable = draw->info[i].id;
if (backPix)
*((CARD32 *) &stuff[1] + pback_offset) = backPix->info[i].id;
if (bordPix)
*((CARD32 *) &stuff[1] + pbord_offset) = bordPix->info[i].id;
if (cmap)
*((CARD32 *) &stuff[1] + cmap_offset) = cmap->info[i].id;
if (orig_visual != CopyFromParent)
stuff->visualID = PanoramiXTranslateVisualID(i, orig_visual);
status = ScreenSaverSetAttributes(client);
}
return status;
}
#endif
return ScreenSaverSetAttributes(client);
}
| @@ -1186,6 +1186,8 @@ ProcScreenSaverUnsetAttributes(ClientPtr client)
PanoramiXRes *draw;
int rc, i;
+ REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq);
+
rc = dixLookupResourceByClass((void **) &draw, stuff->drawable,
XRC_DRAWABLE, client, DixWriteAccess);
if (rc != Success) | CWE-20 | null | null |
13,948 | ProcScreenSaverSuspend(ClientPtr client)
{
ScreenSaverSuspensionPtr *prev, this;
REQUEST(xScreenSaverSuspendReq);
REQUEST_SIZE_MATCH(xScreenSaverSuspendReq);
/* Check if this client is suspending the screensaver */
for (prev = &suspendingClients; (this = *prev); prev = &this->next)
if (this->pClient == client)
break;
if (this) {
if (stuff->suspend == TRUE)
this->count++;
else if (--this->count == 0)
FreeResource(this->clientResource, RT_NONE);
return Success;
}
/* If we get to this point, this client isn't suspending the screensaver */
if (stuff->suspend == FALSE)
return Success;
/*
* Allocate a suspension record for the client, and stop the screensaver
* if it isn't already suspended by another client. We attach a resource ID
* to the record, so the screensaver will be reenabled and the record freed
* if the client disconnects without reenabling it first.
*/
this = malloc(sizeof(ScreenSaverSuspensionRec));
if (!this)
return BadAlloc;
this->next = NULL;
this->pClient = client;
this->count = 1;
this->clientResource = FakeClientID(client->index);
if (!AddResource(this->clientResource, SuspendType, (void *) this)) {
free(this);
return BadAlloc;
}
*prev = this;
if (!screenSaverSuspended) {
screenSaverSuspended = TRUE;
FreeScreenSaverTimer();
}
return Success;
}
| Exec Code | 0 | ProcScreenSaverSuspend(ClientPtr client)
{
ScreenSaverSuspensionPtr *prev, this;
REQUEST(xScreenSaverSuspendReq);
REQUEST_SIZE_MATCH(xScreenSaverSuspendReq);
/* Check if this client is suspending the screensaver */
for (prev = &suspendingClients; (this = *prev); prev = &this->next)
if (this->pClient == client)
break;
if (this) {
if (stuff->suspend == TRUE)
this->count++;
else if (--this->count == 0)
FreeResource(this->clientResource, RT_NONE);
return Success;
}
/* If we get to this point, this client isn't suspending the screensaver */
if (stuff->suspend == FALSE)
return Success;
/*
* Allocate a suspension record for the client, and stop the screensaver
* if it isn't already suspended by another client. We attach a resource ID
* to the record, so the screensaver will be reenabled and the record freed
* if the client disconnects without reenabling it first.
*/
this = malloc(sizeof(ScreenSaverSuspensionRec));
if (!this)
return BadAlloc;
this->next = NULL;
this->pClient = client;
this->count = 1;
this->clientResource = FakeClientID(client->index);
if (!AddResource(this->clientResource, SuspendType, (void *) this)) {
free(this);
return BadAlloc;
}
*prev = this;
if (!screenSaverSuspended) {
screenSaverSuspended = TRUE;
FreeScreenSaverTimer();
}
return Success;
}
| @@ -1186,6 +1186,8 @@ ProcScreenSaverUnsetAttributes(ClientPtr client)
PanoramiXRes *draw;
int rc, i;
+ REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq);
+
rc = dixLookupResourceByClass((void **) &draw, stuff->drawable,
XRC_DRAWABLE, client, DixWriteAccess);
if (rc != Success) | CWE-20 | null | null |
13,949 | SProcScreenSaverDispatch(ClientPtr client)
{
REQUEST(xReq);
if (stuff->data < NUM_REQUESTS)
return (*SwappedVector[stuff->data]) (client);
return BadRequest;
}
| Exec Code | 0 | SProcScreenSaverDispatch(ClientPtr client)
{
REQUEST(xReq);
if (stuff->data < NUM_REQUESTS)
return (*SwappedVector[stuff->data]) (client);
return BadRequest;
}
| @@ -1186,6 +1186,8 @@ ProcScreenSaverUnsetAttributes(ClientPtr client)
PanoramiXRes *draw;
int rc, i;
+ REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq);
+
rc = dixLookupResourceByClass((void **) &draw, stuff->drawable,
XRC_DRAWABLE, client, DixWriteAccess);
if (rc != Success) | CWE-20 | null | null |
13,950 | SProcScreenSaverQueryInfo(ClientPtr client)
{
REQUEST(xScreenSaverQueryInfoReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xScreenSaverQueryInfoReq);
swapl(&stuff->drawable);
return ProcScreenSaverQueryInfo(client);
}
| Exec Code | 0 | SProcScreenSaverQueryInfo(ClientPtr client)
{
REQUEST(xScreenSaverQueryInfoReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xScreenSaverQueryInfoReq);
swapl(&stuff->drawable);
return ProcScreenSaverQueryInfo(client);
}
| @@ -1186,6 +1186,8 @@ ProcScreenSaverUnsetAttributes(ClientPtr client)
PanoramiXRes *draw;
int rc, i;
+ REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq);
+
rc = dixLookupResourceByClass((void **) &draw, stuff->drawable,
XRC_DRAWABLE, client, DixWriteAccess);
if (rc != Success) | CWE-20 | null | null |
13,951 | SProcScreenSaverQueryVersion(ClientPtr client)
{
REQUEST(xScreenSaverQueryVersionReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xScreenSaverQueryVersionReq);
return ProcScreenSaverQueryVersion(client);
}
| Exec Code | 0 | SProcScreenSaverQueryVersion(ClientPtr client)
{
REQUEST(xScreenSaverQueryVersionReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xScreenSaverQueryVersionReq);
return ProcScreenSaverQueryVersion(client);
}
| @@ -1186,6 +1186,8 @@ ProcScreenSaverUnsetAttributes(ClientPtr client)
PanoramiXRes *draw;
int rc, i;
+ REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq);
+
rc = dixLookupResourceByClass((void **) &draw, stuff->drawable,
XRC_DRAWABLE, client, DixWriteAccess);
if (rc != Success) | CWE-20 | null | null |
13,952 | SProcScreenSaverSuspend(ClientPtr client)
{
REQUEST(xScreenSaverSuspendReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xScreenSaverSuspendReq);
return ProcScreenSaverSuspend(client);
}
| Exec Code | 0 | SProcScreenSaverSuspend(ClientPtr client)
{
REQUEST(xScreenSaverSuspendReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xScreenSaverSuspendReq);
return ProcScreenSaverSuspend(client);
}
| @@ -1186,6 +1186,8 @@ ProcScreenSaverUnsetAttributes(ClientPtr client)
PanoramiXRes *draw;
int rc, i;
+ REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq);
+
rc = dixLookupResourceByClass((void **) &draw, stuff->drawable,
XRC_DRAWABLE, client, DixWriteAccess);
if (rc != Success) | CWE-20 | null | null |
13,953 | SScreenSaverNotifyEvent(xScreenSaverNotifyEvent * from,
xScreenSaverNotifyEvent * to)
{
to->type = from->type;
to->state = from->state;
cpswaps(from->sequenceNumber, to->sequenceNumber);
cpswapl(from->timestamp, to->timestamp);
cpswapl(from->root, to->root);
cpswapl(from->window, to->window);
to->kind = from->kind;
to->forced = from->forced;
}
| Exec Code | 0 | SScreenSaverNotifyEvent(xScreenSaverNotifyEvent * from,
xScreenSaverNotifyEvent * to)
{
to->type = from->type;
to->state = from->state;
cpswaps(from->sequenceNumber, to->sequenceNumber);
cpswapl(from->timestamp, to->timestamp);
cpswapl(from->root, to->root);
cpswapl(from->window, to->window);
to->kind = from->kind;
to->forced = from->forced;
}
| @@ -1186,6 +1186,8 @@ ProcScreenSaverUnsetAttributes(ClientPtr client)
PanoramiXRes *draw;
int rc, i;
+ REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq);
+
rc = dixLookupResourceByClass((void **) &draw, stuff->drawable,
XRC_DRAWABLE, client, DixWriteAccess);
if (rc != Success) | CWE-20 | null | null |
13,954 | ScreenSaverFreeAttr(void *value, XID id)
{
ScreenSaverAttrPtr pOldAttr = (ScreenSaverAttrPtr) value;
ScreenPtr pScreen = pOldAttr->screen;
SetupScreen(pScreen);
if (!pPriv)
return TRUE;
if (pPriv->attr != pOldAttr)
return TRUE;
FreeScreenAttr(pOldAttr);
pPriv->attr = NULL;
if (pPriv->hasWindow) {
dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset);
dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverActive);
}
CheckScreenPrivate(pScreen);
return TRUE;
}
| Exec Code | 0 | ScreenSaverFreeAttr(void *value, XID id)
{
ScreenSaverAttrPtr pOldAttr = (ScreenSaverAttrPtr) value;
ScreenPtr pScreen = pOldAttr->screen;
SetupScreen(pScreen);
if (!pPriv)
return TRUE;
if (pPriv->attr != pOldAttr)
return TRUE;
FreeScreenAttr(pOldAttr);
pPriv->attr = NULL;
if (pPriv->hasWindow) {
dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset);
dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverActive);
}
CheckScreenPrivate(pScreen);
return TRUE;
}
| @@ -1186,6 +1186,8 @@ ProcScreenSaverUnsetAttributes(ClientPtr client)
PanoramiXRes *draw;
int rc, i;
+ REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq);
+
rc = dixLookupResourceByClass((void **) &draw, stuff->drawable,
XRC_DRAWABLE, client, DixWriteAccess);
if (rc != Success) | CWE-20 | null | null |
13,955 | ScreenSaverFreeEvents(void *value, XID id)
{
ScreenSaverEventPtr pOld = (ScreenSaverEventPtr) value;
ScreenPtr pScreen = pOld->screen;
SetupScreen(pScreen);
ScreenSaverEventPtr pEv, *pPrev;
if (!pPriv)
return TRUE;
for (pPrev = &pPriv->events; (pEv = *pPrev) != 0; pPrev = &pEv->next)
if (pEv == pOld)
break;
if (!pEv)
return TRUE;
*pPrev = pEv->next;
free(pEv);
CheckScreenPrivate(pScreen);
return TRUE;
}
| Exec Code | 0 | ScreenSaverFreeEvents(void *value, XID id)
{
ScreenSaverEventPtr pOld = (ScreenSaverEventPtr) value;
ScreenPtr pScreen = pOld->screen;
SetupScreen(pScreen);
ScreenSaverEventPtr pEv, *pPrev;
if (!pPriv)
return TRUE;
for (pPrev = &pPriv->events; (pEv = *pPrev) != 0; pPrev = &pEv->next)
if (pEv == pOld)
break;
if (!pEv)
return TRUE;
*pPrev = pEv->next;
free(pEv);
CheckScreenPrivate(pScreen);
return TRUE;
}
| @@ -1186,6 +1186,8 @@ ProcScreenSaverUnsetAttributes(ClientPtr client)
PanoramiXRes *draw;
int rc, i;
+ REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq);
+
rc = dixLookupResourceByClass((void **) &draw, stuff->drawable,
XRC_DRAWABLE, client, DixWriteAccess);
if (rc != Success) | CWE-20 | null | null |
13,956 | ScreenSaverFreeSuspend(void *value, XID id)
{
ScreenSaverSuspensionPtr data = (ScreenSaverSuspensionPtr) value;
ScreenSaverSuspensionPtr *prev, this;
/* Unlink and free the suspension record for the client */
for (prev = &suspendingClients; (this = *prev); prev = &this->next) {
if (this == data) {
*prev = this->next;
free(this);
break;
}
}
/* Reenable the screensaver if this was the last client suspending it. */
if (screenSaverSuspended && suspendingClients == NULL) {
screenSaverSuspended = FALSE;
/* The screensaver could be active, since suspending it (by design)
doesn't prevent it from being forceably activated */
#ifdef DPMSExtension
if (screenIsSaved != SCREEN_SAVER_ON && DPMSPowerLevel == DPMSModeOn)
#else
if (screenIsSaved != SCREEN_SAVER_ON)
#endif
{
DeviceIntPtr dev;
UpdateCurrentTimeIf();
nt_list_for_each_entry(dev, inputInfo.devices, next)
NoticeTime(dev, currentTime);
SetScreenSaverTimer();
}
}
return Success;
}
| Exec Code | 0 | ScreenSaverFreeSuspend(void *value, XID id)
{
ScreenSaverSuspensionPtr data = (ScreenSaverSuspensionPtr) value;
ScreenSaverSuspensionPtr *prev, this;
/* Unlink and free the suspension record for the client */
for (prev = &suspendingClients; (this = *prev); prev = &this->next) {
if (this == data) {
*prev = this->next;
free(this);
break;
}
}
/* Reenable the screensaver if this was the last client suspending it. */
if (screenSaverSuspended && suspendingClients == NULL) {
screenSaverSuspended = FALSE;
/* The screensaver could be active, since suspending it (by design)
doesn't prevent it from being forceably activated */
#ifdef DPMSExtension
if (screenIsSaved != SCREEN_SAVER_ON && DPMSPowerLevel == DPMSModeOn)
#else
if (screenIsSaved != SCREEN_SAVER_ON)
#endif
{
DeviceIntPtr dev;
UpdateCurrentTimeIf();
nt_list_for_each_entry(dev, inputInfo.devices, next)
NoticeTime(dev, currentTime);
SetScreenSaverTimer();
}
}
return Success;
}
| @@ -1186,6 +1186,8 @@ ProcScreenSaverUnsetAttributes(ClientPtr client)
PanoramiXRes *draw;
int rc, i;
+ REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq);
+
rc = dixLookupResourceByClass((void **) &draw, stuff->drawable,
XRC_DRAWABLE, client, DixWriteAccess);
if (rc != Success) | CWE-20 | null | null |
13,957 | ScreenSaverHandle(ScreenPtr pScreen, int xstate, Bool force)
{
int state = 0;
Bool ret = FALSE;
ScreenSaverScreenPrivatePtr pPriv;
switch (xstate) {
case SCREEN_SAVER_ON:
state = ScreenSaverOn;
ret = CreateSaverWindow(pScreen);
break;
case SCREEN_SAVER_OFF:
state = ScreenSaverOff;
ret = DestroySaverWindow(pScreen);
break;
case SCREEN_SAVER_CYCLE:
state = ScreenSaverCycle;
pPriv = GetScreenPrivate(pScreen);
if (pPriv && pPriv->hasWindow)
ret = TRUE;
}
#ifdef PANORAMIX
if (noPanoramiXExtension || !pScreen->myNum)
#endif
SendScreenSaverNotify(pScreen, state, force);
return ret;
}
| Exec Code | 0 | ScreenSaverHandle(ScreenPtr pScreen, int xstate, Bool force)
{
int state = 0;
Bool ret = FALSE;
ScreenSaverScreenPrivatePtr pPriv;
switch (xstate) {
case SCREEN_SAVER_ON:
state = ScreenSaverOn;
ret = CreateSaverWindow(pScreen);
break;
case SCREEN_SAVER_OFF:
state = ScreenSaverOff;
ret = DestroySaverWindow(pScreen);
break;
case SCREEN_SAVER_CYCLE:
state = ScreenSaverCycle;
pPriv = GetScreenPrivate(pScreen);
if (pPriv && pPriv->hasWindow)
ret = TRUE;
}
#ifdef PANORAMIX
if (noPanoramiXExtension || !pScreen->myNum)
#endif
SendScreenSaverNotify(pScreen, state, force);
return ret;
}
| @@ -1186,6 +1186,8 @@ ProcScreenSaverUnsetAttributes(ClientPtr client)
PanoramiXRes *draw;
int rc, i;
+ REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq);
+
rc = dixLookupResourceByClass((void **) &draw, stuff->drawable,
XRC_DRAWABLE, client, DixWriteAccess);
if (rc != Success) | CWE-20 | null | null |
13,958 | ScreenSaverSetAttributes(ClientPtr client)
{
REQUEST(xScreenSaverSetAttributesReq);
DrawablePtr pDraw;
WindowPtr pParent;
ScreenPtr pScreen;
ScreenSaverScreenPrivatePtr pPriv = 0;
ScreenSaverAttrPtr pAttr = 0;
int ret, len, class, bw, depth;
unsigned long visual;
int idepth, ivisual;
Bool fOK;
DepthPtr pDepth;
WindowOptPtr ancwopt;
unsigned int *pVlist;
unsigned long *values = 0;
unsigned long tmask, imask;
unsigned long val;
Pixmap pixID;
PixmapPtr pPixmap;
Cursor cursorID;
CursorPtr pCursor;
Colormap cmap;
ColormapPtr pCmap;
REQUEST_AT_LEAST_SIZE(xScreenSaverSetAttributesReq);
ret = dixLookupDrawable(&pDraw, stuff->drawable, client, 0,
DixGetAttrAccess);
if (ret != Success)
return ret;
pScreen = pDraw->pScreen;
pParent = pScreen->root;
ret = XaceHook(XACE_SCREENSAVER_ACCESS, client, pScreen, DixSetAttrAccess);
if (ret != Success)
return ret;
len = stuff->length - bytes_to_int32(sizeof(xScreenSaverSetAttributesReq));
if (Ones(stuff->mask) != len)
return BadLength;
if (!stuff->width || !stuff->height) {
client->errorValue = 0;
return BadValue;
}
switch (class = stuff->c_class) {
case CopyFromParent:
case InputOnly:
case InputOutput:
break;
default:
client->errorValue = class;
return BadValue;
}
bw = stuff->borderWidth;
depth = stuff->depth;
visual = stuff->visualID;
/* copied directly from CreateWindow */
if (class == CopyFromParent)
class = pParent->drawable.class;
if ((class != InputOutput) && (class != InputOnly)) {
client->errorValue = class;
return BadValue;
}
if ((class != InputOnly) && (pParent->drawable.class == InputOnly))
return BadMatch;
if ((class == InputOnly) && ((bw != 0) || (depth != 0)))
return BadMatch;
if ((class == InputOutput) && (depth == 0))
depth = pParent->drawable.depth;
ancwopt = pParent->optional;
if (!ancwopt)
ancwopt = FindWindowWithOptional(pParent)->optional;
if (visual == CopyFromParent)
visual = ancwopt->visual;
/* Find out if the depth and visual are acceptable for this Screen */
if ((visual != ancwopt->visual) || (depth != pParent->drawable.depth)) {
fOK = FALSE;
for (idepth = 0; idepth < pScreen->numDepths; idepth++) {
pDepth = (DepthPtr) &pScreen->allowedDepths[idepth];
if ((depth == pDepth->depth) || (depth == 0)) {
for (ivisual = 0; ivisual < pDepth->numVids; ivisual++) {
if (visual == pDepth->vids[ivisual]) {
fOK = TRUE;
break;
}
}
}
}
if (fOK == FALSE)
return BadMatch;
}
if (((stuff->mask & (CWBorderPixmap | CWBorderPixel)) == 0) &&
(class != InputOnly) && (depth != pParent->drawable.depth)) {
return BadMatch;
}
if (((stuff->mask & CWColormap) == 0) &&
(class != InputOnly) &&
((visual != ancwopt->visual) || (ancwopt->colormap == None))) {
return BadMatch;
}
/* end of errors from CreateWindow */
pPriv = GetScreenPrivate(pScreen);
if (pPriv && pPriv->attr) {
if (pPriv->attr->client != client)
return BadAccess;
}
if (!pPriv) {
pPriv = MakeScreenPrivate(pScreen);
if (!pPriv)
return FALSE;
}
pAttr = New(ScreenSaverAttrRec);
if (!pAttr) {
ret = BadAlloc;
goto bail;
}
/* over allocate for override redirect */
pAttr->values = values = xallocarray(len + 1, sizeof(unsigned long));
if (!values) {
ret = BadAlloc;
goto bail;
}
pAttr->screen = pScreen;
pAttr->client = client;
pAttr->x = stuff->x;
pAttr->y = stuff->y;
pAttr->width = stuff->width;
pAttr->height = stuff->height;
pAttr->borderWidth = stuff->borderWidth;
pAttr->class = stuff->c_class;
pAttr->depth = depth;
pAttr->visual = visual;
pAttr->colormap = None;
pAttr->pCursor = NullCursor;
pAttr->pBackgroundPixmap = NullPixmap;
pAttr->pBorderPixmap = NullPixmap;
/*
* go through the mask, checking the values,
* looking up pixmaps and cursors and hold a reference
* to them.
*/
pAttr->mask = tmask = stuff->mask | CWOverrideRedirect;
pVlist = (unsigned int *) (stuff + 1);
while (tmask) {
imask = lowbit(tmask);
tmask &= ~imask;
switch (imask) {
case CWBackPixmap:
pixID = (Pixmap) * pVlist;
if (pixID == None) {
*values++ = None;
}
else if (pixID == ParentRelative) {
if (depth != pParent->drawable.depth) {
ret = BadMatch;
goto PatchUp;
}
*values++ = ParentRelative;
}
else {
ret =
dixLookupResourceByType((void **) &pPixmap, pixID,
RT_PIXMAP, client, DixReadAccess);
if (ret == Success) {
if ((pPixmap->drawable.depth != depth) ||
(pPixmap->drawable.pScreen != pScreen)) {
ret = BadMatch;
goto PatchUp;
}
pAttr->pBackgroundPixmap = pPixmap;
pPixmap->refcnt++;
pAttr->mask &= ~CWBackPixmap;
}
else {
client->errorValue = pixID;
goto PatchUp;
}
}
break;
case CWBackPixel:
*values++ = (CARD32) *pVlist;
break;
case CWBorderPixmap:
pixID = (Pixmap) * pVlist;
if (pixID == CopyFromParent) {
if (depth != pParent->drawable.depth) {
ret = BadMatch;
goto PatchUp;
}
*values++ = CopyFromParent;
}
else {
ret =
dixLookupResourceByType((void **) &pPixmap, pixID,
RT_PIXMAP, client, DixReadAccess);
if (ret == Success) {
if ((pPixmap->drawable.depth != depth) ||
(pPixmap->drawable.pScreen != pScreen)) {
ret = BadMatch;
goto PatchUp;
}
pAttr->pBorderPixmap = pPixmap;
pPixmap->refcnt++;
pAttr->mask &= ~CWBorderPixmap;
}
else {
client->errorValue = pixID;
goto PatchUp;
}
}
break;
case CWBorderPixel:
*values++ = (CARD32) *pVlist;
break;
case CWBitGravity:
val = (CARD8) *pVlist;
if (val > StaticGravity) {
ret = BadValue;
client->errorValue = val;
goto PatchUp;
}
*values++ = val;
break;
case CWWinGravity:
val = (CARD8) *pVlist;
if (val > StaticGravity) {
ret = BadValue;
client->errorValue = val;
goto PatchUp;
}
*values++ = val;
break;
case CWBackingStore:
val = (CARD8) *pVlist;
if ((val != NotUseful) && (val != WhenMapped) && (val != Always)) {
ret = BadValue;
client->errorValue = val;
goto PatchUp;
}
*values++ = val;
break;
case CWBackingPlanes:
*values++ = (CARD32) *pVlist;
break;
case CWBackingPixel:
*values++ = (CARD32) *pVlist;
break;
case CWSaveUnder:
val = (BOOL) * pVlist;
if ((val != xTrue) && (val != xFalse)) {
ret = BadValue;
client->errorValue = val;
goto PatchUp;
}
*values++ = val;
break;
case CWEventMask:
*values++ = (CARD32) *pVlist;
break;
case CWDontPropagate:
*values++ = (CARD32) *pVlist;
break;
case CWOverrideRedirect:
if (!(stuff->mask & CWOverrideRedirect))
pVlist--;
else {
val = (BOOL) * pVlist;
if ((val != xTrue) && (val != xFalse)) {
ret = BadValue;
client->errorValue = val;
goto PatchUp;
}
}
*values++ = xTrue;
break;
case CWColormap:
cmap = (Colormap) * pVlist;
ret = dixLookupResourceByType((void **) &pCmap, cmap, RT_COLORMAP,
client, DixUseAccess);
if (ret != Success) {
client->errorValue = cmap;
goto PatchUp;
}
if (pCmap->pVisual->vid != visual || pCmap->pScreen != pScreen) {
ret = BadMatch;
goto PatchUp;
}
pAttr->colormap = cmap;
pAttr->mask &= ~CWColormap;
break;
case CWCursor:
cursorID = (Cursor) * pVlist;
if (cursorID == None) {
*values++ = None;
}
else {
ret = dixLookupResourceByType((void **) &pCursor, cursorID,
RT_CURSOR, client, DixUseAccess);
if (ret != Success) {
client->errorValue = cursorID;
goto PatchUp;
}
pAttr->pCursor = RefCursor(pCursor);
pAttr->mask &= ~CWCursor;
}
break;
default:
ret = BadValue;
client->errorValue = stuff->mask;
goto PatchUp;
}
pVlist++;
}
if (pPriv->attr)
FreeScreenAttr(pPriv->attr);
pPriv->attr = pAttr;
pAttr->resource = FakeClientID(client->index);
if (!AddResource(pAttr->resource, AttrType, (void *) pAttr))
return BadAlloc;
return Success;
PatchUp:
FreeAttrs(pAttr);
bail:
CheckScreenPrivate(pScreen);
if (pAttr)
free(pAttr->values);
free(pAttr);
return ret;
}
| Exec Code | 0 | ScreenSaverSetAttributes(ClientPtr client)
{
REQUEST(xScreenSaverSetAttributesReq);
DrawablePtr pDraw;
WindowPtr pParent;
ScreenPtr pScreen;
ScreenSaverScreenPrivatePtr pPriv = 0;
ScreenSaverAttrPtr pAttr = 0;
int ret, len, class, bw, depth;
unsigned long visual;
int idepth, ivisual;
Bool fOK;
DepthPtr pDepth;
WindowOptPtr ancwopt;
unsigned int *pVlist;
unsigned long *values = 0;
unsigned long tmask, imask;
unsigned long val;
Pixmap pixID;
PixmapPtr pPixmap;
Cursor cursorID;
CursorPtr pCursor;
Colormap cmap;
ColormapPtr pCmap;
REQUEST_AT_LEAST_SIZE(xScreenSaverSetAttributesReq);
ret = dixLookupDrawable(&pDraw, stuff->drawable, client, 0,
DixGetAttrAccess);
if (ret != Success)
return ret;
pScreen = pDraw->pScreen;
pParent = pScreen->root;
ret = XaceHook(XACE_SCREENSAVER_ACCESS, client, pScreen, DixSetAttrAccess);
if (ret != Success)
return ret;
len = stuff->length - bytes_to_int32(sizeof(xScreenSaverSetAttributesReq));
if (Ones(stuff->mask) != len)
return BadLength;
if (!stuff->width || !stuff->height) {
client->errorValue = 0;
return BadValue;
}
switch (class = stuff->c_class) {
case CopyFromParent:
case InputOnly:
case InputOutput:
break;
default:
client->errorValue = class;
return BadValue;
}
bw = stuff->borderWidth;
depth = stuff->depth;
visual = stuff->visualID;
/* copied directly from CreateWindow */
if (class == CopyFromParent)
class = pParent->drawable.class;
if ((class != InputOutput) && (class != InputOnly)) {
client->errorValue = class;
return BadValue;
}
if ((class != InputOnly) && (pParent->drawable.class == InputOnly))
return BadMatch;
if ((class == InputOnly) && ((bw != 0) || (depth != 0)))
return BadMatch;
if ((class == InputOutput) && (depth == 0))
depth = pParent->drawable.depth;
ancwopt = pParent->optional;
if (!ancwopt)
ancwopt = FindWindowWithOptional(pParent)->optional;
if (visual == CopyFromParent)
visual = ancwopt->visual;
/* Find out if the depth and visual are acceptable for this Screen */
if ((visual != ancwopt->visual) || (depth != pParent->drawable.depth)) {
fOK = FALSE;
for (idepth = 0; idepth < pScreen->numDepths; idepth++) {
pDepth = (DepthPtr) &pScreen->allowedDepths[idepth];
if ((depth == pDepth->depth) || (depth == 0)) {
for (ivisual = 0; ivisual < pDepth->numVids; ivisual++) {
if (visual == pDepth->vids[ivisual]) {
fOK = TRUE;
break;
}
}
}
}
if (fOK == FALSE)
return BadMatch;
}
if (((stuff->mask & (CWBorderPixmap | CWBorderPixel)) == 0) &&
(class != InputOnly) && (depth != pParent->drawable.depth)) {
return BadMatch;
}
if (((stuff->mask & CWColormap) == 0) &&
(class != InputOnly) &&
((visual != ancwopt->visual) || (ancwopt->colormap == None))) {
return BadMatch;
}
/* end of errors from CreateWindow */
pPriv = GetScreenPrivate(pScreen);
if (pPriv && pPriv->attr) {
if (pPriv->attr->client != client)
return BadAccess;
}
if (!pPriv) {
pPriv = MakeScreenPrivate(pScreen);
if (!pPriv)
return FALSE;
}
pAttr = New(ScreenSaverAttrRec);
if (!pAttr) {
ret = BadAlloc;
goto bail;
}
/* over allocate for override redirect */
pAttr->values = values = xallocarray(len + 1, sizeof(unsigned long));
if (!values) {
ret = BadAlloc;
goto bail;
}
pAttr->screen = pScreen;
pAttr->client = client;
pAttr->x = stuff->x;
pAttr->y = stuff->y;
pAttr->width = stuff->width;
pAttr->height = stuff->height;
pAttr->borderWidth = stuff->borderWidth;
pAttr->class = stuff->c_class;
pAttr->depth = depth;
pAttr->visual = visual;
pAttr->colormap = None;
pAttr->pCursor = NullCursor;
pAttr->pBackgroundPixmap = NullPixmap;
pAttr->pBorderPixmap = NullPixmap;
/*
* go through the mask, checking the values,
* looking up pixmaps and cursors and hold a reference
* to them.
*/
pAttr->mask = tmask = stuff->mask | CWOverrideRedirect;
pVlist = (unsigned int *) (stuff + 1);
while (tmask) {
imask = lowbit(tmask);
tmask &= ~imask;
switch (imask) {
case CWBackPixmap:
pixID = (Pixmap) * pVlist;
if (pixID == None) {
*values++ = None;
}
else if (pixID == ParentRelative) {
if (depth != pParent->drawable.depth) {
ret = BadMatch;
goto PatchUp;
}
*values++ = ParentRelative;
}
else {
ret =
dixLookupResourceByType((void **) &pPixmap, pixID,
RT_PIXMAP, client, DixReadAccess);
if (ret == Success) {
if ((pPixmap->drawable.depth != depth) ||
(pPixmap->drawable.pScreen != pScreen)) {
ret = BadMatch;
goto PatchUp;
}
pAttr->pBackgroundPixmap = pPixmap;
pPixmap->refcnt++;
pAttr->mask &= ~CWBackPixmap;
}
else {
client->errorValue = pixID;
goto PatchUp;
}
}
break;
case CWBackPixel:
*values++ = (CARD32) *pVlist;
break;
case CWBorderPixmap:
pixID = (Pixmap) * pVlist;
if (pixID == CopyFromParent) {
if (depth != pParent->drawable.depth) {
ret = BadMatch;
goto PatchUp;
}
*values++ = CopyFromParent;
}
else {
ret =
dixLookupResourceByType((void **) &pPixmap, pixID,
RT_PIXMAP, client, DixReadAccess);
if (ret == Success) {
if ((pPixmap->drawable.depth != depth) ||
(pPixmap->drawable.pScreen != pScreen)) {
ret = BadMatch;
goto PatchUp;
}
pAttr->pBorderPixmap = pPixmap;
pPixmap->refcnt++;
pAttr->mask &= ~CWBorderPixmap;
}
else {
client->errorValue = pixID;
goto PatchUp;
}
}
break;
case CWBorderPixel:
*values++ = (CARD32) *pVlist;
break;
case CWBitGravity:
val = (CARD8) *pVlist;
if (val > StaticGravity) {
ret = BadValue;
client->errorValue = val;
goto PatchUp;
}
*values++ = val;
break;
case CWWinGravity:
val = (CARD8) *pVlist;
if (val > StaticGravity) {
ret = BadValue;
client->errorValue = val;
goto PatchUp;
}
*values++ = val;
break;
case CWBackingStore:
val = (CARD8) *pVlist;
if ((val != NotUseful) && (val != WhenMapped) && (val != Always)) {
ret = BadValue;
client->errorValue = val;
goto PatchUp;
}
*values++ = val;
break;
case CWBackingPlanes:
*values++ = (CARD32) *pVlist;
break;
case CWBackingPixel:
*values++ = (CARD32) *pVlist;
break;
case CWSaveUnder:
val = (BOOL) * pVlist;
if ((val != xTrue) && (val != xFalse)) {
ret = BadValue;
client->errorValue = val;
goto PatchUp;
}
*values++ = val;
break;
case CWEventMask:
*values++ = (CARD32) *pVlist;
break;
case CWDontPropagate:
*values++ = (CARD32) *pVlist;
break;
case CWOverrideRedirect:
if (!(stuff->mask & CWOverrideRedirect))
pVlist--;
else {
val = (BOOL) * pVlist;
if ((val != xTrue) && (val != xFalse)) {
ret = BadValue;
client->errorValue = val;
goto PatchUp;
}
}
*values++ = xTrue;
break;
case CWColormap:
cmap = (Colormap) * pVlist;
ret = dixLookupResourceByType((void **) &pCmap, cmap, RT_COLORMAP,
client, DixUseAccess);
if (ret != Success) {
client->errorValue = cmap;
goto PatchUp;
}
if (pCmap->pVisual->vid != visual || pCmap->pScreen != pScreen) {
ret = BadMatch;
goto PatchUp;
}
pAttr->colormap = cmap;
pAttr->mask &= ~CWColormap;
break;
case CWCursor:
cursorID = (Cursor) * pVlist;
if (cursorID == None) {
*values++ = None;
}
else {
ret = dixLookupResourceByType((void **) &pCursor, cursorID,
RT_CURSOR, client, DixUseAccess);
if (ret != Success) {
client->errorValue = cursorID;
goto PatchUp;
}
pAttr->pCursor = RefCursor(pCursor);
pAttr->mask &= ~CWCursor;
}
break;
default:
ret = BadValue;
client->errorValue = stuff->mask;
goto PatchUp;
}
pVlist++;
}
if (pPriv->attr)
FreeScreenAttr(pPriv->attr);
pPriv->attr = pAttr;
pAttr->resource = FakeClientID(client->index);
if (!AddResource(pAttr->resource, AttrType, (void *) pAttr))
return BadAlloc;
return Success;
PatchUp:
FreeAttrs(pAttr);
bail:
CheckScreenPrivate(pScreen);
if (pAttr)
free(pAttr->values);
free(pAttr);
return ret;
}
| @@ -1186,6 +1186,8 @@ ProcScreenSaverUnsetAttributes(ClientPtr client)
PanoramiXRes *draw;
int rc, i;
+ REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq);
+
rc = dixLookupResourceByClass((void **) &draw, stuff->drawable,
XRC_DRAWABLE, client, DixWriteAccess);
if (rc != Success) | CWE-20 | null | null |
13,959 | SendScreenSaverNotify(ScreenPtr pScreen, int state, Bool forced)
{
ScreenSaverScreenPrivatePtr pPriv;
ScreenSaverEventPtr pEv;
unsigned long mask;
int kind;
UpdateCurrentTimeIf();
mask = ScreenSaverNotifyMask;
if (state == ScreenSaverCycle)
mask = ScreenSaverCycleMask;
pScreen = screenInfo.screens[pScreen->myNum];
pPriv = GetScreenPrivate(pScreen);
if (!pPriv)
return;
if (pPriv->attr)
kind = ScreenSaverExternal;
else if (ScreenSaverBlanking != DontPreferBlanking)
kind = ScreenSaverBlanked;
else
kind = ScreenSaverInternal;
for (pEv = pPriv->events; pEv; pEv = pEv->next) {
if (pEv->mask & mask) {
xScreenSaverNotifyEvent ev = {
.type = ScreenSaverNotify + ScreenSaverEventBase,
.state = state,
.timestamp = currentTime.milliseconds,
.root = pScreen->root->drawable.id,
.window = pScreen->screensaver.wid,
.kind = kind,
.forced = forced
};
WriteEventsToClient(pEv->client, 1, (xEvent *) &ev);
}
}
}
| Exec Code | 0 | SendScreenSaverNotify(ScreenPtr pScreen, int state, Bool forced)
{
ScreenSaverScreenPrivatePtr pPriv;
ScreenSaverEventPtr pEv;
unsigned long mask;
int kind;
UpdateCurrentTimeIf();
mask = ScreenSaverNotifyMask;
if (state == ScreenSaverCycle)
mask = ScreenSaverCycleMask;
pScreen = screenInfo.screens[pScreen->myNum];
pPriv = GetScreenPrivate(pScreen);
if (!pPriv)
return;
if (pPriv->attr)
kind = ScreenSaverExternal;
else if (ScreenSaverBlanking != DontPreferBlanking)
kind = ScreenSaverBlanked;
else
kind = ScreenSaverInternal;
for (pEv = pPriv->events; pEv; pEv = pEv->next) {
if (pEv->mask & mask) {
xScreenSaverNotifyEvent ev = {
.type = ScreenSaverNotify + ScreenSaverEventBase,
.state = state,
.timestamp = currentTime.milliseconds,
.root = pScreen->root->drawable.id,
.window = pScreen->screensaver.wid,
.kind = kind,
.forced = forced
};
WriteEventsToClient(pEv->client, 1, (xEvent *) &ev);
}
}
}
| @@ -1186,6 +1186,8 @@ ProcScreenSaverUnsetAttributes(ClientPtr client)
PanoramiXRes *draw;
int rc, i;
+ REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq);
+
rc = dixLookupResourceByClass((void **) &draw, stuff->drawable,
XRC_DRAWABLE, client, DixWriteAccess);
if (rc != Success) | CWE-20 | null | null |
13,960 | UninstallSaverColormap(ScreenPtr pScreen)
{
SetupScreen(pScreen);
ColormapPtr pCmap;
int rc;
if (pPriv && pPriv->installedMap != None) {
rc = dixLookupResourceByType((void **) &pCmap, pPriv->installedMap,
RT_COLORMAP, serverClient,
DixUninstallAccess);
if (rc == Success)
(*pCmap->pScreen->UninstallColormap) (pCmap);
pPriv->installedMap = None;
CheckScreenPrivate(pScreen);
}
}
| Exec Code | 0 | UninstallSaverColormap(ScreenPtr pScreen)
{
SetupScreen(pScreen);
ColormapPtr pCmap;
int rc;
if (pPriv && pPriv->installedMap != None) {
rc = dixLookupResourceByType((void **) &pCmap, pPriv->installedMap,
RT_COLORMAP, serverClient,
DixUninstallAccess);
if (rc == Success)
(*pCmap->pScreen->UninstallColormap) (pCmap);
pPriv->installedMap = None;
CheckScreenPrivate(pScreen);
}
}
| @@ -1186,6 +1186,8 @@ ProcScreenSaverUnsetAttributes(ClientPtr client)
PanoramiXRes *draw;
int rc, i;
+ REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq);
+
rc = dixLookupResourceByClass((void **) &draw, stuff->drawable,
XRC_DRAWABLE, client, DixWriteAccess);
if (rc != Success) | CWE-20 | null | null |
13,961 | getEventMask(ScreenPtr pScreen, ClientPtr client)
{
SetupScreen(pScreen);
ScreenSaverEventPtr pEv;
if (!pPriv)
return 0;
for (pEv = pPriv->events; pEv; pEv = pEv->next)
if (pEv->client == client)
return pEv->mask;
return 0;
}
| Exec Code | 0 | getEventMask(ScreenPtr pScreen, ClientPtr client)
{
SetupScreen(pScreen);
ScreenSaverEventPtr pEv;
if (!pPriv)
return 0;
for (pEv = pPriv->events; pEv; pEv = pEv->next)
if (pEv->client == client)
return pEv->mask;
return 0;
}
| @@ -1186,6 +1186,8 @@ ProcScreenSaverUnsetAttributes(ClientPtr client)
PanoramiXRes *draw;
int rc, i;
+ REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq);
+
rc = dixLookupResourceByClass((void **) &draw, stuff->drawable,
XRC_DRAWABLE, client, DixWriteAccess);
if (rc != Success) | CWE-20 | null | null |
13,962 | AddFragment(struct xorg_list *frags, int bytes)
{
FragmentList *f = malloc(sizeof(FragmentList) + bytes);
if (!f) {
return NULL;
} else {
f->bytes = bytes;
xorg_list_add(&f->l, frags->prev);
return (char*) f + sizeof(*f);
}
}
| Exec Code | 0 | AddFragment(struct xorg_list *frags, int bytes)
{
FragmentList *f = malloc(sizeof(FragmentList) + bytes);
if (!f) {
return NULL;
} else {
f->bytes = bytes;
xorg_list_add(&f->l, frags->prev);
return (char*) f + sizeof(*f);
}
}
| @@ -947,6 +947,8 @@ ProcXResQueryResourceBytes (ClientPtr client)
ConstructResourceBytesCtx ctx;
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ if (stuff->numSpecs > UINT32_MAX / sizeof(ctx.specs[0]))
+ return BadLength;
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(ctx.specs[0]));
@@ -1052,8 +1054,8 @@ SProcXResQueryResourceBytes (ClientPtr client)
int c;
xXResResourceIdSpec *specs = (void*) ((char*) stuff + sizeof(*stuff));
- swapl(&stuff->numSpecs);
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ swapl(&stuff->numSpecs);
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(specs[0])); | CWE-20 | null | null |
13,963 | AddResourceSizeValue(void *ptr, XID id, RESTYPE type, void *cdata)
{
ConstructResourceBytesCtx *ctx = cdata;
if (ctx->status == Success &&
!ht_find(ctx->visitedResources, &id)) {
Bool ok = TRUE;
HashTable ht;
HtGenericHashSetupRec htSetup = {
.keySize = sizeof(void*)
};
/* it doesn't matter that we don't undo the work done here
* immediately. All but ht_init will be undone at the end
* of the request and there can happen no failure after
* ht_init, so we don't need to clean it up here in any
* special way */
xXResResourceSizeValue *value =
AddFragment(&ctx->response, sizeof(xXResResourceSizeValue));
if (!value) {
ok = FALSE;
}
ok = ok && ht_add(ctx->visitedResources, &id);
if (ok) {
ht = ht_create(htSetup.keySize,
sizeof(xXResResourceSizeSpec*),
ht_generic_hash, ht_generic_compare,
&htSetup);
ok = ok && ht;
}
if (!ok) {
ctx->status = BadAlloc;
} else {
SizeType sizeFunc = GetResourceTypeSizeFunc(type);
ResourceSizeRec size = { 0, 0, 0 };
sizeFunc(ptr, id, &size);
value->size.spec.resource = id;
value->size.spec.type = type;
value->size.bytes = size.resourceSize;
value->size.refCount = size.refCnt;
value->size.useCount = 1;
value->numCrossReferences = 0;
ctx->sizeValue = value;
ctx->visitedSubResources = ht;
FindSubResources(ptr, type, AddSubResourceSizeSpec, ctx);
ctx->visitedSubResources = NULL;
ctx->sizeValue = NULL;
ctx->resultBytes += sizeof(*value);
++ctx->numSizes;
ht_destroy(ht);
}
}
}
| Exec Code | 0 | AddResourceSizeValue(void *ptr, XID id, RESTYPE type, void *cdata)
{
ConstructResourceBytesCtx *ctx = cdata;
if (ctx->status == Success &&
!ht_find(ctx->visitedResources, &id)) {
Bool ok = TRUE;
HashTable ht;
HtGenericHashSetupRec htSetup = {
.keySize = sizeof(void*)
};
/* it doesn't matter that we don't undo the work done here
* immediately. All but ht_init will be undone at the end
* of the request and there can happen no failure after
* ht_init, so we don't need to clean it up here in any
* special way */
xXResResourceSizeValue *value =
AddFragment(&ctx->response, sizeof(xXResResourceSizeValue));
if (!value) {
ok = FALSE;
}
ok = ok && ht_add(ctx->visitedResources, &id);
if (ok) {
ht = ht_create(htSetup.keySize,
sizeof(xXResResourceSizeSpec*),
ht_generic_hash, ht_generic_compare,
&htSetup);
ok = ok && ht;
}
if (!ok) {
ctx->status = BadAlloc;
} else {
SizeType sizeFunc = GetResourceTypeSizeFunc(type);
ResourceSizeRec size = { 0, 0, 0 };
sizeFunc(ptr, id, &size);
value->size.spec.resource = id;
value->size.spec.type = type;
value->size.bytes = size.resourceSize;
value->size.refCount = size.refCnt;
value->size.useCount = 1;
value->numCrossReferences = 0;
ctx->sizeValue = value;
ctx->visitedSubResources = ht;
FindSubResources(ptr, type, AddSubResourceSizeSpec, ctx);
ctx->visitedSubResources = NULL;
ctx->sizeValue = NULL;
ctx->resultBytes += sizeof(*value);
++ctx->numSizes;
ht_destroy(ht);
}
}
}
| @@ -947,6 +947,8 @@ ProcXResQueryResourceBytes (ClientPtr client)
ConstructResourceBytesCtx ctx;
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ if (stuff->numSpecs > UINT32_MAX / sizeof(ctx.specs[0]))
+ return BadLength;
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(ctx.specs[0]));
@@ -1052,8 +1054,8 @@ SProcXResQueryResourceBytes (ClientPtr client)
int c;
xXResResourceIdSpec *specs = (void*) ((char*) stuff + sizeof(*stuff));
- swapl(&stuff->numSpecs);
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ swapl(&stuff->numSpecs);
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(specs[0])); | CWE-20 | null | null |
13,964 | AddResourceSizeValueByResource(void *ptr, XID id, RESTYPE type, void *cdata)
{
ConstructResourceBytesCtx *ctx = cdata;
xXResResourceIdSpec *spec = ctx->curSpec;
if ((!spec->type || spec->type == type) &&
(!spec->resource || spec->resource == id)) {
AddResourceSizeValue(ptr, id, type, ctx);
}
}
| Exec Code | 0 | AddResourceSizeValueByResource(void *ptr, XID id, RESTYPE type, void *cdata)
{
ConstructResourceBytesCtx *ctx = cdata;
xXResResourceIdSpec *spec = ctx->curSpec;
if ((!spec->type || spec->type == type) &&
(!spec->resource || spec->resource == id)) {
AddResourceSizeValue(ptr, id, type, ctx);
}
}
| @@ -947,6 +947,8 @@ ProcXResQueryResourceBytes (ClientPtr client)
ConstructResourceBytesCtx ctx;
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ if (stuff->numSpecs > UINT32_MAX / sizeof(ctx.specs[0]))
+ return BadLength;
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(ctx.specs[0]));
@@ -1052,8 +1054,8 @@ SProcXResQueryResourceBytes (ClientPtr client)
int c;
xXResResourceIdSpec *specs = (void*) ((char*) stuff + sizeof(*stuff));
- swapl(&stuff->numSpecs);
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ swapl(&stuff->numSpecs);
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(specs[0])); | CWE-20 | null | null |
13,965 | AddSubResourceSizeSpec(void *value,
XID id,
RESTYPE type,
void *cdata)
{
ConstructResourceBytesCtx *ctx = cdata;
if (ctx->status == Success) {
xXResResourceSizeSpec **prevCrossRef =
ht_find(ctx->visitedSubResources, &value);
if (!prevCrossRef) {
Bool ok = TRUE;
xXResResourceSizeSpec *crossRef =
AddFragment(&ctx->response, sizeof(xXResResourceSizeSpec));
ok = ok && crossRef != NULL;
if (ok) {
xXResResourceSizeSpec **p;
p = ht_add(ctx->visitedSubResources, &value);
if (!p) {
ok = FALSE;
} else {
*p = crossRef;
}
}
if (!ok) {
ctx->status = BadAlloc;
} else {
SizeType sizeFunc = GetResourceTypeSizeFunc(type);
ResourceSizeRec size = { 0, 0, 0 };
sizeFunc(value, id, &size);
crossRef->spec.resource = id;
crossRef->spec.type = type;
crossRef->bytes = size.resourceSize;
crossRef->refCount = size.refCnt;
crossRef->useCount = 1;
++ctx->sizeValue->numCrossReferences;
ctx->resultBytes += sizeof(*crossRef);
}
} else {
/* if we have visited the subresource earlier (from current parent
resource), just increase its use count by one */
++(*prevCrossRef)->useCount;
}
}
}
| Exec Code | 0 | AddSubResourceSizeSpec(void *value,
XID id,
RESTYPE type,
void *cdata)
{
ConstructResourceBytesCtx *ctx = cdata;
if (ctx->status == Success) {
xXResResourceSizeSpec **prevCrossRef =
ht_find(ctx->visitedSubResources, &value);
if (!prevCrossRef) {
Bool ok = TRUE;
xXResResourceSizeSpec *crossRef =
AddFragment(&ctx->response, sizeof(xXResResourceSizeSpec));
ok = ok && crossRef != NULL;
if (ok) {
xXResResourceSizeSpec **p;
p = ht_add(ctx->visitedSubResources, &value);
if (!p) {
ok = FALSE;
} else {
*p = crossRef;
}
}
if (!ok) {
ctx->status = BadAlloc;
} else {
SizeType sizeFunc = GetResourceTypeSizeFunc(type);
ResourceSizeRec size = { 0, 0, 0 };
sizeFunc(value, id, &size);
crossRef->spec.resource = id;
crossRef->spec.type = type;
crossRef->bytes = size.resourceSize;
crossRef->refCount = size.refCnt;
crossRef->useCount = 1;
++ctx->sizeValue->numCrossReferences;
ctx->resultBytes += sizeof(*crossRef);
}
} else {
/* if we have visited the subresource earlier (from current parent
resource), just increase its use count by one */
++(*prevCrossRef)->useCount;
}
}
}
| @@ -947,6 +947,8 @@ ProcXResQueryResourceBytes (ClientPtr client)
ConstructResourceBytesCtx ctx;
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ if (stuff->numSpecs > UINT32_MAX / sizeof(ctx.specs[0]))
+ return BadLength;
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(ctx.specs[0]));
@@ -1052,8 +1054,8 @@ SProcXResQueryResourceBytes (ClientPtr client)
int c;
xXResResourceIdSpec *specs = (void*) ((char*) stuff + sizeof(*stuff));
- swapl(&stuff->numSpecs);
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ swapl(&stuff->numSpecs);
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(specs[0])); | CWE-20 | null | null |
13,966 | ConstructClientIdValue(ClientPtr sendClient, ClientPtr client, CARD32 mask,
ConstructClientIdCtx *ctx)
{
xXResClientIdValue rep;
rep.spec.client = client->clientAsMask;
if (client->swapped) {
swapl (&rep.spec.client);
}
if (WillConstructMask(client, mask, ctx, X_XResClientXIDMask)) {
void *ptr = AddFragment(&ctx->response, sizeof(rep));
if (!ptr) {
return FALSE;
}
rep.spec.mask = X_XResClientXIDMask;
rep.length = 0;
if (sendClient->swapped) {
swapl (&rep.spec.mask);
/* swapl (&rep.length, n); - not required for rep.length = 0 */
}
memcpy(ptr, &rep, sizeof(rep));
ctx->resultBytes += sizeof(rep);
++ctx->numIds;
}
if (WillConstructMask(client, mask, ctx, X_XResLocalClientPIDMask)) {
pid_t pid = GetClientPid(client);
if (pid != -1) {
void *ptr = AddFragment(&ctx->response,
sizeof(rep) + sizeof(CARD32));
CARD32 *value = (void*) ((char*) ptr + sizeof(rep));
if (!ptr) {
return FALSE;
}
rep.spec.mask = X_XResLocalClientPIDMask;
rep.length = 4;
if (sendClient->swapped) {
swapl (&rep.spec.mask);
swapl (&rep.length);
}
if (sendClient->swapped) {
swapl (value);
}
memcpy(ptr, &rep, sizeof(rep));
*value = pid;
ctx->resultBytes += sizeof(rep) + sizeof(CARD32);
++ctx->numIds;
}
}
/* memory allocation errors earlier may return with FALSE */
return TRUE;
}
| Exec Code | 0 | ConstructClientIdValue(ClientPtr sendClient, ClientPtr client, CARD32 mask,
ConstructClientIdCtx *ctx)
{
xXResClientIdValue rep;
rep.spec.client = client->clientAsMask;
if (client->swapped) {
swapl (&rep.spec.client);
}
if (WillConstructMask(client, mask, ctx, X_XResClientXIDMask)) {
void *ptr = AddFragment(&ctx->response, sizeof(rep));
if (!ptr) {
return FALSE;
}
rep.spec.mask = X_XResClientXIDMask;
rep.length = 0;
if (sendClient->swapped) {
swapl (&rep.spec.mask);
/* swapl (&rep.length, n); - not required for rep.length = 0 */
}
memcpy(ptr, &rep, sizeof(rep));
ctx->resultBytes += sizeof(rep);
++ctx->numIds;
}
if (WillConstructMask(client, mask, ctx, X_XResLocalClientPIDMask)) {
pid_t pid = GetClientPid(client);
if (pid != -1) {
void *ptr = AddFragment(&ctx->response,
sizeof(rep) + sizeof(CARD32));
CARD32 *value = (void*) ((char*) ptr + sizeof(rep));
if (!ptr) {
return FALSE;
}
rep.spec.mask = X_XResLocalClientPIDMask;
rep.length = 4;
if (sendClient->swapped) {
swapl (&rep.spec.mask);
swapl (&rep.length);
}
if (sendClient->swapped) {
swapl (value);
}
memcpy(ptr, &rep, sizeof(rep));
*value = pid;
ctx->resultBytes += sizeof(rep) + sizeof(CARD32);
++ctx->numIds;
}
}
/* memory allocation errors earlier may return with FALSE */
return TRUE;
}
| @@ -947,6 +947,8 @@ ProcXResQueryResourceBytes (ClientPtr client)
ConstructResourceBytesCtx ctx;
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ if (stuff->numSpecs > UINT32_MAX / sizeof(ctx.specs[0]))
+ return BadLength;
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(ctx.specs[0]));
@@ -1052,8 +1054,8 @@ SProcXResQueryResourceBytes (ClientPtr client)
int c;
xXResResourceIdSpec *specs = (void*) ((char*) stuff + sizeof(*stuff));
- swapl(&stuff->numSpecs);
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ swapl(&stuff->numSpecs);
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(specs[0])); | CWE-20 | null | null |
13,967 | ConstructClientIds(ClientPtr client,
int numSpecs, xXResClientIdSpec* specs,
ConstructClientIdCtx *ctx)
{
int specIdx;
for (specIdx = 0; specIdx < numSpecs; ++specIdx) {
if (specs[specIdx].client == 0) {
int c;
for (c = 0; c < currentMaxClients; ++c) {
if (clients[c]) {
if (!ConstructClientIdValue(client, clients[c],
specs[specIdx].mask, ctx)) {
return BadAlloc;
}
}
}
} else {
int clientID = CLIENT_ID(specs[specIdx].client);
if ((clientID < currentMaxClients) && clients[clientID]) {
if (!ConstructClientIdValue(client, clients[clientID],
specs[specIdx].mask, ctx)) {
return BadAlloc;
}
}
}
}
/* memory allocation errors earlier may return with BadAlloc */
return Success;
}
| Exec Code | 0 | ConstructClientIds(ClientPtr client,
int numSpecs, xXResClientIdSpec* specs,
ConstructClientIdCtx *ctx)
{
int specIdx;
for (specIdx = 0; specIdx < numSpecs; ++specIdx) {
if (specs[specIdx].client == 0) {
int c;
for (c = 0; c < currentMaxClients; ++c) {
if (clients[c]) {
if (!ConstructClientIdValue(client, clients[c],
specs[specIdx].mask, ctx)) {
return BadAlloc;
}
}
}
} else {
int clientID = CLIENT_ID(specs[specIdx].client);
if ((clientID < currentMaxClients) && clients[clientID]) {
if (!ConstructClientIdValue(client, clients[clientID],
specs[specIdx].mask, ctx)) {
return BadAlloc;
}
}
}
}
/* memory allocation errors earlier may return with BadAlloc */
return Success;
}
| @@ -947,6 +947,8 @@ ProcXResQueryResourceBytes (ClientPtr client)
ConstructResourceBytesCtx ctx;
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ if (stuff->numSpecs > UINT32_MAX / sizeof(ctx.specs[0]))
+ return BadLength;
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(ctx.specs[0]));
@@ -1052,8 +1054,8 @@ SProcXResQueryResourceBytes (ClientPtr client)
int c;
xXResResourceIdSpec *specs = (void*) ((char*) stuff + sizeof(*stuff));
- swapl(&stuff->numSpecs);
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ swapl(&stuff->numSpecs);
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(specs[0])); | CWE-20 | null | null |
13,968 | ConstructClientResourceBytes(ClientPtr aboutClient,
ConstructResourceBytesCtx *ctx)
{
int specIdx;
for (specIdx = 0; specIdx < ctx->numSpecs; ++specIdx) {
xXResResourceIdSpec* spec = ctx->specs + specIdx;
if (spec->resource) {
/* these specs are handled elsewhere */
} else if (spec->type) {
ctx->resType = spec->type;
FindClientResourcesByType(aboutClient, spec->type,
AddResourceSizeValueWithResType, ctx);
} else {
FindAllClientResources(aboutClient, AddResourceSizeValue, ctx);
}
}
}
| Exec Code | 0 | ConstructClientResourceBytes(ClientPtr aboutClient,
ConstructResourceBytesCtx *ctx)
{
int specIdx;
for (specIdx = 0; specIdx < ctx->numSpecs; ++specIdx) {
xXResResourceIdSpec* spec = ctx->specs + specIdx;
if (spec->resource) {
/* these specs are handled elsewhere */
} else if (spec->type) {
ctx->resType = spec->type;
FindClientResourcesByType(aboutClient, spec->type,
AddResourceSizeValueWithResType, ctx);
} else {
FindAllClientResources(aboutClient, AddResourceSizeValue, ctx);
}
}
}
| @@ -947,6 +947,8 @@ ProcXResQueryResourceBytes (ClientPtr client)
ConstructResourceBytesCtx ctx;
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ if (stuff->numSpecs > UINT32_MAX / sizeof(ctx.specs[0]))
+ return BadLength;
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(ctx.specs[0]));
@@ -1052,8 +1054,8 @@ SProcXResQueryResourceBytes (ClientPtr client)
int c;
xXResResourceIdSpec *specs = (void*) ((char*) stuff + sizeof(*stuff));
- swapl(&stuff->numSpecs);
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ swapl(&stuff->numSpecs);
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(specs[0])); | CWE-20 | null | null |
13,969 | ConstructResourceBytesByResource(XID aboutClient, ConstructResourceBytesCtx *ctx)
{
int specIdx;
for (specIdx = 0; specIdx < ctx->numSpecs; ++specIdx) {
xXResResourceIdSpec *spec = ctx->specs + specIdx;
if (spec->resource) {
int cid = CLIENT_ID(spec->resource);
if (cid < currentMaxClients &&
(aboutClient == None || cid == aboutClient)) {
ClientPtr client = clients[cid];
if (client) {
ctx->curSpec = spec;
FindAllClientResources(client,
AddResourceSizeValueByResource,
ctx);
}
}
}
}
}
| Exec Code | 0 | ConstructResourceBytesByResource(XID aboutClient, ConstructResourceBytesCtx *ctx)
{
int specIdx;
for (specIdx = 0; specIdx < ctx->numSpecs; ++specIdx) {
xXResResourceIdSpec *spec = ctx->specs + specIdx;
if (spec->resource) {
int cid = CLIENT_ID(spec->resource);
if (cid < currentMaxClients &&
(aboutClient == None || cid == aboutClient)) {
ClientPtr client = clients[cid];
if (client) {
ctx->curSpec = spec;
FindAllClientResources(client,
AddResourceSizeValueByResource,
ctx);
}
}
}
}
}
| @@ -947,6 +947,8 @@ ProcXResQueryResourceBytes (ClientPtr client)
ConstructResourceBytesCtx ctx;
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ if (stuff->numSpecs > UINT32_MAX / sizeof(ctx.specs[0]))
+ return BadLength;
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(ctx.specs[0]));
@@ -1052,8 +1054,8 @@ SProcXResQueryResourceBytes (ClientPtr client)
int c;
xXResResourceIdSpec *specs = (void*) ((char*) stuff + sizeof(*stuff));
- swapl(&stuff->numSpecs);
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ swapl(&stuff->numSpecs);
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(specs[0])); | CWE-20 | null | null |
13,970 | DestroyConstructClientIdCtx(ConstructClientIdCtx *ctx)
{
DestroyFragments(&ctx->response);
}
| Exec Code | 0 | DestroyConstructClientIdCtx(ConstructClientIdCtx *ctx)
{
DestroyFragments(&ctx->response);
}
| @@ -947,6 +947,8 @@ ProcXResQueryResourceBytes (ClientPtr client)
ConstructResourceBytesCtx ctx;
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ if (stuff->numSpecs > UINT32_MAX / sizeof(ctx.specs[0]))
+ return BadLength;
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(ctx.specs[0]));
@@ -1052,8 +1054,8 @@ SProcXResQueryResourceBytes (ClientPtr client)
int c;
xXResResourceIdSpec *specs = (void*) ((char*) stuff + sizeof(*stuff));
- swapl(&stuff->numSpecs);
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ swapl(&stuff->numSpecs);
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(specs[0])); | CWE-20 | null | null |
13,971 | DestroyConstructResourceBytesCtx(ConstructResourceBytesCtx *ctx)
{
DestroyFragments(&ctx->response);
ht_destroy(ctx->visitedResources);
}
| Exec Code | 0 | DestroyConstructResourceBytesCtx(ConstructResourceBytesCtx *ctx)
{
DestroyFragments(&ctx->response);
ht_destroy(ctx->visitedResources);
}
| @@ -947,6 +947,8 @@ ProcXResQueryResourceBytes (ClientPtr client)
ConstructResourceBytesCtx ctx;
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ if (stuff->numSpecs > UINT32_MAX / sizeof(ctx.specs[0]))
+ return BadLength;
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(ctx.specs[0]));
@@ -1052,8 +1054,8 @@ SProcXResQueryResourceBytes (ClientPtr client)
int c;
xXResResourceIdSpec *specs = (void*) ((char*) stuff + sizeof(*stuff));
- swapl(&stuff->numSpecs);
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ swapl(&stuff->numSpecs);
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(specs[0])); | CWE-20 | null | null |
13,972 | DestroyFragments(struct xorg_list *frags)
{
FragmentList *it, *tmp;
xorg_list_for_each_entry_safe(it, tmp, frags, l) {
xorg_list_del(&it->l);
free(it);
}
}
| Exec Code | 0 | DestroyFragments(struct xorg_list *frags)
{
FragmentList *it, *tmp;
xorg_list_for_each_entry_safe(it, tmp, frags, l) {
xorg_list_del(&it->l);
free(it);
}
}
| @@ -947,6 +947,8 @@ ProcXResQueryResourceBytes (ClientPtr client)
ConstructResourceBytesCtx ctx;
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ if (stuff->numSpecs > UINT32_MAX / sizeof(ctx.specs[0]))
+ return BadLength;
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(ctx.specs[0]));
@@ -1052,8 +1054,8 @@ SProcXResQueryResourceBytes (ClientPtr client)
int c;
xXResResourceIdSpec *specs = (void*) ((char*) stuff + sizeof(*stuff));
- swapl(&stuff->numSpecs);
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ swapl(&stuff->numSpecs);
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(specs[0])); | CWE-20 | null | null |
13,973 | InitConstructClientIdCtx(ConstructClientIdCtx *ctx)
{
ctx->numIds = 0;
ctx->resultBytes = 0;
xorg_list_init(&ctx->response);
memset(ctx->sentClientMasks, 0, sizeof(ctx->sentClientMasks));
}
| Exec Code | 0 | InitConstructClientIdCtx(ConstructClientIdCtx *ctx)
{
ctx->numIds = 0;
ctx->resultBytes = 0;
xorg_list_init(&ctx->response);
memset(ctx->sentClientMasks, 0, sizeof(ctx->sentClientMasks));
}
| @@ -947,6 +947,8 @@ ProcXResQueryResourceBytes (ClientPtr client)
ConstructResourceBytesCtx ctx;
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ if (stuff->numSpecs > UINT32_MAX / sizeof(ctx.specs[0]))
+ return BadLength;
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(ctx.specs[0]));
@@ -1052,8 +1054,8 @@ SProcXResQueryResourceBytes (ClientPtr client)
int c;
xXResResourceIdSpec *specs = (void*) ((char*) stuff + sizeof(*stuff));
- swapl(&stuff->numSpecs);
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ swapl(&stuff->numSpecs);
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(specs[0])); | CWE-20 | null | null |
13,974 | ProcResDispatch(ClientPtr client)
{
REQUEST(xReq);
switch (stuff->data) {
case X_XResQueryVersion:
return ProcXResQueryVersion(client);
case X_XResQueryClients:
return ProcXResQueryClients(client);
case X_XResQueryClientResources:
return ProcXResQueryClientResources(client);
case X_XResQueryClientPixmapBytes:
return ProcXResQueryClientPixmapBytes(client);
case X_XResQueryClientIds:
return ProcXResQueryClientIds(client);
case X_XResQueryResourceBytes:
return ProcXResQueryResourceBytes(client);
default: break;
}
return BadRequest;
}
| Exec Code | 0 | ProcResDispatch(ClientPtr client)
{
REQUEST(xReq);
switch (stuff->data) {
case X_XResQueryVersion:
return ProcXResQueryVersion(client);
case X_XResQueryClients:
return ProcXResQueryClients(client);
case X_XResQueryClientResources:
return ProcXResQueryClientResources(client);
case X_XResQueryClientPixmapBytes:
return ProcXResQueryClientPixmapBytes(client);
case X_XResQueryClientIds:
return ProcXResQueryClientIds(client);
case X_XResQueryResourceBytes:
return ProcXResQueryResourceBytes(client);
default: break;
}
return BadRequest;
}
| @@ -947,6 +947,8 @@ ProcXResQueryResourceBytes (ClientPtr client)
ConstructResourceBytesCtx ctx;
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ if (stuff->numSpecs > UINT32_MAX / sizeof(ctx.specs[0]))
+ return BadLength;
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(ctx.specs[0]));
@@ -1052,8 +1054,8 @@ SProcXResQueryResourceBytes (ClientPtr client)
int c;
xXResResourceIdSpec *specs = (void*) ((char*) stuff + sizeof(*stuff));
- swapl(&stuff->numSpecs);
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ swapl(&stuff->numSpecs);
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(specs[0])); | CWE-20 | null | null |
13,975 | ProcXResQueryClientPixmapBytes(ClientPtr client)
{
REQUEST(xXResQueryClientPixmapBytesReq);
xXResQueryClientPixmapBytesReply rep;
int clientID;
unsigned long bytes;
REQUEST_SIZE_MATCH(xXResQueryClientPixmapBytesReq);
clientID = CLIENT_ID(stuff->xid);
if ((clientID >= currentMaxClients) || !clients[clientID]) {
client->errorValue = stuff->xid;
return BadValue;
}
bytes = 0;
FindAllClientResources(clients[clientID], ResFindResourcePixmaps,
(void *) (&bytes));
rep = (xXResQueryClientPixmapBytesReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.bytes = bytes,
#ifdef _XSERVER64
.bytes_overflow = bytes >> 32
#else
.bytes_overflow = 0
#endif
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.bytes);
swapl(&rep.bytes_overflow);
}
WriteToClient(client, sizeof(xXResQueryClientPixmapBytesReply), &rep);
return Success;
}
| Exec Code | 0 | ProcXResQueryClientPixmapBytes(ClientPtr client)
{
REQUEST(xXResQueryClientPixmapBytesReq);
xXResQueryClientPixmapBytesReply rep;
int clientID;
unsigned long bytes;
REQUEST_SIZE_MATCH(xXResQueryClientPixmapBytesReq);
clientID = CLIENT_ID(stuff->xid);
if ((clientID >= currentMaxClients) || !clients[clientID]) {
client->errorValue = stuff->xid;
return BadValue;
}
bytes = 0;
FindAllClientResources(clients[clientID], ResFindResourcePixmaps,
(void *) (&bytes));
rep = (xXResQueryClientPixmapBytesReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.bytes = bytes,
#ifdef _XSERVER64
.bytes_overflow = bytes >> 32
#else
.bytes_overflow = 0
#endif
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.bytes);
swapl(&rep.bytes_overflow);
}
WriteToClient(client, sizeof(xXResQueryClientPixmapBytesReply), &rep);
return Success;
}
| @@ -947,6 +947,8 @@ ProcXResQueryResourceBytes (ClientPtr client)
ConstructResourceBytesCtx ctx;
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ if (stuff->numSpecs > UINT32_MAX / sizeof(ctx.specs[0]))
+ return BadLength;
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(ctx.specs[0]));
@@ -1052,8 +1054,8 @@ SProcXResQueryResourceBytes (ClientPtr client)
int c;
xXResResourceIdSpec *specs = (void*) ((char*) stuff + sizeof(*stuff));
- swapl(&stuff->numSpecs);
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ swapl(&stuff->numSpecs);
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(specs[0])); | CWE-20 | null | null |
13,976 | ProcXResQueryClientResources(ClientPtr client)
{
REQUEST(xXResQueryClientResourcesReq);
xXResQueryClientResourcesReply rep;
int i, clientID, num_types;
int *counts;
REQUEST_SIZE_MATCH(xXResQueryClientResourcesReq);
clientID = CLIENT_ID(stuff->xid);
if ((clientID >= currentMaxClients) || !clients[clientID]) {
client->errorValue = stuff->xid;
return BadValue;
}
counts = calloc(lastResourceType + 1, sizeof(int));
FindAllClientResources(clients[clientID], ResFindAllRes, counts);
num_types = 0;
for (i = 0; i <= lastResourceType; i++) {
if (counts[i])
num_types++;
}
rep = (xXResQueryClientResourcesReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(num_types * sz_xXResType),
.num_types = num_types
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.num_types);
}
WriteToClient(client, sizeof(xXResQueryClientResourcesReply), &rep);
if (num_types) {
xXResType scratch;
const char *name;
for (i = 0; i < lastResourceType; i++) {
if (!counts[i])
continue;
name = LookupResourceName(i + 1);
if (strcmp(name, XREGISTRY_UNKNOWN))
scratch.resource_type = MakeAtom(name, strlen(name), TRUE);
else {
char buf[40];
snprintf(buf, sizeof(buf), "Unregistered resource %i", i + 1);
scratch.resource_type = MakeAtom(buf, strlen(buf), TRUE);
}
scratch.count = counts[i];
if (client->swapped) {
swapl(&scratch.resource_type);
swapl(&scratch.count);
}
WriteToClient(client, sz_xXResType, &scratch);
}
}
free(counts);
return Success;
}
| Exec Code | 0 | ProcXResQueryClientResources(ClientPtr client)
{
REQUEST(xXResQueryClientResourcesReq);
xXResQueryClientResourcesReply rep;
int i, clientID, num_types;
int *counts;
REQUEST_SIZE_MATCH(xXResQueryClientResourcesReq);
clientID = CLIENT_ID(stuff->xid);
if ((clientID >= currentMaxClients) || !clients[clientID]) {
client->errorValue = stuff->xid;
return BadValue;
}
counts = calloc(lastResourceType + 1, sizeof(int));
FindAllClientResources(clients[clientID], ResFindAllRes, counts);
num_types = 0;
for (i = 0; i <= lastResourceType; i++) {
if (counts[i])
num_types++;
}
rep = (xXResQueryClientResourcesReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(num_types * sz_xXResType),
.num_types = num_types
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.num_types);
}
WriteToClient(client, sizeof(xXResQueryClientResourcesReply), &rep);
if (num_types) {
xXResType scratch;
const char *name;
for (i = 0; i < lastResourceType; i++) {
if (!counts[i])
continue;
name = LookupResourceName(i + 1);
if (strcmp(name, XREGISTRY_UNKNOWN))
scratch.resource_type = MakeAtom(name, strlen(name), TRUE);
else {
char buf[40];
snprintf(buf, sizeof(buf), "Unregistered resource %i", i + 1);
scratch.resource_type = MakeAtom(buf, strlen(buf), TRUE);
}
scratch.count = counts[i];
if (client->swapped) {
swapl(&scratch.resource_type);
swapl(&scratch.count);
}
WriteToClient(client, sz_xXResType, &scratch);
}
}
free(counts);
return Success;
}
| @@ -947,6 +947,8 @@ ProcXResQueryResourceBytes (ClientPtr client)
ConstructResourceBytesCtx ctx;
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ if (stuff->numSpecs > UINT32_MAX / sizeof(ctx.specs[0]))
+ return BadLength;
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(ctx.specs[0]));
@@ -1052,8 +1054,8 @@ SProcXResQueryResourceBytes (ClientPtr client)
int c;
xXResResourceIdSpec *specs = (void*) ((char*) stuff + sizeof(*stuff));
- swapl(&stuff->numSpecs);
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ swapl(&stuff->numSpecs);
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(specs[0])); | CWE-20 | null | null |
13,977 | ProcXResQueryClients(ClientPtr client)
{
/* REQUEST(xXResQueryClientsReq); */
xXResQueryClientsReply rep;
int *current_clients;
int i, num_clients;
REQUEST_SIZE_MATCH(xXResQueryClientsReq);
current_clients = xallocarray(currentMaxClients, sizeof(int));
num_clients = 0;
for (i = 0; i < currentMaxClients; i++) {
if (clients[i]) {
current_clients[num_clients] = i;
num_clients++;
}
}
rep = (xXResQueryClientsReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(num_clients * sz_xXResClient),
.num_clients = num_clients
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.num_clients);
}
WriteToClient(client, sizeof(xXResQueryClientsReply), &rep);
if (num_clients) {
xXResClient scratch;
for (i = 0; i < num_clients; i++) {
scratch.resource_base = clients[current_clients[i]]->clientAsMask;
scratch.resource_mask = RESOURCE_ID_MASK;
if (client->swapped) {
swapl(&scratch.resource_base);
swapl(&scratch.resource_mask);
}
WriteToClient(client, sz_xXResClient, &scratch);
}
}
free(current_clients);
return Success;
}
| Exec Code | 0 | ProcXResQueryClients(ClientPtr client)
{
/* REQUEST(xXResQueryClientsReq); */
xXResQueryClientsReply rep;
int *current_clients;
int i, num_clients;
REQUEST_SIZE_MATCH(xXResQueryClientsReq);
current_clients = xallocarray(currentMaxClients, sizeof(int));
num_clients = 0;
for (i = 0; i < currentMaxClients; i++) {
if (clients[i]) {
current_clients[num_clients] = i;
num_clients++;
}
}
rep = (xXResQueryClientsReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(num_clients * sz_xXResClient),
.num_clients = num_clients
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.num_clients);
}
WriteToClient(client, sizeof(xXResQueryClientsReply), &rep);
if (num_clients) {
xXResClient scratch;
for (i = 0; i < num_clients; i++) {
scratch.resource_base = clients[current_clients[i]]->clientAsMask;
scratch.resource_mask = RESOURCE_ID_MASK;
if (client->swapped) {
swapl(&scratch.resource_base);
swapl(&scratch.resource_mask);
}
WriteToClient(client, sz_xXResClient, &scratch);
}
}
free(current_clients);
return Success;
}
| @@ -947,6 +947,8 @@ ProcXResQueryResourceBytes (ClientPtr client)
ConstructResourceBytesCtx ctx;
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ if (stuff->numSpecs > UINT32_MAX / sizeof(ctx.specs[0]))
+ return BadLength;
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(ctx.specs[0]));
@@ -1052,8 +1054,8 @@ SProcXResQueryResourceBytes (ClientPtr client)
int c;
xXResResourceIdSpec *specs = (void*) ((char*) stuff + sizeof(*stuff));
- swapl(&stuff->numSpecs);
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ swapl(&stuff->numSpecs);
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(specs[0])); | CWE-20 | null | null |
13,978 | ProcXResQueryVersion(ClientPtr client)
{
xXResQueryVersionReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.server_major = SERVER_XRES_MAJOR_VERSION,
.server_minor = SERVER_XRES_MINOR_VERSION
};
REQUEST_SIZE_MATCH(xXResQueryVersionReq);
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.server_major);
swaps(&rep.server_minor);
}
WriteToClient(client, sizeof(xXResQueryVersionReply), &rep);
return Success;
}
| Exec Code | 0 | ProcXResQueryVersion(ClientPtr client)
{
xXResQueryVersionReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.server_major = SERVER_XRES_MAJOR_VERSION,
.server_minor = SERVER_XRES_MINOR_VERSION
};
REQUEST_SIZE_MATCH(xXResQueryVersionReq);
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.server_major);
swaps(&rep.server_minor);
}
WriteToClient(client, sizeof(xXResQueryVersionReply), &rep);
return Success;
}
| @@ -947,6 +947,8 @@ ProcXResQueryResourceBytes (ClientPtr client)
ConstructResourceBytesCtx ctx;
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ if (stuff->numSpecs > UINT32_MAX / sizeof(ctx.specs[0]))
+ return BadLength;
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(ctx.specs[0]));
@@ -1052,8 +1054,8 @@ SProcXResQueryResourceBytes (ClientPtr client)
int c;
xXResResourceIdSpec *specs = (void*) ((char*) stuff + sizeof(*stuff));
- swapl(&stuff->numSpecs);
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ swapl(&stuff->numSpecs);
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(specs[0])); | CWE-20 | null | null |
13,979 | ResFindAllRes(void *value, XID id, RESTYPE type, void *cdata)
{
int *counts = (int *) cdata;
counts[(type & TypeMask) - 1]++;
}
| Exec Code | 0 | ResFindAllRes(void *value, XID id, RESTYPE type, void *cdata)
{
int *counts = (int *) cdata;
counts[(type & TypeMask) - 1]++;
}
| @@ -947,6 +947,8 @@ ProcXResQueryResourceBytes (ClientPtr client)
ConstructResourceBytesCtx ctx;
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ if (stuff->numSpecs > UINT32_MAX / sizeof(ctx.specs[0]))
+ return BadLength;
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(ctx.specs[0]));
@@ -1052,8 +1054,8 @@ SProcXResQueryResourceBytes (ClientPtr client)
int c;
xXResResourceIdSpec *specs = (void*) ((char*) stuff + sizeof(*stuff));
- swapl(&stuff->numSpecs);
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ swapl(&stuff->numSpecs);
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(specs[0])); | CWE-20 | null | null |
13,980 | ResFindResourcePixmaps(void *value, XID id, RESTYPE type, void *cdata)
{
SizeType sizeFunc = GetResourceTypeSizeFunc(type);
ResourceSizeRec size = { 0, 0, 0 };
unsigned long *bytes = cdata;
sizeFunc(value, id, &size);
*bytes += size.pixmapRefSize;
}
| Exec Code | 0 | ResFindResourcePixmaps(void *value, XID id, RESTYPE type, void *cdata)
{
SizeType sizeFunc = GetResourceTypeSizeFunc(type);
ResourceSizeRec size = { 0, 0, 0 };
unsigned long *bytes = cdata;
sizeFunc(value, id, &size);
*bytes += size.pixmapRefSize;
}
| @@ -947,6 +947,8 @@ ProcXResQueryResourceBytes (ClientPtr client)
ConstructResourceBytesCtx ctx;
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ if (stuff->numSpecs > UINT32_MAX / sizeof(ctx.specs[0]))
+ return BadLength;
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(ctx.specs[0]));
@@ -1052,8 +1054,8 @@ SProcXResQueryResourceBytes (ClientPtr client)
int c;
xXResResourceIdSpec *specs = (void*) ((char*) stuff + sizeof(*stuff));
- swapl(&stuff->numSpecs);
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ swapl(&stuff->numSpecs);
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(specs[0])); | CWE-20 | null | null |
13,981 | SProcXResQueryClientIds (ClientPtr client)
{
REQUEST(xXResQueryClientIdsReq);
REQUEST_AT_LEAST_SIZE (xXResQueryClientIdsReq);
swapl(&stuff->numSpecs);
return ProcXResQueryClientIds(client);
}
| Exec Code | 0 | SProcXResQueryClientIds (ClientPtr client)
{
REQUEST(xXResQueryClientIdsReq);
REQUEST_AT_LEAST_SIZE (xXResQueryClientIdsReq);
swapl(&stuff->numSpecs);
return ProcXResQueryClientIds(client);
}
| @@ -947,6 +947,8 @@ ProcXResQueryResourceBytes (ClientPtr client)
ConstructResourceBytesCtx ctx;
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ if (stuff->numSpecs > UINT32_MAX / sizeof(ctx.specs[0]))
+ return BadLength;
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(ctx.specs[0]));
@@ -1052,8 +1054,8 @@ SProcXResQueryResourceBytes (ClientPtr client)
int c;
xXResResourceIdSpec *specs = (void*) ((char*) stuff + sizeof(*stuff));
- swapl(&stuff->numSpecs);
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ swapl(&stuff->numSpecs);
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(specs[0])); | CWE-20 | null | null |
13,982 | SProcXResQueryClientPixmapBytes(ClientPtr client)
{
REQUEST(xXResQueryClientPixmapBytesReq);
REQUEST_SIZE_MATCH(xXResQueryClientPixmapBytesReq);
swapl(&stuff->xid);
return ProcXResQueryClientPixmapBytes(client);
}
| Exec Code | 0 | SProcXResQueryClientPixmapBytes(ClientPtr client)
{
REQUEST(xXResQueryClientPixmapBytesReq);
REQUEST_SIZE_MATCH(xXResQueryClientPixmapBytesReq);
swapl(&stuff->xid);
return ProcXResQueryClientPixmapBytes(client);
}
| @@ -947,6 +947,8 @@ ProcXResQueryResourceBytes (ClientPtr client)
ConstructResourceBytesCtx ctx;
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ if (stuff->numSpecs > UINT32_MAX / sizeof(ctx.specs[0]))
+ return BadLength;
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(ctx.specs[0]));
@@ -1052,8 +1054,8 @@ SProcXResQueryResourceBytes (ClientPtr client)
int c;
xXResResourceIdSpec *specs = (void*) ((char*) stuff + sizeof(*stuff));
- swapl(&stuff->numSpecs);
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ swapl(&stuff->numSpecs);
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(specs[0])); | CWE-20 | null | null |
13,983 | SProcXResQueryClientResources(ClientPtr client)
{
REQUEST(xXResQueryClientResourcesReq);
REQUEST_SIZE_MATCH(xXResQueryClientResourcesReq);
swapl(&stuff->xid);
return ProcXResQueryClientResources(client);
}
| Exec Code | 0 | SProcXResQueryClientResources(ClientPtr client)
{
REQUEST(xXResQueryClientResourcesReq);
REQUEST_SIZE_MATCH(xXResQueryClientResourcesReq);
swapl(&stuff->xid);
return ProcXResQueryClientResources(client);
}
| @@ -947,6 +947,8 @@ ProcXResQueryResourceBytes (ClientPtr client)
ConstructResourceBytesCtx ctx;
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ if (stuff->numSpecs > UINT32_MAX / sizeof(ctx.specs[0]))
+ return BadLength;
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(ctx.specs[0]));
@@ -1052,8 +1054,8 @@ SProcXResQueryResourceBytes (ClientPtr client)
int c;
xXResResourceIdSpec *specs = (void*) ((char*) stuff + sizeof(*stuff));
- swapl(&stuff->numSpecs);
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ swapl(&stuff->numSpecs);
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(specs[0])); | CWE-20 | null | null |
13,984 | SProcXResQueryVersion(ClientPtr client)
{
REQUEST_SIZE_MATCH(xXResQueryVersionReq);
return ProcXResQueryVersion(client);
}
| Exec Code | 0 | SProcXResQueryVersion(ClientPtr client)
{
REQUEST_SIZE_MATCH(xXResQueryVersionReq);
return ProcXResQueryVersion(client);
}
| @@ -947,6 +947,8 @@ ProcXResQueryResourceBytes (ClientPtr client)
ConstructResourceBytesCtx ctx;
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ if (stuff->numSpecs > UINT32_MAX / sizeof(ctx.specs[0]))
+ return BadLength;
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(ctx.specs[0]));
@@ -1052,8 +1054,8 @@ SProcXResQueryResourceBytes (ClientPtr client)
int c;
xXResResourceIdSpec *specs = (void*) ((char*) stuff + sizeof(*stuff));
- swapl(&stuff->numSpecs);
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ swapl(&stuff->numSpecs);
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(specs[0])); | CWE-20 | null | null |
13,985 | SwapXResQueryResourceBytes(struct xorg_list *response)
{
struct xorg_list *it = response->next;
int c;
while (it != response) {
xXResResourceSizeValue *value = FRAGMENT_DATA(it);
it = it->next;
for (c = 0; c < value->numCrossReferences; ++c) {
xXResResourceSizeSpec *spec = FRAGMENT_DATA(it);
SwapXResResourceSizeSpec(spec);
it = it->next;
}
SwapXResResourceSizeValue(value);
}
}
| Exec Code | 0 | SwapXResQueryResourceBytes(struct xorg_list *response)
{
struct xorg_list *it = response->next;
int c;
while (it != response) {
xXResResourceSizeValue *value = FRAGMENT_DATA(it);
it = it->next;
for (c = 0; c < value->numCrossReferences; ++c) {
xXResResourceSizeSpec *spec = FRAGMENT_DATA(it);
SwapXResResourceSizeSpec(spec);
it = it->next;
}
SwapXResResourceSizeValue(value);
}
}
| @@ -947,6 +947,8 @@ ProcXResQueryResourceBytes (ClientPtr client)
ConstructResourceBytesCtx ctx;
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ if (stuff->numSpecs > UINT32_MAX / sizeof(ctx.specs[0]))
+ return BadLength;
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(ctx.specs[0]));
@@ -1052,8 +1054,8 @@ SProcXResQueryResourceBytes (ClientPtr client)
int c;
xXResResourceIdSpec *specs = (void*) ((char*) stuff + sizeof(*stuff));
- swapl(&stuff->numSpecs);
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ swapl(&stuff->numSpecs);
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(specs[0])); | CWE-20 | null | null |
13,986 | SwapXResResourceIdSpec(xXResResourceIdSpec *spec)
{
swapl(&spec->resource);
swapl(&spec->type);
}
| Exec Code | 0 | SwapXResResourceIdSpec(xXResResourceIdSpec *spec)
{
swapl(&spec->resource);
swapl(&spec->type);
}
| @@ -947,6 +947,8 @@ ProcXResQueryResourceBytes (ClientPtr client)
ConstructResourceBytesCtx ctx;
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ if (stuff->numSpecs > UINT32_MAX / sizeof(ctx.specs[0]))
+ return BadLength;
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(ctx.specs[0]));
@@ -1052,8 +1054,8 @@ SProcXResQueryResourceBytes (ClientPtr client)
int c;
xXResResourceIdSpec *specs = (void*) ((char*) stuff + sizeof(*stuff));
- swapl(&stuff->numSpecs);
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ swapl(&stuff->numSpecs);
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(specs[0])); | CWE-20 | null | null |
13,987 | SwapXResResourceSizeValue(xXResResourceSizeValue *rep)
{
SwapXResResourceSizeSpec(&rep->size);
swapl(&rep->numCrossReferences);
}
| Exec Code | 0 | SwapXResResourceSizeValue(xXResResourceSizeValue *rep)
{
SwapXResResourceSizeSpec(&rep->size);
swapl(&rep->numCrossReferences);
}
| @@ -947,6 +947,8 @@ ProcXResQueryResourceBytes (ClientPtr client)
ConstructResourceBytesCtx ctx;
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ if (stuff->numSpecs > UINT32_MAX / sizeof(ctx.specs[0]))
+ return BadLength;
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(ctx.specs[0]));
@@ -1052,8 +1054,8 @@ SProcXResQueryResourceBytes (ClientPtr client)
int c;
xXResResourceIdSpec *specs = (void*) ((char*) stuff + sizeof(*stuff));
- swapl(&stuff->numSpecs);
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ swapl(&stuff->numSpecs);
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(specs[0])); | CWE-20 | null | null |
13,988 | WillConstructMask(ClientPtr client, CARD32 mask,
ConstructClientIdCtx *ctx, int sendMask)
{
if ((!mask || (mask & sendMask))
&& !(ctx->sentClientMasks[client->index] & sendMask)) {
ctx->sentClientMasks[client->index] |= sendMask;
return TRUE;
} else {
return FALSE;
}
}
| Exec Code | 0 | WillConstructMask(ClientPtr client, CARD32 mask,
ConstructClientIdCtx *ctx, int sendMask)
{
if ((!mask || (mask & sendMask))
&& !(ctx->sentClientMasks[client->index] & sendMask)) {
ctx->sentClientMasks[client->index] |= sendMask;
return TRUE;
} else {
return FALSE;
}
}
| @@ -947,6 +947,8 @@ ProcXResQueryResourceBytes (ClientPtr client)
ConstructResourceBytesCtx ctx;
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ if (stuff->numSpecs > UINT32_MAX / sizeof(ctx.specs[0]))
+ return BadLength;
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(ctx.specs[0]));
@@ -1052,8 +1054,8 @@ SProcXResQueryResourceBytes (ClientPtr client)
int c;
xXResResourceIdSpec *specs = (void*) ((char*) stuff + sizeof(*stuff));
- swapl(&stuff->numSpecs);
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ swapl(&stuff->numSpecs);
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(specs[0])); | CWE-20 | null | null |
13,989 | WriteFragmentsToClient(ClientPtr client, struct xorg_list *frags)
{
FragmentList *it;
xorg_list_for_each_entry(it, frags, l) {
WriteToClient(client, it->bytes, (char*) it + sizeof(*it));
}
}
| Exec Code | 0 | WriteFragmentsToClient(ClientPtr client, struct xorg_list *frags)
{
FragmentList *it;
xorg_list_for_each_entry(it, frags, l) {
WriteToClient(client, it->bytes, (char*) it + sizeof(*it));
}
}
| @@ -947,6 +947,8 @@ ProcXResQueryResourceBytes (ClientPtr client)
ConstructResourceBytesCtx ctx;
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ if (stuff->numSpecs > UINT32_MAX / sizeof(ctx.specs[0]))
+ return BadLength;
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(ctx.specs[0]));
@@ -1052,8 +1054,8 @@ SProcXResQueryResourceBytes (ClientPtr client)
int c;
xXResResourceIdSpec *specs = (void*) ((char*) stuff + sizeof(*stuff));
- swapl(&stuff->numSpecs);
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
+ swapl(&stuff->numSpecs);
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
stuff->numSpecs * sizeof(specs[0])); | CWE-20 | null | null |
13,990 | ProcXvDispatch(ClientPtr client)
{
REQUEST(xReq);
UpdateCurrentTime();
if (stuff->data >= xvNumRequests) {
return BadRequest;
}
return XvProcVector[stuff->data] (client);
}
| Exec Code | 0 | ProcXvDispatch(ClientPtr client)
{
REQUEST(xReq);
UpdateCurrentTime();
if (stuff->data >= xvNumRequests) {
return BadRequest;
}
return XvProcVector[stuff->data] (client);
}
| @@ -1493,12 +1493,14 @@ XineramaXvShmPutImage(ClientPtr client)
{
REQUEST(xvShmPutImageReq);
PanoramiXRes *draw, *gc, *port;
- Bool send_event = stuff->send_event;
+ Bool send_event;
Bool isRoot;
int result, i, x, y;
REQUEST_SIZE_MATCH(xvShmPutImageReq);
+ send_event = stuff->send_event;
+
result = dixLookupResourceByClass((void **) &draw, stuff->drawable,
XRC_DRAWABLE, client, DixWriteAccess);
if (result != Success) | CWE-20 | null | null |
13,991 | ProcXvGetPortAttribute(ClientPtr client)
{
INT32 value;
int status;
XvPortPtr pPort;
xvGetPortAttributeReply rep;
REQUEST(xvGetPortAttributeReq);
REQUEST_SIZE_MATCH(xvGetPortAttributeReq);
VALIDATE_XV_PORT(stuff->port, pPort, DixGetAttrAccess);
if (!ValidAtom(stuff->attribute)) {
client->errorValue = stuff->attribute;
return BadAtom;
}
status = XvdiGetPortAttribute(client, pPort, stuff->attribute, &value);
if (status != Success) {
client->errorValue = stuff->attribute;
return status;
}
rep = (xvGetPortAttributeReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.value = value
};
_WriteGetPortAttributeReply(client, &rep);
return Success;
}
| Exec Code | 0 | ProcXvGetPortAttribute(ClientPtr client)
{
INT32 value;
int status;
XvPortPtr pPort;
xvGetPortAttributeReply rep;
REQUEST(xvGetPortAttributeReq);
REQUEST_SIZE_MATCH(xvGetPortAttributeReq);
VALIDATE_XV_PORT(stuff->port, pPort, DixGetAttrAccess);
if (!ValidAtom(stuff->attribute)) {
client->errorValue = stuff->attribute;
return BadAtom;
}
status = XvdiGetPortAttribute(client, pPort, stuff->attribute, &value);
if (status != Success) {
client->errorValue = stuff->attribute;
return status;
}
rep = (xvGetPortAttributeReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.value = value
};
_WriteGetPortAttributeReply(client, &rep);
return Success;
}
| @@ -1493,12 +1493,14 @@ XineramaXvShmPutImage(ClientPtr client)
{
REQUEST(xvShmPutImageReq);
PanoramiXRes *draw, *gc, *port;
- Bool send_event = stuff->send_event;
+ Bool send_event;
Bool isRoot;
int result, i, x, y;
REQUEST_SIZE_MATCH(xvShmPutImageReq);
+ send_event = stuff->send_event;
+
result = dixLookupResourceByClass((void **) &draw, stuff->drawable,
XRC_DRAWABLE, client, DixWriteAccess);
if (result != Success) | CWE-20 | null | null |
13,992 | ProcXvGetStill(ClientPtr client)
{
DrawablePtr pDraw;
XvPortPtr pPort;
GCPtr pGC;
int status;
REQUEST(xvGetStillReq);
REQUEST_SIZE_MATCH(xvGetStillReq);
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixReadAccess);
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
if (!(pPort->pAdaptor->type & XvOutputMask) ||
!(pPort->pAdaptor->type & XvStillMask)) {
client->errorValue = stuff->port;
return BadMatch;
}
status = XvdiMatchPort(pPort, pDraw);
if (status != Success) {
return status;
}
return XvdiGetStill(client, pDraw, pPort, pGC, stuff->vid_x, stuff->vid_y,
stuff->vid_w, stuff->vid_h, stuff->drw_x, stuff->drw_y,
stuff->drw_w, stuff->drw_h);
}
| Exec Code | 0 | ProcXvGetStill(ClientPtr client)
{
DrawablePtr pDraw;
XvPortPtr pPort;
GCPtr pGC;
int status;
REQUEST(xvGetStillReq);
REQUEST_SIZE_MATCH(xvGetStillReq);
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixReadAccess);
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
if (!(pPort->pAdaptor->type & XvOutputMask) ||
!(pPort->pAdaptor->type & XvStillMask)) {
client->errorValue = stuff->port;
return BadMatch;
}
status = XvdiMatchPort(pPort, pDraw);
if (status != Success) {
return status;
}
return XvdiGetStill(client, pDraw, pPort, pGC, stuff->vid_x, stuff->vid_y,
stuff->vid_w, stuff->vid_h, stuff->drw_x, stuff->drw_y,
stuff->drw_w, stuff->drw_h);
}
| @@ -1493,12 +1493,14 @@ XineramaXvShmPutImage(ClientPtr client)
{
REQUEST(xvShmPutImageReq);
PanoramiXRes *draw, *gc, *port;
- Bool send_event = stuff->send_event;
+ Bool send_event;
Bool isRoot;
int result, i, x, y;
REQUEST_SIZE_MATCH(xvShmPutImageReq);
+ send_event = stuff->send_event;
+
result = dixLookupResourceByClass((void **) &draw, stuff->drawable,
XRC_DRAWABLE, client, DixWriteAccess);
if (result != Success) | CWE-20 | null | null |
13,993 | ProcXvGetVideo(ClientPtr client)
{
DrawablePtr pDraw;
XvPortPtr pPort;
GCPtr pGC;
int status;
REQUEST(xvGetVideoReq);
REQUEST_SIZE_MATCH(xvGetVideoReq);
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixReadAccess);
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
if (!(pPort->pAdaptor->type & XvOutputMask) ||
!(pPort->pAdaptor->type & XvVideoMask)) {
client->errorValue = stuff->port;
return BadMatch;
}
status = XvdiMatchPort(pPort, pDraw);
if (status != Success) {
return status;
}
return XvdiGetVideo(client, pDraw, pPort, pGC, stuff->vid_x, stuff->vid_y,
stuff->vid_w, stuff->vid_h, stuff->drw_x, stuff->drw_y,
stuff->drw_w, stuff->drw_h);
}
| Exec Code | 0 | ProcXvGetVideo(ClientPtr client)
{
DrawablePtr pDraw;
XvPortPtr pPort;
GCPtr pGC;
int status;
REQUEST(xvGetVideoReq);
REQUEST_SIZE_MATCH(xvGetVideoReq);
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixReadAccess);
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
if (!(pPort->pAdaptor->type & XvOutputMask) ||
!(pPort->pAdaptor->type & XvVideoMask)) {
client->errorValue = stuff->port;
return BadMatch;
}
status = XvdiMatchPort(pPort, pDraw);
if (status != Success) {
return status;
}
return XvdiGetVideo(client, pDraw, pPort, pGC, stuff->vid_x, stuff->vid_y,
stuff->vid_w, stuff->vid_h, stuff->drw_x, stuff->drw_y,
stuff->drw_w, stuff->drw_h);
}
| @@ -1493,12 +1493,14 @@ XineramaXvShmPutImage(ClientPtr client)
{
REQUEST(xvShmPutImageReq);
PanoramiXRes *draw, *gc, *port;
- Bool send_event = stuff->send_event;
+ Bool send_event;
Bool isRoot;
int result, i, x, y;
REQUEST_SIZE_MATCH(xvShmPutImageReq);
+ send_event = stuff->send_event;
+
result = dixLookupResourceByClass((void **) &draw, stuff->drawable,
XRC_DRAWABLE, client, DixWriteAccess);
if (result != Success) | CWE-20 | null | null |
13,994 | ProcXvGrabPort(ClientPtr client)
{
int result, status;
XvPortPtr pPort;
xvGrabPortReply rep;
REQUEST(xvGrabPortReq);
REQUEST_SIZE_MATCH(xvGrabPortReq);
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
status = XvdiGrabPort(client, pPort, stuff->time, &result);
if (status != Success) {
return status;
}
rep = (xvGrabPortReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.result = result
};
_WriteGrabPortReply(client, &rep);
return Success;
}
| Exec Code | 0 | ProcXvGrabPort(ClientPtr client)
{
int result, status;
XvPortPtr pPort;
xvGrabPortReply rep;
REQUEST(xvGrabPortReq);
REQUEST_SIZE_MATCH(xvGrabPortReq);
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
status = XvdiGrabPort(client, pPort, stuff->time, &result);
if (status != Success) {
return status;
}
rep = (xvGrabPortReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.result = result
};
_WriteGrabPortReply(client, &rep);
return Success;
}
| @@ -1493,12 +1493,14 @@ XineramaXvShmPutImage(ClientPtr client)
{
REQUEST(xvShmPutImageReq);
PanoramiXRes *draw, *gc, *port;
- Bool send_event = stuff->send_event;
+ Bool send_event;
Bool isRoot;
int result, i, x, y;
REQUEST_SIZE_MATCH(xvShmPutImageReq);
+ send_event = stuff->send_event;
+
result = dixLookupResourceByClass((void **) &draw, stuff->drawable,
XRC_DRAWABLE, client, DixWriteAccess);
if (result != Success) | CWE-20 | null | null |
13,995 | ProcXvPutStill(ClientPtr client)
{
DrawablePtr pDraw;
XvPortPtr pPort;
GCPtr pGC;
int status;
REQUEST(xvPutStillReq);
REQUEST_SIZE_MATCH(xvPutStillReq);
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
if (!(pPort->pAdaptor->type & XvInputMask) ||
!(pPort->pAdaptor->type & XvStillMask)) {
client->errorValue = stuff->port;
return BadMatch;
}
status = XvdiMatchPort(pPort, pDraw);
if (status != Success) {
return status;
}
return XvdiPutStill(client, pDraw, pPort, pGC, stuff->vid_x, stuff->vid_y,
stuff->vid_w, stuff->vid_h, stuff->drw_x, stuff->drw_y,
stuff->drw_w, stuff->drw_h);
}
| Exec Code | 0 | ProcXvPutStill(ClientPtr client)
{
DrawablePtr pDraw;
XvPortPtr pPort;
GCPtr pGC;
int status;
REQUEST(xvPutStillReq);
REQUEST_SIZE_MATCH(xvPutStillReq);
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
if (!(pPort->pAdaptor->type & XvInputMask) ||
!(pPort->pAdaptor->type & XvStillMask)) {
client->errorValue = stuff->port;
return BadMatch;
}
status = XvdiMatchPort(pPort, pDraw);
if (status != Success) {
return status;
}
return XvdiPutStill(client, pDraw, pPort, pGC, stuff->vid_x, stuff->vid_y,
stuff->vid_w, stuff->vid_h, stuff->drw_x, stuff->drw_y,
stuff->drw_w, stuff->drw_h);
}
| @@ -1493,12 +1493,14 @@ XineramaXvShmPutImage(ClientPtr client)
{
REQUEST(xvShmPutImageReq);
PanoramiXRes *draw, *gc, *port;
- Bool send_event = stuff->send_event;
+ Bool send_event;
Bool isRoot;
int result, i, x, y;
REQUEST_SIZE_MATCH(xvShmPutImageReq);
+ send_event = stuff->send_event;
+
result = dixLookupResourceByClass((void **) &draw, stuff->drawable,
XRC_DRAWABLE, client, DixWriteAccess);
if (result != Success) | CWE-20 | null | null |
13,996 | ProcXvPutVideo(ClientPtr client)
{
DrawablePtr pDraw;
XvPortPtr pPort;
GCPtr pGC;
int status;
REQUEST(xvPutVideoReq);
REQUEST_SIZE_MATCH(xvPutVideoReq);
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
if (!(pPort->pAdaptor->type & XvInputMask) ||
!(pPort->pAdaptor->type & XvVideoMask)) {
client->errorValue = stuff->port;
return BadMatch;
}
status = XvdiMatchPort(pPort, pDraw);
if (status != Success) {
return status;
}
return XvdiPutVideo(client, pDraw, pPort, pGC, stuff->vid_x, stuff->vid_y,
stuff->vid_w, stuff->vid_h, stuff->drw_x, stuff->drw_y,
stuff->drw_w, stuff->drw_h);
}
| Exec Code | 0 | ProcXvPutVideo(ClientPtr client)
{
DrawablePtr pDraw;
XvPortPtr pPort;
GCPtr pGC;
int status;
REQUEST(xvPutVideoReq);
REQUEST_SIZE_MATCH(xvPutVideoReq);
VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
if (!(pPort->pAdaptor->type & XvInputMask) ||
!(pPort->pAdaptor->type & XvVideoMask)) {
client->errorValue = stuff->port;
return BadMatch;
}
status = XvdiMatchPort(pPort, pDraw);
if (status != Success) {
return status;
}
return XvdiPutVideo(client, pDraw, pPort, pGC, stuff->vid_x, stuff->vid_y,
stuff->vid_w, stuff->vid_h, stuff->drw_x, stuff->drw_y,
stuff->drw_w, stuff->drw_h);
}
| @@ -1493,12 +1493,14 @@ XineramaXvShmPutImage(ClientPtr client)
{
REQUEST(xvShmPutImageReq);
PanoramiXRes *draw, *gc, *port;
- Bool send_event = stuff->send_event;
+ Bool send_event;
Bool isRoot;
int result, i, x, y;
REQUEST_SIZE_MATCH(xvShmPutImageReq);
+ send_event = stuff->send_event;
+
result = dixLookupResourceByClass((void **) &draw, stuff->drawable,
XRC_DRAWABLE, client, DixWriteAccess);
if (result != Success) | CWE-20 | null | null |
13,997 | ProcXvQueryAdaptors(ClientPtr client)
{
xvFormat format;
xvAdaptorInfo ainfo;
xvQueryAdaptorsReply rep;
int totalSize, na, nf, rc;
int nameSize;
XvAdaptorPtr pa;
XvFormatPtr pf;
WindowPtr pWin;
ScreenPtr pScreen;
XvScreenPtr pxvs;
REQUEST(xvQueryAdaptorsReq);
REQUEST_SIZE_MATCH(xvQueryAdaptorsReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc;
pScreen = pWin->drawable.pScreen;
pxvs = (XvScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
XvGetScreenKey());
if (!pxvs) {
rep = (xvQueryAdaptorsReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.num_adaptors = 0
};
_WriteQueryAdaptorsReply(client, &rep);
return Success;
}
rep = (xvQueryAdaptorsReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.num_adaptors = pxvs->nAdaptors
};
/* CALCULATE THE TOTAL SIZE OF THE REPLY IN BYTES */
totalSize = pxvs->nAdaptors * sz_xvAdaptorInfo;
/* FOR EACH ADPATOR ADD UP THE BYTES FOR ENCODINGS AND FORMATS */
na = pxvs->nAdaptors;
pa = pxvs->pAdaptors;
while (na--) {
totalSize += pad_to_int32(strlen(pa->name));
totalSize += pa->nFormats * sz_xvFormat;
pa++;
}
rep.length = bytes_to_int32(totalSize);
_WriteQueryAdaptorsReply(client, &rep);
na = pxvs->nAdaptors;
pa = pxvs->pAdaptors;
while (na--) {
ainfo.base_id = pa->base_id;
ainfo.num_ports = pa->nPorts;
ainfo.type = pa->type;
ainfo.name_size = nameSize = strlen(pa->name);
ainfo.num_formats = pa->nFormats;
_WriteAdaptorInfo(client, &ainfo);
WriteToClient(client, nameSize, pa->name);
nf = pa->nFormats;
pf = pa->pFormats;
while (nf--) {
format.depth = pf->depth;
format.visual = pf->visual;
_WriteFormat(client, &format);
pf++;
}
pa++;
}
return Success;
}
| Exec Code | 0 | ProcXvQueryAdaptors(ClientPtr client)
{
xvFormat format;
xvAdaptorInfo ainfo;
xvQueryAdaptorsReply rep;
int totalSize, na, nf, rc;
int nameSize;
XvAdaptorPtr pa;
XvFormatPtr pf;
WindowPtr pWin;
ScreenPtr pScreen;
XvScreenPtr pxvs;
REQUEST(xvQueryAdaptorsReq);
REQUEST_SIZE_MATCH(xvQueryAdaptorsReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc;
pScreen = pWin->drawable.pScreen;
pxvs = (XvScreenPtr) dixLookupPrivate(&pScreen->devPrivates,
XvGetScreenKey());
if (!pxvs) {
rep = (xvQueryAdaptorsReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.num_adaptors = 0
};
_WriteQueryAdaptorsReply(client, &rep);
return Success;
}
rep = (xvQueryAdaptorsReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.num_adaptors = pxvs->nAdaptors
};
/* CALCULATE THE TOTAL SIZE OF THE REPLY IN BYTES */
totalSize = pxvs->nAdaptors * sz_xvAdaptorInfo;
/* FOR EACH ADPATOR ADD UP THE BYTES FOR ENCODINGS AND FORMATS */
na = pxvs->nAdaptors;
pa = pxvs->pAdaptors;
while (na--) {
totalSize += pad_to_int32(strlen(pa->name));
totalSize += pa->nFormats * sz_xvFormat;
pa++;
}
rep.length = bytes_to_int32(totalSize);
_WriteQueryAdaptorsReply(client, &rep);
na = pxvs->nAdaptors;
pa = pxvs->pAdaptors;
while (na--) {
ainfo.base_id = pa->base_id;
ainfo.num_ports = pa->nPorts;
ainfo.type = pa->type;
ainfo.name_size = nameSize = strlen(pa->name);
ainfo.num_formats = pa->nFormats;
_WriteAdaptorInfo(client, &ainfo);
WriteToClient(client, nameSize, pa->name);
nf = pa->nFormats;
pf = pa->pFormats;
while (nf--) {
format.depth = pf->depth;
format.visual = pf->visual;
_WriteFormat(client, &format);
pf++;
}
pa++;
}
return Success;
}
| @@ -1493,12 +1493,14 @@ XineramaXvShmPutImage(ClientPtr client)
{
REQUEST(xvShmPutImageReq);
PanoramiXRes *draw, *gc, *port;
- Bool send_event = stuff->send_event;
+ Bool send_event;
Bool isRoot;
int result, i, x, y;
REQUEST_SIZE_MATCH(xvShmPutImageReq);
+ send_event = stuff->send_event;
+
result = dixLookupResourceByClass((void **) &draw, stuff->drawable,
XRC_DRAWABLE, client, DixWriteAccess);
if (result != Success) | CWE-20 | null | null |
13,998 | ProcXvQueryBestSize(ClientPtr client)
{
unsigned int actual_width, actual_height;
XvPortPtr pPort;
xvQueryBestSizeReply rep;
REQUEST(xvQueryBestSizeReq);
REQUEST_SIZE_MATCH(xvQueryBestSizeReq);
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
(*pPort->pAdaptor->ddQueryBestSize) (pPort, stuff->motion,
stuff->vid_w, stuff->vid_h,
stuff->drw_w, stuff->drw_h,
&actual_width, &actual_height);
rep = (xvQueryBestSizeReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.actual_width = actual_width,
.actual_height = actual_height
};
_WriteQueryBestSizeReply(client, &rep);
return Success;
}
| Exec Code | 0 | ProcXvQueryBestSize(ClientPtr client)
{
unsigned int actual_width, actual_height;
XvPortPtr pPort;
xvQueryBestSizeReply rep;
REQUEST(xvQueryBestSizeReq);
REQUEST_SIZE_MATCH(xvQueryBestSizeReq);
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
(*pPort->pAdaptor->ddQueryBestSize) (pPort, stuff->motion,
stuff->vid_w, stuff->vid_h,
stuff->drw_w, stuff->drw_h,
&actual_width, &actual_height);
rep = (xvQueryBestSizeReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.actual_width = actual_width,
.actual_height = actual_height
};
_WriteQueryBestSizeReply(client, &rep);
return Success;
}
| @@ -1493,12 +1493,14 @@ XineramaXvShmPutImage(ClientPtr client)
{
REQUEST(xvShmPutImageReq);
PanoramiXRes *draw, *gc, *port;
- Bool send_event = stuff->send_event;
+ Bool send_event;
Bool isRoot;
int result, i, x, y;
REQUEST_SIZE_MATCH(xvShmPutImageReq);
+ send_event = stuff->send_event;
+
result = dixLookupResourceByClass((void **) &draw, stuff->drawable,
XRC_DRAWABLE, client, DixWriteAccess);
if (result != Success) | CWE-20 | null | null |
13,999 | ProcXvQueryEncodings(ClientPtr client)
{
xvEncodingInfo einfo;
xvQueryEncodingsReply rep;
int totalSize;
int nameSize;
XvPortPtr pPort;
int ne;
XvEncodingPtr pe;
REQUEST(xvQueryEncodingsReq);
REQUEST_SIZE_MATCH(xvQueryEncodingsReq);
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
rep = (xvQueryEncodingsReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.num_encodings = pPort->pAdaptor->nEncodings
};
/* FOR EACH ENCODING ADD UP THE BYTES FOR ENCODING NAMES */
ne = pPort->pAdaptor->nEncodings;
pe = pPort->pAdaptor->pEncodings;
totalSize = ne * sz_xvEncodingInfo;
while (ne--) {
totalSize += pad_to_int32(strlen(pe->name));
pe++;
}
rep.length = bytes_to_int32(totalSize);
_WriteQueryEncodingsReply(client, &rep);
ne = pPort->pAdaptor->nEncodings;
pe = pPort->pAdaptor->pEncodings;
while (ne--) {
einfo.encoding = pe->id;
einfo.name_size = nameSize = strlen(pe->name);
einfo.width = pe->width;
einfo.height = pe->height;
einfo.rate.numerator = pe->rate.numerator;
einfo.rate.denominator = pe->rate.denominator;
_WriteEncodingInfo(client, &einfo);
WriteToClient(client, nameSize, pe->name);
pe++;
}
return Success;
}
| Exec Code | 0 | ProcXvQueryEncodings(ClientPtr client)
{
xvEncodingInfo einfo;
xvQueryEncodingsReply rep;
int totalSize;
int nameSize;
XvPortPtr pPort;
int ne;
XvEncodingPtr pe;
REQUEST(xvQueryEncodingsReq);
REQUEST_SIZE_MATCH(xvQueryEncodingsReq);
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
rep = (xvQueryEncodingsReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.num_encodings = pPort->pAdaptor->nEncodings
};
/* FOR EACH ENCODING ADD UP THE BYTES FOR ENCODING NAMES */
ne = pPort->pAdaptor->nEncodings;
pe = pPort->pAdaptor->pEncodings;
totalSize = ne * sz_xvEncodingInfo;
while (ne--) {
totalSize += pad_to_int32(strlen(pe->name));
pe++;
}
rep.length = bytes_to_int32(totalSize);
_WriteQueryEncodingsReply(client, &rep);
ne = pPort->pAdaptor->nEncodings;
pe = pPort->pAdaptor->pEncodings;
while (ne--) {
einfo.encoding = pe->id;
einfo.name_size = nameSize = strlen(pe->name);
einfo.width = pe->width;
einfo.height = pe->height;
einfo.rate.numerator = pe->rate.numerator;
einfo.rate.denominator = pe->rate.denominator;
_WriteEncodingInfo(client, &einfo);
WriteToClient(client, nameSize, pe->name);
pe++;
}
return Success;
}
| @@ -1493,12 +1493,14 @@ XineramaXvShmPutImage(ClientPtr client)
{
REQUEST(xvShmPutImageReq);
PanoramiXRes *draw, *gc, *port;
- Bool send_event = stuff->send_event;
+ Bool send_event;
Bool isRoot;
int result, i, x, y;
REQUEST_SIZE_MATCH(xvShmPutImageReq);
+ send_event = stuff->send_event;
+
result = dixLookupResourceByClass((void **) &draw, stuff->drawable,
XRC_DRAWABLE, client, DixWriteAccess);
if (result != Success) | CWE-20 | null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.