idx
int64
func_before
string
Vulnerability Classification
string
vul
int64
func_after
string
patch
string
CWE ID
string
lines_before
string
lines_after
string
11,200
gsicc_load_namedcolor_buffer(cmm_profile_t *profile, stream *s, gs_memory_t *memory) { int num_bytes,profile_size; unsigned char *buffer_ptr; int code; code = srewind(s); if (code < 0) return code; code = sfseek(s,0,SEEK_END); if (code < 0) return code; profile_size = sftell(s); code = srewind(s); if (code < 0) return code; /* Allocate the buffer, stuff with the profile */ buffer_ptr = gs_alloc_bytes(memory->non_gc_memory, profile_size, "gsicc_load_profile"); if (buffer_ptr == NULL) return gs_throw(gs_error_VMerror, "Insufficient memory for profile buffer"); num_bytes = sfread(buffer_ptr,sizeof(unsigned char),profile_size,s); if( num_bytes != profile_size) { gs_free_object(memory->non_gc_memory, buffer_ptr, "gsicc_load_profile"); return -1; } profile->buffer = buffer_ptr; profile->buffer_size = num_bytes; return 0; }
Exec Code
0
gsicc_load_namedcolor_buffer(cmm_profile_t *profile, stream *s, gs_memory_t *memory) { int num_bytes,profile_size; unsigned char *buffer_ptr; int code; code = srewind(s); if (code < 0) return code; code = sfseek(s,0,SEEK_END); if (code < 0) return code; profile_size = sftell(s); code = srewind(s); if (code < 0) return code; /* Allocate the buffer, stuff with the profile */ buffer_ptr = gs_alloc_bytes(memory->non_gc_memory, profile_size, "gsicc_load_profile"); if (buffer_ptr == NULL) return gs_throw(gs_error_VMerror, "Insufficient memory for profile buffer"); num_bytes = sfread(buffer_ptr,sizeof(unsigned char),profile_size,s); if( num_bytes != profile_size) { gs_free_object(memory->non_gc_memory, buffer_ptr, "gsicc_load_profile"); return -1; } profile->buffer = buffer_ptr; profile->buffer_size = num_bytes; return 0; }
@@ -1124,10 +1124,12 @@ gsicc_open_search(const char* pname, int namelen, gs_memory_t *mem_gc, } /* First just try it like it is */ - str = sfopen(pname, "r", mem_gc); - if (str != NULL) { - *strp = str; - return 0; + if (gs_check_file_permission(mem_gc, pname, namelen, "r") >= 0) { + str = sfopen(pname, "r", mem_gc); + if (str != NULL) { + *strp = str; + return 0; + } } /* If that fails, try %rom% */ /* FIXME: Not sure this is needed or correct */
CWE-20
null
null
11,201
gsicc_load_profile_buffer(cmm_profile_t *profile, stream *s, gs_memory_t *memory) { int num_bytes,profile_size; unsigned char *buffer_ptr; int code; code = srewind(s); /* Work around for issue with sfread return 0 bytes and not doing a retry if there is an issue. This is a bug in the stream logic or strmio layer. Occurs with smask_withicc.pdf on linux 64 bit system */ if (code < 0) return code; /* Get the size from doing a seek to the end and then a rewind instead of relying upon the profile size indicated in the header */ code = sfseek(s,0,SEEK_END); if (code < 0) return code; profile_size = sftell(s); code = srewind(s); if (code < 0) return code; if (profile_size < ICC_HEADER_SIZE) return_error(gs_error_VMerror); /* Allocate the buffer, stuff with the profile */ buffer_ptr = gs_alloc_bytes(memory, profile_size, "gsicc_load_profile"); if (buffer_ptr == NULL) return gs_throw(gs_error_VMerror, "Insufficient memory for profile buffer"); num_bytes = sfread(buffer_ptr,sizeof(unsigned char),profile_size,s); if( num_bytes != profile_size) { gs_free_object(memory, buffer_ptr, "gsicc_load_profile"); return -1; } profile->buffer = buffer_ptr; profile->buffer_size = num_bytes; return 0; }
Exec Code
0
gsicc_load_profile_buffer(cmm_profile_t *profile, stream *s, gs_memory_t *memory) { int num_bytes,profile_size; unsigned char *buffer_ptr; int code; code = srewind(s); /* Work around for issue with sfread return 0 bytes and not doing a retry if there is an issue. This is a bug in the stream logic or strmio layer. Occurs with smask_withicc.pdf on linux 64 bit system */ if (code < 0) return code; /* Get the size from doing a seek to the end and then a rewind instead of relying upon the profile size indicated in the header */ code = sfseek(s,0,SEEK_END); if (code < 0) return code; profile_size = sftell(s); code = srewind(s); if (code < 0) return code; if (profile_size < ICC_HEADER_SIZE) return_error(gs_error_VMerror); /* Allocate the buffer, stuff with the profile */ buffer_ptr = gs_alloc_bytes(memory, profile_size, "gsicc_load_profile"); if (buffer_ptr == NULL) return gs_throw(gs_error_VMerror, "Insufficient memory for profile buffer"); num_bytes = sfread(buffer_ptr,sizeof(unsigned char),profile_size,s); if( num_bytes != profile_size) { gs_free_object(memory, buffer_ptr, "gsicc_load_profile"); return -1; } profile->buffer = buffer_ptr; profile->buffer_size = num_bytes; return 0; }
@@ -1124,10 +1124,12 @@ gsicc_open_search(const char* pname, int namelen, gs_memory_t *mem_gc, } /* First just try it like it is */ - str = sfopen(pname, "r", mem_gc); - if (str != NULL) { - *strp = str; - return 0; + if (gs_check_file_permission(mem_gc, pname, namelen, "r") >= 0) { + str = sfopen(pname, "r", mem_gc); + if (str != NULL) { + *strp = str; + return 0; + } } /* If that fails, try %rom% */ /* FIXME: Not sure this is needed or correct */
CWE-20
null
null
11,202
gsicc_manager_finalize(const gs_memory_t *memory, void * vptr) { gsicc_manager_t *icc_man = (gsicc_manager_t *)vptr; gsicc_manager_free_contents(icc_man, "gsicc_manager_finalize"); }
Exec Code
0
gsicc_manager_finalize(const gs_memory_t *memory, void * vptr) { gsicc_manager_t *icc_man = (gsicc_manager_t *)vptr; gsicc_manager_free_contents(icc_man, "gsicc_manager_finalize"); }
@@ -1124,10 +1124,12 @@ gsicc_open_search(const char* pname, int namelen, gs_memory_t *mem_gc, } /* First just try it like it is */ - str = sfopen(pname, "r", mem_gc); - if (str != NULL) { - *strp = str; - return 0; + if (gs_check_file_permission(mem_gc, pname, namelen, "r") >= 0) { + str = sfopen(pname, "r", mem_gc); + if (str != NULL) { + *strp = str; + return 0; + } } /* If that fails, try %rom% */ /* FIXME: Not sure this is needed or correct */
CWE-20
null
null
11,203
static void gsicc_manager_free_contents(gsicc_manager_t *icc_manager, client_name_t cname) { int k; gsicc_devicen_entry_t *device_n, *device_n_next; rc_decrement(icc_manager->default_cmyk, "gsicc_manager_free_contents"); rc_decrement(icc_manager->default_gray, "gsicc_manager_free_contents"); rc_decrement(icc_manager->default_rgb, "gsicc_manager_free_contents"); rc_decrement(icc_manager->device_named, "gsicc_manager_free_contents"); rc_decrement(icc_manager->lab_profile, "gsicc_manager_free_contents"); rc_decrement(icc_manager->graytok_profile, "gsicc_manager_free_contents"); rc_decrement(icc_manager->srcgtag_profile, "gsicc_manager_free_contents"); /* Loop through the DeviceN profiles */ if ( icc_manager->device_n != NULL) { device_n = icc_manager->device_n->head; for ( k = 0; k < icc_manager->device_n->count; k++) { rc_decrement(device_n->iccprofile, "gsicc_manager_free_contents"); device_n_next = device_n->next; gs_free_object(icc_manager->memory, device_n, "gsicc_manager_free_contents"); device_n = device_n_next; } gs_free_object(icc_manager->memory, icc_manager->device_n, "gsicc_manager_free_contents"); } /* The soft mask profiles */ if (icc_manager->smask_profiles != NULL) { gs_free_object(icc_manager->smask_profiles->memory, icc_manager->smask_profiles, "gsicc_manager_free_contents"); icc_manager->smask_profiles = NULL; } }
Exec Code
0
static void gsicc_manager_free_contents(gsicc_manager_t *icc_manager, client_name_t cname) { int k; gsicc_devicen_entry_t *device_n, *device_n_next; rc_decrement(icc_manager->default_cmyk, "gsicc_manager_free_contents"); rc_decrement(icc_manager->default_gray, "gsicc_manager_free_contents"); rc_decrement(icc_manager->default_rgb, "gsicc_manager_free_contents"); rc_decrement(icc_manager->device_named, "gsicc_manager_free_contents"); rc_decrement(icc_manager->lab_profile, "gsicc_manager_free_contents"); rc_decrement(icc_manager->graytok_profile, "gsicc_manager_free_contents"); rc_decrement(icc_manager->srcgtag_profile, "gsicc_manager_free_contents"); /* Loop through the DeviceN profiles */ if ( icc_manager->device_n != NULL) { device_n = icc_manager->device_n->head; for ( k = 0; k < icc_manager->device_n->count; k++) { rc_decrement(device_n->iccprofile, "gsicc_manager_free_contents"); device_n_next = device_n->next; gs_free_object(icc_manager->memory, device_n, "gsicc_manager_free_contents"); device_n = device_n_next; } gs_free_object(icc_manager->memory, icc_manager->device_n, "gsicc_manager_free_contents"); } /* The soft mask profiles */ if (icc_manager->smask_profiles != NULL) { gs_free_object(icc_manager->smask_profiles->memory, icc_manager->smask_profiles, "gsicc_manager_free_contents"); icc_manager->smask_profiles = NULL; } }
@@ -1124,10 +1124,12 @@ gsicc_open_search(const char* pname, int namelen, gs_memory_t *mem_gc, } /* First just try it like it is */ - str = sfopen(pname, "r", mem_gc); - if (str != NULL) { - *strp = str; - return 0; + if (gs_check_file_permission(mem_gc, pname, namelen, "r") >= 0) { + str = sfopen(pname, "r", mem_gc); + if (str != NULL) { + *strp = str; + return 0; + } } /* If that fails, try %rom% */ /* FIXME: Not sure this is needed or correct */
CWE-20
null
null
11,204
gsicc_manager_new(gs_memory_t *memory) { gsicc_manager_t *result; /* Allocated in stable gc memory. This done since the profiles may be introduced late in the process. */ result = gs_alloc_struct(memory->stable_memory, gsicc_manager_t, &st_gsicc_manager, "gsicc_manager_new"); if ( result == NULL ) return NULL; rc_init_free(result, memory->stable_memory, 1, rc_gsicc_manager_free); result->default_gray = NULL; result->default_rgb = NULL; result->default_cmyk = NULL; result->lab_profile = NULL; result->xyz_profile = NULL; result->graytok_profile = NULL; result->device_named = NULL; result->device_n = NULL; result->smask_profiles = NULL; result->memory = memory->stable_memory; result->srcgtag_profile = NULL; result->override_internal = false; return result; }
Exec Code
0
gsicc_manager_new(gs_memory_t *memory) { gsicc_manager_t *result; /* Allocated in stable gc memory. This done since the profiles may be introduced late in the process. */ result = gs_alloc_struct(memory->stable_memory, gsicc_manager_t, &st_gsicc_manager, "gsicc_manager_new"); if ( result == NULL ) return NULL; rc_init_free(result, memory->stable_memory, 1, rc_gsicc_manager_free); result->default_gray = NULL; result->default_rgb = NULL; result->default_cmyk = NULL; result->lab_profile = NULL; result->xyz_profile = NULL; result->graytok_profile = NULL; result->device_named = NULL; result->device_n = NULL; result->smask_profiles = NULL; result->memory = memory->stable_memory; result->srcgtag_profile = NULL; result->override_internal = false; return result; }
@@ -1124,10 +1124,12 @@ gsicc_open_search(const char* pname, int namelen, gs_memory_t *mem_gc, } /* First just try it like it is */ - str = sfopen(pname, "r", mem_gc); - if (str != NULL) { - *strp = str; - return 0; + if (gs_check_file_permission(mem_gc, pname, namelen, "r") >= 0) { + str = sfopen(pname, "r", mem_gc); + if (str != NULL) { + *strp = str; + return 0; + } } /* If that fails, try %rom% */ /* FIXME: Not sure this is needed or correct */
CWE-20
null
null
11,205
gsicc_new_colorname(gs_memory_t *memory) { gsicc_colorname_t *result; result = gs_alloc_struct(memory,gsicc_colorname_t, &st_gsicc_colorname, "gsicc_new_colorname"); if (result == NULL) return NULL; result->length = 0; result->name = NULL; result->next = NULL; return result; }
Exec Code
0
gsicc_new_colorname(gs_memory_t *memory) { gsicc_colorname_t *result; result = gs_alloc_struct(memory,gsicc_colorname_t, &st_gsicc_colorname, "gsicc_new_colorname"); if (result == NULL) return NULL; result->length = 0; result->name = NULL; result->next = NULL; return result; }
@@ -1124,10 +1124,12 @@ gsicc_open_search(const char* pname, int namelen, gs_memory_t *mem_gc, } /* First just try it like it is */ - str = sfopen(pname, "r", mem_gc); - if (str != NULL) { - *strp = str; - return 0; + if (gs_check_file_permission(mem_gc, pname, namelen, "r") >= 0) { + str = sfopen(pname, "r", mem_gc); + if (str != NULL) { + *strp = str; + return 0; + } } /* If that fails, try %rom% */ /* FIXME: Not sure this is needed or correct */
CWE-20
null
null
11,206
gsicc_new_device_profile_array(gs_memory_t *memory) { cmm_dev_profile_t *result; int k; if_debug0m(gs_debug_flag_icc,memory,"[icc] Allocating device profile struct\n"); result = (cmm_dev_profile_t *) gs_alloc_bytes(memory->non_gc_memory, sizeof(cmm_dev_profile_t), "gsicc_new_device_profile_array"); if (result == NULL) return NULL; result->memory = memory->non_gc_memory; for (k = 0; k < NUM_DEVICE_PROFILES; k++) { result->device_profile[k] = NULL; result->rendercond[k].rendering_intent = gsRINOTSPECIFIED; result->rendercond[k].black_point_comp = gsBPNOTSPECIFIED; result->rendercond[k].override_icc = false; result->rendercond[k].preserve_black = gsBKPRESNOTSPECIFIED; result->rendercond[k].graphics_type_tag = GS_UNKNOWN_TAG; result->rendercond[k].cmm = gsCMM_DEFAULT; } result->proof_profile = NULL; result->link_profile = NULL; result->postren_profile = NULL; result->oi_profile = NULL; result->spotnames = NULL; result->devicegraytok = true; /* Default is to map gray to pure K */ result->graydetection = false; result->pageneutralcolor = false; result->usefastcolor = false; /* Default is to not use fast color */ result->prebandthreshold = true; result->supports_devn = false; result->sim_overprint = false; /* Default is now not to simulate overprint */ rc_init_free(result, memory->non_gc_memory, 1, rc_free_profile_array); return result; }
Exec Code
0
gsicc_new_device_profile_array(gs_memory_t *memory) { cmm_dev_profile_t *result; int k; if_debug0m(gs_debug_flag_icc,memory,"[icc] Allocating device profile struct\n"); result = (cmm_dev_profile_t *) gs_alloc_bytes(memory->non_gc_memory, sizeof(cmm_dev_profile_t), "gsicc_new_device_profile_array"); if (result == NULL) return NULL; result->memory = memory->non_gc_memory; for (k = 0; k < NUM_DEVICE_PROFILES; k++) { result->device_profile[k] = NULL; result->rendercond[k].rendering_intent = gsRINOTSPECIFIED; result->rendercond[k].black_point_comp = gsBPNOTSPECIFIED; result->rendercond[k].override_icc = false; result->rendercond[k].preserve_black = gsBKPRESNOTSPECIFIED; result->rendercond[k].graphics_type_tag = GS_UNKNOWN_TAG; result->rendercond[k].cmm = gsCMM_DEFAULT; } result->proof_profile = NULL; result->link_profile = NULL; result->postren_profile = NULL; result->oi_profile = NULL; result->spotnames = NULL; result->devicegraytok = true; /* Default is to map gray to pure K */ result->graydetection = false; result->pageneutralcolor = false; result->usefastcolor = false; /* Default is to not use fast color */ result->prebandthreshold = true; result->supports_devn = false; result->sim_overprint = false; /* Default is now not to simulate overprint */ rc_init_free(result, memory->non_gc_memory, 1, rc_free_profile_array); return result; }
@@ -1124,10 +1124,12 @@ gsicc_open_search(const char* pname, int namelen, gs_memory_t *mem_gc, } /* First just try it like it is */ - str = sfopen(pname, "r", mem_gc); - if (str != NULL) { - *strp = str; - return 0; + if (gs_check_file_permission(mem_gc, pname, namelen, "r") >= 0) { + str = sfopen(pname, "r", mem_gc); + if (str != NULL) { + *strp = str; + return 0; + } } /* If that fails, try %rom% */ /* FIXME: Not sure this is needed or correct */
CWE-20
null
null
11,207
gsicc_new_devicen(gsicc_manager_t *icc_manager) { /* Allocate a new deviceN ICC profile entry in the deviceN list */ gsicc_devicen_entry_t *device_n_entry = gs_alloc_struct(icc_manager->memory, gsicc_devicen_entry_t, &st_gsicc_devicen_entry, "gsicc_new_devicen"); if (device_n_entry == NULL) return gs_throw(gs_error_VMerror, "insufficient memory to allocate device n profile"); device_n_entry->next = NULL; device_n_entry->iccprofile = NULL; /* Check if we already have one in the manager */ if ( icc_manager->device_n == NULL ) { /* First one. Need to allocate the DeviceN main object */ icc_manager->device_n = gs_alloc_struct(icc_manager->memory, gsicc_devicen_t, &st_gsicc_devicen, "gsicc_new_devicen"); if (icc_manager->device_n == NULL) return gs_throw(gs_error_VMerror, "insufficient memory to allocate device n profile"); icc_manager->device_n->head = device_n_entry; icc_manager->device_n->final = device_n_entry; icc_manager->device_n->count = 1; return 0; } else { /* We have one or more in the list. */ icc_manager->device_n->final->next = device_n_entry; icc_manager->device_n->final = device_n_entry; icc_manager->device_n->count++; return 0; } }
Exec Code
0
gsicc_new_devicen(gsicc_manager_t *icc_manager) { /* Allocate a new deviceN ICC profile entry in the deviceN list */ gsicc_devicen_entry_t *device_n_entry = gs_alloc_struct(icc_manager->memory, gsicc_devicen_entry_t, &st_gsicc_devicen_entry, "gsicc_new_devicen"); if (device_n_entry == NULL) return gs_throw(gs_error_VMerror, "insufficient memory to allocate device n profile"); device_n_entry->next = NULL; device_n_entry->iccprofile = NULL; /* Check if we already have one in the manager */ if ( icc_manager->device_n == NULL ) { /* First one. Need to allocate the DeviceN main object */ icc_manager->device_n = gs_alloc_struct(icc_manager->memory, gsicc_devicen_t, &st_gsicc_devicen, "gsicc_new_devicen"); if (icc_manager->device_n == NULL) return gs_throw(gs_error_VMerror, "insufficient memory to allocate device n profile"); icc_manager->device_n->head = device_n_entry; icc_manager->device_n->final = device_n_entry; icc_manager->device_n->count = 1; return 0; } else { /* We have one or more in the list. */ icc_manager->device_n->final->next = device_n_entry; icc_manager->device_n->final = device_n_entry; icc_manager->device_n->count++; return 0; } }
@@ -1124,10 +1124,12 @@ gsicc_open_search(const char* pname, int namelen, gs_memory_t *mem_gc, } /* First just try it like it is */ - str = sfopen(pname, "r", mem_gc); - if (str != NULL) { - *strp = str; - return 0; + if (gs_check_file_permission(mem_gc, pname, namelen, "r") >= 0) { + str = sfopen(pname, "r", mem_gc); + if (str != NULL) { + *strp = str; + return 0; + } } /* If that fails, try %rom% */ /* FIXME: Not sure this is needed or correct */
CWE-20
null
null
11,208
gsicc_new_iccsmask(gs_memory_t *memory) { gsicc_smask_t *result; result = (gsicc_smask_t *) gs_alloc_struct(memory, gsicc_smask_t, &st_gsicc_smask, "gsicc_new_iccsmask"); if (result != NULL) { result->smask_gray = NULL; result->smask_rgb = NULL; result->smask_cmyk = NULL; result->memory = memory; result->swapped = false; } return result; }
Exec Code
0
gsicc_new_iccsmask(gs_memory_t *memory) { gsicc_smask_t *result; result = (gsicc_smask_t *) gs_alloc_struct(memory, gsicc_smask_t, &st_gsicc_smask, "gsicc_new_iccsmask"); if (result != NULL) { result->smask_gray = NULL; result->smask_rgb = NULL; result->smask_cmyk = NULL; result->memory = memory; result->swapped = false; } return result; }
@@ -1124,10 +1124,12 @@ gsicc_open_search(const char* pname, int namelen, gs_memory_t *mem_gc, } /* First just try it like it is */ - str = sfopen(pname, "r", mem_gc); - if (str != NULL) { - *strp = str; - return 0; + if (gs_check_file_permission(mem_gc, pname, namelen, "r") >= 0) { + str = sfopen(pname, "r", mem_gc); + if (str != NULL) { + *strp = str; + return 0; + } } /* If that fails, try %rom% */ /* FIXME: Not sure this is needed or correct */
CWE-20
null
null
11,209
gsicc_new_srcgtag_profile(gs_memory_t *memory) { cmm_srcgtag_profile_t *result; int k; result = (cmm_srcgtag_profile_t *) gs_alloc_bytes(memory->non_gc_memory, sizeof(cmm_srcgtag_profile_t), "gsicc_new_srcgtag_profile"); if (result == NULL) return NULL; result->memory = memory->non_gc_memory; for (k = 0; k < NUM_SOURCE_PROFILES; k++) { result->rgb_profiles[k] = NULL; result->cmyk_profiles[k] = NULL; result->gray_profiles[k] = NULL; result->gray_rend_cond[k].black_point_comp = gsBPNOTSPECIFIED; result->gray_rend_cond[k].rendering_intent = gsRINOTSPECIFIED; result->gray_rend_cond[k].override_icc = false; result->gray_rend_cond[k].preserve_black = gsBKPRESNOTSPECIFIED; result->gray_rend_cond[k].cmm = gsCMM_DEFAULT; result->rgb_rend_cond[k].black_point_comp = gsBPNOTSPECIFIED; result->rgb_rend_cond[k].rendering_intent = gsRINOTSPECIFIED; result->rgb_rend_cond[k].override_icc = false; result->rgb_rend_cond[k].preserve_black = gsBKPRESNOTSPECIFIED; result->rgb_rend_cond[k].cmm = gsCMM_DEFAULT; result->cmyk_rend_cond[k].black_point_comp = gsBPNOTSPECIFIED; result->cmyk_rend_cond[k].rendering_intent = gsRINOTSPECIFIED; result->cmyk_rend_cond[k].override_icc = false; result->cmyk_rend_cond[k].preserve_black = gsBKPRESNOTSPECIFIED; result->cmyk_rend_cond[k].cmm = gsCMM_DEFAULT; } result->color_warp_profile = NULL; result->name = NULL; result->name_length = 0; rc_init_free(result, memory->non_gc_memory, 1, rc_free_srcgtag_profile); return result; }
Exec Code
0
gsicc_new_srcgtag_profile(gs_memory_t *memory) { cmm_srcgtag_profile_t *result; int k; result = (cmm_srcgtag_profile_t *) gs_alloc_bytes(memory->non_gc_memory, sizeof(cmm_srcgtag_profile_t), "gsicc_new_srcgtag_profile"); if (result == NULL) return NULL; result->memory = memory->non_gc_memory; for (k = 0; k < NUM_SOURCE_PROFILES; k++) { result->rgb_profiles[k] = NULL; result->cmyk_profiles[k] = NULL; result->gray_profiles[k] = NULL; result->gray_rend_cond[k].black_point_comp = gsBPNOTSPECIFIED; result->gray_rend_cond[k].rendering_intent = gsRINOTSPECIFIED; result->gray_rend_cond[k].override_icc = false; result->gray_rend_cond[k].preserve_black = gsBKPRESNOTSPECIFIED; result->gray_rend_cond[k].cmm = gsCMM_DEFAULT; result->rgb_rend_cond[k].black_point_comp = gsBPNOTSPECIFIED; result->rgb_rend_cond[k].rendering_intent = gsRINOTSPECIFIED; result->rgb_rend_cond[k].override_icc = false; result->rgb_rend_cond[k].preserve_black = gsBKPRESNOTSPECIFIED; result->rgb_rend_cond[k].cmm = gsCMM_DEFAULT; result->cmyk_rend_cond[k].black_point_comp = gsBPNOTSPECIFIED; result->cmyk_rend_cond[k].rendering_intent = gsRINOTSPECIFIED; result->cmyk_rend_cond[k].override_icc = false; result->cmyk_rend_cond[k].preserve_black = gsBKPRESNOTSPECIFIED; result->cmyk_rend_cond[k].cmm = gsCMM_DEFAULT; } result->color_warp_profile = NULL; result->name = NULL; result->name_length = 0; rc_init_free(result, memory->non_gc_memory, 1, rc_free_srcgtag_profile); return result; }
@@ -1124,10 +1124,12 @@ gsicc_open_search(const char* pname, int namelen, gs_memory_t *mem_gc, } /* First just try it like it is */ - str = sfopen(pname, "r", mem_gc); - if (str != NULL) { - *strp = str; - return 0; + if (gs_check_file_permission(mem_gc, pname, namelen, "r") >= 0) { + str = sfopen(pname, "r", mem_gc); + if (str != NULL) { + *strp = str; + return 0; + } } /* If that fails, try %rom% */ /* FIXME: Not sure this is needed or correct */
CWE-20
null
null
11,210
gsicc_profile_new(stream *s, gs_memory_t *memory, const char* pname, int namelen) { cmm_profile_t *result; int code; char *nameptr = NULL; gs_memory_t *mem_nongc = memory->non_gc_memory; result = (cmm_profile_t*) gs_alloc_bytes(mem_nongc, sizeof(cmm_profile_t), "gsicc_profile_new"); if (result == NULL) return result; memset(result, 0, GSICC_SERIALIZED_SIZE); if (namelen > 0) { nameptr = (char*) gs_alloc_bytes(mem_nongc, namelen+1, "gsicc_profile_new"); if (nameptr == NULL) { gs_free_object(mem_nongc, result, "gsicc_profile_new"); return NULL; } memcpy(nameptr, pname, namelen); nameptr[namelen] = '\0'; result->name = nameptr; } else { result->name = NULL; } result->name_length = namelen; /* We may not have a stream if we are creating this object from our own constructed buffer. For example if we are converting CalRGB to an ICC type */ if ( s != NULL) { code = gsicc_load_profile_buffer(result, s, mem_nongc); if (code < 0) { gs_free_object(mem_nongc, result, "gsicc_profile_new"); gs_free_object(mem_nongc, nameptr, "gsicc_profile_new"); return NULL; } } else { result->buffer = NULL; result->buffer_size = 0; } rc_init_free(result, mem_nongc, 1, rc_free_icc_profile); result->profile_handle = NULL; result->spotnames = NULL; result->rend_is_valid = false; result->isdevlink = false; /* only used for srcgtag profiles */ result->dev = NULL; result->memory = mem_nongc; result->lock = gx_monitor_label(gx_monitor_alloc(mem_nongc), "gsicc_manage"); result->vers = ICCVERS_UNKNOWN; result->v2_data = NULL; result->v2_size = 0; result->release = gscms_release_profile; /* Default case */ if (result->lock == NULL) { gs_free_object(mem_nongc, result, "gsicc_profile_new"); gs_free_object(mem_nongc, nameptr, "gsicc_profile_new"); return NULL; } if_debug1m(gs_debug_flag_icc, mem_nongc, "[icc] allocating ICC profile = 0x%p\n", result); return result; }
Exec Code
0
gsicc_profile_new(stream *s, gs_memory_t *memory, const char* pname, int namelen) { cmm_profile_t *result; int code; char *nameptr = NULL; gs_memory_t *mem_nongc = memory->non_gc_memory; result = (cmm_profile_t*) gs_alloc_bytes(mem_nongc, sizeof(cmm_profile_t), "gsicc_profile_new"); if (result == NULL) return result; memset(result, 0, GSICC_SERIALIZED_SIZE); if (namelen > 0) { nameptr = (char*) gs_alloc_bytes(mem_nongc, namelen+1, "gsicc_profile_new"); if (nameptr == NULL) { gs_free_object(mem_nongc, result, "gsicc_profile_new"); return NULL; } memcpy(nameptr, pname, namelen); nameptr[namelen] = '\0'; result->name = nameptr; } else { result->name = NULL; } result->name_length = namelen; /* We may not have a stream if we are creating this object from our own constructed buffer. For example if we are converting CalRGB to an ICC type */ if ( s != NULL) { code = gsicc_load_profile_buffer(result, s, mem_nongc); if (code < 0) { gs_free_object(mem_nongc, result, "gsicc_profile_new"); gs_free_object(mem_nongc, nameptr, "gsicc_profile_new"); return NULL; } } else { result->buffer = NULL; result->buffer_size = 0; } rc_init_free(result, mem_nongc, 1, rc_free_icc_profile); result->profile_handle = NULL; result->spotnames = NULL; result->rend_is_valid = false; result->isdevlink = false; /* only used for srcgtag profiles */ result->dev = NULL; result->memory = mem_nongc; result->lock = gx_monitor_label(gx_monitor_alloc(mem_nongc), "gsicc_manage"); result->vers = ICCVERS_UNKNOWN; result->v2_data = NULL; result->v2_size = 0; result->release = gscms_release_profile; /* Default case */ if (result->lock == NULL) { gs_free_object(mem_nongc, result, "gsicc_profile_new"); gs_free_object(mem_nongc, nameptr, "gsicc_profile_new"); return NULL; } if_debug1m(gs_debug_flag_icc, mem_nongc, "[icc] allocating ICC profile = 0x%p\n", result); return result; }
@@ -1124,10 +1124,12 @@ gsicc_open_search(const char* pname, int namelen, gs_memory_t *mem_gc, } /* First just try it like it is */ - str = sfopen(pname, "r", mem_gc); - if (str != NULL) { - *strp = str; - return 0; + if (gs_check_file_permission(mem_gc, pname, namelen, "r") >= 0) { + str = sfopen(pname, "r", mem_gc); + if (str != NULL) { + *strp = str; + return 0; + } } /* If that fails, try %rom% */ /* FIXME: Not sure this is needed or correct */
CWE-20
null
null
11,211
gsicc_profile_reference(cmm_profile_t *icc_profile, int delta) { if (icc_profile != NULL) rc_adjust(icc_profile, delta, "gsicc_profile_reference"); }
Exec Code
0
gsicc_profile_reference(cmm_profile_t *icc_profile, int delta) { if (icc_profile != NULL) rc_adjust(icc_profile, delta, "gsicc_profile_reference"); }
@@ -1124,10 +1124,12 @@ gsicc_open_search(const char* pname, int namelen, gs_memory_t *mem_gc, } /* First just try it like it is */ - str = sfopen(pname, "r", mem_gc); - if (str != NULL) { - *strp = str; - return 0; + if (gs_check_file_permission(mem_gc, pname, namelen, "r") >= 0) { + str = sfopen(pname, "r", mem_gc); + if (str != NULL) { + *strp = str; + return 0; + } } /* If that fails, try %rom% */ /* FIXME: Not sure this is needed or correct */
CWE-20
null
null
11,212
gsicc_profile_serialize(gsicc_serialized_profile_t *profile_data, cmm_profile_t *icc_profile) { if (icc_profile == NULL) return; memcpy(profile_data, icc_profile, GSICC_SERIALIZED_SIZE); }
Exec Code
0
gsicc_profile_serialize(gsicc_serialized_profile_t *profile_data, cmm_profile_t *icc_profile) { if (icc_profile == NULL) return; memcpy(profile_data, icc_profile, GSICC_SERIALIZED_SIZE); }
@@ -1124,10 +1124,12 @@ gsicc_open_search(const char* pname, int namelen, gs_memory_t *mem_gc, } /* First just try it like it is */ - str = sfopen(pname, "r", mem_gc); - if (str != NULL) { - *strp = str; - return 0; + if (gs_check_file_permission(mem_gc, pname, namelen, "r") >= 0) { + str = sfopen(pname, "r", mem_gc); + if (str != NULL) { + *strp = str; + return 0; + } } /* If that fails, try %rom% */ /* FIXME: Not sure this is needed or correct */
CWE-20
null
null
11,213
gsicc_read_serial_icc(gx_device *dev, int64_t icc_hashcode) { cmm_profile_t *profile; int64_t position; int size; int code; gx_device_clist_reader *pcrdev = (gx_device_clist_reader*) dev; /* Create a new ICC profile structure */ profile = gsicc_profile_new(NULL, pcrdev->memory, NULL, 0); if (profile == NULL) return NULL; /* Check ICC table for hash code and get the whole size icc raw buffer plus serialized header information. Make sure the icc_table has been intialized */ if (pcrdev->icc_table == NULL) { code = clist_read_icctable(pcrdev); if (code<0) return NULL; } position = gsicc_search_icc_table(pcrdev->icc_table, icc_hashcode, &size); if ( position < 0 ) return NULL; /* Get the serialized portion of the ICC profile information */ clist_read_chunk(pcrdev, position, GSICC_SERIALIZED_SIZE, (unsigned char *) profile); return profile; }
Exec Code
0
gsicc_read_serial_icc(gx_device *dev, int64_t icc_hashcode) { cmm_profile_t *profile; int64_t position; int size; int code; gx_device_clist_reader *pcrdev = (gx_device_clist_reader*) dev; /* Create a new ICC profile structure */ profile = gsicc_profile_new(NULL, pcrdev->memory, NULL, 0); if (profile == NULL) return NULL; /* Check ICC table for hash code and get the whole size icc raw buffer plus serialized header information. Make sure the icc_table has been intialized */ if (pcrdev->icc_table == NULL) { code = clist_read_icctable(pcrdev); if (code<0) return NULL; } position = gsicc_search_icc_table(pcrdev->icc_table, icc_hashcode, &size); if ( position < 0 ) return NULL; /* Get the serialized portion of the ICC profile information */ clist_read_chunk(pcrdev, position, GSICC_SERIALIZED_SIZE, (unsigned char *) profile); return profile; }
@@ -1124,10 +1124,12 @@ gsicc_open_search(const char* pname, int namelen, gs_memory_t *mem_gc, } /* First just try it like it is */ - str = sfopen(pname, "r", mem_gc); - if (str != NULL) { - *strp = str; - return 0; + if (gs_check_file_permission(mem_gc, pname, namelen, "r") >= 0) { + str = sfopen(pname, "r", mem_gc); + if (str != NULL) { + *strp = str; + return 0; + } } /* If that fails, try %rom% */ /* FIXME: Not sure this is needed or correct */
CWE-20
null
null
11,214
gsicc_set_default_cs_value(cmm_profile_t *picc_profile, gs_gstate *pgs) { gsicc_manager_t *icc_manager = pgs->icc_manager; int64_t hashcode = picc_profile->hashcode; if ( picc_profile->default_match == DEFAULT_NONE ) { switch ( picc_profile->data_cs ) { case gsGRAY: if ( hashcode == icc_manager->default_gray->hashcode ) picc_profile->default_match = DEFAULT_GRAY_s; break; case gsRGB: if ( hashcode == icc_manager->default_rgb->hashcode ) picc_profile->default_match = DEFAULT_RGB_s; break; case gsCMYK: if ( hashcode == icc_manager->default_cmyk->hashcode ) picc_profile->default_match = DEFAULT_CMYK_s; break; case gsCIELAB: if ( hashcode == icc_manager->lab_profile->hashcode ) picc_profile->default_match = LAB_TYPE_s; break; case gsCIEXYZ: return; break; case gsNCHANNEL: return; break; default: return; } } }
Exec Code
0
gsicc_set_default_cs_value(cmm_profile_t *picc_profile, gs_gstate *pgs) { gsicc_manager_t *icc_manager = pgs->icc_manager; int64_t hashcode = picc_profile->hashcode; if ( picc_profile->default_match == DEFAULT_NONE ) { switch ( picc_profile->data_cs ) { case gsGRAY: if ( hashcode == icc_manager->default_gray->hashcode ) picc_profile->default_match = DEFAULT_GRAY_s; break; case gsRGB: if ( hashcode == icc_manager->default_rgb->hashcode ) picc_profile->default_match = DEFAULT_RGB_s; break; case gsCMYK: if ( hashcode == icc_manager->default_cmyk->hashcode ) picc_profile->default_match = DEFAULT_CMYK_s; break; case gsCIELAB: if ( hashcode == icc_manager->lab_profile->hashcode ) picc_profile->default_match = LAB_TYPE_s; break; case gsCIEXYZ: return; break; case gsNCHANNEL: return; break; default: return; } } }
@@ -1124,10 +1124,12 @@ gsicc_open_search(const char* pname, int namelen, gs_memory_t *mem_gc, } /* First just try it like it is */ - str = sfopen(pname, "r", mem_gc); - if (str != NULL) { - *strp = str; - return 0; + if (gs_check_file_permission(mem_gc, pname, namelen, "r") >= 0) { + str = sfopen(pname, "r", mem_gc); + if (str != NULL) { + *strp = str; + return 0; + } } /* If that fails, try %rom% */ /* FIXME: Not sure this is needed or correct */
CWE-20
null
null
11,215
gsicc_set_device_blackpreserve(gx_device *dev, gsicc_blackpreserve_t blackpreserve, gsicc_profile_types_t profile_type) { int code; cmm_dev_profile_t *profile_struct; if (dev->procs.get_profile == NULL) { profile_struct = dev->icc_struct; } else { code = dev_proc(dev, get_profile)(dev, &profile_struct); if (code < 0) return code; } if (profile_struct == NULL) return 0; profile_struct->rendercond[profile_type].preserve_black = blackpreserve; return 0; }
Exec Code
0
gsicc_set_device_blackpreserve(gx_device *dev, gsicc_blackpreserve_t blackpreserve, gsicc_profile_types_t profile_type) { int code; cmm_dev_profile_t *profile_struct; if (dev->procs.get_profile == NULL) { profile_struct = dev->icc_struct; } else { code = dev_proc(dev, get_profile)(dev, &profile_struct); if (code < 0) return code; } if (profile_struct == NULL) return 0; profile_struct->rendercond[profile_type].preserve_black = blackpreserve; return 0; }
@@ -1124,10 +1124,12 @@ gsicc_open_search(const char* pname, int namelen, gs_memory_t *mem_gc, } /* First just try it like it is */ - str = sfopen(pname, "r", mem_gc); - if (str != NULL) { - *strp = str; - return 0; + if (gs_check_file_permission(mem_gc, pname, namelen, "r") >= 0) { + str = sfopen(pname, "r", mem_gc); + if (str != NULL) { + *strp = str; + return 0; + } } /* If that fails, try %rom% */ /* FIXME: Not sure this is needed or correct */
CWE-20
null
null
11,216
gsicc_set_device_profile(gx_device * pdev, gs_memory_t * mem, char *file_name, gsicc_profile_types_t pro_enum) { cmm_profile_t *icc_profile; stream *str; int code; /* This is slightly silly, we have a device method for 'get_profile' we really ought to * have one for 'set_profile' as well. In its absence, make sure we are setting the profile * of the bootm level device. */ while(pdev->child) pdev = pdev->child; /* Check if device has a profile for this slot. Note that we already decremented for any profile that we might be replacing in gsicc_init_device_profile_struct */ if (file_name != '\0') { /* Silent on failure if this is an output intent profile that * could not be found. Bug 695042. Multi-threaded rendering * set up will try to find the file for the profile during the set * up via put/get params. but one does not exist. The OI profile * will be cloned after the put/get params */ if (strncmp(file_name, OI_PROFILE, strlen(OI_PROFILE)) == 0) return -1; code = gsicc_open_search(file_name, strlen(file_name), mem, mem->gs_lib_ctx->profiledir, mem->gs_lib_ctx->profiledir_len, &str); if (code < 0) return code; if (str != NULL) { icc_profile = gsicc_profile_new(str, mem, file_name, strlen(file_name)); code = sfclose(str); if (icc_profile == NULL) return gs_throw(gs_error_VMerror, "Creation of ICC profile failed"); if (pro_enum < gsPROOFPROFILE) { if_debug1m(gs_debug_flag_icc, mem, "[icc] Setting device profile %d\n", pro_enum); pdev->icc_struct->device_profile[pro_enum] = icc_profile; } else { /* The proof, link or post render profile. Output intent profile is set in zicc.c */ if (pro_enum == gsPROOFPROFILE) { if_debug0m(gs_debug_flag_icc, mem, "[icc] Setting proof profile\n"); pdev->icc_struct->proof_profile = icc_profile; } else if (pro_enum == gsLINKPROFILE) { if_debug0m(gs_debug_flag_icc, mem, "[icc] Setting link profile\n"); pdev->icc_struct->link_profile = icc_profile; } else { if_debug0m(gs_debug_flag_icc, mem, "[icc] Setting postrender profile\n"); pdev->icc_struct->postren_profile = icc_profile; } } /* Get the profile handle */ icc_profile->profile_handle = gsicc_get_profile_handle_buffer(icc_profile->buffer, icc_profile->buffer_size, mem); if (icc_profile->profile_handle == NULL) return_error(gs_error_unknownerror); /* Compute the hash code of the profile. Everything in the ICC manager will have it's hash code precomputed */ gsicc_get_icc_buff_hash(icc_profile->buffer, &(icc_profile->hashcode), icc_profile->buffer_size); icc_profile->hash_is_valid = true; /* Get the number of channels in the output profile */ icc_profile->num_comps = gscms_get_input_channel_count(icc_profile->profile_handle); if_debug1m(gs_debug_flag_icc, mem, "[icc] Profile has %d components\n", icc_profile->num_comps); icc_profile->num_comps_out = gscms_get_output_channel_count(icc_profile->profile_handle); icc_profile->data_cs = gscms_get_profile_data_space(icc_profile->profile_handle); /* We need to know if this is one of the "default" profiles or if someone has externally set it. The reason is that if there is an output intent in the file, and someone wants to use the output intent our handling of the output intent profile is different depending upon if someone specified a particular output profile */ switch (icc_profile->num_comps) { case 1: if (strncmp(icc_profile->name, DEFAULT_GRAY_ICC, strlen(icc_profile->name)) == 0) { icc_profile->default_match = DEFAULT_GRAY; } break; case 3: if (strncmp(icc_profile->name, DEFAULT_RGB_ICC, strlen(icc_profile->name)) == 0) { icc_profile->default_match = DEFAULT_RGB; } break; case 4: if (strncmp(icc_profile->name, DEFAULT_CMYK_ICC, strlen(icc_profile->name)) == 0) { icc_profile->default_match = DEFAULT_CMYK; } break; default: /* NCLR Profile. Set up default colorant names */ gsicc_set_device_profile_colorants(pdev, NULL); break; } if_debug1m(gs_debug_flag_icc, mem, "[icc] Profile data CS is %d\n", icc_profile->data_cs); } else return gs_rethrow(-1, "cannot find device profile"); } return 0; }
Exec Code
0
gsicc_set_device_profile(gx_device * pdev, gs_memory_t * mem, char *file_name, gsicc_profile_types_t pro_enum) { cmm_profile_t *icc_profile; stream *str; int code; /* This is slightly silly, we have a device method for 'get_profile' we really ought to * have one for 'set_profile' as well. In its absence, make sure we are setting the profile * of the bootm level device. */ while(pdev->child) pdev = pdev->child; /* Check if device has a profile for this slot. Note that we already decremented for any profile that we might be replacing in gsicc_init_device_profile_struct */ if (file_name != '\0') { /* Silent on failure if this is an output intent profile that * could not be found. Bug 695042. Multi-threaded rendering * set up will try to find the file for the profile during the set * up via put/get params. but one does not exist. The OI profile * will be cloned after the put/get params */ if (strncmp(file_name, OI_PROFILE, strlen(OI_PROFILE)) == 0) return -1; code = gsicc_open_search(file_name, strlen(file_name), mem, mem->gs_lib_ctx->profiledir, mem->gs_lib_ctx->profiledir_len, &str); if (code < 0) return code; if (str != NULL) { icc_profile = gsicc_profile_new(str, mem, file_name, strlen(file_name)); code = sfclose(str); if (icc_profile == NULL) return gs_throw(gs_error_VMerror, "Creation of ICC profile failed"); if (pro_enum < gsPROOFPROFILE) { if_debug1m(gs_debug_flag_icc, mem, "[icc] Setting device profile %d\n", pro_enum); pdev->icc_struct->device_profile[pro_enum] = icc_profile; } else { /* The proof, link or post render profile. Output intent profile is set in zicc.c */ if (pro_enum == gsPROOFPROFILE) { if_debug0m(gs_debug_flag_icc, mem, "[icc] Setting proof profile\n"); pdev->icc_struct->proof_profile = icc_profile; } else if (pro_enum == gsLINKPROFILE) { if_debug0m(gs_debug_flag_icc, mem, "[icc] Setting link profile\n"); pdev->icc_struct->link_profile = icc_profile; } else { if_debug0m(gs_debug_flag_icc, mem, "[icc] Setting postrender profile\n"); pdev->icc_struct->postren_profile = icc_profile; } } /* Get the profile handle */ icc_profile->profile_handle = gsicc_get_profile_handle_buffer(icc_profile->buffer, icc_profile->buffer_size, mem); if (icc_profile->profile_handle == NULL) return_error(gs_error_unknownerror); /* Compute the hash code of the profile. Everything in the ICC manager will have it's hash code precomputed */ gsicc_get_icc_buff_hash(icc_profile->buffer, &(icc_profile->hashcode), icc_profile->buffer_size); icc_profile->hash_is_valid = true; /* Get the number of channels in the output profile */ icc_profile->num_comps = gscms_get_input_channel_count(icc_profile->profile_handle); if_debug1m(gs_debug_flag_icc, mem, "[icc] Profile has %d components\n", icc_profile->num_comps); icc_profile->num_comps_out = gscms_get_output_channel_count(icc_profile->profile_handle); icc_profile->data_cs = gscms_get_profile_data_space(icc_profile->profile_handle); /* We need to know if this is one of the "default" profiles or if someone has externally set it. The reason is that if there is an output intent in the file, and someone wants to use the output intent our handling of the output intent profile is different depending upon if someone specified a particular output profile */ switch (icc_profile->num_comps) { case 1: if (strncmp(icc_profile->name, DEFAULT_GRAY_ICC, strlen(icc_profile->name)) == 0) { icc_profile->default_match = DEFAULT_GRAY; } break; case 3: if (strncmp(icc_profile->name, DEFAULT_RGB_ICC, strlen(icc_profile->name)) == 0) { icc_profile->default_match = DEFAULT_RGB; } break; case 4: if (strncmp(icc_profile->name, DEFAULT_CMYK_ICC, strlen(icc_profile->name)) == 0) { icc_profile->default_match = DEFAULT_CMYK; } break; default: /* NCLR Profile. Set up default colorant names */ gsicc_set_device_profile_colorants(pdev, NULL); break; } if_debug1m(gs_debug_flag_icc, mem, "[icc] Profile data CS is %d\n", icc_profile->data_cs); } else return gs_rethrow(-1, "cannot find device profile"); } return 0; }
@@ -1124,10 +1124,12 @@ gsicc_open_search(const char* pname, int namelen, gs_memory_t *mem_gc, } /* First just try it like it is */ - str = sfopen(pname, "r", mem_gc); - if (str != NULL) { - *strp = str; - return 0; + if (gs_check_file_permission(mem_gc, pname, namelen, "r") >= 0) { + str = sfopen(pname, "r", mem_gc); + if (str != NULL) { + *strp = str; + return 0; + } } /* If that fails, try %rom% */ /* FIXME: Not sure this is needed or correct */
CWE-20
null
null
11,217
gsicc_set_device_profile_colorants(gx_device *dev, char *name_str) { int code; cmm_dev_profile_t *profile_struct; gsicc_colorname_t *name_entry; gsicc_colorname_t **curr_entry; gs_memory_t *mem; char *temp_ptr, *last = NULL; int done; gsicc_namelist_t *spot_names; char *pch; int str_len; int k; bool free_str = false; code = dev_proc(dev, get_profile)((gx_device *)dev, &profile_struct); if (profile_struct != NULL) { int count = 0; if (name_str == NULL) { /* Create a default name string that we can use */ int total_len; int kk; int num_comps = profile_struct->device_profile[0]->num_comps; char temp_str[DEFAULT_ICC_COLORANT_LENGTH+2]; /* If names are already set then we do not want to set default ones */ if (profile_struct->spotnames != NULL) return 0; free_str = true; /* Assume first 4 are CMYK */ total_len = ((DEFAULT_ICC_COLORANT_LENGTH + 1) * (num_comps-4)) + DEFAULT_ICC_PROCESS_LENGTH - 1; /* -1 due to no comma at end */ name_str = (char*) gs_alloc_bytes(dev->memory, total_len+1, "gsicc_set_device_profile_colorants"); if (name_str == NULL) return gs_throw(gs_error_VMerror, "Insufficient memory for colorant name"); gs_sprintf(name_str, DEFAULT_ICC_PROCESS); for (kk = 0; kk < num_comps-5; kk++) { gs_sprintf(temp_str,"ICC_COLOR_%d,",kk); strcat(name_str,temp_str); } /* Last one no comma */ gs_sprintf(temp_str,"ICC_COLOR_%d",kk); strcat(name_str,temp_str); } str_len = strlen(name_str); if (profile_struct->spotnames != NULL && profile_struct->spotnames->name_str != NULL && strlen(profile_struct->spotnames->name_str) == str_len) { /* Here we check if the names are the same */ if (strncmp(name_str, profile_struct->spotnames->name_str, str_len) == 0) { if (free_str) gs_free_object(dev->memory, name_str, "gsicc_set_device_profile_colorants"); return 0; } } mem = dev->memory->non_gc_memory; /* We need to free the existing one if there was one */ if (profile_struct->spotnames != NULL) { /* Free the linked list in this object */ gsicc_free_spotnames(profile_struct->spotnames, mem); /* Free the main object */ gs_free_object(mem, profile_struct->spotnames, "gsicc_set_device_profile_colorants"); } /* Allocate structure for managing names */ spot_names = gsicc_new_namelist(mem); profile_struct->spotnames = spot_names; spot_names->name_str = (char*) gs_alloc_bytes(mem, str_len+1, "gsicc_set_device_profile_colorants"); if (spot_names->name_str == NULL) return gs_throw(gs_error_VMerror, "Insufficient memory for spot name"); memcpy(spot_names->name_str, name_str, strlen(name_str)); spot_names->name_str[str_len] = 0; curr_entry = &(spot_names->head); /* Go ahead and tokenize now */ pch = gs_strtok(name_str, ",", &last); count = 0; while (pch != NULL) { temp_ptr = pch; done = 0; /* Remove any leading spaces */ while (!done) { if (*temp_ptr == 0x20) { temp_ptr++; } else { done = 1; } } /* Allocate a new name object */ name_entry = gsicc_new_colorname(mem); /* Set our current entry to this one */ *curr_entry = name_entry; name_entry->length = strlen(temp_ptr); name_entry->name = (char *) gs_alloc_bytes(mem, name_entry->length, "gsicc_set_device_profile_colorants"); if (spot_names->name_str == NULL) return gs_throw(gs_error_VMerror, "Insufficient memory for spot name"); memcpy(name_entry->name, temp_ptr, name_entry->length); /* Get the next entry location */ curr_entry = &((*curr_entry)->next); count += 1; pch = gs_strtok(NULL, ",", &last); } spot_names->count = count; /* Create the color map. Query the device to find out where these colorants are located. It is possible that the device may not be opened yet. In which case, we need to make sure that when it is opened that it checks this entry and gets itself properly initialized if it is a separation device. */ spot_names->color_map = (gs_devicen_color_map*) gs_alloc_bytes(mem, sizeof(gs_devicen_color_map), "gsicc_set_device_profile_colorants"); if (spot_names->color_map == NULL) return gs_throw(gs_error_VMerror, "Insufficient memory for spot color map"); spot_names->color_map->num_colorants = count; spot_names->color_map->num_components = count; name_entry = spot_names->head; for (k = 0; k < count; k++) { int colorant_number = (*dev_proc(dev, get_color_comp_index)) (dev, (const char *)name_entry->name, name_entry->length, SEPARATION_NAME); name_entry = name_entry->next; spot_names->color_map->color_map[k] = colorant_number; } /* We need to set the equivalent CMYK color for this colorant. This is done by faking out the update spot equivalent call with a special gs_gstate and color space that makes it seem like the spot color is a separation color space. Unfortunately, we need the graphic state to do this so we save it for later when we try to do our first mapping. We then use this flag to know if we did it yet */ spot_names->equiv_cmyk_set = false; if (free_str) gs_free_object(dev->memory, name_str, "gsicc_set_device_profile_colorants"); } return code; }
Exec Code
0
gsicc_set_device_profile_colorants(gx_device *dev, char *name_str) { int code; cmm_dev_profile_t *profile_struct; gsicc_colorname_t *name_entry; gsicc_colorname_t **curr_entry; gs_memory_t *mem; char *temp_ptr, *last = NULL; int done; gsicc_namelist_t *spot_names; char *pch; int str_len; int k; bool free_str = false; code = dev_proc(dev, get_profile)((gx_device *)dev, &profile_struct); if (profile_struct != NULL) { int count = 0; if (name_str == NULL) { /* Create a default name string that we can use */ int total_len; int kk; int num_comps = profile_struct->device_profile[0]->num_comps; char temp_str[DEFAULT_ICC_COLORANT_LENGTH+2]; /* If names are already set then we do not want to set default ones */ if (profile_struct->spotnames != NULL) return 0; free_str = true; /* Assume first 4 are CMYK */ total_len = ((DEFAULT_ICC_COLORANT_LENGTH + 1) * (num_comps-4)) + DEFAULT_ICC_PROCESS_LENGTH - 1; /* -1 due to no comma at end */ name_str = (char*) gs_alloc_bytes(dev->memory, total_len+1, "gsicc_set_device_profile_colorants"); if (name_str == NULL) return gs_throw(gs_error_VMerror, "Insufficient memory for colorant name"); gs_sprintf(name_str, DEFAULT_ICC_PROCESS); for (kk = 0; kk < num_comps-5; kk++) { gs_sprintf(temp_str,"ICC_COLOR_%d,",kk); strcat(name_str,temp_str); } /* Last one no comma */ gs_sprintf(temp_str,"ICC_COLOR_%d",kk); strcat(name_str,temp_str); } str_len = strlen(name_str); if (profile_struct->spotnames != NULL && profile_struct->spotnames->name_str != NULL && strlen(profile_struct->spotnames->name_str) == str_len) { /* Here we check if the names are the same */ if (strncmp(name_str, profile_struct->spotnames->name_str, str_len) == 0) { if (free_str) gs_free_object(dev->memory, name_str, "gsicc_set_device_profile_colorants"); return 0; } } mem = dev->memory->non_gc_memory; /* We need to free the existing one if there was one */ if (profile_struct->spotnames != NULL) { /* Free the linked list in this object */ gsicc_free_spotnames(profile_struct->spotnames, mem); /* Free the main object */ gs_free_object(mem, profile_struct->spotnames, "gsicc_set_device_profile_colorants"); } /* Allocate structure for managing names */ spot_names = gsicc_new_namelist(mem); profile_struct->spotnames = spot_names; spot_names->name_str = (char*) gs_alloc_bytes(mem, str_len+1, "gsicc_set_device_profile_colorants"); if (spot_names->name_str == NULL) return gs_throw(gs_error_VMerror, "Insufficient memory for spot name"); memcpy(spot_names->name_str, name_str, strlen(name_str)); spot_names->name_str[str_len] = 0; curr_entry = &(spot_names->head); /* Go ahead and tokenize now */ pch = gs_strtok(name_str, ",", &last); count = 0; while (pch != NULL) { temp_ptr = pch; done = 0; /* Remove any leading spaces */ while (!done) { if (*temp_ptr == 0x20) { temp_ptr++; } else { done = 1; } } /* Allocate a new name object */ name_entry = gsicc_new_colorname(mem); /* Set our current entry to this one */ *curr_entry = name_entry; name_entry->length = strlen(temp_ptr); name_entry->name = (char *) gs_alloc_bytes(mem, name_entry->length, "gsicc_set_device_profile_colorants"); if (spot_names->name_str == NULL) return gs_throw(gs_error_VMerror, "Insufficient memory for spot name"); memcpy(name_entry->name, temp_ptr, name_entry->length); /* Get the next entry location */ curr_entry = &((*curr_entry)->next); count += 1; pch = gs_strtok(NULL, ",", &last); } spot_names->count = count; /* Create the color map. Query the device to find out where these colorants are located. It is possible that the device may not be opened yet. In which case, we need to make sure that when it is opened that it checks this entry and gets itself properly initialized if it is a separation device. */ spot_names->color_map = (gs_devicen_color_map*) gs_alloc_bytes(mem, sizeof(gs_devicen_color_map), "gsicc_set_device_profile_colorants"); if (spot_names->color_map == NULL) return gs_throw(gs_error_VMerror, "Insufficient memory for spot color map"); spot_names->color_map->num_colorants = count; spot_names->color_map->num_components = count; name_entry = spot_names->head; for (k = 0; k < count; k++) { int colorant_number = (*dev_proc(dev, get_color_comp_index)) (dev, (const char *)name_entry->name, name_entry->length, SEPARATION_NAME); name_entry = name_entry->next; spot_names->color_map->color_map[k] = colorant_number; } /* We need to set the equivalent CMYK color for this colorant. This is done by faking out the update spot equivalent call with a special gs_gstate and color space that makes it seem like the spot color is a separation color space. Unfortunately, we need the graphic state to do this so we save it for later when we try to do our first mapping. We then use this flag to know if we did it yet */ spot_names->equiv_cmyk_set = false; if (free_str) gs_free_object(dev->memory, name_str, "gsicc_set_device_profile_colorants"); } return code; }
@@ -1124,10 +1124,12 @@ gsicc_open_search(const char* pname, int namelen, gs_memory_t *mem_gc, } /* First just try it like it is */ - str = sfopen(pname, "r", mem_gc); - if (str != NULL) { - *strp = str; - return 0; + if (gs_check_file_permission(mem_gc, pname, namelen, "r") >= 0) { + str = sfopen(pname, "r", mem_gc); + if (str != NULL) { + *strp = str; + return 0; + } } /* If that fails, try %rom% */ /* FIXME: Not sure this is needed or correct */
CWE-20
null
null
11,218
gsicc_set_device_profile_intent(gx_device *dev, gsicc_rendering_intents_t intent, gsicc_profile_types_t profile_type) { int code; cmm_dev_profile_t *profile_struct; if (dev->procs.get_profile == NULL) { profile_struct = dev->icc_struct; } else { code = dev_proc(dev, get_profile)(dev, &profile_struct); if (code < 0) return code; } if (profile_struct == NULL) return 0; profile_struct->rendercond[profile_type].rendering_intent = intent; return 0; }
Exec Code
0
gsicc_set_device_profile_intent(gx_device *dev, gsicc_rendering_intents_t intent, gsicc_profile_types_t profile_type) { int code; cmm_dev_profile_t *profile_struct; if (dev->procs.get_profile == NULL) { profile_struct = dev->icc_struct; } else { code = dev_proc(dev, get_profile)(dev, &profile_struct); if (code < 0) return code; } if (profile_struct == NULL) return 0; profile_struct->rendercond[profile_type].rendering_intent = intent; return 0; }
@@ -1124,10 +1124,12 @@ gsicc_open_search(const char* pname, int namelen, gs_memory_t *mem_gc, } /* First just try it like it is */ - str = sfopen(pname, "r", mem_gc); - if (str != NULL) { - *strp = str; - return 0; + if (gs_check_file_permission(mem_gc, pname, namelen, "r") >= 0) { + str = sfopen(pname, "r", mem_gc); + if (str != NULL) { + *strp = str; + return 0; + } } /* If that fails, try %rom% */ /* FIXME: Not sure this is needed or correct */
CWE-20
null
null
11,219
gsicc_set_gscs_profile(gs_color_space *pcs, cmm_profile_t *icc_profile, gs_memory_t * mem) { if (pcs == NULL) return -1; #if ICC_DUMP if (icc_profile->buffer) { dump_icc_buffer(icc_profile->buffer_size, "set_gscs", icc_profile->buffer); global_icc_index++; } #endif rc_increment(icc_profile); if (pcs->cmm_icc_profile_data != NULL) { /* There is already a profile set there */ /* free it and then set to the new one. */ /* should we check the hash code and retain if the same or place this job on the caller? */ rc_decrement(pcs->cmm_icc_profile_data, "gsicc_set_gscs_profile"); } pcs->cmm_icc_profile_data = icc_profile; return 0; }
Exec Code
0
gsicc_set_gscs_profile(gs_color_space *pcs, cmm_profile_t *icc_profile, gs_memory_t * mem) { if (pcs == NULL) return -1; #if ICC_DUMP if (icc_profile->buffer) { dump_icc_buffer(icc_profile->buffer_size, "set_gscs", icc_profile->buffer); global_icc_index++; } #endif rc_increment(icc_profile); if (pcs->cmm_icc_profile_data != NULL) { /* There is already a profile set there */ /* free it and then set to the new one. */ /* should we check the hash code and retain if the same or place this job on the caller? */ rc_decrement(pcs->cmm_icc_profile_data, "gsicc_set_gscs_profile"); } pcs->cmm_icc_profile_data = icc_profile; return 0; }
@@ -1124,10 +1124,12 @@ gsicc_open_search(const char* pname, int namelen, gs_memory_t *mem_gc, } /* First just try it like it is */ - str = sfopen(pname, "r", mem_gc); - if (str != NULL) { - *strp = str; - return 0; + if (gs_check_file_permission(mem_gc, pname, namelen, "r") >= 0) { + str = sfopen(pname, "r", mem_gc); + if (str != NULL) { + *strp = str; + return 0; + } } /* If that fails, try %rom% */ /* FIXME: Not sure this is needed or correct */
CWE-20
null
null
11,220
gsicc_set_iccsmaskprofile(const char *pname, int namelen, gsicc_manager_t *icc_manager, gs_memory_t *mem) { stream *str; int code; cmm_profile_t *icc_profile; if (icc_manager == NULL) { code = gsicc_open_search(pname, namelen, mem, NULL, 0, &str); } else { code = gsicc_open_search(pname, namelen, mem, mem->gs_lib_ctx->profiledir, mem->gs_lib_ctx->profiledir_len, &str); } if (code < 0 || str == NULL) return NULL; icc_profile = gsicc_profile_new(str, mem, pname, namelen); code = sfclose(str); if (icc_profile == NULL) return NULL; /* Get the profile handle */ icc_profile->profile_handle = gsicc_get_profile_handle_buffer(icc_profile->buffer, icc_profile->buffer_size, mem); /* Compute the hash code of the profile. Everything in the ICC manager will have it's hash code precomputed */ gsicc_get_icc_buff_hash(icc_profile->buffer, &(icc_profile->hashcode), icc_profile->buffer_size); icc_profile->hash_is_valid = true; icc_profile->num_comps = gscms_get_input_channel_count(icc_profile->profile_handle); icc_profile->num_comps_out = gscms_get_output_channel_count(icc_profile->profile_handle); icc_profile->data_cs = gscms_get_profile_data_space(icc_profile->profile_handle); gscms_set_icc_range(&icc_profile); return icc_profile; }
Exec Code
0
gsicc_set_iccsmaskprofile(const char *pname, int namelen, gsicc_manager_t *icc_manager, gs_memory_t *mem) { stream *str; int code; cmm_profile_t *icc_profile; if (icc_manager == NULL) { code = gsicc_open_search(pname, namelen, mem, NULL, 0, &str); } else { code = gsicc_open_search(pname, namelen, mem, mem->gs_lib_ctx->profiledir, mem->gs_lib_ctx->profiledir_len, &str); } if (code < 0 || str == NULL) return NULL; icc_profile = gsicc_profile_new(str, mem, pname, namelen); code = sfclose(str); if (icc_profile == NULL) return NULL; /* Get the profile handle */ icc_profile->profile_handle = gsicc_get_profile_handle_buffer(icc_profile->buffer, icc_profile->buffer_size, mem); /* Compute the hash code of the profile. Everything in the ICC manager will have it's hash code precomputed */ gsicc_get_icc_buff_hash(icc_profile->buffer, &(icc_profile->hashcode), icc_profile->buffer_size); icc_profile->hash_is_valid = true; icc_profile->num_comps = gscms_get_input_channel_count(icc_profile->profile_handle); icc_profile->num_comps_out = gscms_get_output_channel_count(icc_profile->profile_handle); icc_profile->data_cs = gscms_get_profile_data_space(icc_profile->profile_handle); gscms_set_icc_range(&icc_profile); return icc_profile; }
@@ -1124,10 +1124,12 @@ gsicc_open_search(const char* pname, int namelen, gs_memory_t *mem_gc, } /* First just try it like it is */ - str = sfopen(pname, "r", mem_gc); - if (str != NULL) { - *strp = str; - return 0; + if (gs_check_file_permission(mem_gc, pname, namelen, "r") >= 0) { + str = sfopen(pname, "r", mem_gc); + if (str != NULL) { + *strp = str; + return 0; + } } /* If that fails, try %rom% */ /* FIXME: Not sure this is needed or correct */
CWE-20
null
null
11,221
gsicc_set_profile(gsicc_manager_t *icc_manager, const char* pname, int namelen, gsicc_profile_t defaulttype) { cmm_profile_t *icc_profile; cmm_profile_t **manager_default_profile = NULL; /* quite compiler */ stream *str; gs_memory_t *mem_gc = icc_manager->memory; int code; int k; int num_comps = 0; gsicc_colorbuffer_t default_space; /* Used to verify that we have the correct type */ /* We need to check for the smask swapped profile condition. If we are in that state, then any requests for setting the profile will be ignored. This is valid, since we are in the middle of drawing right now and this only would occur if we are doing a vmreclaim while in the middle of soft mask rendering */ default_space = gsUNDEFINED; if (icc_manager->smask_profiles !=NULL && icc_manager->smask_profiles->swapped == true) { return 0; } else { switch(defaulttype) { case DEFAULT_GRAY: manager_default_profile = &(icc_manager->default_gray); default_space = gsGRAY; num_comps = 1; break; case DEFAULT_RGB: manager_default_profile = &(icc_manager->default_rgb); default_space = gsRGB; num_comps = 3; break; case DEFAULT_CMYK: manager_default_profile = &(icc_manager->default_cmyk); default_space = gsCMYK; num_comps = 4; break; case NAMED_TYPE: manager_default_profile = &(icc_manager->device_named); default_space = gsNAMED; break; case LAB_TYPE: manager_default_profile = &(icc_manager->lab_profile); num_comps = 3; default_space = gsCIELAB; break; case DEVICEN_TYPE: manager_default_profile = NULL; default_space = gsNCHANNEL; break; case DEFAULT_NONE: default: return 0; break; } } /* If it is not NULL then it has already been set. If it is different than what we already have then we will want to free it. Since other gs_gstates could have different default profiles, this is done via reference counting. If it is the same as what we already have then we DONT increment, since that is done when the gs_gstate is duplicated. It could be the same, due to a resetting of the user params. To avoid recreating the profile data, we compare the string names. */ if (defaulttype != DEVICEN_TYPE && (*manager_default_profile) != NULL) { /* Check if this is what we already have. Also check if it is the output intent profile. */ icc_profile = *manager_default_profile; if ( namelen == icc_profile->name_length ) { if( memcmp(pname, icc_profile->name, namelen) == 0) return 0; } if (strncmp(icc_profile->name, OI_PROFILE, strlen(icc_profile->name)) == 0) { return 0; } rc_decrement(icc_profile,"gsicc_set_profile"); } /* We need to do a special check for DeviceN since we have a linked list of profiles and we can have multiple specifications */ if (defaulttype == DEVICEN_TYPE) { if (icc_manager->device_n != NULL) { gsicc_devicen_entry_t *current_entry = icc_manager->device_n->head; for (k = 0; k < icc_manager->device_n->count; k++) { if (current_entry->iccprofile != NULL) { icc_profile = current_entry->iccprofile; if (namelen == icc_profile->name_length) if (memcmp(pname, icc_profile->name, namelen) == 0) return 0; } current_entry = current_entry->next; } } /* An entry was not found. We need to create a new one to use */ code = gsicc_new_devicen(icc_manager); if (code < 0) return code; manager_default_profile = &(icc_manager->device_n->final->iccprofile); } code = gsicc_open_search(pname, namelen, mem_gc, mem_gc->gs_lib_ctx->profiledir, mem_gc->gs_lib_ctx->profiledir_len, &str); if (code < 0) return code; if (str != NULL) { icc_profile = gsicc_profile_new(str, mem_gc, pname, namelen); /* Add check so that we detect cases where we are loading a named color structure that is not a standard profile type */ if (icc_profile == NULL && defaulttype == NAMED_TYPE) { /* Failed to load the named color profile. Just load the file into the buffer as it is. The profile_handle member variable can then be used to hold the named color structure that is actually search. This is created later when needed. */ char *nameptr; icc_profile = gsicc_profile_new(NULL, mem_gc, NULL, 0); if (icc_profile == NULL) return gs_throw(gs_error_VMerror, "Creation of ICC profile failed"); icc_profile->data_cs = gsNAMED; code = gsicc_load_namedcolor_buffer(icc_profile, str, mem_gc); if (code < 0) return gs_throw1(-1, "problems with profile %s", pname); *manager_default_profile = icc_profile; nameptr = (char*) gs_alloc_bytes(icc_profile->memory, namelen+1, "gsicc_set_profile"); if (nameptr == NULL) return gs_throw(gs_error_VMerror, "Insufficient memory for profile name"); memcpy(nameptr, pname, namelen); nameptr[namelen] = '\0'; icc_profile->name = nameptr; icc_profile->name_length = namelen; return 0; /* Done now, since this is not a standard ICC profile */ } code = sfclose(str); if (icc_profile == NULL) { return gs_throw1(-1, "problems with profile %s",pname); } *manager_default_profile = icc_profile; icc_profile->default_match = defaulttype; if (defaulttype == LAB_TYPE) icc_profile->islab = true; if ( defaulttype == DEVICEN_TYPE ) { /* Lets get the name information out of the profile. The names are contained in the icSigNamedColor2Tag item. The table is in the A2B0Tag item. The names are in the order such that the fastest index in the table is the first name */ gsicc_get_devicen_names(icc_profile, icc_manager->memory); /* Init this profile now */ code = gsicc_init_profile_info(icc_profile); if (code < 0) return gs_throw1(-1, "problems with profile %s", pname); } else { /* Delay the loading of the handle buffer until we need the profile. But set some basic stuff that we need. Take care of DeviceN profile now, since we don't know the number of components etc */ icc_profile->num_comps = num_comps; icc_profile->num_comps_out = 3; gscms_set_icc_range(&icc_profile); icc_profile->data_cs = default_space; } return 0; } return -1; }
Exec Code
0
gsicc_set_profile(gsicc_manager_t *icc_manager, const char* pname, int namelen, gsicc_profile_t defaulttype) { cmm_profile_t *icc_profile; cmm_profile_t **manager_default_profile = NULL; /* quite compiler */ stream *str; gs_memory_t *mem_gc = icc_manager->memory; int code; int k; int num_comps = 0; gsicc_colorbuffer_t default_space; /* Used to verify that we have the correct type */ /* We need to check for the smask swapped profile condition. If we are in that state, then any requests for setting the profile will be ignored. This is valid, since we are in the middle of drawing right now and this only would occur if we are doing a vmreclaim while in the middle of soft mask rendering */ default_space = gsUNDEFINED; if (icc_manager->smask_profiles !=NULL && icc_manager->smask_profiles->swapped == true) { return 0; } else { switch(defaulttype) { case DEFAULT_GRAY: manager_default_profile = &(icc_manager->default_gray); default_space = gsGRAY; num_comps = 1; break; case DEFAULT_RGB: manager_default_profile = &(icc_manager->default_rgb); default_space = gsRGB; num_comps = 3; break; case DEFAULT_CMYK: manager_default_profile = &(icc_manager->default_cmyk); default_space = gsCMYK; num_comps = 4; break; case NAMED_TYPE: manager_default_profile = &(icc_manager->device_named); default_space = gsNAMED; break; case LAB_TYPE: manager_default_profile = &(icc_manager->lab_profile); num_comps = 3; default_space = gsCIELAB; break; case DEVICEN_TYPE: manager_default_profile = NULL; default_space = gsNCHANNEL; break; case DEFAULT_NONE: default: return 0; break; } } /* If it is not NULL then it has already been set. If it is different than what we already have then we will want to free it. Since other gs_gstates could have different default profiles, this is done via reference counting. If it is the same as what we already have then we DONT increment, since that is done when the gs_gstate is duplicated. It could be the same, due to a resetting of the user params. To avoid recreating the profile data, we compare the string names. */ if (defaulttype != DEVICEN_TYPE && (*manager_default_profile) != NULL) { /* Check if this is what we already have. Also check if it is the output intent profile. */ icc_profile = *manager_default_profile; if ( namelen == icc_profile->name_length ) { if( memcmp(pname, icc_profile->name, namelen) == 0) return 0; } if (strncmp(icc_profile->name, OI_PROFILE, strlen(icc_profile->name)) == 0) { return 0; } rc_decrement(icc_profile,"gsicc_set_profile"); } /* We need to do a special check for DeviceN since we have a linked list of profiles and we can have multiple specifications */ if (defaulttype == DEVICEN_TYPE) { if (icc_manager->device_n != NULL) { gsicc_devicen_entry_t *current_entry = icc_manager->device_n->head; for (k = 0; k < icc_manager->device_n->count; k++) { if (current_entry->iccprofile != NULL) { icc_profile = current_entry->iccprofile; if (namelen == icc_profile->name_length) if (memcmp(pname, icc_profile->name, namelen) == 0) return 0; } current_entry = current_entry->next; } } /* An entry was not found. We need to create a new one to use */ code = gsicc_new_devicen(icc_manager); if (code < 0) return code; manager_default_profile = &(icc_manager->device_n->final->iccprofile); } code = gsicc_open_search(pname, namelen, mem_gc, mem_gc->gs_lib_ctx->profiledir, mem_gc->gs_lib_ctx->profiledir_len, &str); if (code < 0) return code; if (str != NULL) { icc_profile = gsicc_profile_new(str, mem_gc, pname, namelen); /* Add check so that we detect cases where we are loading a named color structure that is not a standard profile type */ if (icc_profile == NULL && defaulttype == NAMED_TYPE) { /* Failed to load the named color profile. Just load the file into the buffer as it is. The profile_handle member variable can then be used to hold the named color structure that is actually search. This is created later when needed. */ char *nameptr; icc_profile = gsicc_profile_new(NULL, mem_gc, NULL, 0); if (icc_profile == NULL) return gs_throw(gs_error_VMerror, "Creation of ICC profile failed"); icc_profile->data_cs = gsNAMED; code = gsicc_load_namedcolor_buffer(icc_profile, str, mem_gc); if (code < 0) return gs_throw1(-1, "problems with profile %s", pname); *manager_default_profile = icc_profile; nameptr = (char*) gs_alloc_bytes(icc_profile->memory, namelen+1, "gsicc_set_profile"); if (nameptr == NULL) return gs_throw(gs_error_VMerror, "Insufficient memory for profile name"); memcpy(nameptr, pname, namelen); nameptr[namelen] = '\0'; icc_profile->name = nameptr; icc_profile->name_length = namelen; return 0; /* Done now, since this is not a standard ICC profile */ } code = sfclose(str); if (icc_profile == NULL) { return gs_throw1(-1, "problems with profile %s",pname); } *manager_default_profile = icc_profile; icc_profile->default_match = defaulttype; if (defaulttype == LAB_TYPE) icc_profile->islab = true; if ( defaulttype == DEVICEN_TYPE ) { /* Lets get the name information out of the profile. The names are contained in the icSigNamedColor2Tag item. The table is in the A2B0Tag item. The names are in the order such that the fastest index in the table is the first name */ gsicc_get_devicen_names(icc_profile, icc_manager->memory); /* Init this profile now */ code = gsicc_init_profile_info(icc_profile); if (code < 0) return gs_throw1(-1, "problems with profile %s", pname); } else { /* Delay the loading of the handle buffer until we need the profile. But set some basic stuff that we need. Take care of DeviceN profile now, since we don't know the number of components etc */ icc_profile->num_comps = num_comps; icc_profile->num_comps_out = 3; gscms_set_icc_range(&icc_profile); icc_profile->data_cs = default_space; } return 0; } return -1; }
@@ -1124,10 +1124,12 @@ gsicc_open_search(const char* pname, int namelen, gs_memory_t *mem_gc, } /* First just try it like it is */ - str = sfopen(pname, "r", mem_gc); - if (str != NULL) { - *strp = str; - return 0; + if (gs_check_file_permission(mem_gc, pname, namelen, "r") >= 0) { + str = sfopen(pname, "r", mem_gc); + if (str != NULL) { + *strp = str; + return 0; + } } /* If that fails, try %rom% */ /* FIXME: Not sure this is needed or correct */
CWE-20
null
null
11,222
gsicc_setrange_lab(cmm_profile_t *profile) { profile->Range.ranges[0].rmin = 0.0; profile->Range.ranges[0].rmax = 100.0; profile->Range.ranges[1].rmin = -128.0; profile->Range.ranges[1].rmax = 127.0; profile->Range.ranges[2].rmin = -128.0; profile->Range.ranges[2].rmax = 127.0; }
Exec Code
0
gsicc_setrange_lab(cmm_profile_t *profile) { profile->Range.ranges[0].rmin = 0.0; profile->Range.ranges[0].rmax = 100.0; profile->Range.ranges[1].rmin = -128.0; profile->Range.ranges[1].rmax = 127.0; profile->Range.ranges[2].rmin = -128.0; profile->Range.ranges[2].rmax = 127.0; }
@@ -1124,10 +1124,12 @@ gsicc_open_search(const char* pname, int namelen, gs_memory_t *mem_gc, } /* First just try it like it is */ - str = sfopen(pname, "r", mem_gc); - if (str != NULL) { - *strp = str; - return 0; + if (gs_check_file_permission(mem_gc, pname, namelen, "r") >= 0) { + str = sfopen(pname, "r", mem_gc); + if (str != NULL) { + *strp = str; + return 0; + } } /* If that fails, try %rom% */ /* FIXME: Not sure this is needed or correct */
CWE-20
null
null
11,223
gsicc_smask_finalize(const gs_memory_t *memory, void * vptr) { gsicc_smask_t *iccsmask = (gsicc_smask_t *)vptr; rc_decrement(iccsmask->smask_gray, "gsicc_smask_finalize"); rc_decrement(iccsmask->smask_rgb, "gsicc_smask_finalize"); rc_decrement(iccsmask->smask_cmyk, "gsicc_smask_finalize"); }
Exec Code
0
gsicc_smask_finalize(const gs_memory_t *memory, void * vptr) { gsicc_smask_t *iccsmask = (gsicc_smask_t *)vptr; rc_decrement(iccsmask->smask_gray, "gsicc_smask_finalize"); rc_decrement(iccsmask->smask_rgb, "gsicc_smask_finalize"); rc_decrement(iccsmask->smask_cmyk, "gsicc_smask_finalize"); }
@@ -1124,10 +1124,12 @@ gsicc_open_search(const char* pname, int namelen, gs_memory_t *mem_gc, } /* First just try it like it is */ - str = sfopen(pname, "r", mem_gc); - if (str != NULL) { - *strp = str; - return 0; + if (gs_check_file_permission(mem_gc, pname, namelen, "r") >= 0) { + str = sfopen(pname, "r", mem_gc); + if (str != NULL) { + *strp = str; + return 0; + } } /* If that fails, try %rom% */ /* FIXME: Not sure this is needed or correct */
CWE-20
null
null
11,224
rc_free_icc_profile(gs_memory_t * mem, void *ptr_in, client_name_t cname) { cmm_profile_t *profile = (cmm_profile_t *)ptr_in; gs_memory_t *mem_nongc = profile->memory; if_debug2m(gs_debug_flag_icc, mem, "[icc] rc decrement profile = 0x%p rc = %ld\n", ptr_in, profile->rc.ref_count); if (profile->rc.ref_count <= 1 ) { /* Clear out the buffer if it is full */ if (profile->buffer != NULL) { gs_free_object(mem_nongc, profile->buffer, "rc_free_icc_profile(buffer)"); profile->buffer = NULL; } if_debug0m(gs_debug_flag_icc, mem, "[icc] profile freed\n"); /* Release this handle if it has been set */ if (profile->profile_handle != NULL) { profile->release(profile->profile_handle); profile->profile_handle = NULL; } /* Release the name if it has been set */ if (profile->name != NULL) { gs_free_object(mem_nongc, profile->name,"rc_free_icc_profile(name)"); profile->name = NULL; profile->name_length = 0; } profile->hash_is_valid = 0; if (profile->lock != NULL) { gx_monitor_free(profile->lock); profile->lock = NULL; } /* If we had a DeviceN profile with names deallocate that now */ if (profile->spotnames != NULL) { /* Free the linked list in this object */ gsicc_free_spotnames(profile->spotnames, mem_nongc); /* Free the main object */ gs_free_object(mem_nongc, profile->spotnames, "rc_free_icc_profile(spotnames)"); } /* If we allocated a buffer to hold the v2 profile then free that */ if (profile->v2_data != NULL) { gs_free_object(mem_nongc, profile->v2_data, "rc_free_icc_profile(v2_data)"); } gs_free_object(mem_nongc, profile, "rc_free_icc_profile"); } }
Exec Code
0
rc_free_icc_profile(gs_memory_t * mem, void *ptr_in, client_name_t cname) { cmm_profile_t *profile = (cmm_profile_t *)ptr_in; gs_memory_t *mem_nongc = profile->memory; if_debug2m(gs_debug_flag_icc, mem, "[icc] rc decrement profile = 0x%p rc = %ld\n", ptr_in, profile->rc.ref_count); if (profile->rc.ref_count <= 1 ) { /* Clear out the buffer if it is full */ if (profile->buffer != NULL) { gs_free_object(mem_nongc, profile->buffer, "rc_free_icc_profile(buffer)"); profile->buffer = NULL; } if_debug0m(gs_debug_flag_icc, mem, "[icc] profile freed\n"); /* Release this handle if it has been set */ if (profile->profile_handle != NULL) { profile->release(profile->profile_handle); profile->profile_handle = NULL; } /* Release the name if it has been set */ if (profile->name != NULL) { gs_free_object(mem_nongc, profile->name,"rc_free_icc_profile(name)"); profile->name = NULL; profile->name_length = 0; } profile->hash_is_valid = 0; if (profile->lock != NULL) { gx_monitor_free(profile->lock); profile->lock = NULL; } /* If we had a DeviceN profile with names deallocate that now */ if (profile->spotnames != NULL) { /* Free the linked list in this object */ gsicc_free_spotnames(profile->spotnames, mem_nongc); /* Free the main object */ gs_free_object(mem_nongc, profile->spotnames, "rc_free_icc_profile(spotnames)"); } /* If we allocated a buffer to hold the v2 profile then free that */ if (profile->v2_data != NULL) { gs_free_object(mem_nongc, profile->v2_data, "rc_free_icc_profile(v2_data)"); } gs_free_object(mem_nongc, profile, "rc_free_icc_profile"); } }
@@ -1124,10 +1124,12 @@ gsicc_open_search(const char* pname, int namelen, gs_memory_t *mem_gc, } /* First just try it like it is */ - str = sfopen(pname, "r", mem_gc); - if (str != NULL) { - *strp = str; - return 0; + if (gs_check_file_permission(mem_gc, pname, namelen, "r") >= 0) { + str = sfopen(pname, "r", mem_gc); + if (str != NULL) { + *strp = str; + return 0; + } } /* If that fails, try %rom% */ /* FIXME: Not sure this is needed or correct */
CWE-20
null
null
11,225
rc_free_srcgtag_profile(gs_memory_t * mem, void *ptr_in, client_name_t cname) { cmm_srcgtag_profile_t *srcgtag_profile = (cmm_srcgtag_profile_t *)ptr_in; int k; gs_memory_t *mem_nongc = srcgtag_profile->memory; if (srcgtag_profile->rc.ref_count <= 1 ) { /* Decrement any profiles. */ for (k = 0; k < NUM_SOURCE_PROFILES; k++) { if (srcgtag_profile->gray_profiles[k] != NULL) { rc_decrement(srcgtag_profile->gray_profiles[k], "rc_free_srcgtag_profile(gray)"); } if (srcgtag_profile->rgb_profiles[k] != NULL) { rc_decrement(srcgtag_profile->rgb_profiles[k], "rc_free_srcgtag_profile(rgb)"); } if (srcgtag_profile->cmyk_profiles[k] != NULL) { rc_decrement(srcgtag_profile->cmyk_profiles[k], "rc_free_srcgtag_profile(cmyk)"); } if (srcgtag_profile->color_warp_profile != NULL) { rc_decrement(srcgtag_profile->color_warp_profile, "rc_free_srcgtag_profile(warp)"); } } gs_free_object(mem_nongc, srcgtag_profile->name, "rc_free_srcgtag_profile"); gs_free_object(mem_nongc, srcgtag_profile, "rc_free_srcgtag_profile"); } }
Exec Code
0
rc_free_srcgtag_profile(gs_memory_t * mem, void *ptr_in, client_name_t cname) { cmm_srcgtag_profile_t *srcgtag_profile = (cmm_srcgtag_profile_t *)ptr_in; int k; gs_memory_t *mem_nongc = srcgtag_profile->memory; if (srcgtag_profile->rc.ref_count <= 1 ) { /* Decrement any profiles. */ for (k = 0; k < NUM_SOURCE_PROFILES; k++) { if (srcgtag_profile->gray_profiles[k] != NULL) { rc_decrement(srcgtag_profile->gray_profiles[k], "rc_free_srcgtag_profile(gray)"); } if (srcgtag_profile->rgb_profiles[k] != NULL) { rc_decrement(srcgtag_profile->rgb_profiles[k], "rc_free_srcgtag_profile(rgb)"); } if (srcgtag_profile->cmyk_profiles[k] != NULL) { rc_decrement(srcgtag_profile->cmyk_profiles[k], "rc_free_srcgtag_profile(cmyk)"); } if (srcgtag_profile->color_warp_profile != NULL) { rc_decrement(srcgtag_profile->color_warp_profile, "rc_free_srcgtag_profile(warp)"); } } gs_free_object(mem_nongc, srcgtag_profile->name, "rc_free_srcgtag_profile"); gs_free_object(mem_nongc, srcgtag_profile, "rc_free_srcgtag_profile"); } }
@@ -1124,10 +1124,12 @@ gsicc_open_search(const char* pname, int namelen, gs_memory_t *mem_gc, } /* First just try it like it is */ - str = sfopen(pname, "r", mem_gc); - if (str != NULL) { - *strp = str; - return 0; + if (gs_check_file_permission(mem_gc, pname, namelen, "r") >= 0) { + str = sfopen(pname, "r", mem_gc); + if (str != NULL) { + *strp = str; + return 0; + } } /* If that fails, try %rom% */ /* FIXME: Not sure this is needed or correct */
CWE-20
null
null
11,226
rc_gsicc_manager_free(gs_memory_t * mem, void *ptr_in, client_name_t cname) { /* Ending the manager. Decrement the ref counts of the profiles and then free the structure */ gsicc_manager_t *icc_manager = (gsicc_manager_t * ) ptr_in; gs_free_object(icc_manager->memory, icc_manager, "rc_gsicc_manager_free"); }
Exec Code
0
rc_gsicc_manager_free(gs_memory_t * mem, void *ptr_in, client_name_t cname) { /* Ending the manager. Decrement the ref counts of the profiles and then free the structure */ gsicc_manager_t *icc_manager = (gsicc_manager_t * ) ptr_in; gs_free_object(icc_manager->memory, icc_manager, "rc_gsicc_manager_free"); }
@@ -1124,10 +1124,12 @@ gsicc_open_search(const char* pname, int namelen, gs_memory_t *mem_gc, } /* First just try it like it is */ - str = sfopen(pname, "r", mem_gc); - if (str != NULL) { - *strp = str; - return 0; + if (gs_check_file_permission(mem_gc, pname, namelen, "r") >= 0) { + str = sfopen(pname, "r", mem_gc); + if (str != NULL) { + *strp = str; + return 0; + } } /* If that fails, try %rom% */ /* FIXME: Not sure this is needed or correct */
CWE-20
null
null
11,227
void errflush_nomem(void) { errflush(mem_err_print); }
Exec Code
0
void errflush_nomem(void) { errflush(mem_err_print); }
@@ -189,7 +189,7 @@ Failure: gscms_destroy(mem); goto Failure; } - + pio->client_check_file_permission = NULL; gp_get_realtime(pio->real_time_0); /* Set scanconverter to 1 (default) */ @@ -343,3 +343,13 @@ void errflush(const gs_memory_t *mem) fflush(mem->gs_lib_ctx->fstderr); /* else nothing to flush */ } + +int +gs_check_file_permission (gs_memory_t *mem, const char *fname, const int len, const char *permission) +{ + int code = 0; + if (mem->gs_lib_ctx->client_check_file_permission != NULL) { + code = mem->gs_lib_ctx->client_check_file_permission(mem, fname, len, permission); + } + return code; +}
CWE-20
null
null
11,228
int errwrite(const gs_memory_t *mem, const char *str, int len) { int code; gs_lib_ctx_t *ctx; if (len == 0) return 0; if (mem == NULL) { #ifdef GS_THREADSAFE return 0; #else mem = mem_err_print; if (mem == NULL) return 0; #endif } ctx = mem->gs_lib_ctx; if (ctx == NULL) return 0; if (ctx->stderr_fn) return (*ctx->stderr_fn)(ctx->caller_handle, str, len); code = fwrite(str, 1, len, ctx->fstderr); fflush(ctx->fstderr); return code; }
Exec Code
0
int errwrite(const gs_memory_t *mem, const char *str, int len) { int code; gs_lib_ctx_t *ctx; if (len == 0) return 0; if (mem == NULL) { #ifdef GS_THREADSAFE return 0; #else mem = mem_err_print; if (mem == NULL) return 0; #endif } ctx = mem->gs_lib_ctx; if (ctx == NULL) return 0; if (ctx->stderr_fn) return (*ctx->stderr_fn)(ctx->caller_handle, str, len); code = fwrite(str, 1, len, ctx->fstderr); fflush(ctx->fstderr); return code; }
@@ -189,7 +189,7 @@ Failure: gscms_destroy(mem); goto Failure; } - + pio->client_check_file_permission = NULL; gp_get_realtime(pio->real_time_0); /* Set scanconverter to 1 (default) */ @@ -343,3 +343,13 @@ void errflush(const gs_memory_t *mem) fflush(mem->gs_lib_ctx->fstderr); /* else nothing to flush */ } + +int +gs_check_file_permission (gs_memory_t *mem, const char *fname, const int len, const char *permission) +{ + int code = 0; + if (mem->gs_lib_ctx->client_check_file_permission != NULL) { + code = mem->gs_lib_ctx->client_check_file_permission(mem, fname, len, permission); + } + return code; +}
CWE-20
null
null
11,229
int errwrite_nomem(const char *str, int len) { return errwrite(mem_err_print, str, len); }
Exec Code
0
int errwrite_nomem(const char *str, int len) { return errwrite(mem_err_print, str, len); }
@@ -189,7 +189,7 @@ Failure: gscms_destroy(mem); goto Failure; } - + pio->client_check_file_permission = NULL; gp_get_realtime(pio->real_time_0); /* Set scanconverter to 1 (default) */ @@ -343,3 +343,13 @@ void errflush(const gs_memory_t *mem) fflush(mem->gs_lib_ctx->fstderr); /* else nothing to flush */ } + +int +gs_check_file_permission (gs_memory_t *mem, const char *fname, const int len, const char *permission) +{ + int code = 0; + if (mem->gs_lib_ctx->client_check_file_permission != NULL) { + code = mem->gs_lib_ctx->client_check_file_permission(mem, fname, len, permission); + } + return code; +}
CWE-20
null
null
11,230
void *gs_lib_ctx_get_cms_context( const gs_memory_t *mem ) { if (mem == NULL) return NULL; return mem->gs_lib_ctx->cms_context; }
Exec Code
0
void *gs_lib_ctx_get_cms_context( const gs_memory_t *mem ) { if (mem == NULL) return NULL; return mem->gs_lib_ctx->cms_context; }
@@ -189,7 +189,7 @@ Failure: gscms_destroy(mem); goto Failure; } - + pio->client_check_file_permission = NULL; gp_get_realtime(pio->real_time_0); /* Set scanconverter to 1 (default) */ @@ -343,3 +343,13 @@ void errflush(const gs_memory_t *mem) fflush(mem->gs_lib_ctx->fstderr); /* else nothing to flush */ } + +int +gs_check_file_permission (gs_memory_t *mem, const char *fname, const int len, const char *permission) +{ + int code = 0; + if (mem->gs_lib_ctx->client_check_file_permission != NULL) { + code = mem->gs_lib_ctx->client_check_file_permission(mem, fname, len, permission); + } + return code; +}
CWE-20
null
null
11,231
gs_lib_ctx_get_default_device_list(const gs_memory_t *mem, char** dev_list_str, int *list_str_len) { /* In the case the lib ctx hasn't been initialised */ if (mem && mem->gs_lib_ctx && mem->gs_lib_ctx->default_device_list) { *dev_list_str = mem->gs_lib_ctx->default_device_list; } else { *dev_list_str = (char *)gs_dev_defaults; } *list_str_len = strlen(*dev_list_str); return 0; }
Exec Code
0
gs_lib_ctx_get_default_device_list(const gs_memory_t *mem, char** dev_list_str, int *list_str_len) { /* In the case the lib ctx hasn't been initialised */ if (mem && mem->gs_lib_ctx && mem->gs_lib_ctx->default_device_list) { *dev_list_str = mem->gs_lib_ctx->default_device_list; } else { *dev_list_str = (char *)gs_dev_defaults; } *list_str_len = strlen(*dev_list_str); return 0; }
@@ -189,7 +189,7 @@ Failure: gscms_destroy(mem); goto Failure; } - + pio->client_check_file_permission = NULL; gp_get_realtime(pio->real_time_0); /* Set scanconverter to 1 (default) */ @@ -343,3 +343,13 @@ void errflush(const gs_memory_t *mem) fflush(mem->gs_lib_ctx->fstderr); /* else nothing to flush */ } + +int +gs_check_file_permission (gs_memory_t *mem, const char *fname, const int len, const char *permission) +{ + int code = 0; + if (mem->gs_lib_ctx->client_check_file_permission != NULL) { + code = mem->gs_lib_ctx->client_check_file_permission(mem, fname, len, permission); + } + return code; +}
CWE-20
null
null
11,232
gs_lib_ctx_t *gs_lib_ctx_get_interp_instance(const gs_memory_t *mem) { if (mem == NULL) return NULL; return mem->gs_lib_ctx; }
Exec Code
0
gs_lib_ctx_t *gs_lib_ctx_get_interp_instance(const gs_memory_t *mem) { if (mem == NULL) return NULL; return mem->gs_lib_ctx; }
@@ -189,7 +189,7 @@ Failure: gscms_destroy(mem); goto Failure; } - + pio->client_check_file_permission = NULL; gp_get_realtime(pio->real_time_0); /* Set scanconverter to 1 (default) */ @@ -343,3 +343,13 @@ void errflush(const gs_memory_t *mem) fflush(mem->gs_lib_ctx->fstderr); /* else nothing to flush */ } + +int +gs_check_file_permission (gs_memory_t *mem, const char *fname, const int len, const char *permission) +{ + int code = 0; + if (mem->gs_lib_ctx->client_check_file_permission != NULL) { + code = mem->gs_lib_ctx->client_check_file_permission(mem, fname, len, permission); + } + return code; +}
CWE-20
null
null
11,233
gs_lib_ctx_get_real_stdio(FILE **in, FILE **out, FILE **err) { *in = stdin; *out = stdout; *err = stderr; }
Exec Code
0
gs_lib_ctx_get_real_stdio(FILE **in, FILE **out, FILE **err) { *in = stdin; *out = stdout; *err = stderr; }
@@ -189,7 +189,7 @@ Failure: gscms_destroy(mem); goto Failure; } - + pio->client_check_file_permission = NULL; gp_get_realtime(pio->real_time_0); /* Set scanconverter to 1 (default) */ @@ -343,3 +343,13 @@ void errflush(const gs_memory_t *mem) fflush(mem->gs_lib_ctx->fstderr); /* else nothing to flush */ } + +int +gs_check_file_permission (gs_memory_t *mem, const char *fname, const int len, const char *permission) +{ + int code = 0; + if (mem->gs_lib_ctx->client_check_file_permission != NULL) { + code = mem->gs_lib_ctx->client_check_file_permission(mem, fname, len, permission); + } + return code; +}
CWE-20
null
null
11,234
void gs_lib_ctx_set_cms_context( const gs_memory_t *mem, void *cms_context ) { if (mem == NULL) return; mem->gs_lib_ctx->cms_context = cms_context; }
Exec Code
0
void gs_lib_ctx_set_cms_context( const gs_memory_t *mem, void *cms_context ) { if (mem == NULL) return; mem->gs_lib_ctx->cms_context = cms_context; }
@@ -189,7 +189,7 @@ Failure: gscms_destroy(mem); goto Failure; } - + pio->client_check_file_permission = NULL; gp_get_realtime(pio->real_time_0); /* Set scanconverter to 1 (default) */ @@ -343,3 +343,13 @@ void errflush(const gs_memory_t *mem) fflush(mem->gs_lib_ctx->fstderr); /* else nothing to flush */ } + +int +gs_check_file_permission (gs_memory_t *mem, const char *fname, const int len, const char *permission) +{ + int code = 0; + if (mem->gs_lib_ctx->client_check_file_permission != NULL) { + code = mem->gs_lib_ctx->client_check_file_permission(mem, fname, len, permission); + } + return code; +}
CWE-20
null
null
11,235
gs_lib_ctx_set_default_device_list(const gs_memory_t *mem, const char* dev_list_str, int list_str_len) { char *result; gs_lib_ctx_t *p_ctx = mem->gs_lib_ctx; gs_memory_t *ctx_mem = p_ctx->memory; int code = 0; result = (char *)gs_alloc_bytes(ctx_mem, list_str_len + 1, "gs_lib_ctx_set_default_device_list"); if (result) { gs_free_object(ctx_mem, p_ctx->default_device_list, "gs_lib_ctx_set_default_device_list"); memcpy(result, dev_list_str, list_str_len); result[list_str_len] = '\0'; p_ctx->default_device_list = result; } else { code = gs_note_error(gs_error_VMerror); } return code; }
Exec Code
0
gs_lib_ctx_set_default_device_list(const gs_memory_t *mem, const char* dev_list_str, int list_str_len) { char *result; gs_lib_ctx_t *p_ctx = mem->gs_lib_ctx; gs_memory_t *ctx_mem = p_ctx->memory; int code = 0; result = (char *)gs_alloc_bytes(ctx_mem, list_str_len + 1, "gs_lib_ctx_set_default_device_list"); if (result) { gs_free_object(ctx_mem, p_ctx->default_device_list, "gs_lib_ctx_set_default_device_list"); memcpy(result, dev_list_str, list_str_len); result[list_str_len] = '\0'; p_ctx->default_device_list = result; } else { code = gs_note_error(gs_error_VMerror); } return code; }
@@ -189,7 +189,7 @@ Failure: gscms_destroy(mem); goto Failure; } - + pio->client_check_file_permission = NULL; gp_get_realtime(pio->real_time_0); /* Set scanconverter to 1 (default) */ @@ -343,3 +343,13 @@ void errflush(const gs_memory_t *mem) fflush(mem->gs_lib_ctx->fstderr); /* else nothing to flush */ } + +int +gs_check_file_permission (gs_memory_t *mem, const char *fname, const int len, const char *permission) +{ + int code = 0; + if (mem->gs_lib_ctx->client_check_file_permission != NULL) { + code = mem->gs_lib_ctx->client_check_file_permission(mem, fname, len, permission); + } + return code; +}
CWE-20
null
null
11,236
gs_lib_ctx_set_icc_directory(const gs_memory_t *mem_gc, const char* pname, int dir_namelen) { char *result; gs_lib_ctx_t *p_ctx = mem_gc->gs_lib_ctx; gs_memory_t *p_ctx_mem = p_ctx->memory; /* If it is already set and the incoming is the default then don't set as we are coming from a VMreclaim which is trying to reset the user parameter */ if (p_ctx->profiledir != NULL && strcmp(pname,DEFAULT_DIR_ICC) == 0) { return; } if (p_ctx->profiledir != NULL && p_ctx->profiledir_len > 0) { if (strncmp(pname, p_ctx->profiledir, p_ctx->profiledir_len) == 0) { return; } gs_free_object(p_ctx_mem, p_ctx->profiledir, "gs_lib_ctx_set_icc_directory"); } /* User param string. Must allocate in non-gc memory */ result = (char*) gs_alloc_bytes(p_ctx_mem, dir_namelen+1, "gs_lib_ctx_set_icc_directory"); if (result != NULL) { strcpy(result, pname); p_ctx->profiledir = result; p_ctx->profiledir_len = dir_namelen; } }
Exec Code
0
gs_lib_ctx_set_icc_directory(const gs_memory_t *mem_gc, const char* pname, int dir_namelen) { char *result; gs_lib_ctx_t *p_ctx = mem_gc->gs_lib_ctx; gs_memory_t *p_ctx_mem = p_ctx->memory; /* If it is already set and the incoming is the default then don't set as we are coming from a VMreclaim which is trying to reset the user parameter */ if (p_ctx->profiledir != NULL && strcmp(pname,DEFAULT_DIR_ICC) == 0) { return; } if (p_ctx->profiledir != NULL && p_ctx->profiledir_len > 0) { if (strncmp(pname, p_ctx->profiledir, p_ctx->profiledir_len) == 0) { return; } gs_free_object(p_ctx_mem, p_ctx->profiledir, "gs_lib_ctx_set_icc_directory"); } /* User param string. Must allocate in non-gc memory */ result = (char*) gs_alloc_bytes(p_ctx_mem, dir_namelen+1, "gs_lib_ctx_set_icc_directory"); if (result != NULL) { strcpy(result, pname); p_ctx->profiledir = result; p_ctx->profiledir_len = dir_namelen; } }
@@ -189,7 +189,7 @@ Failure: gscms_destroy(mem); goto Failure; } - + pio->client_check_file_permission = NULL; gp_get_realtime(pio->real_time_0); /* Set scanconverter to 1 (default) */ @@ -343,3 +343,13 @@ void errflush(const gs_memory_t *mem) fflush(mem->gs_lib_ctx->fstderr); /* else nothing to flush */ } + +int +gs_check_file_permission (gs_memory_t *mem, const char *fname, const int len, const char *permission) +{ + int code = 0; + if (mem->gs_lib_ctx->client_check_file_permission != NULL) { + code = mem->gs_lib_ctx->client_check_file_permission(mem, fname, len, permission); + } + return code; +}
CWE-20
null
null
11,237
void outflush(const gs_memory_t *mem) { if (mem->gs_lib_ctx->stdout_is_redirected) { if (mem->gs_lib_ctx->stdout_to_stderr) { if (!mem->gs_lib_ctx->stderr_fn) fflush(mem->gs_lib_ctx->fstderr); } else fflush(mem->gs_lib_ctx->fstdout2); } else if (!mem->gs_lib_ctx->stdout_fn) fflush(mem->gs_lib_ctx->fstdout); }
Exec Code
0
void outflush(const gs_memory_t *mem) { if (mem->gs_lib_ctx->stdout_is_redirected) { if (mem->gs_lib_ctx->stdout_to_stderr) { if (!mem->gs_lib_ctx->stderr_fn) fflush(mem->gs_lib_ctx->fstderr); } else fflush(mem->gs_lib_ctx->fstdout2); } else if (!mem->gs_lib_ctx->stdout_fn) fflush(mem->gs_lib_ctx->fstdout); }
@@ -189,7 +189,7 @@ Failure: gscms_destroy(mem); goto Failure; } - + pio->client_check_file_permission = NULL; gp_get_realtime(pio->real_time_0); /* Set scanconverter to 1 (default) */ @@ -343,3 +343,13 @@ void errflush(const gs_memory_t *mem) fflush(mem->gs_lib_ctx->fstderr); /* else nothing to flush */ } + +int +gs_check_file_permission (gs_memory_t *mem, const char *fname, const int len, const char *permission) +{ + int code = 0; + if (mem->gs_lib_ctx->client_check_file_permission != NULL) { + code = mem->gs_lib_ctx->client_check_file_permission(mem, fname, len, permission); + } + return code; +}
CWE-20
null
null
11,238
int outwrite(const gs_memory_t *mem, const char *str, int len) { int code; FILE *fout; gs_lib_ctx_t *pio = mem->gs_lib_ctx; if (len == 0) return 0; if (pio->stdout_is_redirected) { if (pio->stdout_to_stderr) return errwrite(mem, str, len); fout = pio->fstdout2; } else if (pio->stdout_fn) { return (*pio->stdout_fn)(pio->caller_handle, str, len); } else { fout = pio->fstdout; } code = fwrite(str, 1, len, fout); fflush(fout); return code; }
Exec Code
0
int outwrite(const gs_memory_t *mem, const char *str, int len) { int code; FILE *fout; gs_lib_ctx_t *pio = mem->gs_lib_ctx; if (len == 0) return 0; if (pio->stdout_is_redirected) { if (pio->stdout_to_stderr) return errwrite(mem, str, len); fout = pio->fstdout2; } else if (pio->stdout_fn) { return (*pio->stdout_fn)(pio->caller_handle, str, len); } else { fout = pio->fstdout; } code = fwrite(str, 1, len, fout); fflush(fout); return code; }
@@ -189,7 +189,7 @@ Failure: gscms_destroy(mem); goto Failure; } - + pio->client_check_file_permission = NULL; gp_get_realtime(pio->real_time_0); /* Set scanconverter to 1 (default) */ @@ -343,3 +343,13 @@ void errflush(const gs_memory_t *mem) fflush(mem->gs_lib_ctx->fstderr); /* else nothing to flush */ } + +int +gs_check_file_permission (gs_memory_t *mem, const char *fname, const int len, const char *permission) +{ + int code = 0; + if (mem->gs_lib_ctx->client_check_file_permission != NULL) { + code = mem->gs_lib_ctx->client_check_file_permission(mem, fname, len, permission); + } + return code; +}
CWE-20
null
null
11,239
static void remove_ctx_pointers(gs_memory_t *mem) { mem->gs_lib_ctx = NULL; if (mem->stable_memory && mem->stable_memory != mem) remove_ctx_pointers(mem->stable_memory); if (mem->non_gc_memory && mem->non_gc_memory != mem) remove_ctx_pointers(mem->non_gc_memory); if (mem->thread_safe_memory && mem->thread_safe_memory != mem) remove_ctx_pointers(mem->thread_safe_memory); }
Exec Code
0
static void remove_ctx_pointers(gs_memory_t *mem) { mem->gs_lib_ctx = NULL; if (mem->stable_memory && mem->stable_memory != mem) remove_ctx_pointers(mem->stable_memory); if (mem->non_gc_memory && mem->non_gc_memory != mem) remove_ctx_pointers(mem->non_gc_memory); if (mem->thread_safe_memory && mem->thread_safe_memory != mem) remove_ctx_pointers(mem->thread_safe_memory); }
@@ -189,7 +189,7 @@ Failure: gscms_destroy(mem); goto Failure; } - + pio->client_check_file_permission = NULL; gp_get_realtime(pio->real_time_0); /* Set scanconverter to 1 (default) */ @@ -343,3 +343,13 @@ void errflush(const gs_memory_t *mem) fflush(mem->gs_lib_ctx->fstderr); /* else nothing to flush */ } + +int +gs_check_file_permission (gs_memory_t *mem, const char *fname, const int len, const char *permission) +{ + int code = 0; + if (mem->gs_lib_ctx->client_check_file_permission != NULL) { + code = mem->gs_lib_ctx->client_check_file_permission(mem, fname, len, permission); + } + return code; +}
CWE-20
null
null
11,240
get_minst_from_memory(const gs_memory_t *mem) { #ifdef PSI_INCLUDED extern gs_main_instance *ps_impl_get_minst( const gs_memory_t *mem ); return ps_impl_get_minst(mem); #else return (gs_main_instance*)mem->gs_lib_ctx->top_of_system; #endif }
Exec Code
0
get_minst_from_memory(const gs_memory_t *mem) { #ifdef PSI_INCLUDED extern gs_main_instance *ps_impl_get_minst( const gs_memory_t *mem ); return ps_impl_get_minst(mem); #else return (gs_main_instance*)mem->gs_lib_ctx->top_of_system; #endif }
@@ -57,6 +57,7 @@ #include "ivmspace.h" #include "idisp.h" /* for setting display device callback */ #include "iplugin.h" +#include "zfile.h" #ifdef PACIFY_VALGRIND #include "valgrind.h" @@ -212,6 +213,7 @@ gs_main_init1(gs_main_instance * minst) "the_gs_name_table"); if (code < 0) return code; + mem->gs_lib_ctx->client_check_file_permission = z_check_file_permissions; } code = obj_init(&minst->i_ctx_p, &idmem); /* requires name_init */ if (code < 0)
CWE-20
null
null
11,241
gs_main_alloc_instance(gs_memory_t *mem) { gs_main_instance *minst; if (mem == NULL) return NULL; minst = (gs_main_instance *)gs_alloc_bytes_immovable(mem, sizeof(gs_main_instance), "init_main_instance"); if (minst == NULL) return NULL; memcpy(minst, &gs_main_instance_init_values, sizeof(gs_main_instance_init_values)); minst->heap = mem; # ifndef PSI_INCLUDED mem->gs_lib_ctx->top_of_system = minst; /* else top of system is pl_universe */ # endif return minst; }
Exec Code
0
gs_main_alloc_instance(gs_memory_t *mem) { gs_main_instance *minst; if (mem == NULL) return NULL; minst = (gs_main_instance *)gs_alloc_bytes_immovable(mem, sizeof(gs_main_instance), "init_main_instance"); if (minst == NULL) return NULL; memcpy(minst, &gs_main_instance_init_values, sizeof(gs_main_instance_init_values)); minst->heap = mem; # ifndef PSI_INCLUDED mem->gs_lib_ctx->top_of_system = minst; /* else top of system is pl_universe */ # endif return minst; }
@@ -57,6 +57,7 @@ #include "ivmspace.h" #include "idisp.h" /* for setting display device callback */ #include "iplugin.h" +#include "zfile.h" #ifdef PACIFY_VALGRIND #include "valgrind.h" @@ -212,6 +213,7 @@ gs_main_init1(gs_main_instance * minst) "the_gs_name_table"); if (code < 0) return code; + mem->gs_lib_ctx->client_check_file_permission = z_check_file_permissions; } code = obj_init(&minst->i_ctx_p, &idmem); /* requires name_init */ if (code < 0)
CWE-20
null
null
11,242
gs_main_init0(gs_main_instance * minst, FILE * in, FILE * out, FILE * err, int max_lib_paths) { ref *paths; ref *array; /* Do platform-dependent initialization. */ /* We have to do this as the very first thing, */ /* because it detects attempts to run 80N86 executables (N>0) */ /* on incompatible processors. */ gp_init(); /* Initialize the imager. */ # ifndef PSI_INCLUDED /* Reset debugging flags */ #ifdef PACIFY_VALGRIND VALGRIND_HG_DISABLE_CHECKING(gs_debug, 128); #endif memset(gs_debug, 0, 128); gs_log_errors = 0; /* gs_debug['#'] = 0 */ # else /* plmain settings remain in effect */ # endif gp_get_realtime(minst->base_time); /* Initialize the file search paths. */ paths = (ref *) gs_alloc_byte_array(minst->heap, max_lib_paths, sizeof(ref), "lib_path array"); if (paths == 0) { gs_lib_finit(1, gs_error_VMerror, minst->heap); return_error(gs_error_VMerror); } array = (ref *) gs_alloc_byte_array(minst->heap, max_lib_paths, sizeof(ref), "lib_path array"); if (array == 0) { gs_lib_finit(1, gs_error_VMerror, minst->heap); return_error(gs_error_VMerror); } make_array(&minst->lib_path.container, avm_foreign, max_lib_paths, array); make_array(&minst->lib_path.list, avm_foreign | a_readonly, 0, minst->lib_path.container.value.refs); minst->lib_path.env = 0; minst->lib_path.final = 0; minst->lib_path.count = 0; minst->user_errors = 1; minst->init_done = 0; return 0; }
Exec Code
0
gs_main_init0(gs_main_instance * minst, FILE * in, FILE * out, FILE * err, int max_lib_paths) { ref *paths; ref *array; /* Do platform-dependent initialization. */ /* We have to do this as the very first thing, */ /* because it detects attempts to run 80N86 executables (N>0) */ /* on incompatible processors. */ gp_init(); /* Initialize the imager. */ # ifndef PSI_INCLUDED /* Reset debugging flags */ #ifdef PACIFY_VALGRIND VALGRIND_HG_DISABLE_CHECKING(gs_debug, 128); #endif memset(gs_debug, 0, 128); gs_log_errors = 0; /* gs_debug['#'] = 0 */ # else /* plmain settings remain in effect */ # endif gp_get_realtime(minst->base_time); /* Initialize the file search paths. */ paths = (ref *) gs_alloc_byte_array(minst->heap, max_lib_paths, sizeof(ref), "lib_path array"); if (paths == 0) { gs_lib_finit(1, gs_error_VMerror, minst->heap); return_error(gs_error_VMerror); } array = (ref *) gs_alloc_byte_array(minst->heap, max_lib_paths, sizeof(ref), "lib_path array"); if (array == 0) { gs_lib_finit(1, gs_error_VMerror, minst->heap); return_error(gs_error_VMerror); } make_array(&minst->lib_path.container, avm_foreign, max_lib_paths, array); make_array(&minst->lib_path.list, avm_foreign | a_readonly, 0, minst->lib_path.container.value.refs); minst->lib_path.env = 0; minst->lib_path.final = 0; minst->lib_path.count = 0; minst->user_errors = 1; minst->init_done = 0; return 0; }
@@ -57,6 +57,7 @@ #include "ivmspace.h" #include "idisp.h" /* for setting display device callback */ #include "iplugin.h" +#include "zfile.h" #ifdef PACIFY_VALGRIND #include "valgrind.h" @@ -212,6 +213,7 @@ gs_main_init1(gs_main_instance * minst) "the_gs_name_table"); if (code < 0) return code; + mem->gs_lib_ctx->client_check_file_permission = z_check_file_permissions; } code = obj_init(&minst->i_ctx_p, &idmem); /* requires name_init */ if (code < 0)
CWE-20
null
null
11,243
gs_main_init2(gs_main_instance * minst) { i_ctx_t *i_ctx_p; int code = gs_main_init1(minst); int initial_init_level = minst->init_done; if (code < 0) return code; i_ctx_p = minst->i_ctx_p; code = gs_main_init2aux(minst); if (code < 0) return code; i_ctx_p = minst->i_ctx_p; /* display_set_callback or run_string may change it */ /* Now process the initial saved-pages=... argument, if any as well as saved-pages-test */ if (initial_init_level < 2) { gx_device *pdev = gs_currentdevice(minst->i_ctx_p->pgs); /* get the current device */ gx_device_printer *ppdev = (gx_device_printer *)pdev; if (minst->saved_pages_test_mode) { if ((dev_proc(pdev, dev_spec_op)(pdev, gxdso_supports_saved_pages, NULL, 0) == 0)) { /* no warning or error if saved-pages-test mode is used, just disable it */ minst->saved_pages_test_mode = false; /* device doesn't support it */ } else { if ((code = gx_saved_pages_param_process(ppdev, (byte *)"begin", 5)) < 0) return code; if (code > 0) if ((code = gs_erasepage(minst->i_ctx_p->pgs)) < 0) return code; } } else if (minst->saved_pages_initial_arg != NULL) { if (dev_proc(pdev, dev_spec_op)(pdev, gxdso_supports_saved_pages, NULL, 0) == 0) { outprintf(minst->heap, " --saved-pages not supported by the '%s' device.\n", pdev->dname); return gs_error_Fatal; } code = gx_saved_pages_param_process(ppdev, (byte *)minst->saved_pages_initial_arg, strlen(minst->saved_pages_initial_arg)); if (code > 0) if ((code = gs_erasepage(minst->i_ctx_p->pgs)) < 0) return code; } } if (gs_debug_c(':')) print_resource_usage(minst, &gs_imemory, "Start"); gp_readline_init(&minst->readline_data, imemory_system); return 0; }
Exec Code
0
gs_main_init2(gs_main_instance * minst) { i_ctx_t *i_ctx_p; int code = gs_main_init1(minst); int initial_init_level = minst->init_done; if (code < 0) return code; i_ctx_p = minst->i_ctx_p; code = gs_main_init2aux(minst); if (code < 0) return code; i_ctx_p = minst->i_ctx_p; /* display_set_callback or run_string may change it */ /* Now process the initial saved-pages=... argument, if any as well as saved-pages-test */ if (initial_init_level < 2) { gx_device *pdev = gs_currentdevice(minst->i_ctx_p->pgs); /* get the current device */ gx_device_printer *ppdev = (gx_device_printer *)pdev; if (minst->saved_pages_test_mode) { if ((dev_proc(pdev, dev_spec_op)(pdev, gxdso_supports_saved_pages, NULL, 0) == 0)) { /* no warning or error if saved-pages-test mode is used, just disable it */ minst->saved_pages_test_mode = false; /* device doesn't support it */ } else { if ((code = gx_saved_pages_param_process(ppdev, (byte *)"begin", 5)) < 0) return code; if (code > 0) if ((code = gs_erasepage(minst->i_ctx_p->pgs)) < 0) return code; } } else if (minst->saved_pages_initial_arg != NULL) { if (dev_proc(pdev, dev_spec_op)(pdev, gxdso_supports_saved_pages, NULL, 0) == 0) { outprintf(minst->heap, " --saved-pages not supported by the '%s' device.\n", pdev->dname); return gs_error_Fatal; } code = gx_saved_pages_param_process(ppdev, (byte *)minst->saved_pages_initial_arg, strlen(minst->saved_pages_initial_arg)); if (code > 0) if ((code = gs_erasepage(minst->i_ctx_p->pgs)) < 0) return code; } } if (gs_debug_c(':')) print_resource_usage(minst, &gs_imemory, "Start"); gp_readline_init(&minst->readline_data, imemory_system); return 0; }
@@ -57,6 +57,7 @@ #include "ivmspace.h" #include "idisp.h" /* for setting display device callback */ #include "iplugin.h" +#include "zfile.h" #ifdef PACIFY_VALGRIND #include "valgrind.h" @@ -212,6 +213,7 @@ gs_main_init1(gs_main_instance * minst) "the_gs_name_table"); if (code < 0) return code; + mem->gs_lib_ctx->client_check_file_permission = z_check_file_permissions; } code = obj_init(&minst->i_ctx_p, &idmem); /* requires name_init */ if (code < 0)
CWE-20
null
null
11,244
int gs_main_init2aux(gs_main_instance * minst) { i_ctx_t * i_ctx_p = minst->i_ctx_p; if (minst->init_done < 2) { int code, exit_code; ref error_object, ifa; /* Set up enough so that we can safely be garbage collected */ i_ctx_p->op_array_table_global = empty_table; i_ctx_p->op_array_table_local = empty_table; code = zop_init(i_ctx_p); if (code < 0) return code; code = op_init(i_ctx_p); /* requires obj_init */ if (code < 0) return code; /* Set up the array of additional initialization files. */ make_const_string(&ifa, a_readonly | avm_foreign, gs_init_files_sizeof - 2, gs_init_files); code = initial_enter_name("INITFILES", &ifa); if (code < 0) return code; /* Set up the array of emulator names. */ make_const_string(&ifa, a_readonly | avm_foreign, gs_emulators_sizeof - 2, gs_emulators); code = initial_enter_name("EMULATORS", &ifa); if (code < 0) return code; /* Pass the search path. */ code = initial_enter_name("LIBPATH", &minst->lib_path.list); if (code < 0) return code; /* Execute the standard initialization file. */ code = gs_run_init_file(minst, &exit_code, &error_object); if (code < 0) return code; minst->init_done = 2; /* NB this is to be done with device parameters * both minst->display and display_set_callback() are going away */ if (minst->display) if ((code = display_set_callback(minst, minst->display)) < 0) return code; #ifndef PSI_INCLUDED if ((code = gs_main_run_string(minst, "JOBSERVER " " { false 0 .startnewjob } " " { NOOUTERSAVE not { save pop } if } " "ifelse", 0, &exit_code, &error_object)) < 0) return code; #endif /* PSI_INCLUDED */ } return 0; }
Exec Code
0
int gs_main_init2aux(gs_main_instance * minst) { i_ctx_t * i_ctx_p = minst->i_ctx_p; if (minst->init_done < 2) { int code, exit_code; ref error_object, ifa; /* Set up enough so that we can safely be garbage collected */ i_ctx_p->op_array_table_global = empty_table; i_ctx_p->op_array_table_local = empty_table; code = zop_init(i_ctx_p); if (code < 0) return code; code = op_init(i_ctx_p); /* requires obj_init */ if (code < 0) return code; /* Set up the array of additional initialization files. */ make_const_string(&ifa, a_readonly | avm_foreign, gs_init_files_sizeof - 2, gs_init_files); code = initial_enter_name("INITFILES", &ifa); if (code < 0) return code; /* Set up the array of emulator names. */ make_const_string(&ifa, a_readonly | avm_foreign, gs_emulators_sizeof - 2, gs_emulators); code = initial_enter_name("EMULATORS", &ifa); if (code < 0) return code; /* Pass the search path. */ code = initial_enter_name("LIBPATH", &minst->lib_path.list); if (code < 0) return code; /* Execute the standard initialization file. */ code = gs_run_init_file(minst, &exit_code, &error_object); if (code < 0) return code; minst->init_done = 2; /* NB this is to be done with device parameters * both minst->display and display_set_callback() are going away */ if (minst->display) if ((code = display_set_callback(minst, minst->display)) < 0) return code; #ifndef PSI_INCLUDED if ((code = gs_main_run_string(minst, "JOBSERVER " " { false 0 .startnewjob } " " { NOOUTERSAVE not { save pop } if } " "ifelse", 0, &exit_code, &error_object)) < 0) return code; #endif /* PSI_INCLUDED */ } return 0; }
@@ -57,6 +57,7 @@ #include "ivmspace.h" #include "idisp.h" /* for setting display device callback */ #include "iplugin.h" +#include "zfile.h" #ifdef PACIFY_VALGRIND #include "valgrind.h" @@ -212,6 +213,7 @@ gs_main_init1(gs_main_instance * minst) "the_gs_name_table"); if (code < 0) return code; + mem->gs_lib_ctx->client_check_file_permission = z_check_file_permissions; } code = obj_init(&minst->i_ctx_p, &idmem); /* requires name_init */ if (code < 0)
CWE-20
null
null
11,245
check_file_permissions(i_ctx_t *i_ctx_p, const char *fname, int len, const char *permitgroup) { char fname_reduced[gp_file_name_sizeof]; uint rlen = sizeof(fname_reduced); if (gp_file_name_reduce(fname, len, fname_reduced, &rlen) != gp_combine_success) return gs_error_invalidaccess; /* fail if we couldn't reduce */ return check_file_permissions_reduced(i_ctx_p, fname_reduced, rlen, permitgroup); }
Exec Code
0
check_file_permissions(i_ctx_t *i_ctx_p, const char *fname, int len, const char *permitgroup) { char fname_reduced[gp_file_name_sizeof]; uint rlen = sizeof(fname_reduced); if (gp_file_name_reduce(fname, len, fname_reduced, &rlen) != gp_combine_success) return gs_error_invalidaccess; /* fail if we couldn't reduce */ return check_file_permissions_reduced(i_ctx_p, fname_reduced, rlen, permitgroup); }
@@ -197,6 +197,25 @@ check_file_permissions(i_ctx_t *i_ctx_p, const char *fname, int len, return check_file_permissions_reduced(i_ctx_p, fname_reduced, rlen, permitgroup); } +/* z_check_file_permissions: see zfile.h for explanation + */ +int +z_check_file_permissions(gs_memory_t *mem, const char *fname, const int len, const char *permission) +{ + i_ctx_t *i_ctx_p = get_minst_from_memory(mem)->i_ctx_p; + gs_parsed_file_name_t pname; + const char *permitgroup = permission[0] == 'r' ? "PermitFileReading" : "PermitFileWriting"; + int code = gs_parse_file_name(&pname, fname, len, imemory); + if (code < 0) + return code; + + if (pname.iodev && i_ctx_p->LockFilePermissions && strcmp(pname.iodev->dname, "%pipe%") == 0) + return gs_error_invalidfileaccess; + + code = check_file_permissions(i_ctx_p, fname, len, permitgroup); + return code; +} + /* <name_string> <access_string> file <file> */ int /* exported for zsysvm.c */ zfile(i_ctx_t *i_ctx_p)
CWE-20
null
null
11,246
PanoramiXRenderChangePicture (ClientPtr client) { PanoramiXRes *pict; int result = Success, j; REQUEST(xRenderChangePictureReq); REQUEST_AT_LEAST_SIZE(xRenderChangePictureReq); VERIFY_XIN_PICTURE(pict, stuff->picture, client, DixWriteAccess); FOR_NSCREENS_BACKWARD(j) { stuff->picture = pict->info[j].id; result = (*PanoramiXSaveRenderVector[X_RenderChangePicture]) (client); if(result != Success) break; } return result; }
DoS
0
PanoramiXRenderChangePicture (ClientPtr client) { PanoramiXRes *pict; int result = Success, j; REQUEST(xRenderChangePictureReq); REQUEST_AT_LEAST_SIZE(xRenderChangePictureReq); VERIFY_XIN_PICTURE(pict, stuff->picture, client, DixWriteAccess); FOR_NSCREENS_BACKWARD(j) { stuff->picture = pict->info[j].id; result = (*PanoramiXSaveRenderVector[X_RenderChangePicture]) (client); if(result != Success) break; } return result; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,247
PanoramiXRenderComposite (ClientPtr client) { PanoramiXRes *src, *msk, *dst; int result = Success, j; xRenderCompositeReq orig; REQUEST(xRenderCompositeReq); REQUEST_SIZE_MATCH(xRenderCompositeReq); VERIFY_XIN_PICTURE (src, stuff->src, client, DixReadAccess); VERIFY_XIN_ALPHA (msk, stuff->mask, client, DixReadAccess); VERIFY_XIN_PICTURE (dst, stuff->dst, client, DixWriteAccess); orig = *stuff; FOR_NSCREENS_FORWARD(j) { stuff->src = src->info[j].id; if (src->u.pict.root) { stuff->xSrc = orig.xSrc - screenInfo.screens[j]->x; stuff->ySrc = orig.ySrc - screenInfo.screens[j]->y; } stuff->dst = dst->info[j].id; if (dst->u.pict.root) { stuff->xDst = orig.xDst - screenInfo.screens[j]->x; stuff->yDst = orig.yDst - screenInfo.screens[j]->y; } if (msk) { stuff->mask = msk->info[j].id; if (msk->u.pict.root) { stuff->xMask = orig.xMask - screenInfo.screens[j]->x; stuff->yMask = orig.yMask - screenInfo.screens[j]->y; } } result = (*PanoramiXSaveRenderVector[X_RenderComposite]) (client); if(result != Success) break; } return result; }
DoS
0
PanoramiXRenderComposite (ClientPtr client) { PanoramiXRes *src, *msk, *dst; int result = Success, j; xRenderCompositeReq orig; REQUEST(xRenderCompositeReq); REQUEST_SIZE_MATCH(xRenderCompositeReq); VERIFY_XIN_PICTURE (src, stuff->src, client, DixReadAccess); VERIFY_XIN_ALPHA (msk, stuff->mask, client, DixReadAccess); VERIFY_XIN_PICTURE (dst, stuff->dst, client, DixWriteAccess); orig = *stuff; FOR_NSCREENS_FORWARD(j) { stuff->src = src->info[j].id; if (src->u.pict.root) { stuff->xSrc = orig.xSrc - screenInfo.screens[j]->x; stuff->ySrc = orig.ySrc - screenInfo.screens[j]->y; } stuff->dst = dst->info[j].id; if (dst->u.pict.root) { stuff->xDst = orig.xDst - screenInfo.screens[j]->x; stuff->yDst = orig.yDst - screenInfo.screens[j]->y; } if (msk) { stuff->mask = msk->info[j].id; if (msk->u.pict.root) { stuff->xMask = orig.xMask - screenInfo.screens[j]->x; stuff->yMask = orig.yMask - screenInfo.screens[j]->y; } } result = (*PanoramiXSaveRenderVector[X_RenderComposite]) (client); if(result != Success) break; } return result; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,248
PanoramiXRenderCompositeGlyphs (ClientPtr client) { PanoramiXRes *src, *dst; int result = Success, j; REQUEST(xRenderCompositeGlyphsReq); xGlyphElt origElt, *elt; INT16 xSrc, ySrc; REQUEST_AT_LEAST_SIZE(xRenderCompositeGlyphsReq); VERIFY_XIN_PICTURE (src, stuff->src, client, DixReadAccess); VERIFY_XIN_PICTURE (dst, stuff->dst, client, DixWriteAccess); if (client->req_len << 2 >= (sizeof (xRenderCompositeGlyphsReq) + sizeof (xGlyphElt))) { elt = (xGlyphElt *) (stuff + 1); origElt = *elt; xSrc = stuff->xSrc; ySrc = stuff->ySrc; FOR_NSCREENS_FORWARD(j) { stuff->src = src->info[j].id; if (src->u.pict.root) { stuff->xSrc = xSrc - screenInfo.screens[j]->x; stuff->ySrc = ySrc - screenInfo.screens[j]->y; } stuff->dst = dst->info[j].id; if (dst->u.pict.root) { elt->deltax = origElt.deltax - screenInfo.screens[j]->x; elt->deltay = origElt.deltay - screenInfo.screens[j]->y; } result = (*PanoramiXSaveRenderVector[stuff->renderReqType]) (client); if(result != Success) break; } } return result; }
DoS
0
PanoramiXRenderCompositeGlyphs (ClientPtr client) { PanoramiXRes *src, *dst; int result = Success, j; REQUEST(xRenderCompositeGlyphsReq); xGlyphElt origElt, *elt; INT16 xSrc, ySrc; REQUEST_AT_LEAST_SIZE(xRenderCompositeGlyphsReq); VERIFY_XIN_PICTURE (src, stuff->src, client, DixReadAccess); VERIFY_XIN_PICTURE (dst, stuff->dst, client, DixWriteAccess); if (client->req_len << 2 >= (sizeof (xRenderCompositeGlyphsReq) + sizeof (xGlyphElt))) { elt = (xGlyphElt *) (stuff + 1); origElt = *elt; xSrc = stuff->xSrc; ySrc = stuff->ySrc; FOR_NSCREENS_FORWARD(j) { stuff->src = src->info[j].id; if (src->u.pict.root) { stuff->xSrc = xSrc - screenInfo.screens[j]->x; stuff->ySrc = ySrc - screenInfo.screens[j]->y; } stuff->dst = dst->info[j].id; if (dst->u.pict.root) { elt->deltax = origElt.deltax - screenInfo.screens[j]->x; elt->deltay = origElt.deltay - screenInfo.screens[j]->y; } result = (*PanoramiXSaveRenderVector[stuff->renderReqType]) (client); if(result != Success) break; } } return result; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,249
PanoramiXRenderCreateConicalGradient (ClientPtr client) { REQUEST(xRenderCreateConicalGradientReq); PanoramiXRes *newPict; int result = Success, j; REQUEST_AT_LEAST_SIZE(xRenderCreateConicalGradientReq); if(!(newPict = (PanoramiXRes *) malloc(sizeof(PanoramiXRes)))) return BadAlloc; newPict->type = XRT_PICTURE; newPict->info[0].id = stuff->pid; newPict->u.pict.root = FALSE; for(j = 1; j < PanoramiXNumScreens; j++) newPict->info[j].id = FakeClientID(client->index); FOR_NSCREENS_BACKWARD(j) { stuff->pid = newPict->info[j].id; result = (*PanoramiXSaveRenderVector[X_RenderCreateConicalGradient]) (client); if(result != Success) break; } if (result == Success) AddResource(newPict->info[0].id, XRT_PICTURE, newPict); else free(newPict); return result; }
DoS
0
PanoramiXRenderCreateConicalGradient (ClientPtr client) { REQUEST(xRenderCreateConicalGradientReq); PanoramiXRes *newPict; int result = Success, j; REQUEST_AT_LEAST_SIZE(xRenderCreateConicalGradientReq); if(!(newPict = (PanoramiXRes *) malloc(sizeof(PanoramiXRes)))) return BadAlloc; newPict->type = XRT_PICTURE; newPict->info[0].id = stuff->pid; newPict->u.pict.root = FALSE; for(j = 1; j < PanoramiXNumScreens; j++) newPict->info[j].id = FakeClientID(client->index); FOR_NSCREENS_BACKWARD(j) { stuff->pid = newPict->info[j].id; result = (*PanoramiXSaveRenderVector[X_RenderCreateConicalGradient]) (client); if(result != Success) break; } if (result == Success) AddResource(newPict->info[0].id, XRT_PICTURE, newPict); else free(newPict); return result; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,250
PanoramiXRenderCreateLinearGradient (ClientPtr client) { REQUEST(xRenderCreateLinearGradientReq); PanoramiXRes *newPict; int result = Success, j; REQUEST_AT_LEAST_SIZE(xRenderCreateLinearGradientReq); if(!(newPict = (PanoramiXRes *) malloc(sizeof(PanoramiXRes)))) return BadAlloc; newPict->type = XRT_PICTURE; newPict->info[0].id = stuff->pid; newPict->u.pict.root = FALSE; for(j = 1; j < PanoramiXNumScreens; j++) newPict->info[j].id = FakeClientID(client->index); FOR_NSCREENS_BACKWARD(j) { stuff->pid = newPict->info[j].id; result = (*PanoramiXSaveRenderVector[X_RenderCreateLinearGradient]) (client); if(result != Success) break; } if (result == Success) AddResource(newPict->info[0].id, XRT_PICTURE, newPict); else free(newPict); return result; }
DoS
0
PanoramiXRenderCreateLinearGradient (ClientPtr client) { REQUEST(xRenderCreateLinearGradientReq); PanoramiXRes *newPict; int result = Success, j; REQUEST_AT_LEAST_SIZE(xRenderCreateLinearGradientReq); if(!(newPict = (PanoramiXRes *) malloc(sizeof(PanoramiXRes)))) return BadAlloc; newPict->type = XRT_PICTURE; newPict->info[0].id = stuff->pid; newPict->u.pict.root = FALSE; for(j = 1; j < PanoramiXNumScreens; j++) newPict->info[j].id = FakeClientID(client->index); FOR_NSCREENS_BACKWARD(j) { stuff->pid = newPict->info[j].id; result = (*PanoramiXSaveRenderVector[X_RenderCreateLinearGradient]) (client); if(result != Success) break; } if (result == Success) AddResource(newPict->info[0].id, XRT_PICTURE, newPict); else free(newPict); return result; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,251
PanoramiXRenderCreatePicture (ClientPtr client) { REQUEST(xRenderCreatePictureReq); PanoramiXRes *refDraw, *newPict; int result, j; REQUEST_AT_LEAST_SIZE(xRenderCreatePictureReq); result = dixLookupResourceByClass((pointer *)&refDraw, stuff->drawable, XRC_DRAWABLE, client, DixWriteAccess); if (result != Success) return (result == BadValue) ? BadDrawable : result; if(!(newPict = (PanoramiXRes *) malloc(sizeof(PanoramiXRes)))) return BadAlloc; newPict->type = XRT_PICTURE; newPict->info[0].id = stuff->pid; if (refDraw->type == XRT_WINDOW && stuff->drawable == screenInfo.screens[0]->root->drawable.id) { newPict->u.pict.root = TRUE; } else newPict->u.pict.root = FALSE; for(j = 1; j < PanoramiXNumScreens; j++) newPict->info[j].id = FakeClientID(client->index); FOR_NSCREENS_BACKWARD(j) { stuff->pid = newPict->info[j].id; stuff->drawable = refDraw->info[j].id; result = (*PanoramiXSaveRenderVector[X_RenderCreatePicture]) (client); if(result != Success) break; } if (result == Success) AddResource(newPict->info[0].id, XRT_PICTURE, newPict); else free(newPict); return result; }
DoS
0
PanoramiXRenderCreatePicture (ClientPtr client) { REQUEST(xRenderCreatePictureReq); PanoramiXRes *refDraw, *newPict; int result, j; REQUEST_AT_LEAST_SIZE(xRenderCreatePictureReq); result = dixLookupResourceByClass((pointer *)&refDraw, stuff->drawable, XRC_DRAWABLE, client, DixWriteAccess); if (result != Success) return (result == BadValue) ? BadDrawable : result; if(!(newPict = (PanoramiXRes *) malloc(sizeof(PanoramiXRes)))) return BadAlloc; newPict->type = XRT_PICTURE; newPict->info[0].id = stuff->pid; if (refDraw->type == XRT_WINDOW && stuff->drawable == screenInfo.screens[0]->root->drawable.id) { newPict->u.pict.root = TRUE; } else newPict->u.pict.root = FALSE; for(j = 1; j < PanoramiXNumScreens; j++) newPict->info[j].id = FakeClientID(client->index); FOR_NSCREENS_BACKWARD(j) { stuff->pid = newPict->info[j].id; stuff->drawable = refDraw->info[j].id; result = (*PanoramiXSaveRenderVector[X_RenderCreatePicture]) (client); if(result != Success) break; } if (result == Success) AddResource(newPict->info[0].id, XRT_PICTURE, newPict); else free(newPict); return result; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,252
PanoramiXRenderCreateRadialGradient (ClientPtr client) { REQUEST(xRenderCreateRadialGradientReq); PanoramiXRes *newPict; int result = Success, j; REQUEST_AT_LEAST_SIZE(xRenderCreateRadialGradientReq); if(!(newPict = (PanoramiXRes *) malloc(sizeof(PanoramiXRes)))) return BadAlloc; newPict->type = XRT_PICTURE; newPict->info[0].id = stuff->pid; newPict->u.pict.root = FALSE; for(j = 1; j < PanoramiXNumScreens; j++) newPict->info[j].id = FakeClientID(client->index); FOR_NSCREENS_BACKWARD(j) { stuff->pid = newPict->info[j].id; result = (*PanoramiXSaveRenderVector[X_RenderCreateRadialGradient]) (client); if(result != Success) break; } if (result == Success) AddResource(newPict->info[0].id, XRT_PICTURE, newPict); else free(newPict); return result; }
DoS
0
PanoramiXRenderCreateRadialGradient (ClientPtr client) { REQUEST(xRenderCreateRadialGradientReq); PanoramiXRes *newPict; int result = Success, j; REQUEST_AT_LEAST_SIZE(xRenderCreateRadialGradientReq); if(!(newPict = (PanoramiXRes *) malloc(sizeof(PanoramiXRes)))) return BadAlloc; newPict->type = XRT_PICTURE; newPict->info[0].id = stuff->pid; newPict->u.pict.root = FALSE; for(j = 1; j < PanoramiXNumScreens; j++) newPict->info[j].id = FakeClientID(client->index); FOR_NSCREENS_BACKWARD(j) { stuff->pid = newPict->info[j].id; result = (*PanoramiXSaveRenderVector[X_RenderCreateRadialGradient]) (client); if(result != Success) break; } if (result == Success) AddResource(newPict->info[0].id, XRT_PICTURE, newPict); else free(newPict); return result; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,253
PanoramiXRenderCreateSolidFill (ClientPtr client) { REQUEST(xRenderCreateSolidFillReq); PanoramiXRes *newPict; int result = Success, j; REQUEST_AT_LEAST_SIZE(xRenderCreateSolidFillReq); if(!(newPict = (PanoramiXRes *) malloc(sizeof(PanoramiXRes)))) return BadAlloc; newPict->type = XRT_PICTURE; newPict->info[0].id = stuff->pid; newPict->u.pict.root = FALSE; for(j = 1; j < PanoramiXNumScreens; j++) newPict->info[j].id = FakeClientID(client->index); FOR_NSCREENS_BACKWARD(j) { stuff->pid = newPict->info[j].id; result = (*PanoramiXSaveRenderVector[X_RenderCreateSolidFill]) (client); if(result != Success) break; } if (result == Success) AddResource(newPict->info[0].id, XRT_PICTURE, newPict); else free(newPict); return result; }
DoS
0
PanoramiXRenderCreateSolidFill (ClientPtr client) { REQUEST(xRenderCreateSolidFillReq); PanoramiXRes *newPict; int result = Success, j; REQUEST_AT_LEAST_SIZE(xRenderCreateSolidFillReq); if(!(newPict = (PanoramiXRes *) malloc(sizeof(PanoramiXRes)))) return BadAlloc; newPict->type = XRT_PICTURE; newPict->info[0].id = stuff->pid; newPict->u.pict.root = FALSE; for(j = 1; j < PanoramiXNumScreens; j++) newPict->info[j].id = FakeClientID(client->index); FOR_NSCREENS_BACKWARD(j) { stuff->pid = newPict->info[j].id; result = (*PanoramiXSaveRenderVector[X_RenderCreateSolidFill]) (client); if(result != Success) break; } if (result == Success) AddResource(newPict->info[0].id, XRT_PICTURE, newPict); else free(newPict); return result; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,254
PanoramiXRenderFillRectangles (ClientPtr client) { PanoramiXRes *dst; int result = Success, j; REQUEST(xRenderFillRectanglesReq); char *extra; int extra_len; REQUEST_AT_LEAST_SIZE (xRenderFillRectanglesReq); VERIFY_XIN_PICTURE (dst, stuff->dst, client, DixWriteAccess); extra_len = (client->req_len << 2) - sizeof (xRenderFillRectanglesReq); if (extra_len && (extra = (char *) malloc(extra_len))) { memcpy (extra, stuff + 1, extra_len); FOR_NSCREENS_FORWARD(j) { if (j) memcpy (stuff + 1, extra, extra_len); if (dst->u.pict.root) { int x_off = screenInfo.screens[j]->x; int y_off = screenInfo.screens[j]->y; if(x_off || y_off) { xRectangle *rects = (xRectangle *) (stuff + 1); int i = extra_len / sizeof (xRectangle); while (i--) { rects->x -= x_off; rects->y -= y_off; rects++; } } } stuff->dst = dst->info[j].id; result = (*PanoramiXSaveRenderVector[X_RenderFillRectangles]) (client); if(result != Success) break; } free(extra); } return result; }
DoS
0
PanoramiXRenderFillRectangles (ClientPtr client) { PanoramiXRes *dst; int result = Success, j; REQUEST(xRenderFillRectanglesReq); char *extra; int extra_len; REQUEST_AT_LEAST_SIZE (xRenderFillRectanglesReq); VERIFY_XIN_PICTURE (dst, stuff->dst, client, DixWriteAccess); extra_len = (client->req_len << 2) - sizeof (xRenderFillRectanglesReq); if (extra_len && (extra = (char *) malloc(extra_len))) { memcpy (extra, stuff + 1, extra_len); FOR_NSCREENS_FORWARD(j) { if (j) memcpy (stuff + 1, extra, extra_len); if (dst->u.pict.root) { int x_off = screenInfo.screens[j]->x; int y_off = screenInfo.screens[j]->y; if(x_off || y_off) { xRectangle *rects = (xRectangle *) (stuff + 1); int i = extra_len / sizeof (xRectangle); while (i--) { rects->x -= x_off; rects->y -= y_off; rects++; } } } stuff->dst = dst->info[j].id; result = (*PanoramiXSaveRenderVector[X_RenderFillRectangles]) (client); if(result != Success) break; } free(extra); } return result; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,255
PanoramiXRenderFreePicture (ClientPtr client) { PanoramiXRes *pict; int result = Success, j; REQUEST(xRenderFreePictureReq); REQUEST_SIZE_MATCH(xRenderFreePictureReq); client->errorValue = stuff->picture; VERIFY_XIN_PICTURE(pict, stuff->picture, client, DixDestroyAccess); FOR_NSCREENS_BACKWARD(j) { stuff->picture = pict->info[j].id; result = (*PanoramiXSaveRenderVector[X_RenderFreePicture]) (client); if(result != Success) break; } /* Since ProcRenderFreePicture is using FreeResource, it will free our resource for us on the last pass through the loop above */ return result; }
DoS
0
PanoramiXRenderFreePicture (ClientPtr client) { PanoramiXRes *pict; int result = Success, j; REQUEST(xRenderFreePictureReq); REQUEST_SIZE_MATCH(xRenderFreePictureReq); client->errorValue = stuff->picture; VERIFY_XIN_PICTURE(pict, stuff->picture, client, DixDestroyAccess); FOR_NSCREENS_BACKWARD(j) { stuff->picture = pict->info[j].id; result = (*PanoramiXSaveRenderVector[X_RenderFreePicture]) (client); if(result != Success) break; } /* Since ProcRenderFreePicture is using FreeResource, it will free our resource for us on the last pass through the loop above */ return result; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,256
PanoramiXRenderInit (void) { int i; XRT_PICTURE = CreateNewResourceType (XineramaDeleteResource, "XineramaPicture"); if (RenderErrBase) SetResourceTypeErrorValue(XRT_PICTURE, RenderErrBase + BadPicture); for (i = 0; i < RenderNumberRequests; i++) PanoramiXSaveRenderVector[i] = ProcRenderVector[i]; /* * Stuff in Xinerama aware request processing hooks */ ProcRenderVector[X_RenderCreatePicture] = PanoramiXRenderCreatePicture; ProcRenderVector[X_RenderChangePicture] = PanoramiXRenderChangePicture; ProcRenderVector[X_RenderSetPictureTransform] = PanoramiXRenderSetPictureTransform; ProcRenderVector[X_RenderSetPictureFilter] = PanoramiXRenderSetPictureFilter; ProcRenderVector[X_RenderSetPictureClipRectangles] = PanoramiXRenderSetPictureClipRectangles; ProcRenderVector[X_RenderFreePicture] = PanoramiXRenderFreePicture; ProcRenderVector[X_RenderComposite] = PanoramiXRenderComposite; ProcRenderVector[X_RenderCompositeGlyphs8] = PanoramiXRenderCompositeGlyphs; ProcRenderVector[X_RenderCompositeGlyphs16] = PanoramiXRenderCompositeGlyphs; ProcRenderVector[X_RenderCompositeGlyphs32] = PanoramiXRenderCompositeGlyphs; ProcRenderVector[X_RenderFillRectangles] = PanoramiXRenderFillRectangles; ProcRenderVector[X_RenderTrapezoids] = PanoramiXRenderTrapezoids; ProcRenderVector[X_RenderTriangles] = PanoramiXRenderTriangles; ProcRenderVector[X_RenderTriStrip] = PanoramiXRenderTriStrip; ProcRenderVector[X_RenderTriFan] = PanoramiXRenderTriFan; ProcRenderVector[X_RenderAddTraps] = PanoramiXRenderAddTraps; ProcRenderVector[X_RenderCreateSolidFill] = PanoramiXRenderCreateSolidFill; ProcRenderVector[X_RenderCreateLinearGradient] = PanoramiXRenderCreateLinearGradient; ProcRenderVector[X_RenderCreateRadialGradient] = PanoramiXRenderCreateRadialGradient; ProcRenderVector[X_RenderCreateConicalGradient] = PanoramiXRenderCreateConicalGradient; }
DoS
0
PanoramiXRenderInit (void) { int i; XRT_PICTURE = CreateNewResourceType (XineramaDeleteResource, "XineramaPicture"); if (RenderErrBase) SetResourceTypeErrorValue(XRT_PICTURE, RenderErrBase + BadPicture); for (i = 0; i < RenderNumberRequests; i++) PanoramiXSaveRenderVector[i] = ProcRenderVector[i]; /* * Stuff in Xinerama aware request processing hooks */ ProcRenderVector[X_RenderCreatePicture] = PanoramiXRenderCreatePicture; ProcRenderVector[X_RenderChangePicture] = PanoramiXRenderChangePicture; ProcRenderVector[X_RenderSetPictureTransform] = PanoramiXRenderSetPictureTransform; ProcRenderVector[X_RenderSetPictureFilter] = PanoramiXRenderSetPictureFilter; ProcRenderVector[X_RenderSetPictureClipRectangles] = PanoramiXRenderSetPictureClipRectangles; ProcRenderVector[X_RenderFreePicture] = PanoramiXRenderFreePicture; ProcRenderVector[X_RenderComposite] = PanoramiXRenderComposite; ProcRenderVector[X_RenderCompositeGlyphs8] = PanoramiXRenderCompositeGlyphs; ProcRenderVector[X_RenderCompositeGlyphs16] = PanoramiXRenderCompositeGlyphs; ProcRenderVector[X_RenderCompositeGlyphs32] = PanoramiXRenderCompositeGlyphs; ProcRenderVector[X_RenderFillRectangles] = PanoramiXRenderFillRectangles; ProcRenderVector[X_RenderTrapezoids] = PanoramiXRenderTrapezoids; ProcRenderVector[X_RenderTriangles] = PanoramiXRenderTriangles; ProcRenderVector[X_RenderTriStrip] = PanoramiXRenderTriStrip; ProcRenderVector[X_RenderTriFan] = PanoramiXRenderTriFan; ProcRenderVector[X_RenderAddTraps] = PanoramiXRenderAddTraps; ProcRenderVector[X_RenderCreateSolidFill] = PanoramiXRenderCreateSolidFill; ProcRenderVector[X_RenderCreateLinearGradient] = PanoramiXRenderCreateLinearGradient; ProcRenderVector[X_RenderCreateRadialGradient] = PanoramiXRenderCreateRadialGradient; ProcRenderVector[X_RenderCreateConicalGradient] = PanoramiXRenderCreateConicalGradient; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,257
PanoramiXRenderSetPictureClipRectangles (ClientPtr client) { REQUEST(xRenderSetPictureClipRectanglesReq); int result = Success, j; PanoramiXRes *pict; REQUEST_AT_LEAST_SIZE(xRenderSetPictureClipRectanglesReq); VERIFY_XIN_PICTURE(pict, stuff->picture, client, DixWriteAccess); FOR_NSCREENS_BACKWARD(j) { stuff->picture = pict->info[j].id; result = (*PanoramiXSaveRenderVector[X_RenderSetPictureClipRectangles]) (client); if(result != Success) break; } return result; }
DoS
0
PanoramiXRenderSetPictureClipRectangles (ClientPtr client) { REQUEST(xRenderSetPictureClipRectanglesReq); int result = Success, j; PanoramiXRes *pict; REQUEST_AT_LEAST_SIZE(xRenderSetPictureClipRectanglesReq); VERIFY_XIN_PICTURE(pict, stuff->picture, client, DixWriteAccess); FOR_NSCREENS_BACKWARD(j) { stuff->picture = pict->info[j].id; result = (*PanoramiXSaveRenderVector[X_RenderSetPictureClipRectangles]) (client); if(result != Success) break; } return result; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,258
PanoramiXRenderSetPictureFilter (ClientPtr client) { REQUEST(xRenderSetPictureFilterReq); int result = Success, j; PanoramiXRes *pict; REQUEST_AT_LEAST_SIZE(xRenderSetPictureFilterReq); VERIFY_XIN_PICTURE(pict, stuff->picture, client, DixWriteAccess); FOR_NSCREENS_BACKWARD(j) { stuff->picture = pict->info[j].id; result = (*PanoramiXSaveRenderVector[X_RenderSetPictureFilter]) (client); if(result != Success) break; } return result; }
DoS
0
PanoramiXRenderSetPictureFilter (ClientPtr client) { REQUEST(xRenderSetPictureFilterReq); int result = Success, j; PanoramiXRes *pict; REQUEST_AT_LEAST_SIZE(xRenderSetPictureFilterReq); VERIFY_XIN_PICTURE(pict, stuff->picture, client, DixWriteAccess); FOR_NSCREENS_BACKWARD(j) { stuff->picture = pict->info[j].id; result = (*PanoramiXSaveRenderVector[X_RenderSetPictureFilter]) (client); if(result != Success) break; } return result; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,259
PanoramiXRenderSetPictureTransform (ClientPtr client) { REQUEST(xRenderSetPictureTransformReq); int result = Success, j; PanoramiXRes *pict; REQUEST_AT_LEAST_SIZE(xRenderSetPictureTransformReq); VERIFY_XIN_PICTURE(pict, stuff->picture, client, DixWriteAccess); FOR_NSCREENS_BACKWARD(j) { stuff->picture = pict->info[j].id; result = (*PanoramiXSaveRenderVector[X_RenderSetPictureTransform]) (client); if(result != Success) break; } return result; }
DoS
0
PanoramiXRenderSetPictureTransform (ClientPtr client) { REQUEST(xRenderSetPictureTransformReq); int result = Success, j; PanoramiXRes *pict; REQUEST_AT_LEAST_SIZE(xRenderSetPictureTransformReq); VERIFY_XIN_PICTURE(pict, stuff->picture, client, DixWriteAccess); FOR_NSCREENS_BACKWARD(j) { stuff->picture = pict->info[j].id; result = (*PanoramiXSaveRenderVector[X_RenderSetPictureTransform]) (client); if(result != Success) break; } return result; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,260
PanoramiXRenderTrapezoids(ClientPtr client) { PanoramiXRes *src, *dst; int result = Success, j; REQUEST(xRenderTrapezoidsReq); char *extra; int extra_len; REQUEST_AT_LEAST_SIZE (xRenderTrapezoidsReq); VERIFY_XIN_PICTURE (src, stuff->src, client, DixReadAccess); VERIFY_XIN_PICTURE (dst, stuff->dst, client, DixWriteAccess); extra_len = (client->req_len << 2) - sizeof (xRenderTrapezoidsReq); if (extra_len && (extra = (char *) malloc(extra_len))) { memcpy (extra, stuff + 1, extra_len); FOR_NSCREENS_FORWARD(j) { if (j) memcpy (stuff + 1, extra, extra_len); if (dst->u.pict.root) { int x_off = screenInfo.screens[j]->x; int y_off = screenInfo.screens[j]->y; if(x_off || y_off) { xTrapezoid *trap = (xTrapezoid *) (stuff + 1); int i = extra_len / sizeof (xTrapezoid); while (i--) { trap->top -= y_off; trap->bottom -= y_off; trap->left.p1.x -= x_off; trap->left.p1.y -= y_off; trap->left.p2.x -= x_off; trap->left.p2.y -= y_off; trap->right.p1.x -= x_off; trap->right.p1.y -= y_off; trap->right.p2.x -= x_off; trap->right.p2.y -= y_off; trap++; } } } stuff->src = src->info[j].id; stuff->dst = dst->info[j].id; result = (*PanoramiXSaveRenderVector[X_RenderTrapezoids]) (client); if(result != Success) break; } free(extra); } return result; }
DoS
0
PanoramiXRenderTrapezoids(ClientPtr client) { PanoramiXRes *src, *dst; int result = Success, j; REQUEST(xRenderTrapezoidsReq); char *extra; int extra_len; REQUEST_AT_LEAST_SIZE (xRenderTrapezoidsReq); VERIFY_XIN_PICTURE (src, stuff->src, client, DixReadAccess); VERIFY_XIN_PICTURE (dst, stuff->dst, client, DixWriteAccess); extra_len = (client->req_len << 2) - sizeof (xRenderTrapezoidsReq); if (extra_len && (extra = (char *) malloc(extra_len))) { memcpy (extra, stuff + 1, extra_len); FOR_NSCREENS_FORWARD(j) { if (j) memcpy (stuff + 1, extra, extra_len); if (dst->u.pict.root) { int x_off = screenInfo.screens[j]->x; int y_off = screenInfo.screens[j]->y; if(x_off || y_off) { xTrapezoid *trap = (xTrapezoid *) (stuff + 1); int i = extra_len / sizeof (xTrapezoid); while (i--) { trap->top -= y_off; trap->bottom -= y_off; trap->left.p1.x -= x_off; trap->left.p1.y -= y_off; trap->left.p2.x -= x_off; trap->left.p2.y -= y_off; trap->right.p1.x -= x_off; trap->right.p1.y -= y_off; trap->right.p2.x -= x_off; trap->right.p2.y -= y_off; trap++; } } } stuff->src = src->info[j].id; stuff->dst = dst->info[j].id; result = (*PanoramiXSaveRenderVector[X_RenderTrapezoids]) (client); if(result != Success) break; } free(extra); } return result; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,261
PanoramiXRenderTriFan(ClientPtr client) { PanoramiXRes *src, *dst; int result = Success, j; REQUEST(xRenderTriFanReq); char *extra; int extra_len; REQUEST_AT_LEAST_SIZE (xRenderTriFanReq); VERIFY_XIN_PICTURE (src, stuff->src, client, DixReadAccess); VERIFY_XIN_PICTURE (dst, stuff->dst, client, DixWriteAccess); extra_len = (client->req_len << 2) - sizeof (xRenderTriFanReq); if (extra_len && (extra = (char *) malloc(extra_len))) { memcpy (extra, stuff + 1, extra_len); FOR_NSCREENS_FORWARD(j) { if (j) memcpy (stuff + 1, extra, extra_len); if (dst->u.pict.root) { int x_off = screenInfo.screens[j]->x; int y_off = screenInfo.screens[j]->y; if(x_off || y_off) { xPointFixed *fixed = (xPointFixed *) (stuff + 1); int i = extra_len / sizeof (xPointFixed); while (i--) { fixed->x -= x_off; fixed->y -= y_off; fixed++; } } } stuff->src = src->info[j].id; stuff->dst = dst->info[j].id; result = (*PanoramiXSaveRenderVector[X_RenderTriFan]) (client); if(result != Success) break; } free(extra); } return result; }
DoS
0
PanoramiXRenderTriFan(ClientPtr client) { PanoramiXRes *src, *dst; int result = Success, j; REQUEST(xRenderTriFanReq); char *extra; int extra_len; REQUEST_AT_LEAST_SIZE (xRenderTriFanReq); VERIFY_XIN_PICTURE (src, stuff->src, client, DixReadAccess); VERIFY_XIN_PICTURE (dst, stuff->dst, client, DixWriteAccess); extra_len = (client->req_len << 2) - sizeof (xRenderTriFanReq); if (extra_len && (extra = (char *) malloc(extra_len))) { memcpy (extra, stuff + 1, extra_len); FOR_NSCREENS_FORWARD(j) { if (j) memcpy (stuff + 1, extra, extra_len); if (dst->u.pict.root) { int x_off = screenInfo.screens[j]->x; int y_off = screenInfo.screens[j]->y; if(x_off || y_off) { xPointFixed *fixed = (xPointFixed *) (stuff + 1); int i = extra_len / sizeof (xPointFixed); while (i--) { fixed->x -= x_off; fixed->y -= y_off; fixed++; } } } stuff->src = src->info[j].id; stuff->dst = dst->info[j].id; result = (*PanoramiXSaveRenderVector[X_RenderTriFan]) (client); if(result != Success) break; } free(extra); } return result; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,262
PanoramiXRenderTriStrip(ClientPtr client) { PanoramiXRes *src, *dst; int result = Success, j; REQUEST(xRenderTriStripReq); char *extra; int extra_len; REQUEST_AT_LEAST_SIZE (xRenderTriStripReq); VERIFY_XIN_PICTURE (src, stuff->src, client, DixReadAccess); VERIFY_XIN_PICTURE (dst, stuff->dst, client, DixWriteAccess); extra_len = (client->req_len << 2) - sizeof (xRenderTriStripReq); if (extra_len && (extra = (char *) malloc(extra_len))) { memcpy (extra, stuff + 1, extra_len); FOR_NSCREENS_FORWARD(j) { if (j) memcpy (stuff + 1, extra, extra_len); if (dst->u.pict.root) { int x_off = screenInfo.screens[j]->x; int y_off = screenInfo.screens[j]->y; if(x_off || y_off) { xPointFixed *fixed = (xPointFixed *) (stuff + 1); int i = extra_len / sizeof (xPointFixed); while (i--) { fixed->x -= x_off; fixed->y -= y_off; fixed++; } } } stuff->src = src->info[j].id; stuff->dst = dst->info[j].id; result = (*PanoramiXSaveRenderVector[X_RenderTriStrip]) (client); if(result != Success) break; } free(extra); } return result; }
DoS
0
PanoramiXRenderTriStrip(ClientPtr client) { PanoramiXRes *src, *dst; int result = Success, j; REQUEST(xRenderTriStripReq); char *extra; int extra_len; REQUEST_AT_LEAST_SIZE (xRenderTriStripReq); VERIFY_XIN_PICTURE (src, stuff->src, client, DixReadAccess); VERIFY_XIN_PICTURE (dst, stuff->dst, client, DixWriteAccess); extra_len = (client->req_len << 2) - sizeof (xRenderTriStripReq); if (extra_len && (extra = (char *) malloc(extra_len))) { memcpy (extra, stuff + 1, extra_len); FOR_NSCREENS_FORWARD(j) { if (j) memcpy (stuff + 1, extra, extra_len); if (dst->u.pict.root) { int x_off = screenInfo.screens[j]->x; int y_off = screenInfo.screens[j]->y; if(x_off || y_off) { xPointFixed *fixed = (xPointFixed *) (stuff + 1); int i = extra_len / sizeof (xPointFixed); while (i--) { fixed->x -= x_off; fixed->y -= y_off; fixed++; } } } stuff->src = src->info[j].id; stuff->dst = dst->info[j].id; result = (*PanoramiXSaveRenderVector[X_RenderTriStrip]) (client); if(result != Success) break; } free(extra); } return result; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,263
PanoramiXRenderTriangles(ClientPtr client) { PanoramiXRes *src, *dst; int result = Success, j; REQUEST(xRenderTrianglesReq); char *extra; int extra_len; REQUEST_AT_LEAST_SIZE (xRenderTrianglesReq); VERIFY_XIN_PICTURE (src, stuff->src, client, DixReadAccess); VERIFY_XIN_PICTURE (dst, stuff->dst, client, DixWriteAccess); extra_len = (client->req_len << 2) - sizeof (xRenderTrianglesReq); if (extra_len && (extra = (char *) malloc(extra_len))) { memcpy (extra, stuff + 1, extra_len); FOR_NSCREENS_FORWARD(j) { if (j) memcpy (stuff + 1, extra, extra_len); if (dst->u.pict.root) { int x_off = screenInfo.screens[j]->x; int y_off = screenInfo.screens[j]->y; if(x_off || y_off) { xTriangle *tri = (xTriangle *) (stuff + 1); int i = extra_len / sizeof (xTriangle); while (i--) { tri->p1.x -= x_off; tri->p1.y -= y_off; tri->p2.x -= x_off; tri->p2.y -= y_off; tri->p3.x -= x_off; tri->p3.y -= y_off; tri++; } } } stuff->src = src->info[j].id; stuff->dst = dst->info[j].id; result = (*PanoramiXSaveRenderVector[X_RenderTriangles]) (client); if(result != Success) break; } free(extra); } return result; }
DoS
0
PanoramiXRenderTriangles(ClientPtr client) { PanoramiXRes *src, *dst; int result = Success, j; REQUEST(xRenderTrianglesReq); char *extra; int extra_len; REQUEST_AT_LEAST_SIZE (xRenderTrianglesReq); VERIFY_XIN_PICTURE (src, stuff->src, client, DixReadAccess); VERIFY_XIN_PICTURE (dst, stuff->dst, client, DixWriteAccess); extra_len = (client->req_len << 2) - sizeof (xRenderTrianglesReq); if (extra_len && (extra = (char *) malloc(extra_len))) { memcpy (extra, stuff + 1, extra_len); FOR_NSCREENS_FORWARD(j) { if (j) memcpy (stuff + 1, extra, extra_len); if (dst->u.pict.root) { int x_off = screenInfo.screens[j]->x; int y_off = screenInfo.screens[j]->y; if(x_off || y_off) { xTriangle *tri = (xTriangle *) (stuff + 1); int i = extra_len / sizeof (xTriangle); while (i--) { tri->p1.x -= x_off; tri->p1.y -= y_off; tri->p2.x -= x_off; tri->p2.y -= y_off; tri->p3.x -= x_off; tri->p3.y -= y_off; tri++; } } } stuff->src = src->info[j].id; stuff->dst = dst->info[j].id; result = (*PanoramiXSaveRenderVector[X_RenderTriangles]) (client); if(result != Success) break; } free(extra); } return result; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,264
PictOpValid (CARD8 op) { if (/*PictOpMinimum <= op && */ op <= PictOpMaximum) return TRUE; if (PictOpDisjointMinimum <= op && op <= PictOpDisjointMaximum) return TRUE; if (PictOpConjointMinimum <= op && op <= PictOpConjointMaximum) return TRUE; if (PictOpBlendMinimum <= op && op <= PictOpBlendMaximum) return TRUE; return FALSE; }
DoS
0
PictOpValid (CARD8 op) { if (/*PictOpMinimum <= op && */ op <= PictOpMaximum) return TRUE; if (PictOpDisjointMinimum <= op && op <= PictOpDisjointMaximum) return TRUE; if (PictOpConjointMinimum <= op && op <= PictOpConjointMaximum) return TRUE; if (PictOpBlendMinimum <= op && op <= PictOpBlendMaximum) return TRUE; return FALSE; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,265
ProcRenderAddGlyphsFromPicture (ClientPtr client) { return BadImplementation; }
DoS
0
ProcRenderAddGlyphsFromPicture (ClientPtr client) { return BadImplementation; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,266
ProcRenderAddTraps (ClientPtr client) { int ntraps; PicturePtr pPicture; REQUEST(xRenderAddTrapsReq); REQUEST_AT_LEAST_SIZE(xRenderAddTrapsReq); VERIFY_PICTURE (pPicture, stuff->picture, client, DixWriteAccess); if (!pPicture->pDrawable) return BadDrawable; ntraps = (client->req_len << 2) - sizeof (xRenderAddTrapsReq); if (ntraps % sizeof (xTrap)) return BadLength; ntraps /= sizeof (xTrap); if (ntraps) AddTraps (pPicture, stuff->xOff, stuff->yOff, ntraps, (xTrap *) &stuff[1]); return Success; }
DoS
0
ProcRenderAddTraps (ClientPtr client) { int ntraps; PicturePtr pPicture; REQUEST(xRenderAddTrapsReq); REQUEST_AT_LEAST_SIZE(xRenderAddTrapsReq); VERIFY_PICTURE (pPicture, stuff->picture, client, DixWriteAccess); if (!pPicture->pDrawable) return BadDrawable; ntraps = (client->req_len << 2) - sizeof (xRenderAddTrapsReq); if (ntraps % sizeof (xTrap)) return BadLength; ntraps /= sizeof (xTrap); if (ntraps) AddTraps (pPicture, stuff->xOff, stuff->yOff, ntraps, (xTrap *) &stuff[1]); return Success; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,267
ProcRenderChangePicture (ClientPtr client) { PicturePtr pPicture; REQUEST(xRenderChangePictureReq); int len; REQUEST_AT_LEAST_SIZE(xRenderChangePictureReq); VERIFY_PICTURE (pPicture, stuff->picture, client, DixSetAttrAccess); len = client->req_len - bytes_to_int32(sizeof(xRenderChangePictureReq)); if (Ones(stuff->mask) != len) return BadLength; return ChangePicture (pPicture, stuff->mask, (XID *) (stuff + 1), (DevUnion *) 0, client); }
DoS
0
ProcRenderChangePicture (ClientPtr client) { PicturePtr pPicture; REQUEST(xRenderChangePictureReq); int len; REQUEST_AT_LEAST_SIZE(xRenderChangePictureReq); VERIFY_PICTURE (pPicture, stuff->picture, client, DixSetAttrAccess); len = client->req_len - bytes_to_int32(sizeof(xRenderChangePictureReq)); if (Ones(stuff->mask) != len) return BadLength; return ChangePicture (pPicture, stuff->mask, (XID *) (stuff + 1), (DevUnion *) 0, client); }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,268
ProcRenderColorTrapezoids (ClientPtr client) { return BadImplementation; }
DoS
0
ProcRenderColorTrapezoids (ClientPtr client) { return BadImplementation; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,269
ProcRenderColorTriangles (ClientPtr client) { return BadImplementation; }
DoS
0
ProcRenderColorTriangles (ClientPtr client) { return BadImplementation; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,270
ProcRenderCompositeGlyphs (ClientPtr client) { GlyphSetPtr glyphSet; GlyphSet gs; PicturePtr pSrc, pDst; PictFormatPtr pFormat; GlyphListRec listsLocal[NLOCALDELTA]; GlyphListPtr lists, listsBase; GlyphPtr glyphsLocal[NLOCALGLYPH]; Glyph glyph; GlyphPtr *glyphs, *glyphsBase; xGlyphElt *elt; CARD8 *buffer, *end; int nglyph; int nlist; int space; int size; int rc, n; REQUEST(xRenderCompositeGlyphsReq); REQUEST_AT_LEAST_SIZE(xRenderCompositeGlyphsReq); switch (stuff->renderReqType) { default: size = 1; break; case X_RenderCompositeGlyphs16: size = 2; break; case X_RenderCompositeGlyphs32: size = 4; break; } if (!PictOpValid (stuff->op)) { client->errorValue = stuff->op; return BadValue; } VERIFY_PICTURE (pSrc, stuff->src, client, DixReadAccess); VERIFY_PICTURE (pDst, stuff->dst, client, DixWriteAccess); if (!pDst->pDrawable) return BadDrawable; if (pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen) return BadMatch; if (stuff->maskFormat) { rc = dixLookupResourceByType((pointer *)&pFormat, stuff->maskFormat, PictFormatType, client, DixReadAccess); if (rc != Success) return rc; } else pFormat = 0; rc = dixLookupResourceByType((pointer *)&glyphSet, stuff->glyphset, GlyphSetType, client, DixUseAccess); if (rc != Success) return rc; buffer = (CARD8 *) (stuff + 1); end = (CARD8 *) stuff + (client->req_len << 2); nglyph = 0; nlist = 0; while (buffer + sizeof (xGlyphElt) < end) { elt = (xGlyphElt *) buffer; buffer += sizeof (xGlyphElt); if (elt->len == 0xff) { buffer += 4; } else { nlist++; nglyph += elt->len; space = size * elt->len; if (space & 3) space += 4 - (space & 3); buffer += space; } } if (nglyph <= NLOCALGLYPH) glyphsBase = glyphsLocal; else { glyphsBase = (GlyphPtr *) malloc(nglyph * sizeof (GlyphPtr)); if (!glyphsBase) return BadAlloc; } if (nlist <= NLOCALDELTA) listsBase = listsLocal; else { listsBase = (GlyphListPtr) malloc(nlist * sizeof (GlyphListRec)); if (!listsBase) return BadAlloc; } buffer = (CARD8 *) (stuff + 1); glyphs = glyphsBase; lists = listsBase; while (buffer + sizeof (xGlyphElt) < end) { elt = (xGlyphElt *) buffer; buffer += sizeof (xGlyphElt); if (elt->len == 0xff) { if (buffer + sizeof (GlyphSet) < end) { memcpy(&gs, buffer, sizeof(GlyphSet)); rc = dixLookupResourceByType((pointer *)&glyphSet, gs, GlyphSetType, client, DixUseAccess); if (rc != Success) { if (glyphsBase != glyphsLocal) free(glyphsBase); if (listsBase != listsLocal) free(listsBase); return rc; } } buffer += 4; } else { lists->xOff = elt->deltax; lists->yOff = elt->deltay; lists->format = glyphSet->format; lists->len = 0; n = elt->len; while (n--) { if (buffer + size <= end) { switch (size) { case 1: glyph = *((CARD8 *)buffer); break; case 2: glyph = *((CARD16 *)buffer); break; case 4: default: glyph = *((CARD32 *)buffer); break; } if ((*glyphs = FindGlyph (glyphSet, glyph))) { lists->len++; glyphs++; } } buffer += size; } space = size * elt->len; if (space & 3) buffer += 4 - (space & 3); lists++; } } if (buffer > end) return BadLength; CompositeGlyphs (stuff->op, pSrc, pDst, pFormat, stuff->xSrc, stuff->ySrc, nlist, listsBase, glyphsBase); if (glyphsBase != glyphsLocal) free(glyphsBase); if (listsBase != listsLocal) free(listsBase); return Success; }
DoS
0
ProcRenderCompositeGlyphs (ClientPtr client) { GlyphSetPtr glyphSet; GlyphSet gs; PicturePtr pSrc, pDst; PictFormatPtr pFormat; GlyphListRec listsLocal[NLOCALDELTA]; GlyphListPtr lists, listsBase; GlyphPtr glyphsLocal[NLOCALGLYPH]; Glyph glyph; GlyphPtr *glyphs, *glyphsBase; xGlyphElt *elt; CARD8 *buffer, *end; int nglyph; int nlist; int space; int size; int rc, n; REQUEST(xRenderCompositeGlyphsReq); REQUEST_AT_LEAST_SIZE(xRenderCompositeGlyphsReq); switch (stuff->renderReqType) { default: size = 1; break; case X_RenderCompositeGlyphs16: size = 2; break; case X_RenderCompositeGlyphs32: size = 4; break; } if (!PictOpValid (stuff->op)) { client->errorValue = stuff->op; return BadValue; } VERIFY_PICTURE (pSrc, stuff->src, client, DixReadAccess); VERIFY_PICTURE (pDst, stuff->dst, client, DixWriteAccess); if (!pDst->pDrawable) return BadDrawable; if (pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen) return BadMatch; if (stuff->maskFormat) { rc = dixLookupResourceByType((pointer *)&pFormat, stuff->maskFormat, PictFormatType, client, DixReadAccess); if (rc != Success) return rc; } else pFormat = 0; rc = dixLookupResourceByType((pointer *)&glyphSet, stuff->glyphset, GlyphSetType, client, DixUseAccess); if (rc != Success) return rc; buffer = (CARD8 *) (stuff + 1); end = (CARD8 *) stuff + (client->req_len << 2); nglyph = 0; nlist = 0; while (buffer + sizeof (xGlyphElt) < end) { elt = (xGlyphElt *) buffer; buffer += sizeof (xGlyphElt); if (elt->len == 0xff) { buffer += 4; } else { nlist++; nglyph += elt->len; space = size * elt->len; if (space & 3) space += 4 - (space & 3); buffer += space; } } if (nglyph <= NLOCALGLYPH) glyphsBase = glyphsLocal; else { glyphsBase = (GlyphPtr *) malloc(nglyph * sizeof (GlyphPtr)); if (!glyphsBase) return BadAlloc; } if (nlist <= NLOCALDELTA) listsBase = listsLocal; else { listsBase = (GlyphListPtr) malloc(nlist * sizeof (GlyphListRec)); if (!listsBase) return BadAlloc; } buffer = (CARD8 *) (stuff + 1); glyphs = glyphsBase; lists = listsBase; while (buffer + sizeof (xGlyphElt) < end) { elt = (xGlyphElt *) buffer; buffer += sizeof (xGlyphElt); if (elt->len == 0xff) { if (buffer + sizeof (GlyphSet) < end) { memcpy(&gs, buffer, sizeof(GlyphSet)); rc = dixLookupResourceByType((pointer *)&glyphSet, gs, GlyphSetType, client, DixUseAccess); if (rc != Success) { if (glyphsBase != glyphsLocal) free(glyphsBase); if (listsBase != listsLocal) free(listsBase); return rc; } } buffer += 4; } else { lists->xOff = elt->deltax; lists->yOff = elt->deltay; lists->format = glyphSet->format; lists->len = 0; n = elt->len; while (n--) { if (buffer + size <= end) { switch (size) { case 1: glyph = *((CARD8 *)buffer); break; case 2: glyph = *((CARD16 *)buffer); break; case 4: default: glyph = *((CARD32 *)buffer); break; } if ((*glyphs = FindGlyph (glyphSet, glyph))) { lists->len++; glyphs++; } } buffer += size; } space = size * elt->len; if (space & 3) buffer += 4 - (space & 3); lists++; } } if (buffer > end) return BadLength; CompositeGlyphs (stuff->op, pSrc, pDst, pFormat, stuff->xSrc, stuff->ySrc, nlist, listsBase, glyphsBase); if (glyphsBase != glyphsLocal) free(glyphsBase); if (listsBase != listsLocal) free(listsBase); return Success; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,271
ProcRenderCreateAnimCursor (ClientPtr client) { REQUEST(xRenderCreateAnimCursorReq); CursorPtr *cursors; CARD32 *deltas; CursorPtr pCursor; int ncursor; xAnimCursorElt *elt; int i; int ret; REQUEST_AT_LEAST_SIZE(xRenderCreateAnimCursorReq); LEGAL_NEW_RESOURCE(stuff->cid, client); if (client->req_len & 1) return BadLength; ncursor = (client->req_len - (bytes_to_int32(sizeof(xRenderCreateAnimCursorReq)))) >> 1; cursors = malloc(ncursor * (sizeof (CursorPtr) + sizeof (CARD32))); if (!cursors) return BadAlloc; deltas = (CARD32 *) (cursors + ncursor); elt = (xAnimCursorElt *) (stuff + 1); for (i = 0; i < ncursor; i++) { ret = dixLookupResourceByType((pointer *)(cursors + i), elt->cursor, RT_CURSOR, client, DixReadAccess); if (ret != Success) { free(cursors); return ret; } deltas[i] = elt->delay; elt++; } ret = AnimCursorCreate (cursors, deltas, ncursor, &pCursor, client, stuff->cid); free(cursors); if (ret != Success) return ret; if (AddResource (stuff->cid, RT_CURSOR, (pointer)pCursor)) return Success; return BadAlloc; }
DoS
0
ProcRenderCreateAnimCursor (ClientPtr client) { REQUEST(xRenderCreateAnimCursorReq); CursorPtr *cursors; CARD32 *deltas; CursorPtr pCursor; int ncursor; xAnimCursorElt *elt; int i; int ret; REQUEST_AT_LEAST_SIZE(xRenderCreateAnimCursorReq); LEGAL_NEW_RESOURCE(stuff->cid, client); if (client->req_len & 1) return BadLength; ncursor = (client->req_len - (bytes_to_int32(sizeof(xRenderCreateAnimCursorReq)))) >> 1; cursors = malloc(ncursor * (sizeof (CursorPtr) + sizeof (CARD32))); if (!cursors) return BadAlloc; deltas = (CARD32 *) (cursors + ncursor); elt = (xAnimCursorElt *) (stuff + 1); for (i = 0; i < ncursor; i++) { ret = dixLookupResourceByType((pointer *)(cursors + i), elt->cursor, RT_CURSOR, client, DixReadAccess); if (ret != Success) { free(cursors); return ret; } deltas[i] = elt->delay; elt++; } ret = AnimCursorCreate (cursors, deltas, ncursor, &pCursor, client, stuff->cid); free(cursors); if (ret != Success) return ret; if (AddResource (stuff->cid, RT_CURSOR, (pointer)pCursor)) return Success; return BadAlloc; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,272
ProcRenderCreateCursor (ClientPtr client) { REQUEST(xRenderCreateCursorReq); PicturePtr pSrc; ScreenPtr pScreen; unsigned short width, height; CARD32 *argbbits, *argb; unsigned char *srcbits, *srcline; unsigned char *mskbits, *mskline; int stride; int x, y; int nbytes_mono; CursorMetricRec cm; CursorPtr pCursor; CARD32 twocolor[3]; int rc, ncolor; REQUEST_SIZE_MATCH (xRenderCreateCursorReq); LEGAL_NEW_RESOURCE(stuff->cid, client); VERIFY_PICTURE (pSrc, stuff->src, client, DixReadAccess); if (!pSrc->pDrawable) return BadDrawable; pScreen = pSrc->pDrawable->pScreen; width = pSrc->pDrawable->width; height = pSrc->pDrawable->height; if (height && width > UINT32_MAX/(height*sizeof(CARD32))) return BadAlloc; if ( stuff->x > width || stuff->y > height ) return BadMatch; argbbits = malloc(width * height * sizeof (CARD32)); if (!argbbits) return BadAlloc; stride = BitmapBytePad(width); nbytes_mono = stride*height; srcbits = calloc(1, nbytes_mono); if (!srcbits) { free(argbbits); return BadAlloc; } mskbits = calloc(1, nbytes_mono); if (!mskbits) { free(argbbits); free(srcbits); return BadAlloc; } if (pSrc->format == PICT_a8r8g8b8) { (*pScreen->GetImage) (pSrc->pDrawable, 0, 0, width, height, ZPixmap, 0xffffffff, (pointer) argbbits); } else { PixmapPtr pPixmap; PicturePtr pPicture; PictFormatPtr pFormat; int error; pFormat = PictureMatchFormat (pScreen, 32, PICT_a8r8g8b8); if (!pFormat) { free(argbbits); free(srcbits); free(mskbits); return BadImplementation; } pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height, 32, CREATE_PIXMAP_USAGE_SCRATCH); if (!pPixmap) { free(argbbits); free(srcbits); free(mskbits); return BadAlloc; } pPicture = CreatePicture (0, &pPixmap->drawable, pFormat, 0, 0, client, &error); if (!pPicture) { free(argbbits); free(srcbits); free(mskbits); return error; } (*pScreen->DestroyPixmap) (pPixmap); CompositePicture (PictOpSrc, pSrc, 0, pPicture, 0, 0, 0, 0, 0, 0, width, height); (*pScreen->GetImage) (pPicture->pDrawable, 0, 0, width, height, ZPixmap, 0xffffffff, (pointer) argbbits); FreePicture (pPicture, 0); } /* * Check whether the cursor can be directly supported by * the core cursor code */ ncolor = 0; argb = argbbits; for (y = 0; ncolor <= 2 && y < height; y++) { for (x = 0; ncolor <= 2 && x < width; x++) { CARD32 p = *argb++; CARD32 a = (p >> 24); if (a == 0) /* transparent */ continue; if (a == 0xff) /* opaque */ { int n; for (n = 0; n < ncolor; n++) if (p == twocolor[n]) break; if (n == ncolor) twocolor[ncolor++] = p; } else ncolor = 3; } } /* * Convert argb image to two plane cursor */ srcline = srcbits; mskline = mskbits; argb = argbbits; for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { CARD32 p = *argb++; if (ncolor <= 2) { CARD32 a = ((p >> 24)); RenderSetBit (mskline, x, a != 0); RenderSetBit (srcline, x, a != 0 && p == twocolor[0]); } else { CARD32 a = ((p >> 24) * DITHER_SIZE + 127) / 255; CARD32 i = ((CvtR8G8B8toY15(p) >> 7) * DITHER_SIZE + 127) / 255; CARD32 d = orderedDither[y&(DITHER_DIM-1)][x&(DITHER_DIM-1)]; /* Set mask from dithered alpha value */ RenderSetBit(mskline, x, a > d); /* Set src from dithered intensity value */ RenderSetBit(srcline, x, a > d && i <= d); } } srcline += stride; mskline += stride; } /* * Dither to white and black if the cursor has more than two colors */ if (ncolor > 2) { twocolor[0] = 0xff000000; twocolor[1] = 0xffffffff; } else { free(argbbits); argbbits = 0; } #define GetByte(p,s) (((p) >> (s)) & 0xff) #define GetColor(p,s) (GetByte(p,s) | (GetByte(p,s) << 8)) cm.width = width; cm.height = height; cm.xhot = stuff->x; cm.yhot = stuff->y; rc = AllocARGBCursor(srcbits, mskbits, argbbits, &cm, GetColor(twocolor[0], 16), GetColor(twocolor[0], 8), GetColor(twocolor[0], 0), GetColor(twocolor[1], 16), GetColor(twocolor[1], 8), GetColor(twocolor[1], 0), &pCursor, client, stuff->cid); if (rc != Success) return rc; if (!AddResource(stuff->cid, RT_CURSOR, (pointer)pCursor)) return BadAlloc; return Success; }
DoS
0
ProcRenderCreateCursor (ClientPtr client) { REQUEST(xRenderCreateCursorReq); PicturePtr pSrc; ScreenPtr pScreen; unsigned short width, height; CARD32 *argbbits, *argb; unsigned char *srcbits, *srcline; unsigned char *mskbits, *mskline; int stride; int x, y; int nbytes_mono; CursorMetricRec cm; CursorPtr pCursor; CARD32 twocolor[3]; int rc, ncolor; REQUEST_SIZE_MATCH (xRenderCreateCursorReq); LEGAL_NEW_RESOURCE(stuff->cid, client); VERIFY_PICTURE (pSrc, stuff->src, client, DixReadAccess); if (!pSrc->pDrawable) return BadDrawable; pScreen = pSrc->pDrawable->pScreen; width = pSrc->pDrawable->width; height = pSrc->pDrawable->height; if (height && width > UINT32_MAX/(height*sizeof(CARD32))) return BadAlloc; if ( stuff->x > width || stuff->y > height ) return BadMatch; argbbits = malloc(width * height * sizeof (CARD32)); if (!argbbits) return BadAlloc; stride = BitmapBytePad(width); nbytes_mono = stride*height; srcbits = calloc(1, nbytes_mono); if (!srcbits) { free(argbbits); return BadAlloc; } mskbits = calloc(1, nbytes_mono); if (!mskbits) { free(argbbits); free(srcbits); return BadAlloc; } if (pSrc->format == PICT_a8r8g8b8) { (*pScreen->GetImage) (pSrc->pDrawable, 0, 0, width, height, ZPixmap, 0xffffffff, (pointer) argbbits); } else { PixmapPtr pPixmap; PicturePtr pPicture; PictFormatPtr pFormat; int error; pFormat = PictureMatchFormat (pScreen, 32, PICT_a8r8g8b8); if (!pFormat) { free(argbbits); free(srcbits); free(mskbits); return BadImplementation; } pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height, 32, CREATE_PIXMAP_USAGE_SCRATCH); if (!pPixmap) { free(argbbits); free(srcbits); free(mskbits); return BadAlloc; } pPicture = CreatePicture (0, &pPixmap->drawable, pFormat, 0, 0, client, &error); if (!pPicture) { free(argbbits); free(srcbits); free(mskbits); return error; } (*pScreen->DestroyPixmap) (pPixmap); CompositePicture (PictOpSrc, pSrc, 0, pPicture, 0, 0, 0, 0, 0, 0, width, height); (*pScreen->GetImage) (pPicture->pDrawable, 0, 0, width, height, ZPixmap, 0xffffffff, (pointer) argbbits); FreePicture (pPicture, 0); } /* * Check whether the cursor can be directly supported by * the core cursor code */ ncolor = 0; argb = argbbits; for (y = 0; ncolor <= 2 && y < height; y++) { for (x = 0; ncolor <= 2 && x < width; x++) { CARD32 p = *argb++; CARD32 a = (p >> 24); if (a == 0) /* transparent */ continue; if (a == 0xff) /* opaque */ { int n; for (n = 0; n < ncolor; n++) if (p == twocolor[n]) break; if (n == ncolor) twocolor[ncolor++] = p; } else ncolor = 3; } } /* * Convert argb image to two plane cursor */ srcline = srcbits; mskline = mskbits; argb = argbbits; for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { CARD32 p = *argb++; if (ncolor <= 2) { CARD32 a = ((p >> 24)); RenderSetBit (mskline, x, a != 0); RenderSetBit (srcline, x, a != 0 && p == twocolor[0]); } else { CARD32 a = ((p >> 24) * DITHER_SIZE + 127) / 255; CARD32 i = ((CvtR8G8B8toY15(p) >> 7) * DITHER_SIZE + 127) / 255; CARD32 d = orderedDither[y&(DITHER_DIM-1)][x&(DITHER_DIM-1)]; /* Set mask from dithered alpha value */ RenderSetBit(mskline, x, a > d); /* Set src from dithered intensity value */ RenderSetBit(srcline, x, a > d && i <= d); } } srcline += stride; mskline += stride; } /* * Dither to white and black if the cursor has more than two colors */ if (ncolor > 2) { twocolor[0] = 0xff000000; twocolor[1] = 0xffffffff; } else { free(argbbits); argbbits = 0; } #define GetByte(p,s) (((p) >> (s)) & 0xff) #define GetColor(p,s) (GetByte(p,s) | (GetByte(p,s) << 8)) cm.width = width; cm.height = height; cm.xhot = stuff->x; cm.yhot = stuff->y; rc = AllocARGBCursor(srcbits, mskbits, argbbits, &cm, GetColor(twocolor[0], 16), GetColor(twocolor[0], 8), GetColor(twocolor[0], 0), GetColor(twocolor[1], 16), GetColor(twocolor[1], 8), GetColor(twocolor[1], 0), &pCursor, client, stuff->cid); if (rc != Success) return rc; if (!AddResource(stuff->cid, RT_CURSOR, (pointer)pCursor)) return BadAlloc; return Success; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,273
ProcRenderCreateGlyphSet (ClientPtr client) { GlyphSetPtr glyphSet; PictFormatPtr format; int rc, f; REQUEST(xRenderCreateGlyphSetReq); REQUEST_SIZE_MATCH(xRenderCreateGlyphSetReq); LEGAL_NEW_RESOURCE(stuff->gsid, client); rc = dixLookupResourceByType((pointer *)&format, stuff->format, PictFormatType, client, DixReadAccess); if (rc != Success) return rc; switch (format->depth) { case 1: f = GlyphFormat1; break; case 4: f = GlyphFormat4; break; case 8: f = GlyphFormat8; break; case 16: f = GlyphFormat16; break; case 32: f = GlyphFormat32; break; default: return BadMatch; } if (format->type != PictTypeDirect) return BadMatch; glyphSet = AllocateGlyphSet (f, format); if (!glyphSet) return BadAlloc; /* security creation/labeling check */ rc = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->gsid, GlyphSetType, glyphSet, RT_NONE, NULL, DixCreateAccess); if (rc != Success) return rc; if (!AddResource (stuff->gsid, GlyphSetType, (pointer)glyphSet)) return BadAlloc; return Success; }
DoS
0
ProcRenderCreateGlyphSet (ClientPtr client) { GlyphSetPtr glyphSet; PictFormatPtr format; int rc, f; REQUEST(xRenderCreateGlyphSetReq); REQUEST_SIZE_MATCH(xRenderCreateGlyphSetReq); LEGAL_NEW_RESOURCE(stuff->gsid, client); rc = dixLookupResourceByType((pointer *)&format, stuff->format, PictFormatType, client, DixReadAccess); if (rc != Success) return rc; switch (format->depth) { case 1: f = GlyphFormat1; break; case 4: f = GlyphFormat4; break; case 8: f = GlyphFormat8; break; case 16: f = GlyphFormat16; break; case 32: f = GlyphFormat32; break; default: return BadMatch; } if (format->type != PictTypeDirect) return BadMatch; glyphSet = AllocateGlyphSet (f, format); if (!glyphSet) return BadAlloc; /* security creation/labeling check */ rc = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->gsid, GlyphSetType, glyphSet, RT_NONE, NULL, DixCreateAccess); if (rc != Success) return rc; if (!AddResource (stuff->gsid, GlyphSetType, (pointer)glyphSet)) return BadAlloc; return Success; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,274
ProcRenderCreatePicture (ClientPtr client) { PicturePtr pPicture; DrawablePtr pDrawable; PictFormatPtr pFormat; int len, error, rc; REQUEST(xRenderCreatePictureReq); REQUEST_AT_LEAST_SIZE(xRenderCreatePictureReq); LEGAL_NEW_RESOURCE(stuff->pid, client); rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0, DixReadAccess|DixAddAccess); if (rc != Success) return rc; rc = dixLookupResourceByType((pointer *)&pFormat, stuff->format, PictFormatType, client, DixReadAccess); if (rc != Success) return rc; if (pFormat->depth != pDrawable->depth) return BadMatch; len = client->req_len - bytes_to_int32(sizeof(xRenderCreatePictureReq)); if (Ones(stuff->mask) != len) return BadLength; pPicture = CreatePicture (stuff->pid, pDrawable, pFormat, stuff->mask, (XID *) (stuff + 1), client, &error); if (!pPicture) return error; if (!AddResource (stuff->pid, PictureType, (pointer)pPicture)) return BadAlloc; return Success; }
DoS
0
ProcRenderCreatePicture (ClientPtr client) { PicturePtr pPicture; DrawablePtr pDrawable; PictFormatPtr pFormat; int len, error, rc; REQUEST(xRenderCreatePictureReq); REQUEST_AT_LEAST_SIZE(xRenderCreatePictureReq); LEGAL_NEW_RESOURCE(stuff->pid, client); rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0, DixReadAccess|DixAddAccess); if (rc != Success) return rc; rc = dixLookupResourceByType((pointer *)&pFormat, stuff->format, PictFormatType, client, DixReadAccess); if (rc != Success) return rc; if (pFormat->depth != pDrawable->depth) return BadMatch; len = client->req_len - bytes_to_int32(sizeof(xRenderCreatePictureReq)); if (Ones(stuff->mask) != len) return BadLength; pPicture = CreatePicture (stuff->pid, pDrawable, pFormat, stuff->mask, (XID *) (stuff + 1), client, &error); if (!pPicture) return error; if (!AddResource (stuff->pid, PictureType, (pointer)pPicture)) return BadAlloc; return Success; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,275
static int ProcRenderCreateRadialGradient (ClientPtr client) { PicturePtr pPicture; int len; int error = 0; xFixed *stops; xRenderColor *colors; REQUEST(xRenderCreateRadialGradientReq); REQUEST_AT_LEAST_SIZE(xRenderCreateRadialGradientReq); LEGAL_NEW_RESOURCE(stuff->pid, client); len = (client->req_len << 2) - sizeof(xRenderCreateRadialGradientReq); if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor))) return BadLength; stops = (xFixed *)(stuff + 1); colors = (xRenderColor *)(stops + stuff->nStops); pPicture = CreateRadialGradientPicture (stuff->pid, &stuff->inner, &stuff->outer, stuff->inner_radius, stuff->outer_radius, stuff->nStops, stops, colors, &error); if (!pPicture) return error; /* security creation/labeling check */ error = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, PictureType, pPicture, RT_NONE, NULL, DixCreateAccess); if (error != Success) return error; if (!AddResource (stuff->pid, PictureType, (pointer)pPicture)) return BadAlloc; return Success; }
DoS
0
static int ProcRenderCreateRadialGradient (ClientPtr client) { PicturePtr pPicture; int len; int error = 0; xFixed *stops; xRenderColor *colors; REQUEST(xRenderCreateRadialGradientReq); REQUEST_AT_LEAST_SIZE(xRenderCreateRadialGradientReq); LEGAL_NEW_RESOURCE(stuff->pid, client); len = (client->req_len << 2) - sizeof(xRenderCreateRadialGradientReq); if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor))) return BadLength; stops = (xFixed *)(stuff + 1); colors = (xRenderColor *)(stops + stuff->nStops); pPicture = CreateRadialGradientPicture (stuff->pid, &stuff->inner, &stuff->outer, stuff->inner_radius, stuff->outer_radius, stuff->nStops, stops, colors, &error); if (!pPicture) return error; /* security creation/labeling check */ error = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, PictureType, pPicture, RT_NONE, NULL, DixCreateAccess); if (error != Success) return error; if (!AddResource (stuff->pid, PictureType, (pointer)pPicture)) return BadAlloc; return Success; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,276
static int ProcRenderCreateSolidFill(ClientPtr client) { PicturePtr pPicture; int error = 0; REQUEST(xRenderCreateSolidFillReq); REQUEST_AT_LEAST_SIZE(xRenderCreateSolidFillReq); LEGAL_NEW_RESOURCE(stuff->pid, client); pPicture = CreateSolidPicture(stuff->pid, &stuff->color, &error); if (!pPicture) return error; /* security creation/labeling check */ error = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, PictureType, pPicture, RT_NONE, NULL, DixCreateAccess); if (error != Success) return error; if (!AddResource (stuff->pid, PictureType, (pointer)pPicture)) return BadAlloc; return Success; }
DoS
0
static int ProcRenderCreateSolidFill(ClientPtr client) { PicturePtr pPicture; int error = 0; REQUEST(xRenderCreateSolidFillReq); REQUEST_AT_LEAST_SIZE(xRenderCreateSolidFillReq); LEGAL_NEW_RESOURCE(stuff->pid, client); pPicture = CreateSolidPicture(stuff->pid, &stuff->color, &error); if (!pPicture) return error; /* security creation/labeling check */ error = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, PictureType, pPicture, RT_NONE, NULL, DixCreateAccess); if (error != Success) return error; if (!AddResource (stuff->pid, PictureType, (pointer)pPicture)) return BadAlloc; return Success; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,277
ProcRenderDispatch (ClientPtr client) { REQUEST(xReq); if (stuff->data < RenderNumberRequests) return (*ProcRenderVector[stuff->data]) (client); else return BadRequest; }
DoS
0
ProcRenderDispatch (ClientPtr client) { REQUEST(xReq); if (stuff->data < RenderNumberRequests) return (*ProcRenderVector[stuff->data]) (client); else return BadRequest; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,278
ProcRenderFillRectangles (ClientPtr client) { PicturePtr pDst; int things; REQUEST(xRenderFillRectanglesReq); REQUEST_AT_LEAST_SIZE (xRenderFillRectanglesReq); if (!PictOpValid (stuff->op)) { client->errorValue = stuff->op; return BadValue; } VERIFY_PICTURE (pDst, stuff->dst, client, DixWriteAccess); if (!pDst->pDrawable) return BadDrawable; things = (client->req_len << 2) - sizeof(xRenderFillRectanglesReq); if (things & 4) return BadLength; things >>= 3; CompositeRects (stuff->op, pDst, &stuff->color, things, (xRectangle *) &stuff[1]); return Success; }
DoS
0
ProcRenderFillRectangles (ClientPtr client) { PicturePtr pDst; int things; REQUEST(xRenderFillRectanglesReq); REQUEST_AT_LEAST_SIZE (xRenderFillRectanglesReq); if (!PictOpValid (stuff->op)) { client->errorValue = stuff->op; return BadValue; } VERIFY_PICTURE (pDst, stuff->dst, client, DixWriteAccess); if (!pDst->pDrawable) return BadDrawable; things = (client->req_len << 2) - sizeof(xRenderFillRectanglesReq); if (things & 4) return BadLength; things >>= 3; CompositeRects (stuff->op, pDst, &stuff->color, things, (xRectangle *) &stuff[1]); return Success; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,279
ProcRenderFreeGlyphSet (ClientPtr client) { GlyphSetPtr glyphSet; int rc; REQUEST(xRenderFreeGlyphSetReq); REQUEST_SIZE_MATCH(xRenderFreeGlyphSetReq); rc = dixLookupResourceByType((pointer *)&glyphSet, stuff->glyphset, GlyphSetType, client, DixDestroyAccess); if (rc != Success) { client->errorValue = stuff->glyphset; return rc; } FreeResource (stuff->glyphset, RT_NONE); return Success; }
DoS
0
ProcRenderFreeGlyphSet (ClientPtr client) { GlyphSetPtr glyphSet; int rc; REQUEST(xRenderFreeGlyphSetReq); REQUEST_SIZE_MATCH(xRenderFreeGlyphSetReq); rc = dixLookupResourceByType((pointer *)&glyphSet, stuff->glyphset, GlyphSetType, client, DixDestroyAccess); if (rc != Success) { client->errorValue = stuff->glyphset; return rc; } FreeResource (stuff->glyphset, RT_NONE); return Success; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,280
ProcRenderFreeGlyphs (ClientPtr client) { REQUEST(xRenderFreeGlyphsReq); GlyphSetPtr glyphSet; int rc, nglyph; CARD32 *gids; CARD32 glyph; REQUEST_AT_LEAST_SIZE(xRenderFreeGlyphsReq); rc = dixLookupResourceByType((pointer *)&glyphSet, stuff->glyphset, GlyphSetType, client, DixRemoveAccess); if (rc != Success) { client->errorValue = stuff->glyphset; return rc; } nglyph = bytes_to_int32((client->req_len << 2) - sizeof (xRenderFreeGlyphsReq)); gids = (CARD32 *) (stuff + 1); while (nglyph-- > 0) { glyph = *gids++; if (!DeleteGlyph (glyphSet, glyph)) { client->errorValue = glyph; return RenderErrBase + BadGlyph; } } return Success; }
DoS
0
ProcRenderFreeGlyphs (ClientPtr client) { REQUEST(xRenderFreeGlyphsReq); GlyphSetPtr glyphSet; int rc, nglyph; CARD32 *gids; CARD32 glyph; REQUEST_AT_LEAST_SIZE(xRenderFreeGlyphsReq); rc = dixLookupResourceByType((pointer *)&glyphSet, stuff->glyphset, GlyphSetType, client, DixRemoveAccess); if (rc != Success) { client->errorValue = stuff->glyphset; return rc; } nglyph = bytes_to_int32((client->req_len << 2) - sizeof (xRenderFreeGlyphsReq)); gids = (CARD32 *) (stuff + 1); while (nglyph-- > 0) { glyph = *gids++; if (!DeleteGlyph (glyphSet, glyph)) { client->errorValue = glyph; return RenderErrBase + BadGlyph; } } return Success; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,281
ProcRenderQueryDithers (ClientPtr client) { return BadImplementation; }
DoS
0
ProcRenderQueryDithers (ClientPtr client) { return BadImplementation; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,282
ProcRenderQueryFilters (ClientPtr client) { REQUEST (xRenderQueryFiltersReq); DrawablePtr pDrawable; xRenderQueryFiltersReply *reply; int nbytesName; int nnames; ScreenPtr pScreen; PictureScreenPtr ps; int i, j, len, total_bytes, rc; INT16 *aliases; char *names; REQUEST_SIZE_MATCH(xRenderQueryFiltersReq); rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0, DixGetAttrAccess); if (rc != Success) return rc; pScreen = pDrawable->pScreen; nbytesName = 0; nnames = 0; ps = GetPictureScreenIfSet(pScreen); if (ps) { for (i = 0; i < ps->nfilters; i++) nbytesName += 1 + strlen (ps->filters[i].name); for (i = 0; i < ps->nfilterAliases; i++) nbytesName += 1 + strlen (ps->filterAliases[i].alias); nnames = ps->nfilters + ps->nfilterAliases; } len = ((nnames + 1) >> 1) + bytes_to_int32(nbytesName); total_bytes = sizeof (xRenderQueryFiltersReply) + (len << 2); reply = (xRenderQueryFiltersReply *) malloc(total_bytes); if (!reply) return BadAlloc; aliases = (INT16 *) (reply + 1); names = (char *) (aliases + ((nnames + 1) & ~1)); reply->type = X_Reply; reply->sequenceNumber = client->sequence; reply->length = len; reply->numAliases = nnames; reply->numFilters = nnames; if (ps) { /* fill in alias values */ for (i = 0; i < ps->nfilters; i++) aliases[i] = FilterAliasNone; for (i = 0; i < ps->nfilterAliases; i++) { for (j = 0; j < ps->nfilters; j++) if (ps->filterAliases[i].filter_id == ps->filters[j].id) break; if (j == ps->nfilters) { for (j = 0; j < ps->nfilterAliases; j++) if (ps->filterAliases[i].filter_id == ps->filterAliases[j].alias_id) { break; } if (j == ps->nfilterAliases) j = FilterAliasNone; else j = j + ps->nfilters; } aliases[i + ps->nfilters] = j; } /* fill in filter names */ for (i = 0; i < ps->nfilters; i++) { j = strlen (ps->filters[i].name); *names++ = j; strncpy (names, ps->filters[i].name, j); names += j; } /* fill in filter alias names */ for (i = 0; i < ps->nfilterAliases; i++) { j = strlen (ps->filterAliases[i].alias); *names++ = j; strncpy (names, ps->filterAliases[i].alias, j); names += j; } } if (client->swapped) { register int n; for (i = 0; i < reply->numAliases; i++) { swaps (&aliases[i], n); } swaps(&reply->sequenceNumber, n); swapl(&reply->length, n); swapl(&reply->numAliases, n); swapl(&reply->numFilters, n); } WriteToClient(client, total_bytes, (char *) reply); free(reply); return Success; }
DoS
0
ProcRenderQueryFilters (ClientPtr client) { REQUEST (xRenderQueryFiltersReq); DrawablePtr pDrawable; xRenderQueryFiltersReply *reply; int nbytesName; int nnames; ScreenPtr pScreen; PictureScreenPtr ps; int i, j, len, total_bytes, rc; INT16 *aliases; char *names; REQUEST_SIZE_MATCH(xRenderQueryFiltersReq); rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0, DixGetAttrAccess); if (rc != Success) return rc; pScreen = pDrawable->pScreen; nbytesName = 0; nnames = 0; ps = GetPictureScreenIfSet(pScreen); if (ps) { for (i = 0; i < ps->nfilters; i++) nbytesName += 1 + strlen (ps->filters[i].name); for (i = 0; i < ps->nfilterAliases; i++) nbytesName += 1 + strlen (ps->filterAliases[i].alias); nnames = ps->nfilters + ps->nfilterAliases; } len = ((nnames + 1) >> 1) + bytes_to_int32(nbytesName); total_bytes = sizeof (xRenderQueryFiltersReply) + (len << 2); reply = (xRenderQueryFiltersReply *) malloc(total_bytes); if (!reply) return BadAlloc; aliases = (INT16 *) (reply + 1); names = (char *) (aliases + ((nnames + 1) & ~1)); reply->type = X_Reply; reply->sequenceNumber = client->sequence; reply->length = len; reply->numAliases = nnames; reply->numFilters = nnames; if (ps) { /* fill in alias values */ for (i = 0; i < ps->nfilters; i++) aliases[i] = FilterAliasNone; for (i = 0; i < ps->nfilterAliases; i++) { for (j = 0; j < ps->nfilters; j++) if (ps->filterAliases[i].filter_id == ps->filters[j].id) break; if (j == ps->nfilters) { for (j = 0; j < ps->nfilterAliases; j++) if (ps->filterAliases[i].filter_id == ps->filterAliases[j].alias_id) { break; } if (j == ps->nfilterAliases) j = FilterAliasNone; else j = j + ps->nfilters; } aliases[i + ps->nfilters] = j; } /* fill in filter names */ for (i = 0; i < ps->nfilters; i++) { j = strlen (ps->filters[i].name); *names++ = j; strncpy (names, ps->filters[i].name, j); names += j; } /* fill in filter alias names */ for (i = 0; i < ps->nfilterAliases; i++) { j = strlen (ps->filterAliases[i].alias); *names++ = j; strncpy (names, ps->filterAliases[i].alias, j); names += j; } } if (client->swapped) { register int n; for (i = 0; i < reply->numAliases; i++) { swaps (&aliases[i], n); } swaps(&reply->sequenceNumber, n); swapl(&reply->length, n); swapl(&reply->numAliases, n); swapl(&reply->numFilters, n); } WriteToClient(client, total_bytes, (char *) reply); free(reply); return Success; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,283
ProcRenderQueryPictFormats (ClientPtr client) { RenderClientPtr pRenderClient = GetRenderClient (client); xRenderQueryPictFormatsReply *reply; xPictScreen *pictScreen; xPictDepth *pictDepth; xPictVisual *pictVisual; xPictFormInfo *pictForm; CARD32 *pictSubpixel; ScreenPtr pScreen; VisualPtr pVisual; DepthPtr pDepth; int v, d; PictureScreenPtr ps; PictFormatPtr pFormat; int nformat; int ndepth; int nvisual; int rlength; int s; int n; int numScreens; int numSubpixel; /* REQUEST(xRenderQueryPictFormatsReq); */ REQUEST_SIZE_MATCH(xRenderQueryPictFormatsReq); #ifdef PANORAMIX if (noPanoramiXExtension) numScreens = screenInfo.numScreens; else numScreens = ((xConnSetup *)ConnectionInfo)->numRoots; #else numScreens = screenInfo.numScreens; #endif ndepth = nformat = nvisual = 0; for (s = 0; s < numScreens; s++) { pScreen = screenInfo.screens[s]; for (d = 0; d < pScreen->numDepths; d++) { pDepth = pScreen->allowedDepths + d; ++ndepth; for (v = 0; v < pDepth->numVids; v++) { pVisual = findVisual (pScreen, pDepth->vids[v]); if (pVisual && PictureMatchVisual (pScreen, pDepth->depth, pVisual)) ++nvisual; } } ps = GetPictureScreenIfSet(pScreen); if (ps) nformat += ps->nformats; } if (pRenderClient->major_version == 0 && pRenderClient->minor_version < 6) numSubpixel = 0; else numSubpixel = numScreens; rlength = (sizeof (xRenderQueryPictFormatsReply) + nformat * sizeof (xPictFormInfo) + numScreens * sizeof (xPictScreen) + ndepth * sizeof (xPictDepth) + nvisual * sizeof (xPictVisual) + numSubpixel * sizeof (CARD32)); reply = (xRenderQueryPictFormatsReply *) calloc(1, rlength); if (!reply) return BadAlloc; reply->type = X_Reply; reply->sequenceNumber = client->sequence; reply->length = bytes_to_int32(rlength - sizeof(xGenericReply)); reply->numFormats = nformat; reply->numScreens = numScreens; reply->numDepths = ndepth; reply->numVisuals = nvisual; reply->numSubpixel = numSubpixel; pictForm = (xPictFormInfo *) (reply + 1); for (s = 0; s < numScreens; s++) { pScreen = screenInfo.screens[s]; ps = GetPictureScreenIfSet(pScreen); if (ps) { for (nformat = 0, pFormat = ps->formats; nformat < ps->nformats; nformat++, pFormat++) { pictForm->id = pFormat->id; pictForm->type = pFormat->type; pictForm->depth = pFormat->depth; pictForm->direct.red = pFormat->direct.red; pictForm->direct.redMask = pFormat->direct.redMask; pictForm->direct.green = pFormat->direct.green; pictForm->direct.greenMask = pFormat->direct.greenMask; pictForm->direct.blue = pFormat->direct.blue; pictForm->direct.blueMask = pFormat->direct.blueMask; pictForm->direct.alpha = pFormat->direct.alpha; pictForm->direct.alphaMask = pFormat->direct.alphaMask; if (pFormat->type == PictTypeIndexed && pFormat->index.pColormap) pictForm->colormap = pFormat->index.pColormap->mid; else pictForm->colormap = None; if (client->swapped) { swapl (&pictForm->id, n); swaps (&pictForm->direct.red, n); swaps (&pictForm->direct.redMask, n); swaps (&pictForm->direct.green, n); swaps (&pictForm->direct.greenMask, n); swaps (&pictForm->direct.blue, n); swaps (&pictForm->direct.blueMask, n); swaps (&pictForm->direct.alpha, n); swaps (&pictForm->direct.alphaMask, n); swapl (&pictForm->colormap, n); } pictForm++; } } } pictScreen = (xPictScreen *) pictForm; for (s = 0; s < numScreens; s++) { pScreen = screenInfo.screens[s]; pictDepth = (xPictDepth *) (pictScreen + 1); ndepth = 0; for (d = 0; d < pScreen->numDepths; d++) { pictVisual = (xPictVisual *) (pictDepth + 1); pDepth = pScreen->allowedDepths + d; nvisual = 0; for (v = 0; v < pDepth->numVids; v++) { pVisual = findVisual (pScreen, pDepth->vids[v]); if (pVisual && (pFormat = PictureMatchVisual (pScreen, pDepth->depth, pVisual))) { pictVisual->visual = pVisual->vid; pictVisual->format = pFormat->id; if (client->swapped) { swapl (&pictVisual->visual, n); swapl (&pictVisual->format, n); } pictVisual++; nvisual++; } } pictDepth->depth = pDepth->depth; pictDepth->nPictVisuals = nvisual; if (client->swapped) { swaps (&pictDepth->nPictVisuals, n); } ndepth++; pictDepth = (xPictDepth *) pictVisual; } pictScreen->nDepth = ndepth; ps = GetPictureScreenIfSet(pScreen); if (ps) pictScreen->fallback = ps->fallback->id; else pictScreen->fallback = 0; if (client->swapped) { swapl (&pictScreen->nDepth, n); swapl (&pictScreen->fallback, n); } pictScreen = (xPictScreen *) pictDepth; } pictSubpixel = (CARD32 *) pictScreen; for (s = 0; s < numSubpixel; s++) { pScreen = screenInfo.screens[s]; ps = GetPictureScreenIfSet(pScreen); if (ps) *pictSubpixel = ps->subpixel; else *pictSubpixel = SubPixelUnknown; if (client->swapped) { swapl (pictSubpixel, n); } ++pictSubpixel; } if (client->swapped) { swaps (&reply->sequenceNumber, n); swapl (&reply->length, n); swapl (&reply->numFormats, n); swapl (&reply->numScreens, n); swapl (&reply->numDepths, n); swapl (&reply->numVisuals, n); swapl (&reply->numSubpixel, n); } WriteToClient(client, rlength, (char *) reply); free(reply); return Success; }
DoS
0
ProcRenderQueryPictFormats (ClientPtr client) { RenderClientPtr pRenderClient = GetRenderClient (client); xRenderQueryPictFormatsReply *reply; xPictScreen *pictScreen; xPictDepth *pictDepth; xPictVisual *pictVisual; xPictFormInfo *pictForm; CARD32 *pictSubpixel; ScreenPtr pScreen; VisualPtr pVisual; DepthPtr pDepth; int v, d; PictureScreenPtr ps; PictFormatPtr pFormat; int nformat; int ndepth; int nvisual; int rlength; int s; int n; int numScreens; int numSubpixel; /* REQUEST(xRenderQueryPictFormatsReq); */ REQUEST_SIZE_MATCH(xRenderQueryPictFormatsReq); #ifdef PANORAMIX if (noPanoramiXExtension) numScreens = screenInfo.numScreens; else numScreens = ((xConnSetup *)ConnectionInfo)->numRoots; #else numScreens = screenInfo.numScreens; #endif ndepth = nformat = nvisual = 0; for (s = 0; s < numScreens; s++) { pScreen = screenInfo.screens[s]; for (d = 0; d < pScreen->numDepths; d++) { pDepth = pScreen->allowedDepths + d; ++ndepth; for (v = 0; v < pDepth->numVids; v++) { pVisual = findVisual (pScreen, pDepth->vids[v]); if (pVisual && PictureMatchVisual (pScreen, pDepth->depth, pVisual)) ++nvisual; } } ps = GetPictureScreenIfSet(pScreen); if (ps) nformat += ps->nformats; } if (pRenderClient->major_version == 0 && pRenderClient->minor_version < 6) numSubpixel = 0; else numSubpixel = numScreens; rlength = (sizeof (xRenderQueryPictFormatsReply) + nformat * sizeof (xPictFormInfo) + numScreens * sizeof (xPictScreen) + ndepth * sizeof (xPictDepth) + nvisual * sizeof (xPictVisual) + numSubpixel * sizeof (CARD32)); reply = (xRenderQueryPictFormatsReply *) calloc(1, rlength); if (!reply) return BadAlloc; reply->type = X_Reply; reply->sequenceNumber = client->sequence; reply->length = bytes_to_int32(rlength - sizeof(xGenericReply)); reply->numFormats = nformat; reply->numScreens = numScreens; reply->numDepths = ndepth; reply->numVisuals = nvisual; reply->numSubpixel = numSubpixel; pictForm = (xPictFormInfo *) (reply + 1); for (s = 0; s < numScreens; s++) { pScreen = screenInfo.screens[s]; ps = GetPictureScreenIfSet(pScreen); if (ps) { for (nformat = 0, pFormat = ps->formats; nformat < ps->nformats; nformat++, pFormat++) { pictForm->id = pFormat->id; pictForm->type = pFormat->type; pictForm->depth = pFormat->depth; pictForm->direct.red = pFormat->direct.red; pictForm->direct.redMask = pFormat->direct.redMask; pictForm->direct.green = pFormat->direct.green; pictForm->direct.greenMask = pFormat->direct.greenMask; pictForm->direct.blue = pFormat->direct.blue; pictForm->direct.blueMask = pFormat->direct.blueMask; pictForm->direct.alpha = pFormat->direct.alpha; pictForm->direct.alphaMask = pFormat->direct.alphaMask; if (pFormat->type == PictTypeIndexed && pFormat->index.pColormap) pictForm->colormap = pFormat->index.pColormap->mid; else pictForm->colormap = None; if (client->swapped) { swapl (&pictForm->id, n); swaps (&pictForm->direct.red, n); swaps (&pictForm->direct.redMask, n); swaps (&pictForm->direct.green, n); swaps (&pictForm->direct.greenMask, n); swaps (&pictForm->direct.blue, n); swaps (&pictForm->direct.blueMask, n); swaps (&pictForm->direct.alpha, n); swaps (&pictForm->direct.alphaMask, n); swapl (&pictForm->colormap, n); } pictForm++; } } } pictScreen = (xPictScreen *) pictForm; for (s = 0; s < numScreens; s++) { pScreen = screenInfo.screens[s]; pictDepth = (xPictDepth *) (pictScreen + 1); ndepth = 0; for (d = 0; d < pScreen->numDepths; d++) { pictVisual = (xPictVisual *) (pictDepth + 1); pDepth = pScreen->allowedDepths + d; nvisual = 0; for (v = 0; v < pDepth->numVids; v++) { pVisual = findVisual (pScreen, pDepth->vids[v]); if (pVisual && (pFormat = PictureMatchVisual (pScreen, pDepth->depth, pVisual))) { pictVisual->visual = pVisual->vid; pictVisual->format = pFormat->id; if (client->swapped) { swapl (&pictVisual->visual, n); swapl (&pictVisual->format, n); } pictVisual++; nvisual++; } } pictDepth->depth = pDepth->depth; pictDepth->nPictVisuals = nvisual; if (client->swapped) { swaps (&pictDepth->nPictVisuals, n); } ndepth++; pictDepth = (xPictDepth *) pictVisual; } pictScreen->nDepth = ndepth; ps = GetPictureScreenIfSet(pScreen); if (ps) pictScreen->fallback = ps->fallback->id; else pictScreen->fallback = 0; if (client->swapped) { swapl (&pictScreen->nDepth, n); swapl (&pictScreen->fallback, n); } pictScreen = (xPictScreen *) pictDepth; } pictSubpixel = (CARD32 *) pictScreen; for (s = 0; s < numSubpixel; s++) { pScreen = screenInfo.screens[s]; ps = GetPictureScreenIfSet(pScreen); if (ps) *pictSubpixel = ps->subpixel; else *pictSubpixel = SubPixelUnknown; if (client->swapped) { swapl (pictSubpixel, n); } ++pictSubpixel; } if (client->swapped) { swaps (&reply->sequenceNumber, n); swapl (&reply->length, n); swapl (&reply->numFormats, n); swapl (&reply->numScreens, n); swapl (&reply->numDepths, n); swapl (&reply->numVisuals, n); swapl (&reply->numSubpixel, n); } WriteToClient(client, rlength, (char *) reply); free(reply); return Success; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,284
ProcRenderQueryPictIndexValues (ClientPtr client) { PictFormatPtr pFormat; int rc, num; int rlength; int i, n; REQUEST(xRenderQueryPictIndexValuesReq); xRenderQueryPictIndexValuesReply *reply; xIndexValue *values; REQUEST_AT_LEAST_SIZE(xRenderQueryPictIndexValuesReq); rc = dixLookupResourceByType((pointer *)&pFormat, stuff->format, PictFormatType, client, DixReadAccess); if (rc != Success) return rc; if (pFormat->type != PictTypeIndexed) { client->errorValue = stuff->format; return BadMatch; } num = pFormat->index.nvalues; rlength = (sizeof (xRenderQueryPictIndexValuesReply) + num * sizeof(xIndexValue)); reply = (xRenderQueryPictIndexValuesReply *) malloc(rlength); if (!reply) return BadAlloc; reply->type = X_Reply; reply->sequenceNumber = client->sequence; reply->length = bytes_to_int32(rlength - sizeof(xGenericReply)); reply->numIndexValues = num; values = (xIndexValue *) (reply + 1); memcpy (reply + 1, pFormat->index.pValues, num * sizeof (xIndexValue)); if (client->swapped) { for (i = 0; i < num; i++) { swapl (&values[i].pixel, n); swaps (&values[i].red, n); swaps (&values[i].green, n); swaps (&values[i].blue, n); swaps (&values[i].alpha, n); } swaps (&reply->sequenceNumber, n); swapl (&reply->length, n); swapl (&reply->numIndexValues, n); } WriteToClient(client, rlength, (char *) reply); free(reply); return Success; }
DoS
0
ProcRenderQueryPictIndexValues (ClientPtr client) { PictFormatPtr pFormat; int rc, num; int rlength; int i, n; REQUEST(xRenderQueryPictIndexValuesReq); xRenderQueryPictIndexValuesReply *reply; xIndexValue *values; REQUEST_AT_LEAST_SIZE(xRenderQueryPictIndexValuesReq); rc = dixLookupResourceByType((pointer *)&pFormat, stuff->format, PictFormatType, client, DixReadAccess); if (rc != Success) return rc; if (pFormat->type != PictTypeIndexed) { client->errorValue = stuff->format; return BadMatch; } num = pFormat->index.nvalues; rlength = (sizeof (xRenderQueryPictIndexValuesReply) + num * sizeof(xIndexValue)); reply = (xRenderQueryPictIndexValuesReply *) malloc(rlength); if (!reply) return BadAlloc; reply->type = X_Reply; reply->sequenceNumber = client->sequence; reply->length = bytes_to_int32(rlength - sizeof(xGenericReply)); reply->numIndexValues = num; values = (xIndexValue *) (reply + 1); memcpy (reply + 1, pFormat->index.pValues, num * sizeof (xIndexValue)); if (client->swapped) { for (i = 0; i < num; i++) { swapl (&values[i].pixel, n); swaps (&values[i].red, n); swaps (&values[i].green, n); swaps (&values[i].blue, n); swaps (&values[i].alpha, n); } swaps (&reply->sequenceNumber, n); swapl (&reply->length, n); swapl (&reply->numIndexValues, n); } WriteToClient(client, rlength, (char *) reply); free(reply); return Success; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,285
ProcRenderQueryVersion (ClientPtr client) { RenderClientPtr pRenderClient = GetRenderClient (client); xRenderQueryVersionReply rep; register int n; REQUEST(xRenderQueryVersionReq); pRenderClient->major_version = stuff->majorVersion; pRenderClient->minor_version = stuff->minorVersion; REQUEST_SIZE_MATCH(xRenderQueryVersionReq); memset(&rep, 0, sizeof(xRenderQueryVersionReply)); rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; if ((stuff->majorVersion * 1000 + stuff->minorVersion) < (SERVER_RENDER_MAJOR_VERSION * 1000 + SERVER_RENDER_MINOR_VERSION)) { rep.majorVersion = stuff->majorVersion; rep.minorVersion = stuff->minorVersion; } else { rep.majorVersion = SERVER_RENDER_MAJOR_VERSION; rep.minorVersion = SERVER_RENDER_MINOR_VERSION; } if (client->swapped) { swaps(&rep.sequenceNumber, n); swapl(&rep.length, n); swapl(&rep.majorVersion, n); swapl(&rep.minorVersion, n); } WriteToClient(client, sizeof(xRenderQueryVersionReply), (char *)&rep); return Success; }
DoS
0
ProcRenderQueryVersion (ClientPtr client) { RenderClientPtr pRenderClient = GetRenderClient (client); xRenderQueryVersionReply rep; register int n; REQUEST(xRenderQueryVersionReq); pRenderClient->major_version = stuff->majorVersion; pRenderClient->minor_version = stuff->minorVersion; REQUEST_SIZE_MATCH(xRenderQueryVersionReq); memset(&rep, 0, sizeof(xRenderQueryVersionReply)); rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; if ((stuff->majorVersion * 1000 + stuff->minorVersion) < (SERVER_RENDER_MAJOR_VERSION * 1000 + SERVER_RENDER_MINOR_VERSION)) { rep.majorVersion = stuff->majorVersion; rep.minorVersion = stuff->minorVersion; } else { rep.majorVersion = SERVER_RENDER_MAJOR_VERSION; rep.minorVersion = SERVER_RENDER_MINOR_VERSION; } if (client->swapped) { swaps(&rep.sequenceNumber, n); swapl(&rep.length, n); swapl(&rep.majorVersion, n); swapl(&rep.minorVersion, n); } WriteToClient(client, sizeof(xRenderQueryVersionReply), (char *)&rep); return Success; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,286
ProcRenderReferenceGlyphSet (ClientPtr client) { GlyphSetPtr glyphSet; int rc; REQUEST(xRenderReferenceGlyphSetReq); REQUEST_SIZE_MATCH(xRenderReferenceGlyphSetReq); LEGAL_NEW_RESOURCE(stuff->gsid, client); rc = dixLookupResourceByType((pointer *)&glyphSet, stuff->existing, GlyphSetType, client, DixGetAttrAccess); if (rc != Success) { client->errorValue = stuff->existing; return rc; } glyphSet->refcnt++; if (!AddResource (stuff->gsid, GlyphSetType, (pointer)glyphSet)) return BadAlloc; return Success; }
DoS
0
ProcRenderReferenceGlyphSet (ClientPtr client) { GlyphSetPtr glyphSet; int rc; REQUEST(xRenderReferenceGlyphSetReq); REQUEST_SIZE_MATCH(xRenderReferenceGlyphSetReq); LEGAL_NEW_RESOURCE(stuff->gsid, client); rc = dixLookupResourceByType((pointer *)&glyphSet, stuff->existing, GlyphSetType, client, DixGetAttrAccess); if (rc != Success) { client->errorValue = stuff->existing; return rc; } glyphSet->refcnt++; if (!AddResource (stuff->gsid, GlyphSetType, (pointer)glyphSet)) return BadAlloc; return Success; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,287
ProcRenderScale (ClientPtr client) { return BadImplementation; }
DoS
0
ProcRenderScale (ClientPtr client) { return BadImplementation; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,288
ProcRenderSetPictureTransform (ClientPtr client) { REQUEST(xRenderSetPictureTransformReq); PicturePtr pPicture; REQUEST_SIZE_MATCH(xRenderSetPictureTransformReq); VERIFY_PICTURE (pPicture, stuff->picture, client, DixSetAttrAccess); return SetPictureTransform (pPicture, (PictTransform *) &stuff->transform); }
DoS
0
ProcRenderSetPictureTransform (ClientPtr client) { REQUEST(xRenderSetPictureTransformReq); PicturePtr pPicture; REQUEST_SIZE_MATCH(xRenderSetPictureTransformReq); VERIFY_PICTURE (pPicture, stuff->picture, client, DixSetAttrAccess); return SetPictureTransform (pPicture, (PictTransform *) &stuff->transform); }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,289
ProcRenderTransform (ClientPtr client) { return BadImplementation; }
DoS
0
ProcRenderTransform (ClientPtr client) { return BadImplementation; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,290
ProcRenderTrapezoids (ClientPtr client) { int rc, ntraps; PicturePtr pSrc, pDst; PictFormatPtr pFormat; REQUEST(xRenderTrapezoidsReq); REQUEST_AT_LEAST_SIZE(xRenderTrapezoidsReq); if (!PictOpValid (stuff->op)) { client->errorValue = stuff->op; return BadValue; } VERIFY_PICTURE (pSrc, stuff->src, client, DixReadAccess); VERIFY_PICTURE (pDst, stuff->dst, client, DixWriteAccess); if (!pDst->pDrawable) return BadDrawable; if (pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen) return BadMatch; if (stuff->maskFormat) { rc = dixLookupResourceByType((pointer *)&pFormat, stuff->maskFormat, PictFormatType, client, DixReadAccess); if (rc != Success) return rc; } else pFormat = 0; ntraps = (client->req_len << 2) - sizeof (xRenderTrapezoidsReq); if (ntraps % sizeof (xTrapezoid)) return BadLength; ntraps /= sizeof (xTrapezoid); if (ntraps) CompositeTrapezoids (stuff->op, pSrc, pDst, pFormat, stuff->xSrc, stuff->ySrc, ntraps, (xTrapezoid *) &stuff[1]); return Success; }
DoS
0
ProcRenderTrapezoids (ClientPtr client) { int rc, ntraps; PicturePtr pSrc, pDst; PictFormatPtr pFormat; REQUEST(xRenderTrapezoidsReq); REQUEST_AT_LEAST_SIZE(xRenderTrapezoidsReq); if (!PictOpValid (stuff->op)) { client->errorValue = stuff->op; return BadValue; } VERIFY_PICTURE (pSrc, stuff->src, client, DixReadAccess); VERIFY_PICTURE (pDst, stuff->dst, client, DixWriteAccess); if (!pDst->pDrawable) return BadDrawable; if (pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen) return BadMatch; if (stuff->maskFormat) { rc = dixLookupResourceByType((pointer *)&pFormat, stuff->maskFormat, PictFormatType, client, DixReadAccess); if (rc != Success) return rc; } else pFormat = 0; ntraps = (client->req_len << 2) - sizeof (xRenderTrapezoidsReq); if (ntraps % sizeof (xTrapezoid)) return BadLength; ntraps /= sizeof (xTrapezoid); if (ntraps) CompositeTrapezoids (stuff->op, pSrc, pDst, pFormat, stuff->xSrc, stuff->ySrc, ntraps, (xTrapezoid *) &stuff[1]); return Success; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,291
ProcRenderTriFan (ClientPtr client) { int rc, npoints; PicturePtr pSrc, pDst; PictFormatPtr pFormat; REQUEST(xRenderTrianglesReq); REQUEST_AT_LEAST_SIZE(xRenderTrianglesReq); if (!PictOpValid (stuff->op)) { client->errorValue = stuff->op; return BadValue; } VERIFY_PICTURE (pSrc, stuff->src, client, DixReadAccess); VERIFY_PICTURE (pDst, stuff->dst, client, DixWriteAccess); if (!pDst->pDrawable) return BadDrawable; if (pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen) return BadMatch; if (stuff->maskFormat) { rc = dixLookupResourceByType((pointer *)&pFormat, stuff->maskFormat, PictFormatType, client, DixReadAccess); if (rc != Success) return rc; } else pFormat = 0; npoints = ((client->req_len << 2) - sizeof (xRenderTriStripReq)); if (npoints & 4) return BadLength; npoints >>= 3; if (npoints >= 3) CompositeTriFan (stuff->op, pSrc, pDst, pFormat, stuff->xSrc, stuff->ySrc, npoints, (xPointFixed *) &stuff[1]); return Success; }
DoS
0
ProcRenderTriFan (ClientPtr client) { int rc, npoints; PicturePtr pSrc, pDst; PictFormatPtr pFormat; REQUEST(xRenderTrianglesReq); REQUEST_AT_LEAST_SIZE(xRenderTrianglesReq); if (!PictOpValid (stuff->op)) { client->errorValue = stuff->op; return BadValue; } VERIFY_PICTURE (pSrc, stuff->src, client, DixReadAccess); VERIFY_PICTURE (pDst, stuff->dst, client, DixWriteAccess); if (!pDst->pDrawable) return BadDrawable; if (pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen) return BadMatch; if (stuff->maskFormat) { rc = dixLookupResourceByType((pointer *)&pFormat, stuff->maskFormat, PictFormatType, client, DixReadAccess); if (rc != Success) return rc; } else pFormat = 0; npoints = ((client->req_len << 2) - sizeof (xRenderTriStripReq)); if (npoints & 4) return BadLength; npoints >>= 3; if (npoints >= 3) CompositeTriFan (stuff->op, pSrc, pDst, pFormat, stuff->xSrc, stuff->ySrc, npoints, (xPointFixed *) &stuff[1]); return Success; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,292
ProcRenderTriStrip (ClientPtr client) { int rc, npoints; PicturePtr pSrc, pDst; PictFormatPtr pFormat; REQUEST(xRenderTrianglesReq); REQUEST_AT_LEAST_SIZE(xRenderTrianglesReq); if (!PictOpValid (stuff->op)) { client->errorValue = stuff->op; return BadValue; } VERIFY_PICTURE (pSrc, stuff->src, client, DixReadAccess); VERIFY_PICTURE (pDst, stuff->dst, client, DixWriteAccess); if (!pDst->pDrawable) return BadDrawable; if (pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen) return BadMatch; if (stuff->maskFormat) { rc = dixLookupResourceByType((pointer *)&pFormat, stuff->maskFormat, PictFormatType, client, DixReadAccess); if (rc != Success) return rc; } else pFormat = 0; npoints = ((client->req_len << 2) - sizeof (xRenderTriStripReq)); if (npoints & 4) return BadLength; npoints >>= 3; if (npoints >= 3) CompositeTriStrip (stuff->op, pSrc, pDst, pFormat, stuff->xSrc, stuff->ySrc, npoints, (xPointFixed *) &stuff[1]); return Success; }
DoS
0
ProcRenderTriStrip (ClientPtr client) { int rc, npoints; PicturePtr pSrc, pDst; PictFormatPtr pFormat; REQUEST(xRenderTrianglesReq); REQUEST_AT_LEAST_SIZE(xRenderTrianglesReq); if (!PictOpValid (stuff->op)) { client->errorValue = stuff->op; return BadValue; } VERIFY_PICTURE (pSrc, stuff->src, client, DixReadAccess); VERIFY_PICTURE (pDst, stuff->dst, client, DixWriteAccess); if (!pDst->pDrawable) return BadDrawable; if (pSrc->pDrawable && pSrc->pDrawable->pScreen != pDst->pDrawable->pScreen) return BadMatch; if (stuff->maskFormat) { rc = dixLookupResourceByType((pointer *)&pFormat, stuff->maskFormat, PictFormatType, client, DixReadAccess); if (rc != Success) return rc; } else pFormat = 0; npoints = ((client->req_len << 2) - sizeof (xRenderTriStripReq)); if (npoints & 4) return BadLength; npoints >>= 3; if (npoints >= 3) CompositeTriStrip (stuff->op, pSrc, pDst, pFormat, stuff->xSrc, stuff->ySrc, npoints, (xPointFixed *) &stuff[1]); return Success; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,293
RenderClientCallback (CallbackListPtr *list, pointer closure, pointer data) { NewClientInfoRec *clientinfo = (NewClientInfoRec *) data; ClientPtr pClient = clientinfo->client; RenderClientPtr pRenderClient = GetRenderClient (pClient); pRenderClient->major_version = 0; pRenderClient->minor_version = 0; }
DoS
0
RenderClientCallback (CallbackListPtr *list, pointer closure, pointer data) { NewClientInfoRec *clientinfo = (NewClientInfoRec *) data; ClientPtr pClient = clientinfo->client; RenderClientPtr pRenderClient = GetRenderClient (pClient); pRenderClient->major_version = 0; pRenderClient->minor_version = 0; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,294
RenderExtensionInit (void) { ExtensionEntry *extEntry; if (!PictureType) return; if (!PictureFinishInit ()) return; if (!dixRegisterPrivateKey(&RenderClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(RenderClientRec))) return; if (!AddCallback (&ClientStateCallback, RenderClientCallback, 0)) return; extEntry = AddExtension (RENDER_NAME, 0, RenderNumberErrors, ProcRenderDispatch, SProcRenderDispatch, NULL, StandardMinorOpcode); if (!extEntry) return; RenderErrBase = extEntry->errorBase; #ifdef PANORAMIX if (XRT_PICTURE) SetResourceTypeErrorValue(XRT_PICTURE, RenderErrBase + BadPicture); #endif SetResourceTypeErrorValue(PictureType, RenderErrBase + BadPicture); SetResourceTypeErrorValue(PictFormatType, RenderErrBase + BadPictFormat); SetResourceTypeErrorValue(GlyphSetType, RenderErrBase + BadGlyphSet); }
DoS
0
RenderExtensionInit (void) { ExtensionEntry *extEntry; if (!PictureType) return; if (!PictureFinishInit ()) return; if (!dixRegisterPrivateKey(&RenderClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(RenderClientRec))) return; if (!AddCallback (&ClientStateCallback, RenderClientCallback, 0)) return; extEntry = AddExtension (RENDER_NAME, 0, RenderNumberErrors, ProcRenderDispatch, SProcRenderDispatch, NULL, StandardMinorOpcode); if (!extEntry) return; RenderErrBase = extEntry->errorBase; #ifdef PANORAMIX if (XRT_PICTURE) SetResourceTypeErrorValue(XRT_PICTURE, RenderErrBase + BadPicture); #endif SetResourceTypeErrorValue(PictureType, RenderErrBase + BadPicture); SetResourceTypeErrorValue(PictFormatType, RenderErrBase + BadPictFormat); SetResourceTypeErrorValue(GlyphSetType, RenderErrBase + BadGlyphSet); }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,295
RenderSetBit (unsigned char *line, int x, int bit) { unsigned char mask; if (screenInfo.bitmapBitOrder == LSBFirst) mask = (1 << (x & 7)); else mask = (0x80 >> (x & 7)); /* XXX assumes byte order is host byte order */ line += (x >> 3); if (bit) *line |= mask; else *line &= ~mask; }
DoS
0
RenderSetBit (unsigned char *line, int x, int bit) { unsigned char mask; if (screenInfo.bitmapBitOrder == LSBFirst) mask = (1 << (x & 7)); else mask = (0x80 >> (x & 7)); /* XXX assumes byte order is host byte order */ line += (x >> 3); if (bit) *line |= mask; else *line &= ~mask; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,296
SProcRenderAddGlyphs (ClientPtr client) { register int n; register int i; CARD32 *gids; void *end; xGlyphInfo *gi; REQUEST(xRenderAddGlyphsReq); swaps(&stuff->length, n); swapl(&stuff->glyphset, n); swapl(&stuff->nglyphs, n); if (stuff->nglyphs & 0xe0000000) return BadLength; end = (CARD8 *) stuff + (client->req_len << 2); gids = (CARD32 *) (stuff + 1); gi = (xGlyphInfo *) (gids + stuff->nglyphs); if ((char *) end - (char *) (gids + stuff->nglyphs) < 0) return BadLength; if ((char *) end - (char *) (gi + stuff->nglyphs) < 0) return BadLength; for (i = 0; i < stuff->nglyphs; i++) { swapl (&gids[i], n); swaps (&gi[i].width, n); swaps (&gi[i].height, n); swaps (&gi[i].x, n); swaps (&gi[i].y, n); swaps (&gi[i].xOff, n); swaps (&gi[i].yOff, n); } return (*ProcRenderVector[stuff->renderReqType]) (client); }
DoS
0
SProcRenderAddGlyphs (ClientPtr client) { register int n; register int i; CARD32 *gids; void *end; xGlyphInfo *gi; REQUEST(xRenderAddGlyphsReq); swaps(&stuff->length, n); swapl(&stuff->glyphset, n); swapl(&stuff->nglyphs, n); if (stuff->nglyphs & 0xe0000000) return BadLength; end = (CARD8 *) stuff + (client->req_len << 2); gids = (CARD32 *) (stuff + 1); gi = (xGlyphInfo *) (gids + stuff->nglyphs); if ((char *) end - (char *) (gids + stuff->nglyphs) < 0) return BadLength; if ((char *) end - (char *) (gi + stuff->nglyphs) < 0) return BadLength; for (i = 0; i < stuff->nglyphs; i++) { swapl (&gids[i], n); swaps (&gi[i].width, n); swaps (&gi[i].height, n); swaps (&gi[i].x, n); swaps (&gi[i].y, n); swaps (&gi[i].xOff, n); swaps (&gi[i].yOff, n); } return (*ProcRenderVector[stuff->renderReqType]) (client); }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,297
SProcRenderAddGlyphsFromPicture (ClientPtr client) { return BadImplementation; }
DoS
0
SProcRenderAddGlyphsFromPicture (ClientPtr client) { return BadImplementation; }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,298
SProcRenderAddTraps (ClientPtr client) { register int n; REQUEST (xRenderAddTrapsReq); REQUEST_AT_LEAST_SIZE (xRenderAddTrapsReq); swaps(&stuff->length, n); swapl(&stuff->picture, n); swaps(&stuff->xOff, n); swaps(&stuff->yOff, n); SwapRestL(stuff); return (*ProcRenderVector[stuff->renderReqType]) (client); }
DoS
0
SProcRenderAddTraps (ClientPtr client) { register int n; REQUEST (xRenderAddTrapsReq); REQUEST_AT_LEAST_SIZE (xRenderAddTrapsReq); swaps(&stuff->length, n); swapl(&stuff->picture, n); swaps(&stuff->xOff, n); swaps(&stuff->yOff, n); SwapRestL(stuff); return (*ProcRenderVector[stuff->renderReqType]) (client); }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null
11,299
SProcRenderChangePicture (ClientPtr client) { register int n; REQUEST(xRenderChangePictureReq); swaps(&stuff->length, n); swapl(&stuff->picture, n); swapl(&stuff->mask, n); SwapRestL(stuff); return (*ProcRenderVector[stuff->renderReqType]) (client); }
DoS
0
SProcRenderChangePicture (ClientPtr client) { register int n; REQUEST(xRenderChangePictureReq); swaps(&stuff->length, n); swapl(&stuff->picture, n); swapl(&stuff->mask, n); SwapRestL(stuff); return (*ProcRenderVector[stuff->renderReqType]) (client); }
@@ -1077,6 +1077,14 @@ ProcRenderAddGlyphs (ClientPtr client) gi = (xGlyphInfo *) (gids + nglyphs); bits = (CARD8 *) (gi + nglyphs); remain -= (sizeof (CARD32) + sizeof (xGlyphInfo)) * nglyphs; + + /* protect against bad nglyphs */ + if (gi < stuff || gi > ((CARD32 *)stuff + client->req_len) || + bits < stuff || bits > ((CARD32 *)stuff + client->req_len)) { + err = BadLength; + goto bail; + } + for (i = 0; i < nglyphs; i++) { size_t padded_width;
CWE-20
null
null