idx
int64 | func_before
string | Vulnerability Classification
string | vul
int64 | func_after
string | patch
string | CWE ID
string | lines_before
string | lines_after
string |
|---|---|---|---|---|---|---|---|---|
4,200
|
static inline struct timespec pch_timestamp (bool which)
{
return p_timestamp[which];
}
| null | 0
|
static inline struct timespec pch_timestamp (bool which)
{
return p_timestamp[which];
}
|
@@ -37,6 +37,7 @@ bool pch_write_line (lin, FILE *);
bool there_is_another_patch (bool, mode_t *);
char *pfetch (lin) _GL_ATTRIBUTE_PURE;
char pch_char (lin) _GL_ATTRIBUTE_PURE;
+bool symlink_target_is_valid (char const *, char const *);
int another_hunk (enum diff, bool);
int pch_says_nonexistent (bool) _GL_ATTRIBUTE_PURE;
size_t pch_line_len (lin) _GL_ATTRIBUTE_PURE;
|
CWE-59
| null | null |
4,201
|
hb_buffer_get_direction (hb_buffer_t *buffer)
{
return buffer->direction;
}
|
DoS Exec Code
| 0
|
hb_buffer_get_direction (hb_buffer_t *buffer)
{
return buffer->direction;
}
|
@@ -54,23 +54,23 @@ static hb_buffer_t _hb_buffer_nil = {
* switches info and out_info.
*/
-/* XXX err handling */
/* Internal API */
-static void
+static hb_bool_t
hb_buffer_ensure_separate (hb_buffer_t *buffer, unsigned int size)
{
- hb_buffer_ensure (buffer, size);
+ if (unlikely (!hb_buffer_ensure (buffer, size))) return FALSE;
+
if (buffer->out_info == buffer->info)
{
assert (buffer->have_output);
- if (!buffer->pos)
- buffer->pos = (hb_internal_glyph_position_t *) calloc (buffer->allocated, sizeof (buffer->pos[0]));
buffer->out_info = (hb_internal_glyph_info_t *) buffer->pos;
memcpy (buffer->out_info, buffer->info, buffer->out_len * sizeof (buffer->out_info[0]));
}
+
+ return TRUE;
}
/* Public API */
@@ -84,7 +84,7 @@ hb_buffer_create (unsigned int pre_alloc_size)
return &_hb_buffer_nil;
if (pre_alloc_size)
- hb_buffer_ensure(buffer, pre_alloc_size);
+ hb_buffer_ensure (buffer, pre_alloc_size);
buffer->unicode = &_hb_unicode_funcs_nil;
@@ -181,6 +181,7 @@ hb_buffer_clear (hb_buffer_t *buffer)
{
buffer->have_output = FALSE;
buffer->have_positions = FALSE;
+ buffer->in_error = FALSE;
buffer->len = 0;
buffer->out_len = 0;
buffer->i = 0;
@@ -188,32 +189,42 @@ hb_buffer_clear (hb_buffer_t *buffer)
buffer->max_lig_id = 0;
}
-void
+hb_bool_t
hb_buffer_ensure (hb_buffer_t *buffer, unsigned int size)
{
- unsigned int new_allocated = buffer->allocated;
-
- if (size > new_allocated)
+ if (unlikely (size > buffer->allocated))
{
+ if (unlikely (buffer->in_error))
+ return FALSE;
+
+ unsigned int new_allocated = buffer->allocated;
+ hb_internal_glyph_position_t *new_pos;
+ hb_internal_glyph_info_t *new_info;
+ bool separate_out;
+
+ separate_out = buffer->out_info != buffer->info;
+
while (size > new_allocated)
new_allocated += (new_allocated >> 1) + 8;
- if (buffer->pos)
- buffer->pos = (hb_internal_glyph_position_t *) realloc (buffer->pos, new_allocated * sizeof (buffer->pos[0]));
+ new_pos = (hb_internal_glyph_position_t *) realloc (buffer->pos, new_allocated * sizeof (buffer->pos[0]));
+ new_info = (hb_internal_glyph_info_t *) realloc (buffer->info, new_allocated * sizeof (buffer->info[0]));
- if (buffer->out_info != buffer->info)
- {
- buffer->info = (hb_internal_glyph_info_t *) realloc (buffer->info, new_allocated * sizeof (buffer->info[0]));
- buffer->out_info = (hb_internal_glyph_info_t *) buffer->pos;
- }
- else
- {
- buffer->info = (hb_internal_glyph_info_t *) realloc (buffer->info, new_allocated * sizeof (buffer->info[0]));
- buffer->out_info = buffer->info;
- }
+ if (unlikely (!new_pos || !new_info))
+ buffer->in_error = TRUE;
- buffer->allocated = new_allocated;
+ if (likely (new_pos))
+ buffer->pos = new_pos;
+
+ if (likely (new_info))
+ buffer->info = new_info;
+
+ buffer->out_info = separate_out ? (hb_internal_glyph_info_t *) buffer->pos : buffer->info;
+ if (likely (!buffer->in_error))
+ buffer->allocated = new_allocated;
}
+
+ return likely (!buffer->in_error);
}
void
@@ -224,7 +235,7 @@ hb_buffer_add_glyph (hb_buffer_t *buffer,
{
hb_internal_glyph_info_t *glyph;
- hb_buffer_ensure (buffer, buffer->len + 1);
+ if (unlikely (!hb_buffer_ensure (buffer, buffer->len + 1))) return;
glyph = &buffer->info[buffer->len];
glyph->codepoint = codepoint;
@@ -272,6 +283,8 @@ _hb_buffer_swap (hb_buffer_t *buffer)
assert (buffer->have_output);
+ if (unlikely (buffer->in_error)) return;
+
if (buffer->out_info != buffer->info)
{
hb_internal_glyph_info_t *tmp_string;
@@ -323,7 +336,8 @@ _hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
if (buffer->out_info != buffer->info ||
buffer->out_len + num_out > buffer->i + num_in)
{
- hb_buffer_ensure_separate (buffer, buffer->out_len + num_out);
+ if (unlikely (!hb_buffer_ensure_separate (buffer, buffer->out_len + num_out)))
+ return;
}
mask = buffer->info[buffer->i].mask;
@@ -363,7 +377,8 @@ _hb_buffer_add_output_glyphs_be16 (hb_buffer_t *buffer,
if (buffer->out_info != buffer->info ||
buffer->out_len + num_out > buffer->i + num_in)
{
- hb_buffer_ensure_separate (buffer, buffer->out_len + num_out);
+ if (unlikely (!hb_buffer_ensure_separate (buffer, buffer->out_len + num_out)))
+ return;
}
mask = buffer->info[buffer->i].mask;
@@ -398,7 +413,7 @@ _hb_buffer_add_output_glyph (hb_buffer_t *buffer,
if (buffer->out_info != buffer->info)
{
- hb_buffer_ensure (buffer, buffer->out_len + 1);
+ if (unlikely (!hb_buffer_ensure (buffer, buffer->out_len + 1))) return;
buffer->out_info[buffer->out_len] = buffer->info[buffer->i];
}
else if (buffer->out_len != buffer->i)
@@ -423,7 +438,7 @@ _hb_buffer_next_glyph (hb_buffer_t *buffer)
{
if (buffer->out_info != buffer->info)
{
- hb_buffer_ensure (buffer, buffer->out_len + 1);
+ if (unlikely (!hb_buffer_ensure (buffer, buffer->out_len + 1))) return;
buffer->out_info[buffer->out_len] = buffer->info[buffer->i];
}
else if (buffer->out_len != buffer->i)
| null | null | null |
4,202
|
hb_buffer_get_script (hb_buffer_t *buffer)
{
return buffer->script;
}
|
DoS Exec Code
| 0
|
hb_buffer_get_script (hb_buffer_t *buffer)
{
return buffer->script;
}
|
@@ -54,23 +54,23 @@ static hb_buffer_t _hb_buffer_nil = {
* switches info and out_info.
*/
-/* XXX err handling */
/* Internal API */
-static void
+static hb_bool_t
hb_buffer_ensure_separate (hb_buffer_t *buffer, unsigned int size)
{
- hb_buffer_ensure (buffer, size);
+ if (unlikely (!hb_buffer_ensure (buffer, size))) return FALSE;
+
if (buffer->out_info == buffer->info)
{
assert (buffer->have_output);
- if (!buffer->pos)
- buffer->pos = (hb_internal_glyph_position_t *) calloc (buffer->allocated, sizeof (buffer->pos[0]));
buffer->out_info = (hb_internal_glyph_info_t *) buffer->pos;
memcpy (buffer->out_info, buffer->info, buffer->out_len * sizeof (buffer->out_info[0]));
}
+
+ return TRUE;
}
/* Public API */
@@ -84,7 +84,7 @@ hb_buffer_create (unsigned int pre_alloc_size)
return &_hb_buffer_nil;
if (pre_alloc_size)
- hb_buffer_ensure(buffer, pre_alloc_size);
+ hb_buffer_ensure (buffer, pre_alloc_size);
buffer->unicode = &_hb_unicode_funcs_nil;
@@ -181,6 +181,7 @@ hb_buffer_clear (hb_buffer_t *buffer)
{
buffer->have_output = FALSE;
buffer->have_positions = FALSE;
+ buffer->in_error = FALSE;
buffer->len = 0;
buffer->out_len = 0;
buffer->i = 0;
@@ -188,32 +189,42 @@ hb_buffer_clear (hb_buffer_t *buffer)
buffer->max_lig_id = 0;
}
-void
+hb_bool_t
hb_buffer_ensure (hb_buffer_t *buffer, unsigned int size)
{
- unsigned int new_allocated = buffer->allocated;
-
- if (size > new_allocated)
+ if (unlikely (size > buffer->allocated))
{
+ if (unlikely (buffer->in_error))
+ return FALSE;
+
+ unsigned int new_allocated = buffer->allocated;
+ hb_internal_glyph_position_t *new_pos;
+ hb_internal_glyph_info_t *new_info;
+ bool separate_out;
+
+ separate_out = buffer->out_info != buffer->info;
+
while (size > new_allocated)
new_allocated += (new_allocated >> 1) + 8;
- if (buffer->pos)
- buffer->pos = (hb_internal_glyph_position_t *) realloc (buffer->pos, new_allocated * sizeof (buffer->pos[0]));
+ new_pos = (hb_internal_glyph_position_t *) realloc (buffer->pos, new_allocated * sizeof (buffer->pos[0]));
+ new_info = (hb_internal_glyph_info_t *) realloc (buffer->info, new_allocated * sizeof (buffer->info[0]));
- if (buffer->out_info != buffer->info)
- {
- buffer->info = (hb_internal_glyph_info_t *) realloc (buffer->info, new_allocated * sizeof (buffer->info[0]));
- buffer->out_info = (hb_internal_glyph_info_t *) buffer->pos;
- }
- else
- {
- buffer->info = (hb_internal_glyph_info_t *) realloc (buffer->info, new_allocated * sizeof (buffer->info[0]));
- buffer->out_info = buffer->info;
- }
+ if (unlikely (!new_pos || !new_info))
+ buffer->in_error = TRUE;
- buffer->allocated = new_allocated;
+ if (likely (new_pos))
+ buffer->pos = new_pos;
+
+ if (likely (new_info))
+ buffer->info = new_info;
+
+ buffer->out_info = separate_out ? (hb_internal_glyph_info_t *) buffer->pos : buffer->info;
+ if (likely (!buffer->in_error))
+ buffer->allocated = new_allocated;
}
+
+ return likely (!buffer->in_error);
}
void
@@ -224,7 +235,7 @@ hb_buffer_add_glyph (hb_buffer_t *buffer,
{
hb_internal_glyph_info_t *glyph;
- hb_buffer_ensure (buffer, buffer->len + 1);
+ if (unlikely (!hb_buffer_ensure (buffer, buffer->len + 1))) return;
glyph = &buffer->info[buffer->len];
glyph->codepoint = codepoint;
@@ -272,6 +283,8 @@ _hb_buffer_swap (hb_buffer_t *buffer)
assert (buffer->have_output);
+ if (unlikely (buffer->in_error)) return;
+
if (buffer->out_info != buffer->info)
{
hb_internal_glyph_info_t *tmp_string;
@@ -323,7 +336,8 @@ _hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
if (buffer->out_info != buffer->info ||
buffer->out_len + num_out > buffer->i + num_in)
{
- hb_buffer_ensure_separate (buffer, buffer->out_len + num_out);
+ if (unlikely (!hb_buffer_ensure_separate (buffer, buffer->out_len + num_out)))
+ return;
}
mask = buffer->info[buffer->i].mask;
@@ -363,7 +377,8 @@ _hb_buffer_add_output_glyphs_be16 (hb_buffer_t *buffer,
if (buffer->out_info != buffer->info ||
buffer->out_len + num_out > buffer->i + num_in)
{
- hb_buffer_ensure_separate (buffer, buffer->out_len + num_out);
+ if (unlikely (!hb_buffer_ensure_separate (buffer, buffer->out_len + num_out)))
+ return;
}
mask = buffer->info[buffer->i].mask;
@@ -398,7 +413,7 @@ _hb_buffer_add_output_glyph (hb_buffer_t *buffer,
if (buffer->out_info != buffer->info)
{
- hb_buffer_ensure (buffer, buffer->out_len + 1);
+ if (unlikely (!hb_buffer_ensure (buffer, buffer->out_len + 1))) return;
buffer->out_info[buffer->out_len] = buffer->info[buffer->i];
}
else if (buffer->out_len != buffer->i)
@@ -423,7 +438,7 @@ _hb_buffer_next_glyph (hb_buffer_t *buffer)
{
if (buffer->out_info != buffer->info)
{
- hb_buffer_ensure (buffer, buffer->out_len + 1);
+ if (unlikely (!hb_buffer_ensure (buffer, buffer->out_len + 1))) return;
buffer->out_info[buffer->out_len] = buffer->info[buffer->i];
}
else if (buffer->out_len != buffer->i)
| null | null | null |
4,203
|
hb_buffer_get_unicode_funcs (hb_buffer_t *buffer)
{
return buffer->unicode;
}
|
DoS Exec Code
| 0
|
hb_buffer_get_unicode_funcs (hb_buffer_t *buffer)
{
return buffer->unicode;
}
|
@@ -54,23 +54,23 @@ static hb_buffer_t _hb_buffer_nil = {
* switches info and out_info.
*/
-/* XXX err handling */
/* Internal API */
-static void
+static hb_bool_t
hb_buffer_ensure_separate (hb_buffer_t *buffer, unsigned int size)
{
- hb_buffer_ensure (buffer, size);
+ if (unlikely (!hb_buffer_ensure (buffer, size))) return FALSE;
+
if (buffer->out_info == buffer->info)
{
assert (buffer->have_output);
- if (!buffer->pos)
- buffer->pos = (hb_internal_glyph_position_t *) calloc (buffer->allocated, sizeof (buffer->pos[0]));
buffer->out_info = (hb_internal_glyph_info_t *) buffer->pos;
memcpy (buffer->out_info, buffer->info, buffer->out_len * sizeof (buffer->out_info[0]));
}
+
+ return TRUE;
}
/* Public API */
@@ -84,7 +84,7 @@ hb_buffer_create (unsigned int pre_alloc_size)
return &_hb_buffer_nil;
if (pre_alloc_size)
- hb_buffer_ensure(buffer, pre_alloc_size);
+ hb_buffer_ensure (buffer, pre_alloc_size);
buffer->unicode = &_hb_unicode_funcs_nil;
@@ -181,6 +181,7 @@ hb_buffer_clear (hb_buffer_t *buffer)
{
buffer->have_output = FALSE;
buffer->have_positions = FALSE;
+ buffer->in_error = FALSE;
buffer->len = 0;
buffer->out_len = 0;
buffer->i = 0;
@@ -188,32 +189,42 @@ hb_buffer_clear (hb_buffer_t *buffer)
buffer->max_lig_id = 0;
}
-void
+hb_bool_t
hb_buffer_ensure (hb_buffer_t *buffer, unsigned int size)
{
- unsigned int new_allocated = buffer->allocated;
-
- if (size > new_allocated)
+ if (unlikely (size > buffer->allocated))
{
+ if (unlikely (buffer->in_error))
+ return FALSE;
+
+ unsigned int new_allocated = buffer->allocated;
+ hb_internal_glyph_position_t *new_pos;
+ hb_internal_glyph_info_t *new_info;
+ bool separate_out;
+
+ separate_out = buffer->out_info != buffer->info;
+
while (size > new_allocated)
new_allocated += (new_allocated >> 1) + 8;
- if (buffer->pos)
- buffer->pos = (hb_internal_glyph_position_t *) realloc (buffer->pos, new_allocated * sizeof (buffer->pos[0]));
+ new_pos = (hb_internal_glyph_position_t *) realloc (buffer->pos, new_allocated * sizeof (buffer->pos[0]));
+ new_info = (hb_internal_glyph_info_t *) realloc (buffer->info, new_allocated * sizeof (buffer->info[0]));
- if (buffer->out_info != buffer->info)
- {
- buffer->info = (hb_internal_glyph_info_t *) realloc (buffer->info, new_allocated * sizeof (buffer->info[0]));
- buffer->out_info = (hb_internal_glyph_info_t *) buffer->pos;
- }
- else
- {
- buffer->info = (hb_internal_glyph_info_t *) realloc (buffer->info, new_allocated * sizeof (buffer->info[0]));
- buffer->out_info = buffer->info;
- }
+ if (unlikely (!new_pos || !new_info))
+ buffer->in_error = TRUE;
- buffer->allocated = new_allocated;
+ if (likely (new_pos))
+ buffer->pos = new_pos;
+
+ if (likely (new_info))
+ buffer->info = new_info;
+
+ buffer->out_info = separate_out ? (hb_internal_glyph_info_t *) buffer->pos : buffer->info;
+ if (likely (!buffer->in_error))
+ buffer->allocated = new_allocated;
}
+
+ return likely (!buffer->in_error);
}
void
@@ -224,7 +235,7 @@ hb_buffer_add_glyph (hb_buffer_t *buffer,
{
hb_internal_glyph_info_t *glyph;
- hb_buffer_ensure (buffer, buffer->len + 1);
+ if (unlikely (!hb_buffer_ensure (buffer, buffer->len + 1))) return;
glyph = &buffer->info[buffer->len];
glyph->codepoint = codepoint;
@@ -272,6 +283,8 @@ _hb_buffer_swap (hb_buffer_t *buffer)
assert (buffer->have_output);
+ if (unlikely (buffer->in_error)) return;
+
if (buffer->out_info != buffer->info)
{
hb_internal_glyph_info_t *tmp_string;
@@ -323,7 +336,8 @@ _hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
if (buffer->out_info != buffer->info ||
buffer->out_len + num_out > buffer->i + num_in)
{
- hb_buffer_ensure_separate (buffer, buffer->out_len + num_out);
+ if (unlikely (!hb_buffer_ensure_separate (buffer, buffer->out_len + num_out)))
+ return;
}
mask = buffer->info[buffer->i].mask;
@@ -363,7 +377,8 @@ _hb_buffer_add_output_glyphs_be16 (hb_buffer_t *buffer,
if (buffer->out_info != buffer->info ||
buffer->out_len + num_out > buffer->i + num_in)
{
- hb_buffer_ensure_separate (buffer, buffer->out_len + num_out);
+ if (unlikely (!hb_buffer_ensure_separate (buffer, buffer->out_len + num_out)))
+ return;
}
mask = buffer->info[buffer->i].mask;
@@ -398,7 +413,7 @@ _hb_buffer_add_output_glyph (hb_buffer_t *buffer,
if (buffer->out_info != buffer->info)
{
- hb_buffer_ensure (buffer, buffer->out_len + 1);
+ if (unlikely (!hb_buffer_ensure (buffer, buffer->out_len + 1))) return;
buffer->out_info[buffer->out_len] = buffer->info[buffer->i];
}
else if (buffer->out_len != buffer->i)
@@ -423,7 +438,7 @@ _hb_buffer_next_glyph (hb_buffer_t *buffer)
{
if (buffer->out_info != buffer->info)
{
- hb_buffer_ensure (buffer, buffer->out_len + 1);
+ if (unlikely (!hb_buffer_ensure (buffer, buffer->out_len + 1))) return;
buffer->out_info[buffer->out_len] = buffer->info[buffer->i];
}
else if (buffer->out_len != buffer->i)
| null | null | null |
4,204
|
hb_buffer_reference (hb_buffer_t *buffer)
{
HB_OBJECT_DO_REFERENCE (buffer);
}
|
DoS Exec Code
| 0
|
hb_buffer_reference (hb_buffer_t *buffer)
{
HB_OBJECT_DO_REFERENCE (buffer);
}
|
@@ -54,23 +54,23 @@ static hb_buffer_t _hb_buffer_nil = {
* switches info and out_info.
*/
-/* XXX err handling */
/* Internal API */
-static void
+static hb_bool_t
hb_buffer_ensure_separate (hb_buffer_t *buffer, unsigned int size)
{
- hb_buffer_ensure (buffer, size);
+ if (unlikely (!hb_buffer_ensure (buffer, size))) return FALSE;
+
if (buffer->out_info == buffer->info)
{
assert (buffer->have_output);
- if (!buffer->pos)
- buffer->pos = (hb_internal_glyph_position_t *) calloc (buffer->allocated, sizeof (buffer->pos[0]));
buffer->out_info = (hb_internal_glyph_info_t *) buffer->pos;
memcpy (buffer->out_info, buffer->info, buffer->out_len * sizeof (buffer->out_info[0]));
}
+
+ return TRUE;
}
/* Public API */
@@ -84,7 +84,7 @@ hb_buffer_create (unsigned int pre_alloc_size)
return &_hb_buffer_nil;
if (pre_alloc_size)
- hb_buffer_ensure(buffer, pre_alloc_size);
+ hb_buffer_ensure (buffer, pre_alloc_size);
buffer->unicode = &_hb_unicode_funcs_nil;
@@ -181,6 +181,7 @@ hb_buffer_clear (hb_buffer_t *buffer)
{
buffer->have_output = FALSE;
buffer->have_positions = FALSE;
+ buffer->in_error = FALSE;
buffer->len = 0;
buffer->out_len = 0;
buffer->i = 0;
@@ -188,32 +189,42 @@ hb_buffer_clear (hb_buffer_t *buffer)
buffer->max_lig_id = 0;
}
-void
+hb_bool_t
hb_buffer_ensure (hb_buffer_t *buffer, unsigned int size)
{
- unsigned int new_allocated = buffer->allocated;
-
- if (size > new_allocated)
+ if (unlikely (size > buffer->allocated))
{
+ if (unlikely (buffer->in_error))
+ return FALSE;
+
+ unsigned int new_allocated = buffer->allocated;
+ hb_internal_glyph_position_t *new_pos;
+ hb_internal_glyph_info_t *new_info;
+ bool separate_out;
+
+ separate_out = buffer->out_info != buffer->info;
+
while (size > new_allocated)
new_allocated += (new_allocated >> 1) + 8;
- if (buffer->pos)
- buffer->pos = (hb_internal_glyph_position_t *) realloc (buffer->pos, new_allocated * sizeof (buffer->pos[0]));
+ new_pos = (hb_internal_glyph_position_t *) realloc (buffer->pos, new_allocated * sizeof (buffer->pos[0]));
+ new_info = (hb_internal_glyph_info_t *) realloc (buffer->info, new_allocated * sizeof (buffer->info[0]));
- if (buffer->out_info != buffer->info)
- {
- buffer->info = (hb_internal_glyph_info_t *) realloc (buffer->info, new_allocated * sizeof (buffer->info[0]));
- buffer->out_info = (hb_internal_glyph_info_t *) buffer->pos;
- }
- else
- {
- buffer->info = (hb_internal_glyph_info_t *) realloc (buffer->info, new_allocated * sizeof (buffer->info[0]));
- buffer->out_info = buffer->info;
- }
+ if (unlikely (!new_pos || !new_info))
+ buffer->in_error = TRUE;
- buffer->allocated = new_allocated;
+ if (likely (new_pos))
+ buffer->pos = new_pos;
+
+ if (likely (new_info))
+ buffer->info = new_info;
+
+ buffer->out_info = separate_out ? (hb_internal_glyph_info_t *) buffer->pos : buffer->info;
+ if (likely (!buffer->in_error))
+ buffer->allocated = new_allocated;
}
+
+ return likely (!buffer->in_error);
}
void
@@ -224,7 +235,7 @@ hb_buffer_add_glyph (hb_buffer_t *buffer,
{
hb_internal_glyph_info_t *glyph;
- hb_buffer_ensure (buffer, buffer->len + 1);
+ if (unlikely (!hb_buffer_ensure (buffer, buffer->len + 1))) return;
glyph = &buffer->info[buffer->len];
glyph->codepoint = codepoint;
@@ -272,6 +283,8 @@ _hb_buffer_swap (hb_buffer_t *buffer)
assert (buffer->have_output);
+ if (unlikely (buffer->in_error)) return;
+
if (buffer->out_info != buffer->info)
{
hb_internal_glyph_info_t *tmp_string;
@@ -323,7 +336,8 @@ _hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
if (buffer->out_info != buffer->info ||
buffer->out_len + num_out > buffer->i + num_in)
{
- hb_buffer_ensure_separate (buffer, buffer->out_len + num_out);
+ if (unlikely (!hb_buffer_ensure_separate (buffer, buffer->out_len + num_out)))
+ return;
}
mask = buffer->info[buffer->i].mask;
@@ -363,7 +377,8 @@ _hb_buffer_add_output_glyphs_be16 (hb_buffer_t *buffer,
if (buffer->out_info != buffer->info ||
buffer->out_len + num_out > buffer->i + num_in)
{
- hb_buffer_ensure_separate (buffer, buffer->out_len + num_out);
+ if (unlikely (!hb_buffer_ensure_separate (buffer, buffer->out_len + num_out)))
+ return;
}
mask = buffer->info[buffer->i].mask;
@@ -398,7 +413,7 @@ _hb_buffer_add_output_glyph (hb_buffer_t *buffer,
if (buffer->out_info != buffer->info)
{
- hb_buffer_ensure (buffer, buffer->out_len + 1);
+ if (unlikely (!hb_buffer_ensure (buffer, buffer->out_len + 1))) return;
buffer->out_info[buffer->out_len] = buffer->info[buffer->i];
}
else if (buffer->out_len != buffer->i)
@@ -423,7 +438,7 @@ _hb_buffer_next_glyph (hb_buffer_t *buffer)
{
if (buffer->out_info != buffer->info)
{
- hb_buffer_ensure (buffer, buffer->out_len + 1);
+ if (unlikely (!hb_buffer_ensure (buffer, buffer->out_len + 1))) return;
buffer->out_info[buffer->out_len] = buffer->info[buffer->i];
}
else if (buffer->out_len != buffer->i)
| null | null | null |
4,205
|
hb_buffer_set_direction (hb_buffer_t *buffer,
hb_direction_t direction)
{
buffer->direction = direction;
}
|
DoS Exec Code
| 0
|
hb_buffer_set_direction (hb_buffer_t *buffer,
hb_direction_t direction)
{
buffer->direction = direction;
}
|
@@ -54,23 +54,23 @@ static hb_buffer_t _hb_buffer_nil = {
* switches info and out_info.
*/
-/* XXX err handling */
/* Internal API */
-static void
+static hb_bool_t
hb_buffer_ensure_separate (hb_buffer_t *buffer, unsigned int size)
{
- hb_buffer_ensure (buffer, size);
+ if (unlikely (!hb_buffer_ensure (buffer, size))) return FALSE;
+
if (buffer->out_info == buffer->info)
{
assert (buffer->have_output);
- if (!buffer->pos)
- buffer->pos = (hb_internal_glyph_position_t *) calloc (buffer->allocated, sizeof (buffer->pos[0]));
buffer->out_info = (hb_internal_glyph_info_t *) buffer->pos;
memcpy (buffer->out_info, buffer->info, buffer->out_len * sizeof (buffer->out_info[0]));
}
+
+ return TRUE;
}
/* Public API */
@@ -84,7 +84,7 @@ hb_buffer_create (unsigned int pre_alloc_size)
return &_hb_buffer_nil;
if (pre_alloc_size)
- hb_buffer_ensure(buffer, pre_alloc_size);
+ hb_buffer_ensure (buffer, pre_alloc_size);
buffer->unicode = &_hb_unicode_funcs_nil;
@@ -181,6 +181,7 @@ hb_buffer_clear (hb_buffer_t *buffer)
{
buffer->have_output = FALSE;
buffer->have_positions = FALSE;
+ buffer->in_error = FALSE;
buffer->len = 0;
buffer->out_len = 0;
buffer->i = 0;
@@ -188,32 +189,42 @@ hb_buffer_clear (hb_buffer_t *buffer)
buffer->max_lig_id = 0;
}
-void
+hb_bool_t
hb_buffer_ensure (hb_buffer_t *buffer, unsigned int size)
{
- unsigned int new_allocated = buffer->allocated;
-
- if (size > new_allocated)
+ if (unlikely (size > buffer->allocated))
{
+ if (unlikely (buffer->in_error))
+ return FALSE;
+
+ unsigned int new_allocated = buffer->allocated;
+ hb_internal_glyph_position_t *new_pos;
+ hb_internal_glyph_info_t *new_info;
+ bool separate_out;
+
+ separate_out = buffer->out_info != buffer->info;
+
while (size > new_allocated)
new_allocated += (new_allocated >> 1) + 8;
- if (buffer->pos)
- buffer->pos = (hb_internal_glyph_position_t *) realloc (buffer->pos, new_allocated * sizeof (buffer->pos[0]));
+ new_pos = (hb_internal_glyph_position_t *) realloc (buffer->pos, new_allocated * sizeof (buffer->pos[0]));
+ new_info = (hb_internal_glyph_info_t *) realloc (buffer->info, new_allocated * sizeof (buffer->info[0]));
- if (buffer->out_info != buffer->info)
- {
- buffer->info = (hb_internal_glyph_info_t *) realloc (buffer->info, new_allocated * sizeof (buffer->info[0]));
- buffer->out_info = (hb_internal_glyph_info_t *) buffer->pos;
- }
- else
- {
- buffer->info = (hb_internal_glyph_info_t *) realloc (buffer->info, new_allocated * sizeof (buffer->info[0]));
- buffer->out_info = buffer->info;
- }
+ if (unlikely (!new_pos || !new_info))
+ buffer->in_error = TRUE;
- buffer->allocated = new_allocated;
+ if (likely (new_pos))
+ buffer->pos = new_pos;
+
+ if (likely (new_info))
+ buffer->info = new_info;
+
+ buffer->out_info = separate_out ? (hb_internal_glyph_info_t *) buffer->pos : buffer->info;
+ if (likely (!buffer->in_error))
+ buffer->allocated = new_allocated;
}
+
+ return likely (!buffer->in_error);
}
void
@@ -224,7 +235,7 @@ hb_buffer_add_glyph (hb_buffer_t *buffer,
{
hb_internal_glyph_info_t *glyph;
- hb_buffer_ensure (buffer, buffer->len + 1);
+ if (unlikely (!hb_buffer_ensure (buffer, buffer->len + 1))) return;
glyph = &buffer->info[buffer->len];
glyph->codepoint = codepoint;
@@ -272,6 +283,8 @@ _hb_buffer_swap (hb_buffer_t *buffer)
assert (buffer->have_output);
+ if (unlikely (buffer->in_error)) return;
+
if (buffer->out_info != buffer->info)
{
hb_internal_glyph_info_t *tmp_string;
@@ -323,7 +336,8 @@ _hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
if (buffer->out_info != buffer->info ||
buffer->out_len + num_out > buffer->i + num_in)
{
- hb_buffer_ensure_separate (buffer, buffer->out_len + num_out);
+ if (unlikely (!hb_buffer_ensure_separate (buffer, buffer->out_len + num_out)))
+ return;
}
mask = buffer->info[buffer->i].mask;
@@ -363,7 +377,8 @@ _hb_buffer_add_output_glyphs_be16 (hb_buffer_t *buffer,
if (buffer->out_info != buffer->info ||
buffer->out_len + num_out > buffer->i + num_in)
{
- hb_buffer_ensure_separate (buffer, buffer->out_len + num_out);
+ if (unlikely (!hb_buffer_ensure_separate (buffer, buffer->out_len + num_out)))
+ return;
}
mask = buffer->info[buffer->i].mask;
@@ -398,7 +413,7 @@ _hb_buffer_add_output_glyph (hb_buffer_t *buffer,
if (buffer->out_info != buffer->info)
{
- hb_buffer_ensure (buffer, buffer->out_len + 1);
+ if (unlikely (!hb_buffer_ensure (buffer, buffer->out_len + 1))) return;
buffer->out_info[buffer->out_len] = buffer->info[buffer->i];
}
else if (buffer->out_len != buffer->i)
@@ -423,7 +438,7 @@ _hb_buffer_next_glyph (hb_buffer_t *buffer)
{
if (buffer->out_info != buffer->info)
{
- hb_buffer_ensure (buffer, buffer->out_len + 1);
+ if (unlikely (!hb_buffer_ensure (buffer, buffer->out_len + 1))) return;
buffer->out_info[buffer->out_len] = buffer->info[buffer->i];
}
else if (buffer->out_len != buffer->i)
| null | null | null |
4,206
|
hb_buffer_set_script (hb_buffer_t *buffer,
hb_script_t script)
{
buffer->script = script;
}
|
DoS Exec Code
| 0
|
hb_buffer_set_script (hb_buffer_t *buffer,
hb_script_t script)
{
buffer->script = script;
}
|
@@ -54,23 +54,23 @@ static hb_buffer_t _hb_buffer_nil = {
* switches info and out_info.
*/
-/* XXX err handling */
/* Internal API */
-static void
+static hb_bool_t
hb_buffer_ensure_separate (hb_buffer_t *buffer, unsigned int size)
{
- hb_buffer_ensure (buffer, size);
+ if (unlikely (!hb_buffer_ensure (buffer, size))) return FALSE;
+
if (buffer->out_info == buffer->info)
{
assert (buffer->have_output);
- if (!buffer->pos)
- buffer->pos = (hb_internal_glyph_position_t *) calloc (buffer->allocated, sizeof (buffer->pos[0]));
buffer->out_info = (hb_internal_glyph_info_t *) buffer->pos;
memcpy (buffer->out_info, buffer->info, buffer->out_len * sizeof (buffer->out_info[0]));
}
+
+ return TRUE;
}
/* Public API */
@@ -84,7 +84,7 @@ hb_buffer_create (unsigned int pre_alloc_size)
return &_hb_buffer_nil;
if (pre_alloc_size)
- hb_buffer_ensure(buffer, pre_alloc_size);
+ hb_buffer_ensure (buffer, pre_alloc_size);
buffer->unicode = &_hb_unicode_funcs_nil;
@@ -181,6 +181,7 @@ hb_buffer_clear (hb_buffer_t *buffer)
{
buffer->have_output = FALSE;
buffer->have_positions = FALSE;
+ buffer->in_error = FALSE;
buffer->len = 0;
buffer->out_len = 0;
buffer->i = 0;
@@ -188,32 +189,42 @@ hb_buffer_clear (hb_buffer_t *buffer)
buffer->max_lig_id = 0;
}
-void
+hb_bool_t
hb_buffer_ensure (hb_buffer_t *buffer, unsigned int size)
{
- unsigned int new_allocated = buffer->allocated;
-
- if (size > new_allocated)
+ if (unlikely (size > buffer->allocated))
{
+ if (unlikely (buffer->in_error))
+ return FALSE;
+
+ unsigned int new_allocated = buffer->allocated;
+ hb_internal_glyph_position_t *new_pos;
+ hb_internal_glyph_info_t *new_info;
+ bool separate_out;
+
+ separate_out = buffer->out_info != buffer->info;
+
while (size > new_allocated)
new_allocated += (new_allocated >> 1) + 8;
- if (buffer->pos)
- buffer->pos = (hb_internal_glyph_position_t *) realloc (buffer->pos, new_allocated * sizeof (buffer->pos[0]));
+ new_pos = (hb_internal_glyph_position_t *) realloc (buffer->pos, new_allocated * sizeof (buffer->pos[0]));
+ new_info = (hb_internal_glyph_info_t *) realloc (buffer->info, new_allocated * sizeof (buffer->info[0]));
- if (buffer->out_info != buffer->info)
- {
- buffer->info = (hb_internal_glyph_info_t *) realloc (buffer->info, new_allocated * sizeof (buffer->info[0]));
- buffer->out_info = (hb_internal_glyph_info_t *) buffer->pos;
- }
- else
- {
- buffer->info = (hb_internal_glyph_info_t *) realloc (buffer->info, new_allocated * sizeof (buffer->info[0]));
- buffer->out_info = buffer->info;
- }
+ if (unlikely (!new_pos || !new_info))
+ buffer->in_error = TRUE;
- buffer->allocated = new_allocated;
+ if (likely (new_pos))
+ buffer->pos = new_pos;
+
+ if (likely (new_info))
+ buffer->info = new_info;
+
+ buffer->out_info = separate_out ? (hb_internal_glyph_info_t *) buffer->pos : buffer->info;
+ if (likely (!buffer->in_error))
+ buffer->allocated = new_allocated;
}
+
+ return likely (!buffer->in_error);
}
void
@@ -224,7 +235,7 @@ hb_buffer_add_glyph (hb_buffer_t *buffer,
{
hb_internal_glyph_info_t *glyph;
- hb_buffer_ensure (buffer, buffer->len + 1);
+ if (unlikely (!hb_buffer_ensure (buffer, buffer->len + 1))) return;
glyph = &buffer->info[buffer->len];
glyph->codepoint = codepoint;
@@ -272,6 +283,8 @@ _hb_buffer_swap (hb_buffer_t *buffer)
assert (buffer->have_output);
+ if (unlikely (buffer->in_error)) return;
+
if (buffer->out_info != buffer->info)
{
hb_internal_glyph_info_t *tmp_string;
@@ -323,7 +336,8 @@ _hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
if (buffer->out_info != buffer->info ||
buffer->out_len + num_out > buffer->i + num_in)
{
- hb_buffer_ensure_separate (buffer, buffer->out_len + num_out);
+ if (unlikely (!hb_buffer_ensure_separate (buffer, buffer->out_len + num_out)))
+ return;
}
mask = buffer->info[buffer->i].mask;
@@ -363,7 +377,8 @@ _hb_buffer_add_output_glyphs_be16 (hb_buffer_t *buffer,
if (buffer->out_info != buffer->info ||
buffer->out_len + num_out > buffer->i + num_in)
{
- hb_buffer_ensure_separate (buffer, buffer->out_len + num_out);
+ if (unlikely (!hb_buffer_ensure_separate (buffer, buffer->out_len + num_out)))
+ return;
}
mask = buffer->info[buffer->i].mask;
@@ -398,7 +413,7 @@ _hb_buffer_add_output_glyph (hb_buffer_t *buffer,
if (buffer->out_info != buffer->info)
{
- hb_buffer_ensure (buffer, buffer->out_len + 1);
+ if (unlikely (!hb_buffer_ensure (buffer, buffer->out_len + 1))) return;
buffer->out_info[buffer->out_len] = buffer->info[buffer->i];
}
else if (buffer->out_len != buffer->i)
@@ -423,7 +438,7 @@ _hb_buffer_next_glyph (hb_buffer_t *buffer)
{
if (buffer->out_info != buffer->info)
{
- hb_buffer_ensure (buffer, buffer->out_len + 1);
+ if (unlikely (!hb_buffer_ensure (buffer, buffer->out_len + 1))) return;
buffer->out_info[buffer->out_len] = buffer->info[buffer->i];
}
else if (buffer->out_len != buffer->i)
| null | null | null |
4,207
|
hb_buffer_set_unicode_funcs (hb_buffer_t *buffer,
hb_unicode_funcs_t *unicode)
{
if (!unicode)
unicode = &_hb_unicode_funcs_nil;
hb_unicode_funcs_reference (unicode);
hb_unicode_funcs_destroy (buffer->unicode);
buffer->unicode = unicode;
}
|
DoS Exec Code
| 0
|
hb_buffer_set_unicode_funcs (hb_buffer_t *buffer,
hb_unicode_funcs_t *unicode)
{
if (!unicode)
unicode = &_hb_unicode_funcs_nil;
hb_unicode_funcs_reference (unicode);
hb_unicode_funcs_destroy (buffer->unicode);
buffer->unicode = unicode;
}
|
@@ -54,23 +54,23 @@ static hb_buffer_t _hb_buffer_nil = {
* switches info and out_info.
*/
-/* XXX err handling */
/* Internal API */
-static void
+static hb_bool_t
hb_buffer_ensure_separate (hb_buffer_t *buffer, unsigned int size)
{
- hb_buffer_ensure (buffer, size);
+ if (unlikely (!hb_buffer_ensure (buffer, size))) return FALSE;
+
if (buffer->out_info == buffer->info)
{
assert (buffer->have_output);
- if (!buffer->pos)
- buffer->pos = (hb_internal_glyph_position_t *) calloc (buffer->allocated, sizeof (buffer->pos[0]));
buffer->out_info = (hb_internal_glyph_info_t *) buffer->pos;
memcpy (buffer->out_info, buffer->info, buffer->out_len * sizeof (buffer->out_info[0]));
}
+
+ return TRUE;
}
/* Public API */
@@ -84,7 +84,7 @@ hb_buffer_create (unsigned int pre_alloc_size)
return &_hb_buffer_nil;
if (pre_alloc_size)
- hb_buffer_ensure(buffer, pre_alloc_size);
+ hb_buffer_ensure (buffer, pre_alloc_size);
buffer->unicode = &_hb_unicode_funcs_nil;
@@ -181,6 +181,7 @@ hb_buffer_clear (hb_buffer_t *buffer)
{
buffer->have_output = FALSE;
buffer->have_positions = FALSE;
+ buffer->in_error = FALSE;
buffer->len = 0;
buffer->out_len = 0;
buffer->i = 0;
@@ -188,32 +189,42 @@ hb_buffer_clear (hb_buffer_t *buffer)
buffer->max_lig_id = 0;
}
-void
+hb_bool_t
hb_buffer_ensure (hb_buffer_t *buffer, unsigned int size)
{
- unsigned int new_allocated = buffer->allocated;
-
- if (size > new_allocated)
+ if (unlikely (size > buffer->allocated))
{
+ if (unlikely (buffer->in_error))
+ return FALSE;
+
+ unsigned int new_allocated = buffer->allocated;
+ hb_internal_glyph_position_t *new_pos;
+ hb_internal_glyph_info_t *new_info;
+ bool separate_out;
+
+ separate_out = buffer->out_info != buffer->info;
+
while (size > new_allocated)
new_allocated += (new_allocated >> 1) + 8;
- if (buffer->pos)
- buffer->pos = (hb_internal_glyph_position_t *) realloc (buffer->pos, new_allocated * sizeof (buffer->pos[0]));
+ new_pos = (hb_internal_glyph_position_t *) realloc (buffer->pos, new_allocated * sizeof (buffer->pos[0]));
+ new_info = (hb_internal_glyph_info_t *) realloc (buffer->info, new_allocated * sizeof (buffer->info[0]));
- if (buffer->out_info != buffer->info)
- {
- buffer->info = (hb_internal_glyph_info_t *) realloc (buffer->info, new_allocated * sizeof (buffer->info[0]));
- buffer->out_info = (hb_internal_glyph_info_t *) buffer->pos;
- }
- else
- {
- buffer->info = (hb_internal_glyph_info_t *) realloc (buffer->info, new_allocated * sizeof (buffer->info[0]));
- buffer->out_info = buffer->info;
- }
+ if (unlikely (!new_pos || !new_info))
+ buffer->in_error = TRUE;
- buffer->allocated = new_allocated;
+ if (likely (new_pos))
+ buffer->pos = new_pos;
+
+ if (likely (new_info))
+ buffer->info = new_info;
+
+ buffer->out_info = separate_out ? (hb_internal_glyph_info_t *) buffer->pos : buffer->info;
+ if (likely (!buffer->in_error))
+ buffer->allocated = new_allocated;
}
+
+ return likely (!buffer->in_error);
}
void
@@ -224,7 +235,7 @@ hb_buffer_add_glyph (hb_buffer_t *buffer,
{
hb_internal_glyph_info_t *glyph;
- hb_buffer_ensure (buffer, buffer->len + 1);
+ if (unlikely (!hb_buffer_ensure (buffer, buffer->len + 1))) return;
glyph = &buffer->info[buffer->len];
glyph->codepoint = codepoint;
@@ -272,6 +283,8 @@ _hb_buffer_swap (hb_buffer_t *buffer)
assert (buffer->have_output);
+ if (unlikely (buffer->in_error)) return;
+
if (buffer->out_info != buffer->info)
{
hb_internal_glyph_info_t *tmp_string;
@@ -323,7 +336,8 @@ _hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
if (buffer->out_info != buffer->info ||
buffer->out_len + num_out > buffer->i + num_in)
{
- hb_buffer_ensure_separate (buffer, buffer->out_len + num_out);
+ if (unlikely (!hb_buffer_ensure_separate (buffer, buffer->out_len + num_out)))
+ return;
}
mask = buffer->info[buffer->i].mask;
@@ -363,7 +377,8 @@ _hb_buffer_add_output_glyphs_be16 (hb_buffer_t *buffer,
if (buffer->out_info != buffer->info ||
buffer->out_len + num_out > buffer->i + num_in)
{
- hb_buffer_ensure_separate (buffer, buffer->out_len + num_out);
+ if (unlikely (!hb_buffer_ensure_separate (buffer, buffer->out_len + num_out)))
+ return;
}
mask = buffer->info[buffer->i].mask;
@@ -398,7 +413,7 @@ _hb_buffer_add_output_glyph (hb_buffer_t *buffer,
if (buffer->out_info != buffer->info)
{
- hb_buffer_ensure (buffer, buffer->out_len + 1);
+ if (unlikely (!hb_buffer_ensure (buffer, buffer->out_len + 1))) return;
buffer->out_info[buffer->out_len] = buffer->info[buffer->i];
}
else if (buffer->out_len != buffer->i)
@@ -423,7 +438,7 @@ _hb_buffer_next_glyph (hb_buffer_t *buffer)
{
if (buffer->out_info != buffer->info)
{
- hb_buffer_ensure (buffer, buffer->out_len + 1);
+ if (unlikely (!hb_buffer_ensure (buffer, buffer->out_len + 1))) return;
buffer->out_info[buffer->out_len] = buffer->info[buffer->i];
}
else if (buffer->out_len != buffer->i)
| null | null | null |
4,208
|
check_sparse_region (struct tar_sparse_file *file, off_t beg, off_t end)
{
if (!lseek_or_error (file, beg))
return false;
while (beg < end)
{
size_t bytes_read;
size_t rdsize = BLOCKSIZE < end - beg ? BLOCKSIZE : end - beg;
char diff_buffer[BLOCKSIZE];
bytes_read = safe_read (file->fd, diff_buffer, rdsize);
if (bytes_read == SAFE_READ_ERROR)
{
read_diag_details (file->stat_info->orig_file_name,
beg,
rdsize);
return false;
}
else if (bytes_read == 0)
{
report_difference (file->stat_info, _("Size differs"));
return false;
}
if (!zero_block_p (diff_buffer, bytes_read))
{
char begbuf[INT_BUFSIZE_BOUND (off_t)];
report_difference (file->stat_info,
_("File fragment at %s is not a hole"),
offtostr (beg, begbuf));
return false;
}
beg += bytes_read;
}
return true;
}
| null | 0
|
check_sparse_region (struct tar_sparse_file *file, off_t beg, off_t end)
{
if (!lseek_or_error (file, beg))
return false;
while (beg < end)
{
size_t bytes_read;
size_t rdsize = BLOCKSIZE < end - beg ? BLOCKSIZE : end - beg;
char diff_buffer[BLOCKSIZE];
bytes_read = safe_read (file->fd, diff_buffer, rdsize);
if (bytes_read == SAFE_READ_ERROR)
{
read_diag_details (file->stat_info->orig_file_name,
beg,
rdsize);
return false;
}
else if (bytes_read == 0)
{
report_difference (file->stat_info, _("Size differs"));
return false;
}
if (!zero_block_p (diff_buffer, bytes_read))
{
char begbuf[INT_BUFSIZE_BOUND (off_t)];
report_difference (file->stat_info,
_("File fragment at %s is not a hole"),
offtostr (beg, begbuf));
return false;
}
beg += bytes_read;
}
return true;
}
|
@@ -1267,6 +1267,8 @@ pax_decode_header (struct tar_sparse_file *file)
{ \
set_next_block_after (b); \
b = find_next_block (); \
+ if (!b) \
+ FATAL_ERROR ((0, 0, _("Unexpected EOF in archive"))); \
src = b->buffer; \
endp = b->buffer + BLOCKSIZE; \
} \
@@ -1279,6 +1281,8 @@ pax_decode_header (struct tar_sparse_file *file)
start = current_block_ordinal ();
set_next_block_after (current_header);
blk = find_next_block ();
+ if (!blk)
+ FATAL_ERROR ((0, 0, _("Unexpected EOF in archive")));
p = blk->buffer;
COPY_BUF (blk,nbuf,p);
if (!decode_num (&u, nbuf, TYPE_MAXIMUM (size_t)))
|
CWE-476
| null | null |
4,209
|
decode_num (uintmax_t *num, char const *arg, uintmax_t maxval)
{
uintmax_t u;
char *arg_lim;
if (!ISDIGIT (*arg))
return false;
errno = 0;
u = strtoumax (arg, &arg_lim, 10);
if (! (u <= maxval && errno != ERANGE) || *arg_lim)
return false;
*num = u;
return true;
}
| null | 0
|
decode_num (uintmax_t *num, char const *arg, uintmax_t maxval)
{
uintmax_t u;
char *arg_lim;
if (!ISDIGIT (*arg))
return false;
errno = 0;
u = strtoumax (arg, &arg_lim, 10);
if (! (u <= maxval && errno != ERANGE) || *arg_lim)
return false;
*num = u;
return true;
}
|
@@ -1267,6 +1267,8 @@ pax_decode_header (struct tar_sparse_file *file)
{ \
set_next_block_after (b); \
b = find_next_block (); \
+ if (!b) \
+ FATAL_ERROR ((0, 0, _("Unexpected EOF in archive"))); \
src = b->buffer; \
endp = b->buffer + BLOCKSIZE; \
} \
@@ -1279,6 +1281,8 @@ pax_decode_header (struct tar_sparse_file *file)
start = current_block_ordinal ();
set_next_block_after (current_header);
blk = find_next_block ();
+ if (!blk)
+ FATAL_ERROR ((0, 0, _("Unexpected EOF in archive")));
p = blk->buffer;
COPY_BUF (blk,nbuf,p);
if (!decode_num (&u, nbuf, TYPE_MAXIMUM (size_t)))
|
CWE-476
| null | null |
4,210
|
oldgnu_add_sparse (struct tar_sparse_file *file, struct sparse *s)
{
struct sp_array sp;
if (s->numbytes[0] == '\0')
return add_finish;
sp.offset = OFF_FROM_HEADER (s->offset);
sp.numbytes = OFF_FROM_HEADER (s->numbytes);
if (sp.offset < 0 || sp.numbytes < 0
|| INT_ADD_OVERFLOW (sp.offset, sp.numbytes)
|| file->stat_info->stat.st_size < sp.offset + sp.numbytes
|| file->stat_info->archive_file_size < 0)
return add_fail;
sparse_add_map (file->stat_info, &sp);
return add_ok;
}
| null | 0
|
oldgnu_add_sparse (struct tar_sparse_file *file, struct sparse *s)
{
struct sp_array sp;
if (s->numbytes[0] == '\0')
return add_finish;
sp.offset = OFF_FROM_HEADER (s->offset);
sp.numbytes = OFF_FROM_HEADER (s->numbytes);
if (sp.offset < 0 || sp.numbytes < 0
|| INT_ADD_OVERFLOW (sp.offset, sp.numbytes)
|| file->stat_info->stat.st_size < sp.offset + sp.numbytes
|| file->stat_info->archive_file_size < 0)
return add_fail;
sparse_add_map (file->stat_info, &sp);
return add_ok;
}
|
@@ -1267,6 +1267,8 @@ pax_decode_header (struct tar_sparse_file *file)
{ \
set_next_block_after (b); \
b = find_next_block (); \
+ if (!b) \
+ FATAL_ERROR ((0, 0, _("Unexpected EOF in archive"))); \
src = b->buffer; \
endp = b->buffer + BLOCKSIZE; \
} \
@@ -1279,6 +1281,8 @@ pax_decode_header (struct tar_sparse_file *file)
start = current_block_ordinal ();
set_next_block_after (current_header);
blk = find_next_block ();
+ if (!blk)
+ FATAL_ERROR ((0, 0, _("Unexpected EOF in archive")));
p = blk->buffer;
COPY_BUF (blk,nbuf,p);
if (!decode_num (&u, nbuf, TYPE_MAXIMUM (size_t)))
|
CWE-476
| null | null |
4,211
|
oldgnu_dump_header (struct tar_sparse_file *file)
{
off_t block_ordinal = current_block_ordinal ();
union block *blk;
size_t i;
blk = start_header (file->stat_info);
blk->header.typeflag = GNUTYPE_SPARSE;
if (file->stat_info->sparse_map_avail > SPARSES_IN_OLDGNU_HEADER)
blk->oldgnu_header.isextended = 1;
/* Store the real file size */
OFF_TO_CHARS (file->stat_info->stat.st_size, blk->oldgnu_header.realsize);
/* Store the effective (shrunken) file size */
OFF_TO_CHARS (file->stat_info->archive_file_size, blk->header.size);
i = 0;
oldgnu_store_sparse_info (file, &i,
blk->oldgnu_header.sp,
SPARSES_IN_OLDGNU_HEADER);
blk->oldgnu_header.isextended = i < file->stat_info->sparse_map_avail;
finish_header (file->stat_info, blk, block_ordinal);
while (i < file->stat_info->sparse_map_avail)
{
blk = find_next_block ();
memset (blk->buffer, 0, BLOCKSIZE);
oldgnu_store_sparse_info (file, &i,
blk->sparse_header.sp,
SPARSES_IN_SPARSE_HEADER);
if (i < file->stat_info->sparse_map_avail)
blk->sparse_header.isextended = 1;
set_next_block_after (blk);
}
return true;
}
| null | 0
|
oldgnu_dump_header (struct tar_sparse_file *file)
{
off_t block_ordinal = current_block_ordinal ();
union block *blk;
size_t i;
blk = start_header (file->stat_info);
blk->header.typeflag = GNUTYPE_SPARSE;
if (file->stat_info->sparse_map_avail > SPARSES_IN_OLDGNU_HEADER)
blk->oldgnu_header.isextended = 1;
/* Store the real file size */
OFF_TO_CHARS (file->stat_info->stat.st_size, blk->oldgnu_header.realsize);
/* Store the effective (shrunken) file size */
OFF_TO_CHARS (file->stat_info->archive_file_size, blk->header.size);
i = 0;
oldgnu_store_sparse_info (file, &i,
blk->oldgnu_header.sp,
SPARSES_IN_OLDGNU_HEADER);
blk->oldgnu_header.isextended = i < file->stat_info->sparse_map_avail;
finish_header (file->stat_info, blk, block_ordinal);
while (i < file->stat_info->sparse_map_avail)
{
blk = find_next_block ();
memset (blk->buffer, 0, BLOCKSIZE);
oldgnu_store_sparse_info (file, &i,
blk->sparse_header.sp,
SPARSES_IN_SPARSE_HEADER);
if (i < file->stat_info->sparse_map_avail)
blk->sparse_header.isextended = 1;
set_next_block_after (blk);
}
return true;
}
|
@@ -1267,6 +1267,8 @@ pax_decode_header (struct tar_sparse_file *file)
{ \
set_next_block_after (b); \
b = find_next_block (); \
+ if (!b) \
+ FATAL_ERROR ((0, 0, _("Unexpected EOF in archive"))); \
src = b->buffer; \
endp = b->buffer + BLOCKSIZE; \
} \
@@ -1279,6 +1281,8 @@ pax_decode_header (struct tar_sparse_file *file)
start = current_block_ordinal ();
set_next_block_after (current_header);
blk = find_next_block ();
+ if (!blk)
+ FATAL_ERROR ((0, 0, _("Unexpected EOF in archive")));
p = blk->buffer;
COPY_BUF (blk,nbuf,p);
if (!decode_num (&u, nbuf, TYPE_MAXIMUM (size_t)))
|
CWE-476
| null | null |
4,212
|
oldgnu_fixup_header (struct tar_sparse_file *file)
{
/* NOTE! st_size was initialized from the header
which actually contains archived size. The following fixes it */
off_t realsize = OFF_FROM_HEADER (current_header->oldgnu_header.realsize);
file->stat_info->archive_file_size = file->stat_info->stat.st_size;
file->stat_info->stat.st_size = max (0, realsize);
return 0 <= realsize;
}
| null | 0
|
oldgnu_fixup_header (struct tar_sparse_file *file)
{
/* NOTE! st_size was initialized from the header
which actually contains archived size. The following fixes it */
off_t realsize = OFF_FROM_HEADER (current_header->oldgnu_header.realsize);
file->stat_info->archive_file_size = file->stat_info->stat.st_size;
file->stat_info->stat.st_size = max (0, realsize);
return 0 <= realsize;
}
|
@@ -1267,6 +1267,8 @@ pax_decode_header (struct tar_sparse_file *file)
{ \
set_next_block_after (b); \
b = find_next_block (); \
+ if (!b) \
+ FATAL_ERROR ((0, 0, _("Unexpected EOF in archive"))); \
src = b->buffer; \
endp = b->buffer + BLOCKSIZE; \
} \
@@ -1279,6 +1281,8 @@ pax_decode_header (struct tar_sparse_file *file)
start = current_block_ordinal ();
set_next_block_after (current_header);
blk = find_next_block ();
+ if (!blk)
+ FATAL_ERROR ((0, 0, _("Unexpected EOF in archive")));
p = blk->buffer;
COPY_BUF (blk,nbuf,p);
if (!decode_num (&u, nbuf, TYPE_MAXIMUM (size_t)))
|
CWE-476
| null | null |
4,213
|
oldgnu_get_sparse_info (struct tar_sparse_file *file)
{
size_t i;
union block *h = current_header;
int ext_p;
enum oldgnu_add_status rc;
file->stat_info->sparse_map_avail = 0;
for (i = 0; i < SPARSES_IN_OLDGNU_HEADER; i++)
{
rc = oldgnu_add_sparse (file, &h->oldgnu_header.sp[i]);
if (rc != add_ok)
break;
}
for (ext_p = h->oldgnu_header.isextended;
rc == add_ok && ext_p; ext_p = h->sparse_header.isextended)
{
h = find_next_block ();
if (!h)
{
ERROR ((0, 0, _("Unexpected EOF in archive")));
return false;
}
set_next_block_after (h);
for (i = 0; i < SPARSES_IN_SPARSE_HEADER && rc == add_ok; i++)
rc = oldgnu_add_sparse (file, &h->sparse_header.sp[i]);
}
if (rc == add_fail)
{
ERROR ((0, 0, _("%s: invalid sparse archive member"),
file->stat_info->orig_file_name));
return false;
}
return true;
}
| null | 0
|
oldgnu_get_sparse_info (struct tar_sparse_file *file)
{
size_t i;
union block *h = current_header;
int ext_p;
enum oldgnu_add_status rc;
file->stat_info->sparse_map_avail = 0;
for (i = 0; i < SPARSES_IN_OLDGNU_HEADER; i++)
{
rc = oldgnu_add_sparse (file, &h->oldgnu_header.sp[i]);
if (rc != add_ok)
break;
}
for (ext_p = h->oldgnu_header.isextended;
rc == add_ok && ext_p; ext_p = h->sparse_header.isextended)
{
h = find_next_block ();
if (!h)
{
ERROR ((0, 0, _("Unexpected EOF in archive")));
return false;
}
set_next_block_after (h);
for (i = 0; i < SPARSES_IN_SPARSE_HEADER && rc == add_ok; i++)
rc = oldgnu_add_sparse (file, &h->sparse_header.sp[i]);
}
if (rc == add_fail)
{
ERROR ((0, 0, _("%s: invalid sparse archive member"),
file->stat_info->orig_file_name));
return false;
}
return true;
}
|
@@ -1267,6 +1267,8 @@ pax_decode_header (struct tar_sparse_file *file)
{ \
set_next_block_after (b); \
b = find_next_block (); \
+ if (!b) \
+ FATAL_ERROR ((0, 0, _("Unexpected EOF in archive"))); \
src = b->buffer; \
endp = b->buffer + BLOCKSIZE; \
} \
@@ -1279,6 +1281,8 @@ pax_decode_header (struct tar_sparse_file *file)
start = current_block_ordinal ();
set_next_block_after (current_header);
blk = find_next_block ();
+ if (!blk)
+ FATAL_ERROR ((0, 0, _("Unexpected EOF in archive")));
p = blk->buffer;
COPY_BUF (blk,nbuf,p);
if (!decode_num (&u, nbuf, TYPE_MAXIMUM (size_t)))
|
CWE-476
| null | null |
4,214
|
oldgnu_store_sparse_info (struct tar_sparse_file *file, size_t *pindex,
struct sparse *sp, size_t sparse_size)
{
for (; *pindex < file->stat_info->sparse_map_avail
&& sparse_size > 0; sparse_size--, sp++, ++*pindex)
{
OFF_TO_CHARS (file->stat_info->sparse_map[*pindex].offset,
sp->offset);
OFF_TO_CHARS (file->stat_info->sparse_map[*pindex].numbytes,
sp->numbytes);
}
}
| null | 0
|
oldgnu_store_sparse_info (struct tar_sparse_file *file, size_t *pindex,
struct sparse *sp, size_t sparse_size)
{
for (; *pindex < file->stat_info->sparse_map_avail
&& sparse_size > 0; sparse_size--, sp++, ++*pindex)
{
OFF_TO_CHARS (file->stat_info->sparse_map[*pindex].offset,
sp->offset);
OFF_TO_CHARS (file->stat_info->sparse_map[*pindex].numbytes,
sp->numbytes);
}
}
|
@@ -1267,6 +1267,8 @@ pax_decode_header (struct tar_sparse_file *file)
{ \
set_next_block_after (b); \
b = find_next_block (); \
+ if (!b) \
+ FATAL_ERROR ((0, 0, _("Unexpected EOF in archive"))); \
src = b->buffer; \
endp = b->buffer + BLOCKSIZE; \
} \
@@ -1279,6 +1281,8 @@ pax_decode_header (struct tar_sparse_file *file)
start = current_block_ordinal ();
set_next_block_after (current_header);
blk = find_next_block ();
+ if (!blk)
+ FATAL_ERROR ((0, 0, _("Unexpected EOF in archive")));
p = blk->buffer;
COPY_BUF (blk,nbuf,p);
if (!decode_num (&u, nbuf, TYPE_MAXIMUM (size_t)))
|
CWE-476
| null | null |
4,215
|
pax_dump_header (struct tar_sparse_file *file)
{
file->stat_info->sparse_major = tar_sparse_major;
file->stat_info->sparse_minor = tar_sparse_minor;
return (file->stat_info->sparse_major == 0) ?
pax_dump_header_0 (file) : pax_dump_header_1 (file);
}
| null | 0
|
pax_dump_header (struct tar_sparse_file *file)
{
file->stat_info->sparse_major = tar_sparse_major;
file->stat_info->sparse_minor = tar_sparse_minor;
return (file->stat_info->sparse_major == 0) ?
pax_dump_header_0 (file) : pax_dump_header_1 (file);
}
|
@@ -1267,6 +1267,8 @@ pax_decode_header (struct tar_sparse_file *file)
{ \
set_next_block_after (b); \
b = find_next_block (); \
+ if (!b) \
+ FATAL_ERROR ((0, 0, _("Unexpected EOF in archive"))); \
src = b->buffer; \
endp = b->buffer + BLOCKSIZE; \
} \
@@ -1279,6 +1281,8 @@ pax_decode_header (struct tar_sparse_file *file)
start = current_block_ordinal ();
set_next_block_after (current_header);
blk = find_next_block ();
+ if (!blk)
+ FATAL_ERROR ((0, 0, _("Unexpected EOF in archive")));
p = blk->buffer;
COPY_BUF (blk,nbuf,p);
if (!decode_num (&u, nbuf, TYPE_MAXIMUM (size_t)))
|
CWE-476
| null | null |
4,216
|
pax_dump_header_1 (struct tar_sparse_file *file)
{
off_t block_ordinal = current_block_ordinal ();
union block *blk;
char *p, *q;
size_t i;
char nbuf[UINTMAX_STRSIZE_BOUND];
off_t size = 0;
struct sp_array *map = file->stat_info->sparse_map;
char *save_file_name = file->stat_info->file_name;
#define COPY_STRING(b,dst,src) do \
{ \
char *endp = b->buffer + BLOCKSIZE; \
char const *srcp = src; \
while (*srcp) \
{ \
if (dst == endp) \
{ \
set_next_block_after (b); \
b = find_next_block (); \
dst = b->buffer; \
endp = b->buffer + BLOCKSIZE; \
} \
*dst++ = *srcp++; \
} \
} while (0)
/* Compute stored file size */
p = umaxtostr (file->stat_info->sparse_map_avail, nbuf);
size += strlen (p) + 1;
for (i = 0; i < file->stat_info->sparse_map_avail; i++)
{
p = umaxtostr (map[i].offset, nbuf);
size += strlen (p) + 1;
p = umaxtostr (map[i].numbytes, nbuf);
size += strlen (p) + 1;
}
size = (size + BLOCKSIZE - 1) / BLOCKSIZE;
file->stat_info->archive_file_size += size * BLOCKSIZE;
file->dumped_size += size * BLOCKSIZE;
/* Store sparse file identification */
xheader_store ("GNU.sparse.major", file->stat_info, NULL);
xheader_store ("GNU.sparse.minor", file->stat_info, NULL);
xheader_store ("GNU.sparse.name", file->stat_info, NULL);
xheader_store ("GNU.sparse.realsize", file->stat_info, NULL);
file->stat_info->file_name =
xheader_format_name (file->stat_info, "%d/GNUSparseFile.%p/%f", 0);
/* Make sure the created header name is shorter than NAME_FIELD_SIZE: */
if (strlen (file->stat_info->file_name) > NAME_FIELD_SIZE)
file->stat_info->file_name[NAME_FIELD_SIZE] = 0;
blk = pax_start_header (file->stat_info);
finish_header (file->stat_info, blk, block_ordinal);
free (file->stat_info->file_name);
file->stat_info->file_name = save_file_name;
blk = find_next_block ();
q = blk->buffer;
p = umaxtostr (file->stat_info->sparse_map_avail, nbuf);
COPY_STRING (blk, q, p);
COPY_STRING (blk, q, "\n");
for (i = 0; i < file->stat_info->sparse_map_avail; i++)
{
p = umaxtostr (map[i].offset, nbuf);
COPY_STRING (blk, q, p);
COPY_STRING (blk, q, "\n");
p = umaxtostr (map[i].numbytes, nbuf);
COPY_STRING (blk, q, p);
COPY_STRING (blk, q, "\n");
}
memset (q, 0, BLOCKSIZE - (q - blk->buffer));
set_next_block_after (blk);
return true;
}
| null | 0
|
pax_dump_header_1 (struct tar_sparse_file *file)
{
off_t block_ordinal = current_block_ordinal ();
union block *blk;
char *p, *q;
size_t i;
char nbuf[UINTMAX_STRSIZE_BOUND];
off_t size = 0;
struct sp_array *map = file->stat_info->sparse_map;
char *save_file_name = file->stat_info->file_name;
#define COPY_STRING(b,dst,src) do \
{ \
char *endp = b->buffer + BLOCKSIZE; \
char const *srcp = src; \
while (*srcp) \
{ \
if (dst == endp) \
{ \
set_next_block_after (b); \
b = find_next_block (); \
dst = b->buffer; \
endp = b->buffer + BLOCKSIZE; \
} \
*dst++ = *srcp++; \
} \
} while (0)
/* Compute stored file size */
p = umaxtostr (file->stat_info->sparse_map_avail, nbuf);
size += strlen (p) + 1;
for (i = 0; i < file->stat_info->sparse_map_avail; i++)
{
p = umaxtostr (map[i].offset, nbuf);
size += strlen (p) + 1;
p = umaxtostr (map[i].numbytes, nbuf);
size += strlen (p) + 1;
}
size = (size + BLOCKSIZE - 1) / BLOCKSIZE;
file->stat_info->archive_file_size += size * BLOCKSIZE;
file->dumped_size += size * BLOCKSIZE;
/* Store sparse file identification */
xheader_store ("GNU.sparse.major", file->stat_info, NULL);
xheader_store ("GNU.sparse.minor", file->stat_info, NULL);
xheader_store ("GNU.sparse.name", file->stat_info, NULL);
xheader_store ("GNU.sparse.realsize", file->stat_info, NULL);
file->stat_info->file_name =
xheader_format_name (file->stat_info, "%d/GNUSparseFile.%p/%f", 0);
/* Make sure the created header name is shorter than NAME_FIELD_SIZE: */
if (strlen (file->stat_info->file_name) > NAME_FIELD_SIZE)
file->stat_info->file_name[NAME_FIELD_SIZE] = 0;
blk = pax_start_header (file->stat_info);
finish_header (file->stat_info, blk, block_ordinal);
free (file->stat_info->file_name);
file->stat_info->file_name = save_file_name;
blk = find_next_block ();
q = blk->buffer;
p = umaxtostr (file->stat_info->sparse_map_avail, nbuf);
COPY_STRING (blk, q, p);
COPY_STRING (blk, q, "\n");
for (i = 0; i < file->stat_info->sparse_map_avail; i++)
{
p = umaxtostr (map[i].offset, nbuf);
COPY_STRING (blk, q, p);
COPY_STRING (blk, q, "\n");
p = umaxtostr (map[i].numbytes, nbuf);
COPY_STRING (blk, q, p);
COPY_STRING (blk, q, "\n");
}
memset (q, 0, BLOCKSIZE - (q - blk->buffer));
set_next_block_after (blk);
return true;
}
|
@@ -1267,6 +1267,8 @@ pax_decode_header (struct tar_sparse_file *file)
{ \
set_next_block_after (b); \
b = find_next_block (); \
+ if (!b) \
+ FATAL_ERROR ((0, 0, _("Unexpected EOF in archive"))); \
src = b->buffer; \
endp = b->buffer + BLOCKSIZE; \
} \
@@ -1279,6 +1281,8 @@ pax_decode_header (struct tar_sparse_file *file)
start = current_block_ordinal ();
set_next_block_after (current_header);
blk = find_next_block ();
+ if (!blk)
+ FATAL_ERROR ((0, 0, _("Unexpected EOF in archive")));
p = blk->buffer;
COPY_BUF (blk,nbuf,p);
if (!decode_num (&u, nbuf, TYPE_MAXIMUM (size_t)))
|
CWE-476
| null | null |
4,217
|
pax_sparse_member_p (struct tar_sparse_file *file)
{
return file->stat_info->sparse_map_avail > 0
|| file->stat_info->sparse_major > 0;
}
| null | 0
|
pax_sparse_member_p (struct tar_sparse_file *file)
{
return file->stat_info->sparse_map_avail > 0
|| file->stat_info->sparse_major > 0;
}
|
@@ -1267,6 +1267,8 @@ pax_decode_header (struct tar_sparse_file *file)
{ \
set_next_block_after (b); \
b = find_next_block (); \
+ if (!b) \
+ FATAL_ERROR ((0, 0, _("Unexpected EOF in archive"))); \
src = b->buffer; \
endp = b->buffer + BLOCKSIZE; \
} \
@@ -1279,6 +1281,8 @@ pax_decode_header (struct tar_sparse_file *file)
start = current_block_ordinal ();
set_next_block_after (current_header);
blk = find_next_block ();
+ if (!blk)
+ FATAL_ERROR ((0, 0, _("Unexpected EOF in archive")));
p = blk->buffer;
COPY_BUF (blk,nbuf,p);
if (!decode_num (&u, nbuf, TYPE_MAXIMUM (size_t)))
|
CWE-476
| null | null |
4,218
|
pax_start_header (struct tar_stat_info *st)
{
off_t realsize = st->stat.st_size;
union block *blk;
st->stat.st_size = st->archive_file_size;
blk = start_header (st);
st->stat.st_size = realsize;
return blk;
}
| null | 0
|
pax_start_header (struct tar_stat_info *st)
{
off_t realsize = st->stat.st_size;
union block *blk;
st->stat.st_size = st->archive_file_size;
blk = start_header (st);
st->stat.st_size = realsize;
return blk;
}
|
@@ -1267,6 +1267,8 @@ pax_decode_header (struct tar_sparse_file *file)
{ \
set_next_block_after (b); \
b = find_next_block (); \
+ if (!b) \
+ FATAL_ERROR ((0, 0, _("Unexpected EOF in archive"))); \
src = b->buffer; \
endp = b->buffer + BLOCKSIZE; \
} \
@@ -1279,6 +1281,8 @@ pax_decode_header (struct tar_sparse_file *file)
start = current_block_ordinal ();
set_next_block_after (current_header);
blk = find_next_block ();
+ if (!blk)
+ FATAL_ERROR ((0, 0, _("Unexpected EOF in archive")));
p = blk->buffer;
COPY_BUF (blk,nbuf,p);
if (!decode_num (&u, nbuf, TYPE_MAXIMUM (size_t)))
|
CWE-476
| null | null |
4,219
|
sparse_diff_file (int fd, struct tar_stat_info *st)
{
bool rc = true;
struct tar_sparse_file file;
size_t i;
off_t offset = 0;
if (!tar_sparse_init (&file))
return dump_status_not_implemented;
file.stat_info = st;
file.fd = fd;
file.seekable = true; /* File *must* be seekable for compare to work */
rc = tar_sparse_decode_header (&file);
mv_begin_read (st);
for (i = 0; rc && i < file.stat_info->sparse_map_avail; i++)
{
rc = check_sparse_region (&file,
offset, file.stat_info->sparse_map[i].offset)
&& check_data_region (&file, i);
offset = file.stat_info->sparse_map[i].offset
+ file.stat_info->sparse_map[i].numbytes;
}
if (!rc)
skip_file (file.stat_info->archive_file_size - file.dumped_size);
mv_end ();
tar_sparse_done (&file);
return rc;
}
| null | 0
|
sparse_diff_file (int fd, struct tar_stat_info *st)
{
bool rc = true;
struct tar_sparse_file file;
size_t i;
off_t offset = 0;
if (!tar_sparse_init (&file))
return dump_status_not_implemented;
file.stat_info = st;
file.fd = fd;
file.seekable = true; /* File *must* be seekable for compare to work */
rc = tar_sparse_decode_header (&file);
mv_begin_read (st);
for (i = 0; rc && i < file.stat_info->sparse_map_avail; i++)
{
rc = check_sparse_region (&file,
offset, file.stat_info->sparse_map[i].offset)
&& check_data_region (&file, i);
offset = file.stat_info->sparse_map[i].offset
+ file.stat_info->sparse_map[i].numbytes;
}
if (!rc)
skip_file (file.stat_info->archive_file_size - file.dumped_size);
mv_end ();
tar_sparse_done (&file);
return rc;
}
|
@@ -1267,6 +1267,8 @@ pax_decode_header (struct tar_sparse_file *file)
{ \
set_next_block_after (b); \
b = find_next_block (); \
+ if (!b) \
+ FATAL_ERROR ((0, 0, _("Unexpected EOF in archive"))); \
src = b->buffer; \
endp = b->buffer + BLOCKSIZE; \
} \
@@ -1279,6 +1281,8 @@ pax_decode_header (struct tar_sparse_file *file)
start = current_block_ordinal ();
set_next_block_after (current_header);
blk = find_next_block ();
+ if (!blk)
+ FATAL_ERROR ((0, 0, _("Unexpected EOF in archive")));
p = blk->buffer;
COPY_BUF (blk,nbuf,p);
if (!decode_num (&u, nbuf, TYPE_MAXIMUM (size_t)))
|
CWE-476
| null | null |
4,220
|
sparse_extract_region (struct tar_sparse_file *file, size_t i)
{
off_t write_size;
if (!lseek_or_error (file, file->stat_info->sparse_map[i].offset))
return false;
write_size = file->stat_info->sparse_map[i].numbytes;
if (write_size == 0)
{
/* Last block of the file is a hole */
if (file->seekable && sys_truncate (file->fd))
truncate_warn (file->stat_info->orig_file_name);
}
else while (write_size > 0)
{
size_t count;
size_t wrbytes = (write_size > BLOCKSIZE) ? BLOCKSIZE : write_size;
union block *blk = find_next_block ();
if (!blk)
{
ERROR ((0, 0, _("Unexpected EOF in archive")));
return false;
}
set_next_block_after (blk);
file->dumped_size += BLOCKSIZE;
count = blocking_write (file->fd, blk->buffer, wrbytes);
write_size -= count;
mv_size_left (file->stat_info->archive_file_size - file->dumped_size);
file->offset += count;
if (count != wrbytes)
{
write_error_details (file->stat_info->orig_file_name,
count, wrbytes);
return false;
}
}
return true;
}
| null | 0
|
sparse_extract_region (struct tar_sparse_file *file, size_t i)
{
off_t write_size;
if (!lseek_or_error (file, file->stat_info->sparse_map[i].offset))
return false;
write_size = file->stat_info->sparse_map[i].numbytes;
if (write_size == 0)
{
/* Last block of the file is a hole */
if (file->seekable && sys_truncate (file->fd))
truncate_warn (file->stat_info->orig_file_name);
}
else while (write_size > 0)
{
size_t count;
size_t wrbytes = (write_size > BLOCKSIZE) ? BLOCKSIZE : write_size;
union block *blk = find_next_block ();
if (!blk)
{
ERROR ((0, 0, _("Unexpected EOF in archive")));
return false;
}
set_next_block_after (blk);
file->dumped_size += BLOCKSIZE;
count = blocking_write (file->fd, blk->buffer, wrbytes);
write_size -= count;
mv_size_left (file->stat_info->archive_file_size - file->dumped_size);
file->offset += count;
if (count != wrbytes)
{
write_error_details (file->stat_info->orig_file_name,
count, wrbytes);
return false;
}
}
return true;
}
|
@@ -1267,6 +1267,8 @@ pax_decode_header (struct tar_sparse_file *file)
{ \
set_next_block_after (b); \
b = find_next_block (); \
+ if (!b) \
+ FATAL_ERROR ((0, 0, _("Unexpected EOF in archive"))); \
src = b->buffer; \
endp = b->buffer + BLOCKSIZE; \
} \
@@ -1279,6 +1281,8 @@ pax_decode_header (struct tar_sparse_file *file)
start = current_block_ordinal ();
set_next_block_after (current_header);
blk = find_next_block ();
+ if (!blk)
+ FATAL_ERROR ((0, 0, _("Unexpected EOF in archive")));
p = blk->buffer;
COPY_BUF (blk,nbuf,p);
if (!decode_num (&u, nbuf, TYPE_MAXIMUM (size_t)))
|
CWE-476
| null | null |
4,221
|
star_fixup_header (struct tar_sparse_file *file)
{
/* NOTE! st_size was initialized from the header
which actually contains archived size. The following fixes it */
off_t realsize = OFF_FROM_HEADER (current_header->star_in_header.realsize);
file->stat_info->archive_file_size = file->stat_info->stat.st_size;
file->stat_info->stat.st_size = max (0, realsize);
return 0 <= realsize;
}
| null | 0
|
star_fixup_header (struct tar_sparse_file *file)
{
/* NOTE! st_size was initialized from the header
which actually contains archived size. The following fixes it */
off_t realsize = OFF_FROM_HEADER (current_header->star_in_header.realsize);
file->stat_info->archive_file_size = file->stat_info->stat.st_size;
file->stat_info->stat.st_size = max (0, realsize);
return 0 <= realsize;
}
|
@@ -1267,6 +1267,8 @@ pax_decode_header (struct tar_sparse_file *file)
{ \
set_next_block_after (b); \
b = find_next_block (); \
+ if (!b) \
+ FATAL_ERROR ((0, 0, _("Unexpected EOF in archive"))); \
src = b->buffer; \
endp = b->buffer + BLOCKSIZE; \
} \
@@ -1279,6 +1281,8 @@ pax_decode_header (struct tar_sparse_file *file)
start = current_block_ordinal ();
set_next_block_after (current_header);
blk = find_next_block ();
+ if (!blk)
+ FATAL_ERROR ((0, 0, _("Unexpected EOF in archive")));
p = blk->buffer;
COPY_BUF (blk,nbuf,p);
if (!decode_num (&u, nbuf, TYPE_MAXIMUM (size_t)))
|
CWE-476
| null | null |
4,222
|
star_get_sparse_info (struct tar_sparse_file *file)
{
size_t i;
union block *h = current_header;
int ext_p;
enum oldgnu_add_status rc = add_ok;
file->stat_info->sparse_map_avail = 0;
if (h->star_in_header.prefix[0] == '\0'
&& h->star_in_header.sp[0].offset[10] != '\0')
{
/* Old star format */
for (i = 0; i < SPARSES_IN_STAR_HEADER; i++)
{
rc = oldgnu_add_sparse (file, &h->star_in_header.sp[i]);
if (rc != add_ok)
break;
}
ext_p = h->star_in_header.isextended;
}
else
ext_p = 1;
for (; rc == add_ok && ext_p; ext_p = h->star_ext_header.isextended)
{
h = find_next_block ();
if (!h)
{
ERROR ((0, 0, _("Unexpected EOF in archive")));
return false;
}
set_next_block_after (h);
for (i = 0; i < SPARSES_IN_STAR_EXT_HEADER && rc == add_ok; i++)
rc = oldgnu_add_sparse (file, &h->star_ext_header.sp[i]);
file->dumped_size += BLOCKSIZE;
}
if (rc == add_fail)
{
ERROR ((0, 0, _("%s: invalid sparse archive member"),
file->stat_info->orig_file_name));
return false;
}
return true;
}
| null | 0
|
star_get_sparse_info (struct tar_sparse_file *file)
{
size_t i;
union block *h = current_header;
int ext_p;
enum oldgnu_add_status rc = add_ok;
file->stat_info->sparse_map_avail = 0;
if (h->star_in_header.prefix[0] == '\0'
&& h->star_in_header.sp[0].offset[10] != '\0')
{
/* Old star format */
for (i = 0; i < SPARSES_IN_STAR_HEADER; i++)
{
rc = oldgnu_add_sparse (file, &h->star_in_header.sp[i]);
if (rc != add_ok)
break;
}
ext_p = h->star_in_header.isextended;
}
else
ext_p = 1;
for (; rc == add_ok && ext_p; ext_p = h->star_ext_header.isextended)
{
h = find_next_block ();
if (!h)
{
ERROR ((0, 0, _("Unexpected EOF in archive")));
return false;
}
set_next_block_after (h);
for (i = 0; i < SPARSES_IN_STAR_EXT_HEADER && rc == add_ok; i++)
rc = oldgnu_add_sparse (file, &h->star_ext_header.sp[i]);
file->dumped_size += BLOCKSIZE;
}
if (rc == add_fail)
{
ERROR ((0, 0, _("%s: invalid sparse archive member"),
file->stat_info->orig_file_name));
return false;
}
return true;
}
|
@@ -1267,6 +1267,8 @@ pax_decode_header (struct tar_sparse_file *file)
{ \
set_next_block_after (b); \
b = find_next_block (); \
+ if (!b) \
+ FATAL_ERROR ((0, 0, _("Unexpected EOF in archive"))); \
src = b->buffer; \
endp = b->buffer + BLOCKSIZE; \
} \
@@ -1279,6 +1281,8 @@ pax_decode_header (struct tar_sparse_file *file)
start = current_block_ordinal ();
set_next_block_after (current_header);
blk = find_next_block ();
+ if (!blk)
+ FATAL_ERROR ((0, 0, _("Unexpected EOF in archive")));
p = blk->buffer;
COPY_BUF (blk,nbuf,p);
if (!decode_num (&u, nbuf, TYPE_MAXIMUM (size_t)))
|
CWE-476
| null | null |
4,223
|
alloc_trace_space(const gs_ref_memory_t *imem)
{
return imem->space + (imem->stable_memory == (const gs_memory_t *)imem);
}
|
DoS Overflow
| 0
|
alloc_trace_space(const gs_ref_memory_t *imem)
{
return imem->space + (imem->stable_memory == (const gs_memory_t *)imem);
}
|
@@ -1248,19 +1248,32 @@ i_alloc_struct_immovable(gs_memory_t * mem, gs_memory_type_ptr_t pstype,
alloc_trace("|+<.", imem, cname, pstype, size, obj);
return obj;
}
+
+static inline bool
+alloc_array_check_size(ulong num_elements, ulong elt_size, ulong *lsize)
+{
+ int64_t s = (int64_t)num_elements * elt_size;
+ if (s > max_uint) {
+ return false;
+ }
+ *lsize = (ulong)s;
+ return true;
+}
+
static byte *
i_alloc_byte_array(gs_memory_t * mem, uint num_elements, uint elt_size,
client_name_t cname)
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
-
- obj = alloc_obj(imem, (ulong) num_elements * elt_size,
+ if (alloc_array_check_size(num_elements, elt_size, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize,
&st_bytes, ALLOC_DIRECT, cname);
if_debug6m('A', mem, "[a%d:+b.]%s -bytes-*(%lu=%u*%u) = 0x%lx\n",
@@ -1275,13 +1288,14 @@ i_alloc_byte_array_immovable(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
-
- obj = alloc_obj(imem, (ulong) num_elements * elt_size,
+ if (alloc_array_check_size(num_elements, elt_size, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize,
&st_bytes, ALLOC_IMMOVABLE | ALLOC_DIRECT,
cname);
@@ -1297,7 +1311,7 @@ i_alloc_struct_array(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
@@ -1311,9 +1325,9 @@ i_alloc_struct_array(gs_memory_t * mem, uint num_elements,
return NULL; /* fail */
}
#endif
- obj = alloc_obj(imem,
- (ulong) num_elements * pstype->ssize,
- pstype, ALLOC_DIRECT, cname);
+ if (alloc_array_check_size(num_elements, pstype->ssize, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize, pstype, ALLOC_DIRECT, cname);
if_debug7m('A', mem, "[a%d:+<.]%s %s*(%lu=%u*%u) = 0x%lx\n",
alloc_trace_space(imem), client_name_string(cname),
struct_type_name_string(pstype),
@@ -1327,16 +1341,16 @@ i_alloc_struct_array_immovable(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
ALLOC_CHECK_SIZE(mem,pstype);
- obj = alloc_obj(imem,
- (ulong) num_elements * pstype->ssize,
- pstype, ALLOC_IMMOVABLE | ALLOC_DIRECT, cname);
+ if (alloc_array_check_size(num_elements, pstype->ssize, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize, pstype, ALLOC_IMMOVABLE | ALLOC_DIRECT, cname);
if_debug7m('A', mem, "[a%d|+<.]%s %s*(%lu=%u*%u) = 0x%lx\n",
alloc_trace_space(imem), client_name_string(cname),
struct_type_name_string(pstype),
|
CWE-190
| null | null |
4,224
|
broken_splay()
{
dlprintf("Broken splay tree!\n");
}
|
DoS Overflow
| 0
|
broken_splay()
{
dlprintf("Broken splay tree!\n");
}
|
@@ -1248,19 +1248,32 @@ i_alloc_struct_immovable(gs_memory_t * mem, gs_memory_type_ptr_t pstype,
alloc_trace("|+<.", imem, cname, pstype, size, obj);
return obj;
}
+
+static inline bool
+alloc_array_check_size(ulong num_elements, ulong elt_size, ulong *lsize)
+{
+ int64_t s = (int64_t)num_elements * elt_size;
+ if (s > max_uint) {
+ return false;
+ }
+ *lsize = (ulong)s;
+ return true;
+}
+
static byte *
i_alloc_byte_array(gs_memory_t * mem, uint num_elements, uint elt_size,
client_name_t cname)
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
-
- obj = alloc_obj(imem, (ulong) num_elements * elt_size,
+ if (alloc_array_check_size(num_elements, elt_size, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize,
&st_bytes, ALLOC_DIRECT, cname);
if_debug6m('A', mem, "[a%d:+b.]%s -bytes-*(%lu=%u*%u) = 0x%lx\n",
@@ -1275,13 +1288,14 @@ i_alloc_byte_array_immovable(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
-
- obj = alloc_obj(imem, (ulong) num_elements * elt_size,
+ if (alloc_array_check_size(num_elements, elt_size, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize,
&st_bytes, ALLOC_IMMOVABLE | ALLOC_DIRECT,
cname);
@@ -1297,7 +1311,7 @@ i_alloc_struct_array(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
@@ -1311,9 +1325,9 @@ i_alloc_struct_array(gs_memory_t * mem, uint num_elements,
return NULL; /* fail */
}
#endif
- obj = alloc_obj(imem,
- (ulong) num_elements * pstype->ssize,
- pstype, ALLOC_DIRECT, cname);
+ if (alloc_array_check_size(num_elements, pstype->ssize, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize, pstype, ALLOC_DIRECT, cname);
if_debug7m('A', mem, "[a%d:+<.]%s %s*(%lu=%u*%u) = 0x%lx\n",
alloc_trace_space(imem), client_name_string(cname),
struct_type_name_string(pstype),
@@ -1327,16 +1341,16 @@ i_alloc_struct_array_immovable(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
ALLOC_CHECK_SIZE(mem,pstype);
- obj = alloc_obj(imem,
- (ulong) num_elements * pstype->ssize,
- pstype, ALLOC_IMMOVABLE | ALLOC_DIRECT, cname);
+ if (alloc_array_check_size(num_elements, pstype->ssize, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize, pstype, ALLOC_IMMOVABLE | ALLOC_DIRECT, cname);
if_debug7m('A', mem, "[a%d|+<.]%s %s*(%lu=%u*%u) = 0x%lx\n",
alloc_trace_space(imem), client_name_string(cname),
struct_type_name_string(pstype),
|
CWE-190
| null | null |
4,225
|
clump_splay_app(clump_t *root, gs_ref_memory_t *imem, splay_app_result_t (*fn)(clump_t *, void *), void *arg)
{
clump_t *step_to;
clump_t *cp = root;
int from = SPLAY_FROM_ABOVE;
splay_app_result_t res;
SANITY_CHECK(cp);
while (cp)
{
if (from == SPLAY_FROM_ABOVE)
{
/* We have arrived from above. Step left. */
step_to = cp->left;
if (step_to)
{
from = SPLAY_FROM_ABOVE;
cp = step_to;
}
else
{
/* No left to step to, so imagine we have just arrived from the left */
from = SPLAY_FROM_LEFT;
}
}
if (from == SPLAY_FROM_LEFT)
{
/* We have arrived from the left. Step right. */
step_to = cp->right;
if (step_to)
{
from = SPLAY_FROM_ABOVE;
cp = step_to;
}
else
{
/* No right to step to, so imagine we have just arrived from the right. */
from = SPLAY_FROM_RIGHT;
}
}
if (from == SPLAY_FROM_RIGHT)
{
/* We have arrived from the right. Step up. */
step_to = cp->parent;
if (step_to)
{
from = (step_to->left == cp ? SPLAY_FROM_LEFT : SPLAY_FROM_RIGHT);
}
res = fn(cp, arg);
if (res & SPLAY_APP_STOP)
return cp;
cp = step_to;
}
}
return cp;
}
|
DoS Overflow
| 0
|
clump_splay_app(clump_t *root, gs_ref_memory_t *imem, splay_app_result_t (*fn)(clump_t *, void *), void *arg)
{
clump_t *step_to;
clump_t *cp = root;
int from = SPLAY_FROM_ABOVE;
splay_app_result_t res;
SANITY_CHECK(cp);
while (cp)
{
if (from == SPLAY_FROM_ABOVE)
{
/* We have arrived from above. Step left. */
step_to = cp->left;
if (step_to)
{
from = SPLAY_FROM_ABOVE;
cp = step_to;
}
else
{
/* No left to step to, so imagine we have just arrived from the left */
from = SPLAY_FROM_LEFT;
}
}
if (from == SPLAY_FROM_LEFT)
{
/* We have arrived from the left. Step right. */
step_to = cp->right;
if (step_to)
{
from = SPLAY_FROM_ABOVE;
cp = step_to;
}
else
{
/* No right to step to, so imagine we have just arrived from the right. */
from = SPLAY_FROM_RIGHT;
}
}
if (from == SPLAY_FROM_RIGHT)
{
/* We have arrived from the right. Step up. */
step_to = cp->parent;
if (step_to)
{
from = (step_to->left == cp ? SPLAY_FROM_LEFT : SPLAY_FROM_RIGHT);
}
res = fn(cp, arg);
if (res & SPLAY_APP_STOP)
return cp;
cp = step_to;
}
}
return cp;
}
|
@@ -1248,19 +1248,32 @@ i_alloc_struct_immovable(gs_memory_t * mem, gs_memory_type_ptr_t pstype,
alloc_trace("|+<.", imem, cname, pstype, size, obj);
return obj;
}
+
+static inline bool
+alloc_array_check_size(ulong num_elements, ulong elt_size, ulong *lsize)
+{
+ int64_t s = (int64_t)num_elements * elt_size;
+ if (s > max_uint) {
+ return false;
+ }
+ *lsize = (ulong)s;
+ return true;
+}
+
static byte *
i_alloc_byte_array(gs_memory_t * mem, uint num_elements, uint elt_size,
client_name_t cname)
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
-
- obj = alloc_obj(imem, (ulong) num_elements * elt_size,
+ if (alloc_array_check_size(num_elements, elt_size, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize,
&st_bytes, ALLOC_DIRECT, cname);
if_debug6m('A', mem, "[a%d:+b.]%s -bytes-*(%lu=%u*%u) = 0x%lx\n",
@@ -1275,13 +1288,14 @@ i_alloc_byte_array_immovable(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
-
- obj = alloc_obj(imem, (ulong) num_elements * elt_size,
+ if (alloc_array_check_size(num_elements, elt_size, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize,
&st_bytes, ALLOC_IMMOVABLE | ALLOC_DIRECT,
cname);
@@ -1297,7 +1311,7 @@ i_alloc_struct_array(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
@@ -1311,9 +1325,9 @@ i_alloc_struct_array(gs_memory_t * mem, uint num_elements,
return NULL; /* fail */
}
#endif
- obj = alloc_obj(imem,
- (ulong) num_elements * pstype->ssize,
- pstype, ALLOC_DIRECT, cname);
+ if (alloc_array_check_size(num_elements, pstype->ssize, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize, pstype, ALLOC_DIRECT, cname);
if_debug7m('A', mem, "[a%d:+<.]%s %s*(%lu=%u*%u) = 0x%lx\n",
alloc_trace_space(imem), client_name_string(cname),
struct_type_name_string(pstype),
@@ -1327,16 +1341,16 @@ i_alloc_struct_array_immovable(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
ALLOC_CHECK_SIZE(mem,pstype);
- obj = alloc_obj(imem,
- (ulong) num_elements * pstype->ssize,
- pstype, ALLOC_IMMOVABLE | ALLOC_DIRECT, cname);
+ if (alloc_array_check_size(num_elements, pstype->ssize, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize, pstype, ALLOC_IMMOVABLE | ALLOC_DIRECT, cname);
if_debug7m('A', mem, "[a%d|+<.]%s %s*(%lu=%u*%u) = 0x%lx\n",
alloc_trace_space(imem), client_name_string(cname),
struct_type_name_string(pstype),
|
CWE-190
| null | null |
4,226
|
clump_splay_remove(clump_t *cp, gs_ref_memory_t *imem)
{
clump_t *replacement;
if (cp->left == NULL)
{
/* At most one child - easy */
replacement = cp->right;
}
else if (cp->right == NULL)
{
/* Strictly one child - easy */
replacement = cp->left;
}
else
{
/* 2 Children - tricky */
/* Find in-order predecessor to f */
replacement = cp->left;
while (replacement->right)
replacement = replacement->right;
/* Remove replacement - easy as just one child */
(void)clump_splay_remove(replacement, imem);
/* Replace cp with replacement */
if (cp->left)
cp->left->parent = replacement;
cp->right->parent = replacement;
replacement->left = cp->left;
replacement->right = cp->right;
}
if (cp->parent)
{
if (cp->parent->left == cp)
cp->parent->left = replacement;
else
cp->parent->right = replacement;
}
else
imem->root = replacement;
if (replacement)
replacement->parent = cp->parent;
return replacement;
}
|
DoS Overflow
| 0
|
clump_splay_remove(clump_t *cp, gs_ref_memory_t *imem)
{
clump_t *replacement;
if (cp->left == NULL)
{
/* At most one child - easy */
replacement = cp->right;
}
else if (cp->right == NULL)
{
/* Strictly one child - easy */
replacement = cp->left;
}
else
{
/* 2 Children - tricky */
/* Find in-order predecessor to f */
replacement = cp->left;
while (replacement->right)
replacement = replacement->right;
/* Remove replacement - easy as just one child */
(void)clump_splay_remove(replacement, imem);
/* Replace cp with replacement */
if (cp->left)
cp->left->parent = replacement;
cp->right->parent = replacement;
replacement->left = cp->left;
replacement->right = cp->right;
}
if (cp->parent)
{
if (cp->parent->left == cp)
cp->parent->left = replacement;
else
cp->parent->right = replacement;
}
else
imem->root = replacement;
if (replacement)
replacement->parent = cp->parent;
return replacement;
}
|
@@ -1248,19 +1248,32 @@ i_alloc_struct_immovable(gs_memory_t * mem, gs_memory_type_ptr_t pstype,
alloc_trace("|+<.", imem, cname, pstype, size, obj);
return obj;
}
+
+static inline bool
+alloc_array_check_size(ulong num_elements, ulong elt_size, ulong *lsize)
+{
+ int64_t s = (int64_t)num_elements * elt_size;
+ if (s > max_uint) {
+ return false;
+ }
+ *lsize = (ulong)s;
+ return true;
+}
+
static byte *
i_alloc_byte_array(gs_memory_t * mem, uint num_elements, uint elt_size,
client_name_t cname)
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
-
- obj = alloc_obj(imem, (ulong) num_elements * elt_size,
+ if (alloc_array_check_size(num_elements, elt_size, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize,
&st_bytes, ALLOC_DIRECT, cname);
if_debug6m('A', mem, "[a%d:+b.]%s -bytes-*(%lu=%u*%u) = 0x%lx\n",
@@ -1275,13 +1288,14 @@ i_alloc_byte_array_immovable(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
-
- obj = alloc_obj(imem, (ulong) num_elements * elt_size,
+ if (alloc_array_check_size(num_elements, elt_size, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize,
&st_bytes, ALLOC_IMMOVABLE | ALLOC_DIRECT,
cname);
@@ -1297,7 +1311,7 @@ i_alloc_struct_array(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
@@ -1311,9 +1325,9 @@ i_alloc_struct_array(gs_memory_t * mem, uint num_elements,
return NULL; /* fail */
}
#endif
- obj = alloc_obj(imem,
- (ulong) num_elements * pstype->ssize,
- pstype, ALLOC_DIRECT, cname);
+ if (alloc_array_check_size(num_elements, pstype->ssize, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize, pstype, ALLOC_DIRECT, cname);
if_debug7m('A', mem, "[a%d:+<.]%s %s*(%lu=%u*%u) = 0x%lx\n",
alloc_trace_space(imem), client_name_string(cname),
struct_type_name_string(pstype),
@@ -1327,16 +1341,16 @@ i_alloc_struct_array_immovable(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
ALLOC_CHECK_SIZE(mem,pstype);
- obj = alloc_obj(imem,
- (ulong) num_elements * pstype->ssize,
- pstype, ALLOC_IMMOVABLE | ALLOC_DIRECT, cname);
+ if (alloc_array_check_size(num_elements, pstype->ssize, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize, pstype, ALLOC_IMMOVABLE | ALLOC_DIRECT, cname);
if_debug7m('A', mem, "[a%d|+<.]%s %s*(%lu=%u*%u) = 0x%lx\n",
alloc_trace_space(imem), client_name_string(cname),
struct_type_name_string(pstype),
|
CWE-190
| null | null |
4,227
|
clump_splay_walk_bwd(clump_splay_walker *sw)
{
clump_t *cp = sw->cp;
int from = sw->from;
if (cp == NULL)
return NULL;
/* We step backwards through the tree, and stop when we arrive
* at sw->end in a reverse in order manner (i.e. by moving from
* the right). */
while (1)
{
if (from == SPLAY_FROM_ABOVE)
{
/* We have arrived from above. Step right. */
if (cp->right)
{
cp = cp->right;
from = SPLAY_FROM_ABOVE;
continue;
}
/* No right to step to, so imagine we have just arrived from there. */
from = SPLAY_FROM_RIGHT;
/* Have we reached our end? */
if (cp == sw->end)
cp = NULL;
/* Stop to run inorder operation */
break;
}
if (from == SPLAY_FROM_RIGHT)
{
/* We have arrived from the right. Step left. */
if (cp->left)
{
cp = cp->left;
from = SPLAY_FROM_ABOVE;
continue;
}
/* No left to step to, so imagine we have just arrived from there. */
from = SPLAY_FROM_LEFT;
}
if (from == SPLAY_FROM_LEFT)
{
/* We have arrived from the left. Step up. */
clump_t *old = cp;
cp = cp->parent;
from = (cp == NULL || cp->left != old ? SPLAY_FROM_RIGHT : SPLAY_FROM_LEFT);
if (from == SPLAY_FROM_RIGHT)
{
if (cp == sw->end)
cp = NULL;
break;
}
}
}
sw->cp = cp;
sw->from = from;
return cp;
}
|
DoS Overflow
| 0
|
clump_splay_walk_bwd(clump_splay_walker *sw)
{
clump_t *cp = sw->cp;
int from = sw->from;
if (cp == NULL)
return NULL;
/* We step backwards through the tree, and stop when we arrive
* at sw->end in a reverse in order manner (i.e. by moving from
* the right). */
while (1)
{
if (from == SPLAY_FROM_ABOVE)
{
/* We have arrived from above. Step right. */
if (cp->right)
{
cp = cp->right;
from = SPLAY_FROM_ABOVE;
continue;
}
/* No right to step to, so imagine we have just arrived from there. */
from = SPLAY_FROM_RIGHT;
/* Have we reached our end? */
if (cp == sw->end)
cp = NULL;
/* Stop to run inorder operation */
break;
}
if (from == SPLAY_FROM_RIGHT)
{
/* We have arrived from the right. Step left. */
if (cp->left)
{
cp = cp->left;
from = SPLAY_FROM_ABOVE;
continue;
}
/* No left to step to, so imagine we have just arrived from there. */
from = SPLAY_FROM_LEFT;
}
if (from == SPLAY_FROM_LEFT)
{
/* We have arrived from the left. Step up. */
clump_t *old = cp;
cp = cp->parent;
from = (cp == NULL || cp->left != old ? SPLAY_FROM_RIGHT : SPLAY_FROM_LEFT);
if (from == SPLAY_FROM_RIGHT)
{
if (cp == sw->end)
cp = NULL;
break;
}
}
}
sw->cp = cp;
sw->from = from;
return cp;
}
|
@@ -1248,19 +1248,32 @@ i_alloc_struct_immovable(gs_memory_t * mem, gs_memory_type_ptr_t pstype,
alloc_trace("|+<.", imem, cname, pstype, size, obj);
return obj;
}
+
+static inline bool
+alloc_array_check_size(ulong num_elements, ulong elt_size, ulong *lsize)
+{
+ int64_t s = (int64_t)num_elements * elt_size;
+ if (s > max_uint) {
+ return false;
+ }
+ *lsize = (ulong)s;
+ return true;
+}
+
static byte *
i_alloc_byte_array(gs_memory_t * mem, uint num_elements, uint elt_size,
client_name_t cname)
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
-
- obj = alloc_obj(imem, (ulong) num_elements * elt_size,
+ if (alloc_array_check_size(num_elements, elt_size, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize,
&st_bytes, ALLOC_DIRECT, cname);
if_debug6m('A', mem, "[a%d:+b.]%s -bytes-*(%lu=%u*%u) = 0x%lx\n",
@@ -1275,13 +1288,14 @@ i_alloc_byte_array_immovable(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
-
- obj = alloc_obj(imem, (ulong) num_elements * elt_size,
+ if (alloc_array_check_size(num_elements, elt_size, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize,
&st_bytes, ALLOC_IMMOVABLE | ALLOC_DIRECT,
cname);
@@ -1297,7 +1311,7 @@ i_alloc_struct_array(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
@@ -1311,9 +1325,9 @@ i_alloc_struct_array(gs_memory_t * mem, uint num_elements,
return NULL; /* fail */
}
#endif
- obj = alloc_obj(imem,
- (ulong) num_elements * pstype->ssize,
- pstype, ALLOC_DIRECT, cname);
+ if (alloc_array_check_size(num_elements, pstype->ssize, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize, pstype, ALLOC_DIRECT, cname);
if_debug7m('A', mem, "[a%d:+<.]%s %s*(%lu=%u*%u) = 0x%lx\n",
alloc_trace_space(imem), client_name_string(cname),
struct_type_name_string(pstype),
@@ -1327,16 +1341,16 @@ i_alloc_struct_array_immovable(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
ALLOC_CHECK_SIZE(mem,pstype);
- obj = alloc_obj(imem,
- (ulong) num_elements * pstype->ssize,
- pstype, ALLOC_IMMOVABLE | ALLOC_DIRECT, cname);
+ if (alloc_array_check_size(num_elements, pstype->ssize, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize, pstype, ALLOC_IMMOVABLE | ALLOC_DIRECT, cname);
if_debug7m('A', mem, "[a%d|+<.]%s %s*(%lu=%u*%u) = 0x%lx\n",
alloc_trace_space(imem), client_name_string(cname),
struct_type_name_string(pstype),
|
CWE-190
| null | null |
4,228
|
clump_splay_walk_bwd_init(clump_splay_walker *sw, const gs_ref_memory_t *mem)
{
clump_t *cp = mem->root;
if (cp)
{
SANITY_CHECK(cp);
sw->from = SPLAY_FROM_RIGHT;
while (cp->right)
{
cp = cp->right;
}
}
sw->cp = cp;
sw->end = NULL;
return cp;
}
|
DoS Overflow
| 0
|
clump_splay_walk_bwd_init(clump_splay_walker *sw, const gs_ref_memory_t *mem)
{
clump_t *cp = mem->root;
if (cp)
{
SANITY_CHECK(cp);
sw->from = SPLAY_FROM_RIGHT;
while (cp->right)
{
cp = cp->right;
}
}
sw->cp = cp;
sw->end = NULL;
return cp;
}
|
@@ -1248,19 +1248,32 @@ i_alloc_struct_immovable(gs_memory_t * mem, gs_memory_type_ptr_t pstype,
alloc_trace("|+<.", imem, cname, pstype, size, obj);
return obj;
}
+
+static inline bool
+alloc_array_check_size(ulong num_elements, ulong elt_size, ulong *lsize)
+{
+ int64_t s = (int64_t)num_elements * elt_size;
+ if (s > max_uint) {
+ return false;
+ }
+ *lsize = (ulong)s;
+ return true;
+}
+
static byte *
i_alloc_byte_array(gs_memory_t * mem, uint num_elements, uint elt_size,
client_name_t cname)
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
-
- obj = alloc_obj(imem, (ulong) num_elements * elt_size,
+ if (alloc_array_check_size(num_elements, elt_size, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize,
&st_bytes, ALLOC_DIRECT, cname);
if_debug6m('A', mem, "[a%d:+b.]%s -bytes-*(%lu=%u*%u) = 0x%lx\n",
@@ -1275,13 +1288,14 @@ i_alloc_byte_array_immovable(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
-
- obj = alloc_obj(imem, (ulong) num_elements * elt_size,
+ if (alloc_array_check_size(num_elements, elt_size, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize,
&st_bytes, ALLOC_IMMOVABLE | ALLOC_DIRECT,
cname);
@@ -1297,7 +1311,7 @@ i_alloc_struct_array(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
@@ -1311,9 +1325,9 @@ i_alloc_struct_array(gs_memory_t * mem, uint num_elements,
return NULL; /* fail */
}
#endif
- obj = alloc_obj(imem,
- (ulong) num_elements * pstype->ssize,
- pstype, ALLOC_DIRECT, cname);
+ if (alloc_array_check_size(num_elements, pstype->ssize, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize, pstype, ALLOC_DIRECT, cname);
if_debug7m('A', mem, "[a%d:+<.]%s %s*(%lu=%u*%u) = 0x%lx\n",
alloc_trace_space(imem), client_name_string(cname),
struct_type_name_string(pstype),
@@ -1327,16 +1341,16 @@ i_alloc_struct_array_immovable(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
ALLOC_CHECK_SIZE(mem,pstype);
- obj = alloc_obj(imem,
- (ulong) num_elements * pstype->ssize,
- pstype, ALLOC_IMMOVABLE | ALLOC_DIRECT, cname);
+ if (alloc_array_check_size(num_elements, pstype->ssize, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize, pstype, ALLOC_IMMOVABLE | ALLOC_DIRECT, cname);
if_debug7m('A', mem, "[a%d|+<.]%s %s*(%lu=%u*%u) = 0x%lx\n",
alloc_trace_space(imem), client_name_string(cname),
struct_type_name_string(pstype),
|
CWE-190
| null | null |
4,229
|
clump_splay_walk_fwd(clump_splay_walker *sw)
{
clump_t *cp = sw->cp;
int from = sw->from;
if (cp == NULL)
return NULL;
/* We step through the tree, and stop when we arrive
* at sw->end in an in order manner (i.e. by moving from
* the left). */
while (1)
{
if (from == SPLAY_FROM_ABOVE)
{
/* We have arrived from above. Step left. */
if (cp->left)
{
cp = cp->left;
from = SPLAY_FROM_ABOVE;
continue;
}
/* No left to step to, so imagine we have just arrived from there */
from = SPLAY_FROM_LEFT;
/* Have we reached the stopping point? */
if (cp == sw->end)
cp = NULL;
/* We want to stop here, for inorder operation. So break out of the loop. */
break;
}
if (from == SPLAY_FROM_LEFT)
{
/* We have arrived from the left. Step right. */
if (cp->right)
{
cp = cp->right;
from = SPLAY_FROM_ABOVE;
continue;
}
/* No right to step to, so imagine we have just arrived from there. */
from = SPLAY_FROM_RIGHT;
}
if (from == SPLAY_FROM_RIGHT)
{
/* We have arrived from the right. Step up. */
clump_t *old = cp;
cp = cp->parent;
if (cp == NULL)
{
/* We've reached the root of the tree. Is this our stopping point? */
if (sw->end == NULL)
break;
/* If not, step on. */
cp = old;
from = SPLAY_FROM_ABOVE;
}
else
{
from = (cp->left == old ? SPLAY_FROM_LEFT : SPLAY_FROM_RIGHT);
if (from == SPLAY_FROM_LEFT)
{
/* Have we reached the stopping point? */
if (cp == sw->end)
cp = NULL;
break;
}
}
}
}
sw->cp = cp;
sw->from = from;
return cp;
}
|
DoS Overflow
| 0
|
clump_splay_walk_fwd(clump_splay_walker *sw)
{
clump_t *cp = sw->cp;
int from = sw->from;
if (cp == NULL)
return NULL;
/* We step through the tree, and stop when we arrive
* at sw->end in an in order manner (i.e. by moving from
* the left). */
while (1)
{
if (from == SPLAY_FROM_ABOVE)
{
/* We have arrived from above. Step left. */
if (cp->left)
{
cp = cp->left;
from = SPLAY_FROM_ABOVE;
continue;
}
/* No left to step to, so imagine we have just arrived from there */
from = SPLAY_FROM_LEFT;
/* Have we reached the stopping point? */
if (cp == sw->end)
cp = NULL;
/* We want to stop here, for inorder operation. So break out of the loop. */
break;
}
if (from == SPLAY_FROM_LEFT)
{
/* We have arrived from the left. Step right. */
if (cp->right)
{
cp = cp->right;
from = SPLAY_FROM_ABOVE;
continue;
}
/* No right to step to, so imagine we have just arrived from there. */
from = SPLAY_FROM_RIGHT;
}
if (from == SPLAY_FROM_RIGHT)
{
/* We have arrived from the right. Step up. */
clump_t *old = cp;
cp = cp->parent;
if (cp == NULL)
{
/* We've reached the root of the tree. Is this our stopping point? */
if (sw->end == NULL)
break;
/* If not, step on. */
cp = old;
from = SPLAY_FROM_ABOVE;
}
else
{
from = (cp->left == old ? SPLAY_FROM_LEFT : SPLAY_FROM_RIGHT);
if (from == SPLAY_FROM_LEFT)
{
/* Have we reached the stopping point? */
if (cp == sw->end)
cp = NULL;
break;
}
}
}
}
sw->cp = cp;
sw->from = from;
return cp;
}
|
@@ -1248,19 +1248,32 @@ i_alloc_struct_immovable(gs_memory_t * mem, gs_memory_type_ptr_t pstype,
alloc_trace("|+<.", imem, cname, pstype, size, obj);
return obj;
}
+
+static inline bool
+alloc_array_check_size(ulong num_elements, ulong elt_size, ulong *lsize)
+{
+ int64_t s = (int64_t)num_elements * elt_size;
+ if (s > max_uint) {
+ return false;
+ }
+ *lsize = (ulong)s;
+ return true;
+}
+
static byte *
i_alloc_byte_array(gs_memory_t * mem, uint num_elements, uint elt_size,
client_name_t cname)
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
-
- obj = alloc_obj(imem, (ulong) num_elements * elt_size,
+ if (alloc_array_check_size(num_elements, elt_size, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize,
&st_bytes, ALLOC_DIRECT, cname);
if_debug6m('A', mem, "[a%d:+b.]%s -bytes-*(%lu=%u*%u) = 0x%lx\n",
@@ -1275,13 +1288,14 @@ i_alloc_byte_array_immovable(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
-
- obj = alloc_obj(imem, (ulong) num_elements * elt_size,
+ if (alloc_array_check_size(num_elements, elt_size, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize,
&st_bytes, ALLOC_IMMOVABLE | ALLOC_DIRECT,
cname);
@@ -1297,7 +1311,7 @@ i_alloc_struct_array(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
@@ -1311,9 +1325,9 @@ i_alloc_struct_array(gs_memory_t * mem, uint num_elements,
return NULL; /* fail */
}
#endif
- obj = alloc_obj(imem,
- (ulong) num_elements * pstype->ssize,
- pstype, ALLOC_DIRECT, cname);
+ if (alloc_array_check_size(num_elements, pstype->ssize, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize, pstype, ALLOC_DIRECT, cname);
if_debug7m('A', mem, "[a%d:+<.]%s %s*(%lu=%u*%u) = 0x%lx\n",
alloc_trace_space(imem), client_name_string(cname),
struct_type_name_string(pstype),
@@ -1327,16 +1341,16 @@ i_alloc_struct_array_immovable(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
ALLOC_CHECK_SIZE(mem,pstype);
- obj = alloc_obj(imem,
- (ulong) num_elements * pstype->ssize,
- pstype, ALLOC_IMMOVABLE | ALLOC_DIRECT, cname);
+ if (alloc_array_check_size(num_elements, pstype->ssize, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize, pstype, ALLOC_IMMOVABLE | ALLOC_DIRECT, cname);
if_debug7m('A', mem, "[a%d|+<.]%s %s*(%lu=%u*%u) = 0x%lx\n",
alloc_trace_space(imem), client_name_string(cname),
struct_type_name_string(pstype),
|
CWE-190
| null | null |
4,230
|
clump_splay_walk_init_mid(clump_splay_walker *sw, clump_t *cp)
{
sw->from = SPLAY_FROM_LEFT;
sw->cp = cp;
sw->end = cp;
if (cp)
{
SANITY_CHECK_MID(cp);
}
return cp;
}
|
DoS Overflow
| 0
|
clump_splay_walk_init_mid(clump_splay_walker *sw, clump_t *cp)
{
sw->from = SPLAY_FROM_LEFT;
sw->cp = cp;
sw->end = cp;
if (cp)
{
SANITY_CHECK_MID(cp);
}
return cp;
}
|
@@ -1248,19 +1248,32 @@ i_alloc_struct_immovable(gs_memory_t * mem, gs_memory_type_ptr_t pstype,
alloc_trace("|+<.", imem, cname, pstype, size, obj);
return obj;
}
+
+static inline bool
+alloc_array_check_size(ulong num_elements, ulong elt_size, ulong *lsize)
+{
+ int64_t s = (int64_t)num_elements * elt_size;
+ if (s > max_uint) {
+ return false;
+ }
+ *lsize = (ulong)s;
+ return true;
+}
+
static byte *
i_alloc_byte_array(gs_memory_t * mem, uint num_elements, uint elt_size,
client_name_t cname)
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
-
- obj = alloc_obj(imem, (ulong) num_elements * elt_size,
+ if (alloc_array_check_size(num_elements, elt_size, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize,
&st_bytes, ALLOC_DIRECT, cname);
if_debug6m('A', mem, "[a%d:+b.]%s -bytes-*(%lu=%u*%u) = 0x%lx\n",
@@ -1275,13 +1288,14 @@ i_alloc_byte_array_immovable(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
-
- obj = alloc_obj(imem, (ulong) num_elements * elt_size,
+ if (alloc_array_check_size(num_elements, elt_size, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize,
&st_bytes, ALLOC_IMMOVABLE | ALLOC_DIRECT,
cname);
@@ -1297,7 +1311,7 @@ i_alloc_struct_array(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
@@ -1311,9 +1325,9 @@ i_alloc_struct_array(gs_memory_t * mem, uint num_elements,
return NULL; /* fail */
}
#endif
- obj = alloc_obj(imem,
- (ulong) num_elements * pstype->ssize,
- pstype, ALLOC_DIRECT, cname);
+ if (alloc_array_check_size(num_elements, pstype->ssize, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize, pstype, ALLOC_DIRECT, cname);
if_debug7m('A', mem, "[a%d:+<.]%s %s*(%lu=%u*%u) = 0x%lx\n",
alloc_trace_space(imem), client_name_string(cname),
struct_type_name_string(pstype),
@@ -1327,16 +1341,16 @@ i_alloc_struct_array_immovable(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
ALLOC_CHECK_SIZE(mem,pstype);
- obj = alloc_obj(imem,
- (ulong) num_elements * pstype->ssize,
- pstype, ALLOC_IMMOVABLE | ALLOC_DIRECT, cname);
+ if (alloc_array_check_size(num_elements, pstype->ssize, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize, pstype, ALLOC_IMMOVABLE | ALLOC_DIRECT, cname);
if_debug7m('A', mem, "[a%d|+<.]%s %s*(%lu=%u*%u) = 0x%lx\n",
alloc_trace_space(imem), client_name_string(cname),
struct_type_name_string(pstype),
|
CWE-190
| null | null |
4,231
|
free_all_allocator(clump_t *cp, void *arg)
{
struct free_data *fd = (struct free_data *)arg;
if (cp->cbase + sizeof(obj_header_t) != (byte *)fd->imem)
return SPLAY_APP_CONTINUE;
fd->allocator = cp;
alloc_free_clump(cp, fd->imem);
return SPLAY_APP_STOP;
}
|
DoS Overflow
| 0
|
free_all_allocator(clump_t *cp, void *arg)
{
struct free_data *fd = (struct free_data *)arg;
if (cp->cbase + sizeof(obj_header_t) != (byte *)fd->imem)
return SPLAY_APP_CONTINUE;
fd->allocator = cp;
alloc_free_clump(cp, fd->imem);
return SPLAY_APP_STOP;
}
|
@@ -1248,19 +1248,32 @@ i_alloc_struct_immovable(gs_memory_t * mem, gs_memory_type_ptr_t pstype,
alloc_trace("|+<.", imem, cname, pstype, size, obj);
return obj;
}
+
+static inline bool
+alloc_array_check_size(ulong num_elements, ulong elt_size, ulong *lsize)
+{
+ int64_t s = (int64_t)num_elements * elt_size;
+ if (s > max_uint) {
+ return false;
+ }
+ *lsize = (ulong)s;
+ return true;
+}
+
static byte *
i_alloc_byte_array(gs_memory_t * mem, uint num_elements, uint elt_size,
client_name_t cname)
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
-
- obj = alloc_obj(imem, (ulong) num_elements * elt_size,
+ if (alloc_array_check_size(num_elements, elt_size, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize,
&st_bytes, ALLOC_DIRECT, cname);
if_debug6m('A', mem, "[a%d:+b.]%s -bytes-*(%lu=%u*%u) = 0x%lx\n",
@@ -1275,13 +1288,14 @@ i_alloc_byte_array_immovable(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
-
- obj = alloc_obj(imem, (ulong) num_elements * elt_size,
+ if (alloc_array_check_size(num_elements, elt_size, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize,
&st_bytes, ALLOC_IMMOVABLE | ALLOC_DIRECT,
cname);
@@ -1297,7 +1311,7 @@ i_alloc_struct_array(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
@@ -1311,9 +1325,9 @@ i_alloc_struct_array(gs_memory_t * mem, uint num_elements,
return NULL; /* fail */
}
#endif
- obj = alloc_obj(imem,
- (ulong) num_elements * pstype->ssize,
- pstype, ALLOC_DIRECT, cname);
+ if (alloc_array_check_size(num_elements, pstype->ssize, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize, pstype, ALLOC_DIRECT, cname);
if_debug7m('A', mem, "[a%d:+<.]%s %s*(%lu=%u*%u) = 0x%lx\n",
alloc_trace_space(imem), client_name_string(cname),
struct_type_name_string(pstype),
@@ -1327,16 +1341,16 @@ i_alloc_struct_array_immovable(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
ALLOC_CHECK_SIZE(mem,pstype);
- obj = alloc_obj(imem,
- (ulong) num_elements * pstype->ssize,
- pstype, ALLOC_IMMOVABLE | ALLOC_DIRECT, cname);
+ if (alloc_array_check_size(num_elements, pstype->ssize, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize, pstype, ALLOC_IMMOVABLE | ALLOC_DIRECT, cname);
if_debug7m('A', mem, "[a%d|+<.]%s %s*(%lu=%u*%u) = 0x%lx\n",
alloc_trace_space(imem), client_name_string(cname),
struct_type_name_string(pstype),
|
CWE-190
| null | null |
4,232
|
free_all_not_allocator(clump_t *cp, void *arg)
{
struct free_data *fd = (struct free_data *)arg;
if (cp->cbase + sizeof(obj_header_t) != (byte *)fd->imem)
alloc_free_clump(cp, fd->imem);
else
fd->allocator = cp;
return SPLAY_APP_CONTINUE;
}
|
DoS Overflow
| 0
|
free_all_not_allocator(clump_t *cp, void *arg)
{
struct free_data *fd = (struct free_data *)arg;
if (cp->cbase + sizeof(obj_header_t) != (byte *)fd->imem)
alloc_free_clump(cp, fd->imem);
else
fd->allocator = cp;
return SPLAY_APP_CONTINUE;
}
|
@@ -1248,19 +1248,32 @@ i_alloc_struct_immovable(gs_memory_t * mem, gs_memory_type_ptr_t pstype,
alloc_trace("|+<.", imem, cname, pstype, size, obj);
return obj;
}
+
+static inline bool
+alloc_array_check_size(ulong num_elements, ulong elt_size, ulong *lsize)
+{
+ int64_t s = (int64_t)num_elements * elt_size;
+ if (s > max_uint) {
+ return false;
+ }
+ *lsize = (ulong)s;
+ return true;
+}
+
static byte *
i_alloc_byte_array(gs_memory_t * mem, uint num_elements, uint elt_size,
client_name_t cname)
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
-
- obj = alloc_obj(imem, (ulong) num_elements * elt_size,
+ if (alloc_array_check_size(num_elements, elt_size, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize,
&st_bytes, ALLOC_DIRECT, cname);
if_debug6m('A', mem, "[a%d:+b.]%s -bytes-*(%lu=%u*%u) = 0x%lx\n",
@@ -1275,13 +1288,14 @@ i_alloc_byte_array_immovable(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
-
- obj = alloc_obj(imem, (ulong) num_elements * elt_size,
+ if (alloc_array_check_size(num_elements, elt_size, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize,
&st_bytes, ALLOC_IMMOVABLE | ALLOC_DIRECT,
cname);
@@ -1297,7 +1311,7 @@ i_alloc_struct_array(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
@@ -1311,9 +1325,9 @@ i_alloc_struct_array(gs_memory_t * mem, uint num_elements,
return NULL; /* fail */
}
#endif
- obj = alloc_obj(imem,
- (ulong) num_elements * pstype->ssize,
- pstype, ALLOC_DIRECT, cname);
+ if (alloc_array_check_size(num_elements, pstype->ssize, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize, pstype, ALLOC_DIRECT, cname);
if_debug7m('A', mem, "[a%d:+<.]%s %s*(%lu=%u*%u) = 0x%lx\n",
alloc_trace_space(imem), client_name_string(cname),
struct_type_name_string(pstype),
@@ -1327,16 +1341,16 @@ i_alloc_struct_array_immovable(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
ALLOC_CHECK_SIZE(mem,pstype);
- obj = alloc_obj(imem,
- (ulong) num_elements * pstype->ssize,
- pstype, ALLOC_IMMOVABLE | ALLOC_DIRECT, cname);
+ if (alloc_array_check_size(num_elements, pstype->ssize, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize, pstype, ALLOC_IMMOVABLE | ALLOC_DIRECT, cname);
if_debug7m('A', mem, "[a%d|+<.]%s %s*(%lu=%u*%u) = 0x%lx\n",
alloc_trace_space(imem), client_name_string(cname),
struct_type_name_string(pstype),
|
CWE-190
| null | null |
4,233
|
gs_id get_mem_hdr_id (void *ptr)
{
return (*((hdr_id_t *)((byte *)ptr) - HDR_ID_OFFSET));
}
|
DoS Overflow
| 0
|
gs_id get_mem_hdr_id (void *ptr)
{
return (*((hdr_id_t *)((byte *)ptr) - HDR_ID_OFFSET));
}
|
@@ -1248,19 +1248,32 @@ i_alloc_struct_immovable(gs_memory_t * mem, gs_memory_type_ptr_t pstype,
alloc_trace("|+<.", imem, cname, pstype, size, obj);
return obj;
}
+
+static inline bool
+alloc_array_check_size(ulong num_elements, ulong elt_size, ulong *lsize)
+{
+ int64_t s = (int64_t)num_elements * elt_size;
+ if (s > max_uint) {
+ return false;
+ }
+ *lsize = (ulong)s;
+ return true;
+}
+
static byte *
i_alloc_byte_array(gs_memory_t * mem, uint num_elements, uint elt_size,
client_name_t cname)
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
-
- obj = alloc_obj(imem, (ulong) num_elements * elt_size,
+ if (alloc_array_check_size(num_elements, elt_size, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize,
&st_bytes, ALLOC_DIRECT, cname);
if_debug6m('A', mem, "[a%d:+b.]%s -bytes-*(%lu=%u*%u) = 0x%lx\n",
@@ -1275,13 +1288,14 @@ i_alloc_byte_array_immovable(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
-
- obj = alloc_obj(imem, (ulong) num_elements * elt_size,
+ if (alloc_array_check_size(num_elements, elt_size, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize,
&st_bytes, ALLOC_IMMOVABLE | ALLOC_DIRECT,
cname);
@@ -1297,7 +1311,7 @@ i_alloc_struct_array(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
@@ -1311,9 +1325,9 @@ i_alloc_struct_array(gs_memory_t * mem, uint num_elements,
return NULL; /* fail */
}
#endif
- obj = alloc_obj(imem,
- (ulong) num_elements * pstype->ssize,
- pstype, ALLOC_DIRECT, cname);
+ if (alloc_array_check_size(num_elements, pstype->ssize, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize, pstype, ALLOC_DIRECT, cname);
if_debug7m('A', mem, "[a%d:+<.]%s %s*(%lu=%u*%u) = 0x%lx\n",
alloc_trace_space(imem), client_name_string(cname),
struct_type_name_string(pstype),
@@ -1327,16 +1341,16 @@ i_alloc_struct_array_immovable(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
ALLOC_CHECK_SIZE(mem,pstype);
- obj = alloc_obj(imem,
- (ulong) num_elements * pstype->ssize,
- pstype, ALLOC_IMMOVABLE | ALLOC_DIRECT, cname);
+ if (alloc_array_check_size(num_elements, pstype->ssize, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize, pstype, ALLOC_IMMOVABLE | ALLOC_DIRECT, cname);
if_debug7m('A', mem, "[a%d|+<.]%s %s*(%lu=%u*%u) = 0x%lx\n",
alloc_trace_space(imem), client_name_string(cname),
struct_type_name_string(pstype),
|
CWE-190
| null | null |
4,234
|
gs_memory_gc_status(const gs_ref_memory_t * mem, gs_memory_gc_status_t * pstat)
{
*pstat = mem->gc_status;
}
|
DoS Overflow
| 0
|
gs_memory_gc_status(const gs_ref_memory_t * mem, gs_memory_gc_status_t * pstat)
{
*pstat = mem->gc_status;
}
|
@@ -1248,19 +1248,32 @@ i_alloc_struct_immovable(gs_memory_t * mem, gs_memory_type_ptr_t pstype,
alloc_trace("|+<.", imem, cname, pstype, size, obj);
return obj;
}
+
+static inline bool
+alloc_array_check_size(ulong num_elements, ulong elt_size, ulong *lsize)
+{
+ int64_t s = (int64_t)num_elements * elt_size;
+ if (s > max_uint) {
+ return false;
+ }
+ *lsize = (ulong)s;
+ return true;
+}
+
static byte *
i_alloc_byte_array(gs_memory_t * mem, uint num_elements, uint elt_size,
client_name_t cname)
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
-
- obj = alloc_obj(imem, (ulong) num_elements * elt_size,
+ if (alloc_array_check_size(num_elements, elt_size, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize,
&st_bytes, ALLOC_DIRECT, cname);
if_debug6m('A', mem, "[a%d:+b.]%s -bytes-*(%lu=%u*%u) = 0x%lx\n",
@@ -1275,13 +1288,14 @@ i_alloc_byte_array_immovable(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
-
- obj = alloc_obj(imem, (ulong) num_elements * elt_size,
+ if (alloc_array_check_size(num_elements, elt_size, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize,
&st_bytes, ALLOC_IMMOVABLE | ALLOC_DIRECT,
cname);
@@ -1297,7 +1311,7 @@ i_alloc_struct_array(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
@@ -1311,9 +1325,9 @@ i_alloc_struct_array(gs_memory_t * mem, uint num_elements,
return NULL; /* fail */
}
#endif
- obj = alloc_obj(imem,
- (ulong) num_elements * pstype->ssize,
- pstype, ALLOC_DIRECT, cname);
+ if (alloc_array_check_size(num_elements, pstype->ssize, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize, pstype, ALLOC_DIRECT, cname);
if_debug7m('A', mem, "[a%d:+<.]%s %s*(%lu=%u*%u) = 0x%lx\n",
alloc_trace_space(imem), client_name_string(cname),
struct_type_name_string(pstype),
@@ -1327,16 +1341,16 @@ i_alloc_struct_array_immovable(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
ALLOC_CHECK_SIZE(mem,pstype);
- obj = alloc_obj(imem,
- (ulong) num_elements * pstype->ssize,
- pstype, ALLOC_IMMOVABLE | ALLOC_DIRECT, cname);
+ if (alloc_array_check_size(num_elements, pstype->ssize, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize, pstype, ALLOC_IMMOVABLE | ALLOC_DIRECT, cname);
if_debug7m('A', mem, "[a%d|+<.]%s %s*(%lu=%u*%u) = 0x%lx\n",
alloc_trace_space(imem), client_name_string(cname),
struct_type_name_string(pstype),
|
CWE-190
| null | null |
4,235
|
gs_memory_set_gc_status(gs_ref_memory_t * mem, const gs_memory_gc_status_t * pstat)
{
mem->gc_status = *pstat;
ialloc_set_limit(mem);
}
|
DoS Overflow
| 0
|
gs_memory_set_gc_status(gs_ref_memory_t * mem, const gs_memory_gc_status_t * pstat)
{
mem->gc_status = *pstat;
ialloc_set_limit(mem);
}
|
@@ -1248,19 +1248,32 @@ i_alloc_struct_immovable(gs_memory_t * mem, gs_memory_type_ptr_t pstype,
alloc_trace("|+<.", imem, cname, pstype, size, obj);
return obj;
}
+
+static inline bool
+alloc_array_check_size(ulong num_elements, ulong elt_size, ulong *lsize)
+{
+ int64_t s = (int64_t)num_elements * elt_size;
+ if (s > max_uint) {
+ return false;
+ }
+ *lsize = (ulong)s;
+ return true;
+}
+
static byte *
i_alloc_byte_array(gs_memory_t * mem, uint num_elements, uint elt_size,
client_name_t cname)
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
-
- obj = alloc_obj(imem, (ulong) num_elements * elt_size,
+ if (alloc_array_check_size(num_elements, elt_size, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize,
&st_bytes, ALLOC_DIRECT, cname);
if_debug6m('A', mem, "[a%d:+b.]%s -bytes-*(%lu=%u*%u) = 0x%lx\n",
@@ -1275,13 +1288,14 @@ i_alloc_byte_array_immovable(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
-
- obj = alloc_obj(imem, (ulong) num_elements * elt_size,
+ if (alloc_array_check_size(num_elements, elt_size, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize,
&st_bytes, ALLOC_IMMOVABLE | ALLOC_DIRECT,
cname);
@@ -1297,7 +1311,7 @@ i_alloc_struct_array(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
@@ -1311,9 +1325,9 @@ i_alloc_struct_array(gs_memory_t * mem, uint num_elements,
return NULL; /* fail */
}
#endif
- obj = alloc_obj(imem,
- (ulong) num_elements * pstype->ssize,
- pstype, ALLOC_DIRECT, cname);
+ if (alloc_array_check_size(num_elements, pstype->ssize, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize, pstype, ALLOC_DIRECT, cname);
if_debug7m('A', mem, "[a%d:+<.]%s %s*(%lu=%u*%u) = 0x%lx\n",
alloc_trace_space(imem), client_name_string(cname),
struct_type_name_string(pstype),
@@ -1327,16 +1341,16 @@ i_alloc_struct_array_immovable(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
ALLOC_CHECK_SIZE(mem,pstype);
- obj = alloc_obj(imem,
- (ulong) num_elements * pstype->ssize,
- pstype, ALLOC_IMMOVABLE | ALLOC_DIRECT, cname);
+ if (alloc_array_check_size(num_elements, pstype->ssize, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize, pstype, ALLOC_IMMOVABLE | ALLOC_DIRECT, cname);
if_debug7m('A', mem, "[a%d|+<.]%s %s*(%lu=%u*%u) = 0x%lx\n",
alloc_trace_space(imem), client_name_string(cname),
struct_type_name_string(pstype),
|
CWE-190
| null | null |
4,236
|
gs_memory_set_vm_reclaim(gs_ref_memory_t * mem, bool enabled)
{
gs_memory_gc_status_t stat;
gs_ref_memory_t * stable = (gs_ref_memory_t *)mem->stable_memory;
gs_memory_gc_status(mem, &stat);
stat.enabled = enabled;
gs_memory_set_gc_status(mem, &stat);
gs_memory_gc_status(stable, &stat);
stat.enabled = enabled;
gs_memory_set_gc_status(stable, &stat);
}
|
DoS Overflow
| 0
|
gs_memory_set_vm_reclaim(gs_ref_memory_t * mem, bool enabled)
{
gs_memory_gc_status_t stat;
gs_ref_memory_t * stable = (gs_ref_memory_t *)mem->stable_memory;
gs_memory_gc_status(mem, &stat);
stat.enabled = enabled;
gs_memory_set_gc_status(mem, &stat);
gs_memory_gc_status(stable, &stat);
stat.enabled = enabled;
gs_memory_set_gc_status(stable, &stat);
}
|
@@ -1248,19 +1248,32 @@ i_alloc_struct_immovable(gs_memory_t * mem, gs_memory_type_ptr_t pstype,
alloc_trace("|+<.", imem, cname, pstype, size, obj);
return obj;
}
+
+static inline bool
+alloc_array_check_size(ulong num_elements, ulong elt_size, ulong *lsize)
+{
+ int64_t s = (int64_t)num_elements * elt_size;
+ if (s > max_uint) {
+ return false;
+ }
+ *lsize = (ulong)s;
+ return true;
+}
+
static byte *
i_alloc_byte_array(gs_memory_t * mem, uint num_elements, uint elt_size,
client_name_t cname)
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
-
- obj = alloc_obj(imem, (ulong) num_elements * elt_size,
+ if (alloc_array_check_size(num_elements, elt_size, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize,
&st_bytes, ALLOC_DIRECT, cname);
if_debug6m('A', mem, "[a%d:+b.]%s -bytes-*(%lu=%u*%u) = 0x%lx\n",
@@ -1275,13 +1288,14 @@ i_alloc_byte_array_immovable(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
-
- obj = alloc_obj(imem, (ulong) num_elements * elt_size,
+ if (alloc_array_check_size(num_elements, elt_size, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize,
&st_bytes, ALLOC_IMMOVABLE | ALLOC_DIRECT,
cname);
@@ -1297,7 +1311,7 @@ i_alloc_struct_array(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
@@ -1311,9 +1325,9 @@ i_alloc_struct_array(gs_memory_t * mem, uint num_elements,
return NULL; /* fail */
}
#endif
- obj = alloc_obj(imem,
- (ulong) num_elements * pstype->ssize,
- pstype, ALLOC_DIRECT, cname);
+ if (alloc_array_check_size(num_elements, pstype->ssize, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize, pstype, ALLOC_DIRECT, cname);
if_debug7m('A', mem, "[a%d:+<.]%s %s*(%lu=%u*%u) = 0x%lx\n",
alloc_trace_space(imem), client_name_string(cname),
struct_type_name_string(pstype),
@@ -1327,16 +1341,16 @@ i_alloc_struct_array_immovable(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
ALLOC_CHECK_SIZE(mem,pstype);
- obj = alloc_obj(imem,
- (ulong) num_elements * pstype->ssize,
- pstype, ALLOC_IMMOVABLE | ALLOC_DIRECT, cname);
+ if (alloc_array_check_size(num_elements, pstype->ssize, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize, pstype, ALLOC_IMMOVABLE | ALLOC_DIRECT, cname);
if_debug7m('A', mem, "[a%d|+<.]%s %s*(%lu=%u*%u) = 0x%lx\n",
alloc_trace_space(imem), client_name_string(cname),
struct_type_name_string(pstype),
|
CWE-190
| null | null |
4,237
|
gs_memory_set_vm_threshold(gs_ref_memory_t * mem, long val)
{
gs_memory_gc_status_t stat;
gs_ref_memory_t * stable = (gs_ref_memory_t *)mem->stable_memory;
gs_memory_gc_status(mem, &stat);
stat.vm_threshold = val;
gs_memory_set_gc_status(mem, &stat);
gs_memory_gc_status(stable, &stat);
stat.vm_threshold = val;
gs_memory_set_gc_status(stable, &stat);
}
|
DoS Overflow
| 0
|
gs_memory_set_vm_threshold(gs_ref_memory_t * mem, long val)
{
gs_memory_gc_status_t stat;
gs_ref_memory_t * stable = (gs_ref_memory_t *)mem->stable_memory;
gs_memory_gc_status(mem, &stat);
stat.vm_threshold = val;
gs_memory_set_gc_status(mem, &stat);
gs_memory_gc_status(stable, &stat);
stat.vm_threshold = val;
gs_memory_set_gc_status(stable, &stat);
}
|
@@ -1248,19 +1248,32 @@ i_alloc_struct_immovable(gs_memory_t * mem, gs_memory_type_ptr_t pstype,
alloc_trace("|+<.", imem, cname, pstype, size, obj);
return obj;
}
+
+static inline bool
+alloc_array_check_size(ulong num_elements, ulong elt_size, ulong *lsize)
+{
+ int64_t s = (int64_t)num_elements * elt_size;
+ if (s > max_uint) {
+ return false;
+ }
+ *lsize = (ulong)s;
+ return true;
+}
+
static byte *
i_alloc_byte_array(gs_memory_t * mem, uint num_elements, uint elt_size,
client_name_t cname)
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
-
- obj = alloc_obj(imem, (ulong) num_elements * elt_size,
+ if (alloc_array_check_size(num_elements, elt_size, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize,
&st_bytes, ALLOC_DIRECT, cname);
if_debug6m('A', mem, "[a%d:+b.]%s -bytes-*(%lu=%u*%u) = 0x%lx\n",
@@ -1275,13 +1288,14 @@ i_alloc_byte_array_immovable(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
-
- obj = alloc_obj(imem, (ulong) num_elements * elt_size,
+ if (alloc_array_check_size(num_elements, elt_size, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize,
&st_bytes, ALLOC_IMMOVABLE | ALLOC_DIRECT,
cname);
@@ -1297,7 +1311,7 @@ i_alloc_struct_array(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
@@ -1311,9 +1325,9 @@ i_alloc_struct_array(gs_memory_t * mem, uint num_elements,
return NULL; /* fail */
}
#endif
- obj = alloc_obj(imem,
- (ulong) num_elements * pstype->ssize,
- pstype, ALLOC_DIRECT, cname);
+ if (alloc_array_check_size(num_elements, pstype->ssize, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize, pstype, ALLOC_DIRECT, cname);
if_debug7m('A', mem, "[a%d:+<.]%s %s*(%lu=%u*%u) = 0x%lx\n",
alloc_trace_space(imem), client_name_string(cname),
struct_type_name_string(pstype),
@@ -1327,16 +1341,16 @@ i_alloc_struct_array_immovable(gs_memory_t * mem, uint num_elements,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
obj_header_t *obj;
-
+ ulong lsize;
#ifdef MEMENTO
if (Memento_failThisEvent())
return NULL;
#endif
ALLOC_CHECK_SIZE(mem,pstype);
- obj = alloc_obj(imem,
- (ulong) num_elements * pstype->ssize,
- pstype, ALLOC_IMMOVABLE | ALLOC_DIRECT, cname);
+ if (alloc_array_check_size(num_elements, pstype->ssize, &lsize) == false)
+ return NULL;
+ obj = alloc_obj(imem, lsize, pstype, ALLOC_IMMOVABLE | ALLOC_DIRECT, cname);
if_debug7m('A', mem, "[a%d|+<.]%s %s*(%lu=%u*%u) = 0x%lx\n",
alloc_trace_space(imem), client_name_string(cname),
struct_type_name_string(pstype),
|
CWE-190
| null | null |
4,238
|
DOMElement* XMLHelper::appendChildElement(DOMElement* parentElement, DOMElement* childElement)
{
DOMDocument* parentDocument = parentElement->getOwnerDocument();
if (childElement->getOwnerDocument() != parentDocument) {
childElement = static_cast<DOMElement*>(parentDocument->importNode(childElement, true));
}
parentElement->appendChild(childElement);
return childElement;
}
|
DoS
| 0
|
DOMElement* XMLHelper::appendChildElement(DOMElement* parentElement, DOMElement* childElement)
{
DOMDocument* parentDocument = parentElement->getOwnerDocument();
if (childElement->getOwnerDocument() != parentDocument) {
childElement = static_cast<DOMElement*>(parentDocument->importNode(childElement, true));
}
parentElement->appendChild(childElement);
return childElement;
}
|
@@ -338,9 +338,11 @@ int XMLHelper::getAttrInt(const DOMElement* e, int defValue, const XMLCh* localN
if (e) {
const XMLCh* val = e->getAttributeNS(ns, localName);
if (val && *val) {
- int i = XMLString::parseInt(val);
- if (i)
- return i;
+ try {
+ return XMLString::parseInt(val);
+ }
+ catch (XMLException&) {
+ }
}
}
return defValue;
|
CWE-189
| null | null |
4,239
|
static inline int s16(byte *p)
{
return (signed short)( (p[0] << 8) | p[1] );
}
|
DoS
| 0
|
static inline int s16(byte *p)
{
return (signed short)( (p[0] << 8) | p[1] );
}
|
@@ -379,9 +379,14 @@ xps_encode_font_char_imp(xps_font_t *font, int code)
byte *startCount = endCount + segCount2 + 2;
byte *idDelta = startCount + segCount2;
byte *idRangeOffset = idDelta + segCount2;
+ byte *giddata;
int i2;
- for (i2 = 0; i2 < segCount2 - 3; i2 += 2)
+ if (segCount2 < 3 || segCount2 > 65535 ||
+ idRangeOffset > font->data + font->length)
+ return gs_error_invalidfont;
+
+ for (i2 = 0; i2 < segCount2 - 3; i2 += 2)
{
int delta, roff;
int start = u16(startCount + i2);
@@ -396,9 +401,12 @@ xps_encode_font_char_imp(xps_font_t *font, int code)
if ( roff == 0 )
{
return ( code + delta ) & 0xffff; /* mod 65536 */
- return 0;
}
- glyph = u16(idRangeOffset + i2 + roff + ((code - start) << 1));
+ if ((giddata = (idRangeOffset + i2 + roff + ((code - start) << 1))) >
+ font->data + font->length) {
+ return code;
+ }
+ glyph = u16(giddata);
return (glyph == 0 ? 0 : glyph + delta);
}
@@ -498,9 +506,11 @@ xps_decode_font_char_imp(xps_font_t *font, int code)
byte *startCount = endCount + segCount2 + 2;
byte *idDelta = startCount + segCount2;
byte *idRangeOffset = idDelta + segCount2;
+ byte *giddata;
int i2;
- if (segCount2 < 3 || segCount2 > 65535)
+ if (segCount2 < 3 || segCount2 > 65535 ||
+ idRangeOffset > font->data + font->length)
return gs_error_invalidfont;
for (i2 = 0; i2 < segCount2 - 3; i2 += 2)
@@ -517,7 +527,11 @@ xps_decode_font_char_imp(xps_font_t *font, int code)
if (roff == 0) {
glyph = (i + delta) & 0xffff;
} else {
- glyph = u16(idRangeOffset + i2 + roff + ((i - start) << 1));
+ if ((giddata = (idRangeOffset + i2 + roff + ((i - start) << 1))) >
+ font->data + font->length) {
+ return_error(gs_error_invalidfont);
+ }
+ glyph = u16(giddata);
}
if (glyph == code) {
return i;
|
CWE-125
| null | null |
4,240
|
static inline int u24(byte *p)
{
return (p[0] << 16) | (p[1] << 8) | p[2];
}
|
DoS
| 0
|
static inline int u24(byte *p)
{
return (p[0] << 16) | (p[1] << 8) | p[2];
}
|
@@ -379,9 +379,14 @@ xps_encode_font_char_imp(xps_font_t *font, int code)
byte *startCount = endCount + segCount2 + 2;
byte *idDelta = startCount + segCount2;
byte *idRangeOffset = idDelta + segCount2;
+ byte *giddata;
int i2;
- for (i2 = 0; i2 < segCount2 - 3; i2 += 2)
+ if (segCount2 < 3 || segCount2 > 65535 ||
+ idRangeOffset > font->data + font->length)
+ return gs_error_invalidfont;
+
+ for (i2 = 0; i2 < segCount2 - 3; i2 += 2)
{
int delta, roff;
int start = u16(startCount + i2);
@@ -396,9 +401,12 @@ xps_encode_font_char_imp(xps_font_t *font, int code)
if ( roff == 0 )
{
return ( code + delta ) & 0xffff; /* mod 65536 */
- return 0;
}
- glyph = u16(idRangeOffset + i2 + roff + ((code - start) << 1));
+ if ((giddata = (idRangeOffset + i2 + roff + ((code - start) << 1))) >
+ font->data + font->length) {
+ return code;
+ }
+ glyph = u16(giddata);
return (glyph == 0 ? 0 : glyph + delta);
}
@@ -498,9 +506,11 @@ xps_decode_font_char_imp(xps_font_t *font, int code)
byte *startCount = endCount + segCount2 + 2;
byte *idDelta = startCount + segCount2;
byte *idRangeOffset = idDelta + segCount2;
+ byte *giddata;
int i2;
- if (segCount2 < 3 || segCount2 > 65535)
+ if (segCount2 < 3 || segCount2 > 65535 ||
+ idRangeOffset > font->data + font->length)
return gs_error_invalidfont;
for (i2 = 0; i2 < segCount2 - 3; i2 += 2)
@@ -517,7 +527,11 @@ xps_decode_font_char_imp(xps_font_t *font, int code)
if (roff == 0) {
glyph = (i + delta) & 0xffff;
} else {
- glyph = u16(idRangeOffset + i2 + roff + ((i - start) << 1));
+ if ((giddata = (idRangeOffset + i2 + roff + ((i - start) << 1))) >
+ font->data + font->length) {
+ return_error(gs_error_invalidfont);
+ }
+ glyph = u16(giddata);
}
if (glyph == code) {
return i;
|
CWE-125
| null | null |
4,241
|
static inline int u32(byte *p)
{
return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
}
|
DoS
| 0
|
static inline int u32(byte *p)
{
return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
}
|
@@ -379,9 +379,14 @@ xps_encode_font_char_imp(xps_font_t *font, int code)
byte *startCount = endCount + segCount2 + 2;
byte *idDelta = startCount + segCount2;
byte *idRangeOffset = idDelta + segCount2;
+ byte *giddata;
int i2;
- for (i2 = 0; i2 < segCount2 - 3; i2 += 2)
+ if (segCount2 < 3 || segCount2 > 65535 ||
+ idRangeOffset > font->data + font->length)
+ return gs_error_invalidfont;
+
+ for (i2 = 0; i2 < segCount2 - 3; i2 += 2)
{
int delta, roff;
int start = u16(startCount + i2);
@@ -396,9 +401,12 @@ xps_encode_font_char_imp(xps_font_t *font, int code)
if ( roff == 0 )
{
return ( code + delta ) & 0xffff; /* mod 65536 */
- return 0;
}
- glyph = u16(idRangeOffset + i2 + roff + ((code - start) << 1));
+ if ((giddata = (idRangeOffset + i2 + roff + ((code - start) << 1))) >
+ font->data + font->length) {
+ return code;
+ }
+ glyph = u16(giddata);
return (glyph == 0 ? 0 : glyph + delta);
}
@@ -498,9 +506,11 @@ xps_decode_font_char_imp(xps_font_t *font, int code)
byte *startCount = endCount + segCount2 + 2;
byte *idDelta = startCount + segCount2;
byte *idRangeOffset = idDelta + segCount2;
+ byte *giddata;
int i2;
- if (segCount2 < 3 || segCount2 > 65535)
+ if (segCount2 < 3 || segCount2 > 65535 ||
+ idRangeOffset > font->data + font->length)
return gs_error_invalidfont;
for (i2 = 0; i2 < segCount2 - 3; i2 += 2)
@@ -517,7 +527,11 @@ xps_decode_font_char_imp(xps_font_t *font, int code)
if (roff == 0) {
glyph = (i + delta) & 0xffff;
} else {
- glyph = u16(idRangeOffset + i2 + roff + ((i - start) << 1));
+ if ((giddata = (idRangeOffset + i2 + roff + ((i - start) << 1))) >
+ font->data + font->length) {
+ return_error(gs_error_invalidfont);
+ }
+ glyph = u16(giddata);
}
if (glyph == code) {
return i;
|
CWE-125
| null | null |
4,242
|
xps_count_font_encodings(xps_font_t *font)
{
return font->cmapsubcount;
}
|
DoS
| 0
|
xps_count_font_encodings(xps_font_t *font)
{
return font->cmapsubcount;
}
|
@@ -379,9 +379,14 @@ xps_encode_font_char_imp(xps_font_t *font, int code)
byte *startCount = endCount + segCount2 + 2;
byte *idDelta = startCount + segCount2;
byte *idRangeOffset = idDelta + segCount2;
+ byte *giddata;
int i2;
- for (i2 = 0; i2 < segCount2 - 3; i2 += 2)
+ if (segCount2 < 3 || segCount2 > 65535 ||
+ idRangeOffset > font->data + font->length)
+ return gs_error_invalidfont;
+
+ for (i2 = 0; i2 < segCount2 - 3; i2 += 2)
{
int delta, roff;
int start = u16(startCount + i2);
@@ -396,9 +401,12 @@ xps_encode_font_char_imp(xps_font_t *font, int code)
if ( roff == 0 )
{
return ( code + delta ) & 0xffff; /* mod 65536 */
- return 0;
}
- glyph = u16(idRangeOffset + i2 + roff + ((code - start) << 1));
+ if ((giddata = (idRangeOffset + i2 + roff + ((code - start) << 1))) >
+ font->data + font->length) {
+ return code;
+ }
+ glyph = u16(giddata);
return (glyph == 0 ? 0 : glyph + delta);
}
@@ -498,9 +506,11 @@ xps_decode_font_char_imp(xps_font_t *font, int code)
byte *startCount = endCount + segCount2 + 2;
byte *idDelta = startCount + segCount2;
byte *idRangeOffset = idDelta + segCount2;
+ byte *giddata;
int i2;
- if (segCount2 < 3 || segCount2 > 65535)
+ if (segCount2 < 3 || segCount2 > 65535 ||
+ idRangeOffset > font->data + font->length)
return gs_error_invalidfont;
for (i2 = 0; i2 < segCount2 - 3; i2 += 2)
@@ -517,7 +527,11 @@ xps_decode_font_char_imp(xps_font_t *font, int code)
if (roff == 0) {
glyph = (i + delta) & 0xffff;
} else {
- glyph = u16(idRangeOffset + i2 + roff + ((i - start) << 1));
+ if ((giddata = (idRangeOffset + i2 + roff + ((i - start) << 1))) >
+ font->data + font->length) {
+ return_error(gs_error_invalidfont);
+ }
+ glyph = u16(giddata);
}
if (glyph == code) {
return i;
|
CWE-125
| null | null |
4,243
|
xps_find_sfnt_table(xps_font_t *font, const char *name, int *lengthp)
{
int offset;
int ntables;
int i;
if (font->length < 12)
return -1;
if (!memcmp(font->data, "ttcf", 4))
{
int nfonts = u32(font->data + 8);
if (font->subfontid < 0 || font->subfontid >= nfonts)
{
gs_warn("Invalid subfont ID");
return -1;
}
offset = u32(font->data + 12 + font->subfontid * 4);
}
else
{
offset = 0;
}
ntables = u16(font->data + offset + 4);
if (font->length < offset + 12 + ntables * 16)
return -1;
for (i = 0; i < ntables; i++)
{
byte *entry = font->data + offset + 12 + i * 16;
if (!memcmp(entry, name, 4))
{
if (lengthp)
*lengthp = u32(entry + 12);
return u32(entry + 8);
}
}
return -1;
}
|
DoS
| 0
|
xps_find_sfnt_table(xps_font_t *font, const char *name, int *lengthp)
{
int offset;
int ntables;
int i;
if (font->length < 12)
return -1;
if (!memcmp(font->data, "ttcf", 4))
{
int nfonts = u32(font->data + 8);
if (font->subfontid < 0 || font->subfontid >= nfonts)
{
gs_warn("Invalid subfont ID");
return -1;
}
offset = u32(font->data + 12 + font->subfontid * 4);
}
else
{
offset = 0;
}
ntables = u16(font->data + offset + 4);
if (font->length < offset + 12 + ntables * 16)
return -1;
for (i = 0; i < ntables; i++)
{
byte *entry = font->data + offset + 12 + i * 16;
if (!memcmp(entry, name, 4))
{
if (lengthp)
*lengthp = u32(entry + 12);
return u32(entry + 8);
}
}
return -1;
}
|
@@ -379,9 +379,14 @@ xps_encode_font_char_imp(xps_font_t *font, int code)
byte *startCount = endCount + segCount2 + 2;
byte *idDelta = startCount + segCount2;
byte *idRangeOffset = idDelta + segCount2;
+ byte *giddata;
int i2;
- for (i2 = 0; i2 < segCount2 - 3; i2 += 2)
+ if (segCount2 < 3 || segCount2 > 65535 ||
+ idRangeOffset > font->data + font->length)
+ return gs_error_invalidfont;
+
+ for (i2 = 0; i2 < segCount2 - 3; i2 += 2)
{
int delta, roff;
int start = u16(startCount + i2);
@@ -396,9 +401,12 @@ xps_encode_font_char_imp(xps_font_t *font, int code)
if ( roff == 0 )
{
return ( code + delta ) & 0xffff; /* mod 65536 */
- return 0;
}
- glyph = u16(idRangeOffset + i2 + roff + ((code - start) << 1));
+ if ((giddata = (idRangeOffset + i2 + roff + ((code - start) << 1))) >
+ font->data + font->length) {
+ return code;
+ }
+ glyph = u16(giddata);
return (glyph == 0 ? 0 : glyph + delta);
}
@@ -498,9 +506,11 @@ xps_decode_font_char_imp(xps_font_t *font, int code)
byte *startCount = endCount + segCount2 + 2;
byte *idDelta = startCount + segCount2;
byte *idRangeOffset = idDelta + segCount2;
+ byte *giddata;
int i2;
- if (segCount2 < 3 || segCount2 > 65535)
+ if (segCount2 < 3 || segCount2 > 65535 ||
+ idRangeOffset > font->data + font->length)
return gs_error_invalidfont;
for (i2 = 0; i2 < segCount2 - 3; i2 += 2)
@@ -517,7 +527,11 @@ xps_decode_font_char_imp(xps_font_t *font, int code)
if (roff == 0) {
glyph = (i + delta) & 0xffff;
} else {
- glyph = u16(idRangeOffset + i2 + roff + ((i - start) << 1));
+ if ((giddata = (idRangeOffset + i2 + roff + ((i - start) << 1))) >
+ font->data + font->length) {
+ return_error(gs_error_invalidfont);
+ }
+ glyph = u16(giddata);
}
if (glyph == code) {
return i;
|
CWE-125
| null | null |
4,244
|
xps_free_font(xps_context_t *ctx, xps_font_t *font)
{
if (font->font)
{
gs_font_finalize(ctx->memory, font->font);
gs_free_object(ctx->memory, font->font, "font object");
}
xps_free(ctx, font);
}
|
DoS
| 0
|
xps_free_font(xps_context_t *ctx, xps_font_t *font)
{
if (font->font)
{
gs_font_finalize(ctx->memory, font->font);
gs_free_object(ctx->memory, font->font, "font object");
}
xps_free(ctx, font);
}
|
@@ -379,9 +379,14 @@ xps_encode_font_char_imp(xps_font_t *font, int code)
byte *startCount = endCount + segCount2 + 2;
byte *idDelta = startCount + segCount2;
byte *idRangeOffset = idDelta + segCount2;
+ byte *giddata;
int i2;
- for (i2 = 0; i2 < segCount2 - 3; i2 += 2)
+ if (segCount2 < 3 || segCount2 > 65535 ||
+ idRangeOffset > font->data + font->length)
+ return gs_error_invalidfont;
+
+ for (i2 = 0; i2 < segCount2 - 3; i2 += 2)
{
int delta, roff;
int start = u16(startCount + i2);
@@ -396,9 +401,12 @@ xps_encode_font_char_imp(xps_font_t *font, int code)
if ( roff == 0 )
{
return ( code + delta ) & 0xffff; /* mod 65536 */
- return 0;
}
- glyph = u16(idRangeOffset + i2 + roff + ((code - start) << 1));
+ if ((giddata = (idRangeOffset + i2 + roff + ((code - start) << 1))) >
+ font->data + font->length) {
+ return code;
+ }
+ glyph = u16(giddata);
return (glyph == 0 ? 0 : glyph + delta);
}
@@ -498,9 +506,11 @@ xps_decode_font_char_imp(xps_font_t *font, int code)
byte *startCount = endCount + segCount2 + 2;
byte *idDelta = startCount + segCount2;
byte *idRangeOffset = idDelta + segCount2;
+ byte *giddata;
int i2;
- if (segCount2 < 3 || segCount2 > 65535)
+ if (segCount2 < 3 || segCount2 > 65535 ||
+ idRangeOffset > font->data + font->length)
return gs_error_invalidfont;
for (i2 = 0; i2 < segCount2 - 3; i2 += 2)
@@ -517,7 +527,11 @@ xps_decode_font_char_imp(xps_font_t *font, int code)
if (roff == 0) {
glyph = (i + delta) & 0xffff;
} else {
- glyph = u16(idRangeOffset + i2 + roff + ((i - start) << 1));
+ if ((giddata = (idRangeOffset + i2 + roff + ((i - start) << 1))) >
+ font->data + font->length) {
+ return_error(gs_error_invalidfont);
+ }
+ glyph = u16(giddata);
}
if (glyph == code) {
return i;
|
CWE-125
| null | null |
4,245
|
xps_load_sfnt_cmap(xps_font_t *font)
{
byte *cmapdata;
int offset, length;
int nsubtables;
offset = xps_find_sfnt_table(font, "cmap", &length);
if (offset < 0 || length < 4)
{
gs_warn("cannot find cmap table");
return;
}
cmapdata = font->data + offset;
nsubtables = u16(cmapdata + 2);
if (nsubtables < 0 || length < 4 + nsubtables * 8)
{
gs_warn("cannot find cmap sub-tables");
return;
}
font->cmaptable = offset;
font->cmapsubcount = nsubtables;
font->cmapsubtable = 0;
}
|
DoS
| 0
|
xps_load_sfnt_cmap(xps_font_t *font)
{
byte *cmapdata;
int offset, length;
int nsubtables;
offset = xps_find_sfnt_table(font, "cmap", &length);
if (offset < 0 || length < 4)
{
gs_warn("cannot find cmap table");
return;
}
cmapdata = font->data + offset;
nsubtables = u16(cmapdata + 2);
if (nsubtables < 0 || length < 4 + nsubtables * 8)
{
gs_warn("cannot find cmap sub-tables");
return;
}
font->cmaptable = offset;
font->cmapsubcount = nsubtables;
font->cmapsubtable = 0;
}
|
@@ -379,9 +379,14 @@ xps_encode_font_char_imp(xps_font_t *font, int code)
byte *startCount = endCount + segCount2 + 2;
byte *idDelta = startCount + segCount2;
byte *idRangeOffset = idDelta + segCount2;
+ byte *giddata;
int i2;
- for (i2 = 0; i2 < segCount2 - 3; i2 += 2)
+ if (segCount2 < 3 || segCount2 > 65535 ||
+ idRangeOffset > font->data + font->length)
+ return gs_error_invalidfont;
+
+ for (i2 = 0; i2 < segCount2 - 3; i2 += 2)
{
int delta, roff;
int start = u16(startCount + i2);
@@ -396,9 +401,12 @@ xps_encode_font_char_imp(xps_font_t *font, int code)
if ( roff == 0 )
{
return ( code + delta ) & 0xffff; /* mod 65536 */
- return 0;
}
- glyph = u16(idRangeOffset + i2 + roff + ((code - start) << 1));
+ if ((giddata = (idRangeOffset + i2 + roff + ((code - start) << 1))) >
+ font->data + font->length) {
+ return code;
+ }
+ glyph = u16(giddata);
return (glyph == 0 ? 0 : glyph + delta);
}
@@ -498,9 +506,11 @@ xps_decode_font_char_imp(xps_font_t *font, int code)
byte *startCount = endCount + segCount2 + 2;
byte *idDelta = startCount + segCount2;
byte *idRangeOffset = idDelta + segCount2;
+ byte *giddata;
int i2;
- if (segCount2 < 3 || segCount2 > 65535)
+ if (segCount2 < 3 || segCount2 > 65535 ||
+ idRangeOffset > font->data + font->length)
return gs_error_invalidfont;
for (i2 = 0; i2 < segCount2 - 3; i2 += 2)
@@ -517,7 +527,11 @@ xps_decode_font_char_imp(xps_font_t *font, int code)
if (roff == 0) {
glyph = (i + delta) & 0xffff;
} else {
- glyph = u16(idRangeOffset + i2 + roff + ((i - start) << 1));
+ if ((giddata = (idRangeOffset + i2 + roff + ((i - start) << 1))) >
+ font->data + font->length) {
+ return_error(gs_error_invalidfont);
+ }
+ glyph = u16(giddata);
}
if (glyph == code) {
return i;
|
CWE-125
| null | null |
4,246
|
xps_load_sfnt_name(xps_font_t *font, char *namep, const int buflen)
{
byte *namedata;
int offset, length;
/*int format;*/
int count, stringoffset;
int found;
int i, k;
found = 0;
strcpy(namep, "Unknown");
offset = xps_find_sfnt_table(font, "name", &length);
if (offset < 0 || length < 6)
{
gs_warn("cannot find name table");
return;
}
/* validate the offset, and the data for the two
* values we're about to read
*/
if (offset + 6 > font->length)
{
gs_warn("name table byte offset invalid");
return;
}
namedata = font->data + offset;
/*format = u16(namedata + 0);*/
count = u16(namedata + 2);
stringoffset = u16(namedata + 4);
if (stringoffset + offset > font->length
|| offset + 6 + count * 12 > font->length)
{
gs_warn("name table invalid");
return;
}
if (length < 6 + (count * 12))
{
gs_warn("name table too short");
return;
}
for (i = 0; i < count; i++)
{
byte *record = namedata + 6 + i * 12;
int pid = u16(record + 0);
int eid = u16(record + 2);
int langid = u16(record + 4);
int nameid = u16(record + 6);
length = u16(record + 8);
offset = u16(record + 10);
length = length > buflen - 1 ? buflen - 1: length;
/* Full font name or postscript name */
if (nameid == 4 || nameid == 6)
{
if (pid == 1 && eid == 0 && langid == 0) /* mac roman, english */
{
if (found < 3)
{
memcpy(namep, namedata + stringoffset + offset, length);
namep[length] = 0;
found = 3;
}
}
if (pid == 3 && eid == 1 && langid == 0x409) /* windows unicode ucs-2, US */
{
if (found < 2)
{
unsigned char *s = namedata + stringoffset + offset;
int n = length / 2;
for (k = 0; k < n; k ++)
{
int c = u16(s + k * 2);
namep[k] = isprint(c) ? c : '?';
}
namep[k] = 0;
found = 2;
}
}
if (pid == 3 && eid == 10 && langid == 0x409) /* windows unicode ucs-4, US */
{
if (found < 1)
{
unsigned char *s = namedata + stringoffset + offset;
int n = length / 4;
for (k = 0; k < n; k ++)
{
int c = u32(s + k * 4);
namep[k] = isprint(c) ? c : '?';
}
namep[k] = 0;
found = 1;
}
}
}
}
}
|
DoS
| 0
|
xps_load_sfnt_name(xps_font_t *font, char *namep, const int buflen)
{
byte *namedata;
int offset, length;
/*int format;*/
int count, stringoffset;
int found;
int i, k;
found = 0;
strcpy(namep, "Unknown");
offset = xps_find_sfnt_table(font, "name", &length);
if (offset < 0 || length < 6)
{
gs_warn("cannot find name table");
return;
}
/* validate the offset, and the data for the two
* values we're about to read
*/
if (offset + 6 > font->length)
{
gs_warn("name table byte offset invalid");
return;
}
namedata = font->data + offset;
/*format = u16(namedata + 0);*/
count = u16(namedata + 2);
stringoffset = u16(namedata + 4);
if (stringoffset + offset > font->length
|| offset + 6 + count * 12 > font->length)
{
gs_warn("name table invalid");
return;
}
if (length < 6 + (count * 12))
{
gs_warn("name table too short");
return;
}
for (i = 0; i < count; i++)
{
byte *record = namedata + 6 + i * 12;
int pid = u16(record + 0);
int eid = u16(record + 2);
int langid = u16(record + 4);
int nameid = u16(record + 6);
length = u16(record + 8);
offset = u16(record + 10);
length = length > buflen - 1 ? buflen - 1: length;
/* Full font name or postscript name */
if (nameid == 4 || nameid == 6)
{
if (pid == 1 && eid == 0 && langid == 0) /* mac roman, english */
{
if (found < 3)
{
memcpy(namep, namedata + stringoffset + offset, length);
namep[length] = 0;
found = 3;
}
}
if (pid == 3 && eid == 1 && langid == 0x409) /* windows unicode ucs-2, US */
{
if (found < 2)
{
unsigned char *s = namedata + stringoffset + offset;
int n = length / 2;
for (k = 0; k < n; k ++)
{
int c = u16(s + k * 2);
namep[k] = isprint(c) ? c : '?';
}
namep[k] = 0;
found = 2;
}
}
if (pid == 3 && eid == 10 && langid == 0x409) /* windows unicode ucs-4, US */
{
if (found < 1)
{
unsigned char *s = namedata + stringoffset + offset;
int n = length / 4;
for (k = 0; k < n; k ++)
{
int c = u32(s + k * 4);
namep[k] = isprint(c) ? c : '?';
}
namep[k] = 0;
found = 1;
}
}
}
}
}
|
@@ -379,9 +379,14 @@ xps_encode_font_char_imp(xps_font_t *font, int code)
byte *startCount = endCount + segCount2 + 2;
byte *idDelta = startCount + segCount2;
byte *idRangeOffset = idDelta + segCount2;
+ byte *giddata;
int i2;
- for (i2 = 0; i2 < segCount2 - 3; i2 += 2)
+ if (segCount2 < 3 || segCount2 > 65535 ||
+ idRangeOffset > font->data + font->length)
+ return gs_error_invalidfont;
+
+ for (i2 = 0; i2 < segCount2 - 3; i2 += 2)
{
int delta, roff;
int start = u16(startCount + i2);
@@ -396,9 +401,12 @@ xps_encode_font_char_imp(xps_font_t *font, int code)
if ( roff == 0 )
{
return ( code + delta ) & 0xffff; /* mod 65536 */
- return 0;
}
- glyph = u16(idRangeOffset + i2 + roff + ((code - start) << 1));
+ if ((giddata = (idRangeOffset + i2 + roff + ((code - start) << 1))) >
+ font->data + font->length) {
+ return code;
+ }
+ glyph = u16(giddata);
return (glyph == 0 ? 0 : glyph + delta);
}
@@ -498,9 +506,11 @@ xps_decode_font_char_imp(xps_font_t *font, int code)
byte *startCount = endCount + segCount2 + 2;
byte *idDelta = startCount + segCount2;
byte *idRangeOffset = idDelta + segCount2;
+ byte *giddata;
int i2;
- if (segCount2 < 3 || segCount2 > 65535)
+ if (segCount2 < 3 || segCount2 > 65535 ||
+ idRangeOffset > font->data + font->length)
return gs_error_invalidfont;
for (i2 = 0; i2 < segCount2 - 3; i2 += 2)
@@ -517,7 +527,11 @@ xps_decode_font_char_imp(xps_font_t *font, int code)
if (roff == 0) {
glyph = (i + delta) & 0xffff;
} else {
- glyph = u16(idRangeOffset + i2 + roff + ((i - start) << 1));
+ if ((giddata = (idRangeOffset + i2 + roff + ((i - start) << 1))) >
+ font->data + font->length) {
+ return_error(gs_error_invalidfont);
+ }
+ glyph = u16(giddata);
}
if (glyph == code) {
return i;
|
CWE-125
| null | null |
4,247
|
xps_new_font(xps_context_t *ctx, byte *buf, int buflen, int index)
{
xps_font_t *font;
int code;
font = xps_alloc(ctx, sizeof(xps_font_t));
if (!font)
{
gs_throw(gs_error_VMerror, "out of memory");
return NULL;
}
font->data = buf;
font->length = buflen;
font->font = NULL;
font->subfontid = index;
font->cmaptable = 0;
font->cmapsubcount = 0;
font->cmapsubtable = 0;
font->usepua = 0;
font->cffdata = 0;
font->cffend = 0;
font->gsubrs = 0;
font->subrs = 0;
font->charstrings = 0;
if (memcmp(font->data, "OTTO", 4) == 0)
code = xps_init_postscript_font(ctx, font);
else if (memcmp(font->data, "\0\1\0\0", 4) == 0)
code = xps_init_truetype_font(ctx, font);
else if (memcmp(font->data, "true", 4) == 0)
code = xps_init_truetype_font(ctx, font);
else if (memcmp(font->data, "ttcf", 4) == 0)
code = xps_init_truetype_font(ctx, font);
else
{
xps_free_font(ctx, font);
gs_throw(-1, "not an opentype font");
return NULL;
}
if (code < 0)
{
xps_free_font(ctx, font);
gs_rethrow(-1, "cannot init font");
return NULL;
}
xps_load_sfnt_cmap(font);
return font;
}
|
DoS
| 0
|
xps_new_font(xps_context_t *ctx, byte *buf, int buflen, int index)
{
xps_font_t *font;
int code;
font = xps_alloc(ctx, sizeof(xps_font_t));
if (!font)
{
gs_throw(gs_error_VMerror, "out of memory");
return NULL;
}
font->data = buf;
font->length = buflen;
font->font = NULL;
font->subfontid = index;
font->cmaptable = 0;
font->cmapsubcount = 0;
font->cmapsubtable = 0;
font->usepua = 0;
font->cffdata = 0;
font->cffend = 0;
font->gsubrs = 0;
font->subrs = 0;
font->charstrings = 0;
if (memcmp(font->data, "OTTO", 4) == 0)
code = xps_init_postscript_font(ctx, font);
else if (memcmp(font->data, "\0\1\0\0", 4) == 0)
code = xps_init_truetype_font(ctx, font);
else if (memcmp(font->data, "true", 4) == 0)
code = xps_init_truetype_font(ctx, font);
else if (memcmp(font->data, "ttcf", 4) == 0)
code = xps_init_truetype_font(ctx, font);
else
{
xps_free_font(ctx, font);
gs_throw(-1, "not an opentype font");
return NULL;
}
if (code < 0)
{
xps_free_font(ctx, font);
gs_rethrow(-1, "cannot init font");
return NULL;
}
xps_load_sfnt_cmap(font);
return font;
}
|
@@ -379,9 +379,14 @@ xps_encode_font_char_imp(xps_font_t *font, int code)
byte *startCount = endCount + segCount2 + 2;
byte *idDelta = startCount + segCount2;
byte *idRangeOffset = idDelta + segCount2;
+ byte *giddata;
int i2;
- for (i2 = 0; i2 < segCount2 - 3; i2 += 2)
+ if (segCount2 < 3 || segCount2 > 65535 ||
+ idRangeOffset > font->data + font->length)
+ return gs_error_invalidfont;
+
+ for (i2 = 0; i2 < segCount2 - 3; i2 += 2)
{
int delta, roff;
int start = u16(startCount + i2);
@@ -396,9 +401,12 @@ xps_encode_font_char_imp(xps_font_t *font, int code)
if ( roff == 0 )
{
return ( code + delta ) & 0xffff; /* mod 65536 */
- return 0;
}
- glyph = u16(idRangeOffset + i2 + roff + ((code - start) << 1));
+ if ((giddata = (idRangeOffset + i2 + roff + ((code - start) << 1))) >
+ font->data + font->length) {
+ return code;
+ }
+ glyph = u16(giddata);
return (glyph == 0 ? 0 : glyph + delta);
}
@@ -498,9 +506,11 @@ xps_decode_font_char_imp(xps_font_t *font, int code)
byte *startCount = endCount + segCount2 + 2;
byte *idDelta = startCount + segCount2;
byte *idRangeOffset = idDelta + segCount2;
+ byte *giddata;
int i2;
- if (segCount2 < 3 || segCount2 > 65535)
+ if (segCount2 < 3 || segCount2 > 65535 ||
+ idRangeOffset > font->data + font->length)
return gs_error_invalidfont;
for (i2 = 0; i2 < segCount2 - 3; i2 += 2)
@@ -517,7 +527,11 @@ xps_decode_font_char_imp(xps_font_t *font, int code)
if (roff == 0) {
glyph = (i + delta) & 0xffff;
} else {
- glyph = u16(idRangeOffset + i2 + roff + ((i - start) << 1));
+ if ((giddata = (idRangeOffset + i2 + roff + ((i - start) << 1))) >
+ font->data + font->length) {
+ return_error(gs_error_invalidfont);
+ }
+ glyph = u16(giddata);
}
if (glyph == code) {
return i;
|
CWE-125
| null | null |
4,248
|
static void Compute_Funcs( EXEC_OP )
{
if ( CUR.GS.freeVector.x == 0x4000 )
{
CUR.func_freeProj = (TProject_Function)Project_x;
CUR.F_dot_P = CUR.GS.projVector.x * 0x10000L;
}
else
{
if ( CUR.GS.freeVector.y == 0x4000 )
{
CUR.func_freeProj = (TProject_Function)Project_y;
CUR.F_dot_P = CUR.GS.projVector.y * 0x10000L;
}
else
{
CUR.func_move = (TMove_Function)Direct_Move;
CUR.func_freeProj = (TProject_Function)Free_Project;
CUR.F_dot_P = (Long)CUR.GS.projVector.x * CUR.GS.freeVector.x * 4 +
(Long)CUR.GS.projVector.y * CUR.GS.freeVector.y * 4;
}
}
CUR.cached_metrics = FALSE;
if ( CUR.GS.projVector.x == 0x4000 )
CUR.func_project = (TProject_Function)Project_x;
else
{
if ( CUR.GS.projVector.y == 0x4000 )
CUR.func_project = (TProject_Function)Project_y;
else
CUR.func_project = (TProject_Function)Project;
}
if ( CUR.GS.dualVector.x == 0x4000 )
CUR.func_dualproj = (TProject_Function)Project_x;
else
{
if ( CUR.GS.dualVector.y == 0x4000 )
CUR.func_dualproj = (TProject_Function)Project_y;
else
CUR.func_dualproj = (TProject_Function)Dual_Project;
}
CUR.func_move = (TMove_Function)Direct_Move;
if ( CUR.F_dot_P == 0x40000000L )
{
if ( CUR.GS.freeVector.x == 0x4000 )
CUR.func_move = (TMove_Function)Direct_Move_X;
else
{
if ( CUR.GS.freeVector.y == 0x4000 )
CUR.func_move = (TMove_Function)Direct_Move_Y;
}
}
/* at small sizes, F_dot_P can become too small, resulting */
/* in overflows and 'spikes' in a number of glyphs like 'w'. */
if ( ABS( CUR.F_dot_P ) < 0x4000000L )
CUR.F_dot_P = 0x40000000L;
/* Disable cached aspect ratio */
CUR.metrics.ratio = 0;
}
|
DoS
| 0
|
static void Compute_Funcs( EXEC_OP )
{
if ( CUR.GS.freeVector.x == 0x4000 )
{
CUR.func_freeProj = (TProject_Function)Project_x;
CUR.F_dot_P = CUR.GS.projVector.x * 0x10000L;
}
else
{
if ( CUR.GS.freeVector.y == 0x4000 )
{
CUR.func_freeProj = (TProject_Function)Project_y;
CUR.F_dot_P = CUR.GS.projVector.y * 0x10000L;
}
else
{
CUR.func_move = (TMove_Function)Direct_Move;
CUR.func_freeProj = (TProject_Function)Free_Project;
CUR.F_dot_P = (Long)CUR.GS.projVector.x * CUR.GS.freeVector.x * 4 +
(Long)CUR.GS.projVector.y * CUR.GS.freeVector.y * 4;
}
}
CUR.cached_metrics = FALSE;
if ( CUR.GS.projVector.x == 0x4000 )
CUR.func_project = (TProject_Function)Project_x;
else
{
if ( CUR.GS.projVector.y == 0x4000 )
CUR.func_project = (TProject_Function)Project_y;
else
CUR.func_project = (TProject_Function)Project;
}
if ( CUR.GS.dualVector.x == 0x4000 )
CUR.func_dualproj = (TProject_Function)Project_x;
else
{
if ( CUR.GS.dualVector.y == 0x4000 )
CUR.func_dualproj = (TProject_Function)Project_y;
else
CUR.func_dualproj = (TProject_Function)Dual_Project;
}
CUR.func_move = (TMove_Function)Direct_Move;
if ( CUR.F_dot_P == 0x40000000L )
{
if ( CUR.GS.freeVector.x == 0x4000 )
CUR.func_move = (TMove_Function)Direct_Move_X;
else
{
if ( CUR.GS.freeVector.y == 0x4000 )
CUR.func_move = (TMove_Function)Direct_Move_Y;
}
}
/* at small sizes, F_dot_P can become too small, resulting */
/* in overflows and 'spikes' in a number of glyphs like 'w'. */
if ( ABS( CUR.F_dot_P ) < 0x4000000L )
CUR.F_dot_P = 0x40000000L;
/* Disable cached aspect ratio */
CUR.metrics.ratio = 0;
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,249
|
static Bool Compute_Point_Displacement( EXEC_OPS
PCoordinates x,
PCoordinates y,
PGlyph_Zone zone,
Int* refp )
{
TGlyph_Zone zp;
Int p;
TT_F26Dot6 d;
if ( CUR.opcode & 1 )
{
zp = CUR.zp0;
p = CUR.GS.rp1;
}
else
{
zp = CUR.zp1;
p = CUR.GS.rp2;
}
if ( BOUNDS( p, zp.n_points ) )
{
/* Don't set error code, just return. */
/* Ported from Freetype2 */
*refp = 0;
return FAILURE;
}
*zone = zp;
*refp = p;
d = CUR_Func_project( zp.cur_x[p] - zp.org_x[p],
zp.cur_y[p] - zp.org_y[p] );
*x = MulDiv_Round(d, (Long)CUR.GS.freeVector.x * 0x10000L, CUR.F_dot_P );
*y = MulDiv_Round(d, (Long)CUR.GS.freeVector.y * 0x10000L, CUR.F_dot_P );
return SUCCESS;
}
|
DoS
| 0
|
static Bool Compute_Point_Displacement( EXEC_OPS
PCoordinates x,
PCoordinates y,
PGlyph_Zone zone,
Int* refp )
{
TGlyph_Zone zp;
Int p;
TT_F26Dot6 d;
if ( CUR.opcode & 1 )
{
zp = CUR.zp0;
p = CUR.GS.rp1;
}
else
{
zp = CUR.zp1;
p = CUR.GS.rp2;
}
if ( BOUNDS( p, zp.n_points ) )
{
/* Don't set error code, just return. */
/* Ported from Freetype2 */
*refp = 0;
return FAILURE;
}
*zone = zp;
*refp = p;
d = CUR_Func_project( zp.cur_x[p] - zp.org_x[p],
zp.cur_y[p] - zp.org_y[p] );
*x = MulDiv_Round(d, (Long)CUR.GS.freeVector.x * 0x10000L, CUR.F_dot_P );
*y = MulDiv_Round(d, (Long)CUR.GS.freeVector.y * 0x10000L, CUR.F_dot_P );
return SUCCESS;
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,250
|
static void Compute_Round( EXEC_OPS Byte round_mode )
{
switch ( round_mode )
{
case TT_Round_Off:
CUR.func_round = (TRound_Function)Round_None;
break;
case TT_Round_To_Grid:
CUR.func_round = (TRound_Function)Round_To_Grid;
break;
case TT_Round_Up_To_Grid:
CUR.func_round = (TRound_Function)Round_Up_To_Grid;
break;
case TT_Round_Down_To_Grid:
CUR.func_round = (TRound_Function)Round_Down_To_Grid;
break;
case TT_Round_To_Half_Grid:
CUR.func_round = (TRound_Function)Round_To_Half_Grid;
break;
case TT_Round_To_Double_Grid:
CUR.func_round = (TRound_Function)Round_To_Double_Grid;
break;
case TT_Round_Super:
CUR.func_round = (TRound_Function)Round_Super;
break;
case TT_Round_Super_45:
CUR.func_round = (TRound_Function)Round_Super_45;
break;
}
}
|
DoS
| 0
|
static void Compute_Round( EXEC_OPS Byte round_mode )
{
switch ( round_mode )
{
case TT_Round_Off:
CUR.func_round = (TRound_Function)Round_None;
break;
case TT_Round_To_Grid:
CUR.func_round = (TRound_Function)Round_To_Grid;
break;
case TT_Round_Up_To_Grid:
CUR.func_round = (TRound_Function)Round_Up_To_Grid;
break;
case TT_Round_Down_To_Grid:
CUR.func_round = (TRound_Function)Round_Down_To_Grid;
break;
case TT_Round_To_Half_Grid:
CUR.func_round = (TRound_Function)Round_To_Half_Grid;
break;
case TT_Round_To_Double_Grid:
CUR.func_round = (TRound_Function)Round_To_Double_Grid;
break;
case TT_Round_Super:
CUR.func_round = (TRound_Function)Round_Super;
break;
case TT_Round_Super_45:
CUR.func_round = (TRound_Function)Round_Super_45;
break;
}
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,251
|
static Int Current_Ppem( EXEC_OP )
{
return MulDiv_Round( CUR.metrics.ppem, CURRENT_Ratio(), 0x10000 );
}
|
DoS
| 0
|
static Int Current_Ppem( EXEC_OP )
{
return MulDiv_Round( CUR.metrics.ppem, CURRENT_Ratio(), 0x10000 );
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,252
|
static Long Current_Ratio( EXEC_OP )
{
if ( CUR.metrics.ratio )
return CUR.metrics.ratio;
if ( CUR.GS.projVector.y == 0 )
CUR.metrics.ratio = CUR.metrics.x_ratio;
else if ( CUR.GS.projVector.x == 0 )
CUR.metrics.ratio = CUR.metrics.y_ratio;
else
{
Long x, y;
x = MulDiv_Round( CUR.GS.projVector.x, CUR.metrics.x_ratio, 0x4000 );
y = MulDiv_Round( CUR.GS.projVector.y, CUR.metrics.y_ratio, 0x4000 );
CUR.metrics.ratio = Norm( x, y );
}
return CUR.metrics.ratio;
}
|
DoS
| 0
|
static Long Current_Ratio( EXEC_OP )
{
if ( CUR.metrics.ratio )
return CUR.metrics.ratio;
if ( CUR.GS.projVector.y == 0 )
CUR.metrics.ratio = CUR.metrics.x_ratio;
else if ( CUR.GS.projVector.x == 0 )
CUR.metrics.ratio = CUR.metrics.y_ratio;
else
{
Long x, y;
x = MulDiv_Round( CUR.GS.projVector.x, CUR.metrics.x_ratio, 0x4000 );
y = MulDiv_Round( CUR.GS.projVector.y, CUR.metrics.y_ratio, 0x4000 );
CUR.metrics.ratio = Norm( x, y );
}
return CUR.metrics.ratio;
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,253
|
static void Direct_Move( EXEC_OPS PGlyph_Zone zone,
Int point,
TT_F26Dot6 distance )
{
TT_F26Dot6 v;
v = CUR.GS.freeVector.x;
if ( v != 0 )
{
zone->cur_x[point] += MulDiv_Round( distance,
v * 0x10000L,
CUR.F_dot_P );
zone->touch[point] |= TT_Flag_Touched_X;
}
v = CUR.GS.freeVector.y;
if ( v != 0 )
{
zone->cur_y[point] += MulDiv_Round( distance,
v * 0x10000L,
CUR.F_dot_P );
zone->touch[point] |= TT_Flag_Touched_Y;
}
}
|
DoS
| 0
|
static void Direct_Move( EXEC_OPS PGlyph_Zone zone,
Int point,
TT_F26Dot6 distance )
{
TT_F26Dot6 v;
v = CUR.GS.freeVector.x;
if ( v != 0 )
{
zone->cur_x[point] += MulDiv_Round( distance,
v * 0x10000L,
CUR.F_dot_P );
zone->touch[point] |= TT_Flag_Touched_X;
}
v = CUR.GS.freeVector.y;
if ( v != 0 )
{
zone->cur_y[point] += MulDiv_Round( distance,
v * 0x10000L,
CUR.F_dot_P );
zone->touch[point] |= TT_Flag_Touched_Y;
}
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,254
|
static void Direct_Move_X( EXEC_OPS PGlyph_Zone zone,
Int point,
TT_F26Dot6 distance )
{ (void)exc;
zone->cur_x[point] += distance;
zone->touch[point] |= TT_Flag_Touched_X;
}
|
DoS
| 0
|
static void Direct_Move_X( EXEC_OPS PGlyph_Zone zone,
Int point,
TT_F26Dot6 distance )
{ (void)exc;
zone->cur_x[point] += distance;
zone->touch[point] |= TT_Flag_Touched_X;
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,255
|
static TT_F26Dot6 Dual_Project( EXEC_OPS TT_F26Dot6 Vx, TT_F26Dot6 Vy )
{
THROW_PATENTED;
return 0;
}
|
DoS
| 0
|
static TT_F26Dot6 Dual_Project( EXEC_OPS TT_F26Dot6 Vx, TT_F26Dot6 Vy )
{
THROW_PATENTED;
return 0;
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,256
|
static TT_F26Dot6 FUnits_To_Pixels( EXEC_OPS Int distance )
{
return MulDiv_Round( distance,
CUR.metrics.scale1,
CUR.metrics.scale2 );
}
|
DoS
| 0
|
static TT_F26Dot6 FUnits_To_Pixels( EXEC_OPS Int distance )
{
return MulDiv_Round( distance,
CUR.metrics.scale1,
CUR.metrics.scale2 );
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,257
|
static TT_F26Dot6 Free_Project( EXEC_OPS TT_F26Dot6 Vx, TT_F26Dot6 Vy )
{
THROW_PATENTED;
return 0;
}
|
DoS
| 0
|
static TT_F26Dot6 Free_Project( EXEC_OPS TT_F26Dot6 Vx, TT_F26Dot6 Vy )
{
THROW_PATENTED;
return 0;
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,258
|
static Short GetShortIns( EXEC_OP )
{
/* Reading a byte stream so there is no endianess (DaveP) */
CUR.IP += 2;
return ( CUR.code[CUR.IP-2] << 8) +
CUR.code[CUR.IP-1];
}
|
DoS
| 0
|
static Short GetShortIns( EXEC_OP )
{
/* Reading a byte stream so there is no endianess (DaveP) */
CUR.IP += 2;
return ( CUR.code[CUR.IP-2] << 8) +
CUR.code[CUR.IP-1];
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,259
|
static void Ins_AA( INS_ARG )
{ (void)exc; (void)args;
/* Intentional - no longer supported */
}
|
DoS
| 0
|
static void Ins_AA( INS_ARG )
{ (void)exc; (void)args;
/* Intentional - no longer supported */
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,260
|
static void Ins_ABS( INS_ARG )
{ (void)exc;
args[0] = ABS( args[0] );
}
|
DoS
| 0
|
static void Ins_ABS( INS_ARG )
{ (void)exc;
args[0] = ABS( args[0] );
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,261
|
static void Ins_ALIGNPTS( INS_ARG )
{
Int p1, p2;
TT_F26Dot6 distance;
p1 = (Int)args[0];
p2 = (Int)args[1];
if ( BOUNDS( args[0], CUR.zp1.n_points ) ||
BOUNDS( args[1], CUR.zp0.n_points ) )
{
CUR.error = TT_Err_Invalid_Reference;
return;
}
distance = CUR_Func_project( CUR.zp0.cur_x[p2] -
CUR.zp1.cur_x[p1],
CUR.zp0.cur_y[p2] -
CUR.zp1.cur_y[p1] ) / 2;
CUR_Func_move( &CUR.zp1, p1, distance );
CUR_Func_move( &CUR.zp0, p2, -distance );
}
|
DoS
| 0
|
static void Ins_ALIGNPTS( INS_ARG )
{
Int p1, p2;
TT_F26Dot6 distance;
p1 = (Int)args[0];
p2 = (Int)args[1];
if ( BOUNDS( args[0], CUR.zp1.n_points ) ||
BOUNDS( args[1], CUR.zp0.n_points ) )
{
CUR.error = TT_Err_Invalid_Reference;
return;
}
distance = CUR_Func_project( CUR.zp0.cur_x[p2] -
CUR.zp1.cur_x[p1],
CUR.zp0.cur_y[p2] -
CUR.zp1.cur_y[p1] ) / 2;
CUR_Func_move( &CUR.zp1, p1, distance );
CUR_Func_move( &CUR.zp0, p2, -distance );
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,262
|
static void Ins_AND( INS_ARG )
{ (void)exc;
if ( args[0] != 0 && args[1] != 0 )
args[0] = 1;
else
args[0] = 0;
}
|
DoS
| 0
|
static void Ins_AND( INS_ARG )
{ (void)exc;
if ( args[0] != 0 && args[1] != 0 )
args[0] = 1;
else
args[0] = 0;
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,263
|
static void Ins_CALL( INS_ARG )
{
PCallRecord pCrec;
if ( BOUNDS( args[0], CUR.numFDefs ) || !CUR.FDefs[args[0]].Active )
{
CUR.error = TT_Err_Invalid_Reference;
return;
}
if ( CUR.callTop >= CUR.callSize )
{
CUR.error = TT_Err_Stack_Overflow;
return;
}
DBG_PRINT1("%d", args[0]);
pCrec = &CUR.callStack[CUR.callTop];
pCrec->Caller_Range = CUR.curRange;
pCrec->Caller_IP = CUR.IP + 1;
pCrec->Cur_Count = 1;
pCrec->Cur_Restart = CUR.FDefs[args[0]].Start;
CUR.callTop++;
INS_Goto_CodeRange( CUR.FDefs[args[0]].Range,
CUR.FDefs[args[0]].Start );
CUR.step_ins = FALSE;
}
|
DoS
| 0
|
static void Ins_CALL( INS_ARG )
{
PCallRecord pCrec;
if ( BOUNDS( args[0], CUR.numFDefs ) || !CUR.FDefs[args[0]].Active )
{
CUR.error = TT_Err_Invalid_Reference;
return;
}
if ( CUR.callTop >= CUR.callSize )
{
CUR.error = TT_Err_Stack_Overflow;
return;
}
DBG_PRINT1("%d", args[0]);
pCrec = &CUR.callStack[CUR.callTop];
pCrec->Caller_Range = CUR.curRange;
pCrec->Caller_IP = CUR.IP + 1;
pCrec->Cur_Count = 1;
pCrec->Cur_Restart = CUR.FDefs[args[0]].Start;
CUR.callTop++;
INS_Goto_CodeRange( CUR.FDefs[args[0]].Range,
CUR.FDefs[args[0]].Start );
CUR.step_ins = FALSE;
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,264
|
static void Ins_CEILING( INS_ARG )
{ (void)exc;
args[0] = (args[0] + 63) & (-64);
}
|
DoS
| 0
|
static void Ins_CEILING( INS_ARG )
{ (void)exc;
args[0] = (args[0] + 63) & (-64);
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,265
|
static void Ins_CLEAR( INS_ARG )
{ (void)args;
CUR.new_top = 0;
}
|
DoS
| 0
|
static void Ins_CLEAR( INS_ARG )
{ (void)args;
CUR.new_top = 0;
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,266
|
static void Ins_DELTAC( INS_ARG )
{
Long nump, k;
Long A, B, C;
nump = args[0];
for ( k = 1; k <= nump; k++ )
{
if ( CUR.args < 2 )
{
CUR.error = TT_Err_Too_Few_Arguments;
return;
}
CUR.args -= 2;
A = CUR.stack[CUR.args + 1];
B = CUR.stack[CUR.args];
if ( A >= CUR.cvtSize )
{
CUR.error = TT_Err_Invalid_Reference;
return;
}
C = ((unsigned long)(B & 0xF0)) >> 4;
switch ( CUR.opcode )
{
case 0x73:
break;
case 0x74:
C += 16;
break;
case 0x75:
C += 32;
break;
}
C += CUR.GS.delta_base;
if ( CURRENT_Ppem() == C )
{
B = (B & 0xF) - 8;
if ( B >= 0 )
B++;
B = B * 64 / (1L << CUR.GS.delta_shift);
CUR_Func_move_cvt( A, B );
}
}
CUR.new_top = CUR.args;
}
|
DoS
| 0
|
static void Ins_DELTAC( INS_ARG )
{
Long nump, k;
Long A, B, C;
nump = args[0];
for ( k = 1; k <= nump; k++ )
{
if ( CUR.args < 2 )
{
CUR.error = TT_Err_Too_Few_Arguments;
return;
}
CUR.args -= 2;
A = CUR.stack[CUR.args + 1];
B = CUR.stack[CUR.args];
if ( A >= CUR.cvtSize )
{
CUR.error = TT_Err_Invalid_Reference;
return;
}
C = ((unsigned long)(B & 0xF0)) >> 4;
switch ( CUR.opcode )
{
case 0x73:
break;
case 0x74:
C += 16;
break;
case 0x75:
C += 32;
break;
}
C += CUR.GS.delta_base;
if ( CURRENT_Ppem() == C )
{
B = (B & 0xF) - 8;
if ( B >= 0 )
B++;
B = B * 64 / (1L << CUR.GS.delta_shift);
CUR_Func_move_cvt( A, B );
}
}
CUR.new_top = CUR.args;
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,267
|
static void Ins_DELTAP( INS_ARG )
{
Int k;
Long A, B, C, nump;
nump = args[0];
for ( k = 1; k <= nump; k++ )
{
if ( CUR.args < 2 )
{
CUR.error = TT_Err_Too_Few_Arguments;
return;
}
CUR.args -= 2;
A = CUR.stack[CUR.args + 1];
B = CUR.stack[CUR.args];
#if 0
if ( BOUNDS( A, CUR.zp0.n_points ) )
#else
/* igorm changed : allow phantom points (Altona.Page_3.2002-09-27.pdf). */
if ( BOUNDS( A, CUR.zp0.n_points + 2 ) )
#endif
{
/* CUR.error = TT_Err_Invalid_Reference;*/
return;
}
C = (B & 0xF0) >> 4;
switch ( CUR.opcode )
{
case 0x5d:
break;
case 0x71:
C += 16;
break;
case 0x72:
C += 32;
break;
}
C += CUR.GS.delta_base;
if ( CURRENT_Ppem() == C )
{
B = (B & 0xF) - 8;
if ( B >= 0 )
B++;
B = B * 64 / (1L << CUR.GS.delta_shift);
CUR_Func_move( &CUR.zp0, (Int)A, (Int)B );
}
}
CUR.new_top = CUR.args;
}
|
DoS
| 0
|
static void Ins_DELTAP( INS_ARG )
{
Int k;
Long A, B, C, nump;
nump = args[0];
for ( k = 1; k <= nump; k++ )
{
if ( CUR.args < 2 )
{
CUR.error = TT_Err_Too_Few_Arguments;
return;
}
CUR.args -= 2;
A = CUR.stack[CUR.args + 1];
B = CUR.stack[CUR.args];
#if 0
if ( BOUNDS( A, CUR.zp0.n_points ) )
#else
/* igorm changed : allow phantom points (Altona.Page_3.2002-09-27.pdf). */
if ( BOUNDS( A, CUR.zp0.n_points + 2 ) )
#endif
{
/* CUR.error = TT_Err_Invalid_Reference;*/
return;
}
C = (B & 0xF0) >> 4;
switch ( CUR.opcode )
{
case 0x5d:
break;
case 0x71:
C += 16;
break;
case 0x72:
C += 32;
break;
}
C += CUR.GS.delta_base;
if ( CURRENT_Ppem() == C )
{
B = (B & 0xF) - 8;
if ( B >= 0 )
B++;
B = B * 64 / (1L << CUR.GS.delta_shift);
CUR_Func_move( &CUR.zp0, (Int)A, (Int)B );
}
}
CUR.new_top = CUR.args;
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,268
|
static void Ins_DEPTH( INS_ARG )
{
args[0] = CUR.top;
}
|
DoS
| 0
|
static void Ins_DEPTH( INS_ARG )
{
args[0] = CUR.top;
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,269
|
static void Ins_DIV( INS_ARG )
{
if ( args[1] == 0 )
{
CUR.error = TT_Err_Divide_By_Zero;
return;
}
args[0] = MulDiv_Round( args[0], 64L, args[1] );
DBG_PRINT1(" %d", args[0]);
}
|
DoS
| 0
|
static void Ins_DIV( INS_ARG )
{
if ( args[1] == 0 )
{
CUR.error = TT_Err_Divide_By_Zero;
return;
}
args[0] = MulDiv_Round( args[0], 64L, args[1] );
DBG_PRINT1(" %d", args[0]);
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,270
|
static void Ins_DUP( INS_ARG )
{ (void)exc;
args[1] = args[0];
}
|
DoS
| 0
|
static void Ins_DUP( INS_ARG )
{ (void)exc;
args[1] = args[0];
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,271
|
static void Ins_EIF( INS_ARG )
{ (void)exc; (void)args;
/* nothing to do */
}
|
DoS
| 0
|
static void Ins_EIF( INS_ARG )
{ (void)exc; (void)args;
/* nothing to do */
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,272
|
static void Ins_ELSE( INS_ARG )
{
Int nIfs;
(void)args;
nIfs = 1;
do
{
if ( SKIP_Code() == FAILURE )
return;
switch ( CUR.opcode )
{
case 0x58: /* IF */
nIfs++;
break;
case 0x59: /* EIF */
nIfs--;
break;
}
} while ( nIfs != 0 );
}
|
DoS
| 0
|
static void Ins_ELSE( INS_ARG )
{
Int nIfs;
(void)args;
nIfs = 1;
do
{
if ( SKIP_Code() == FAILURE )
return;
switch ( CUR.opcode )
{
case 0x58: /* IF */
nIfs++;
break;
case 0x59: /* EIF */
nIfs--;
break;
}
} while ( nIfs != 0 );
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,273
|
static void Ins_EQ( INS_ARG )
{ (void)exc;
if ( args[0] == args[1] )
args[0] = 1;
else
args[0] = 0;
}
|
DoS
| 0
|
static void Ins_EQ( INS_ARG )
{ (void)exc;
if ( args[0] == args[1] )
args[0] = 1;
else
args[0] = 0;
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,274
|
static void Ins_FDEF( INS_ARG )
{
PDefRecord pRec;
if ( BOUNDS( args[0], CUR.numFDefs ) )
{
CUR.error = TT_Err_Invalid_Reference;
return;
}
pRec = &CUR.FDefs[args[0]];
pRec->Range = CUR.curRange;
pRec->Opc = (Byte)(args[0]);
pRec->Start = CUR.IP + 1;
pRec->Active = TRUE;
skip_FDEF(EXEC_ARG);
}
|
DoS
| 0
|
static void Ins_FDEF( INS_ARG )
{
PDefRecord pRec;
if ( BOUNDS( args[0], CUR.numFDefs ) )
{
CUR.error = TT_Err_Invalid_Reference;
return;
}
pRec = &CUR.FDefs[args[0]];
pRec->Range = CUR.curRange;
pRec->Opc = (Byte)(args[0]);
pRec->Start = CUR.IP + 1;
pRec->Active = TRUE;
skip_FDEF(EXEC_ARG);
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,275
|
static void Ins_FLIPOFF( INS_ARG )
{ (void)args;
CUR.GS.auto_flip = FALSE;
}
|
DoS
| 0
|
static void Ins_FLIPOFF( INS_ARG )
{ (void)args;
CUR.GS.auto_flip = FALSE;
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,276
|
static void Ins_FLIPON( INS_ARG )
{ (void)args;
CUR.GS.auto_flip = TRUE;
}
|
DoS
| 0
|
static void Ins_FLIPON( INS_ARG )
{ (void)args;
CUR.GS.auto_flip = TRUE;
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,277
|
static void Ins_FLIPPT( INS_ARG )
{
Long point;
(void)args;
if ( CUR.top < CUR.GS.loop )
{
CUR.error = TT_Err_Too_Few_Arguments;
return;
}
while ( CUR.GS.loop > 0 )
{
CUR.args--;
point = CUR.stack[CUR.args];
if ( BOUNDS( point, CUR.pts.n_points ) )
{
CUR.error = TT_Err_Invalid_Reference;
return;
}
CUR.pts.touch[point] ^= TT_Flag_On_Curve;
CUR.GS.loop--;
}
CUR.GS.loop = 1;
CUR.new_top = CUR.args;
}
|
DoS
| 0
|
static void Ins_FLIPPT( INS_ARG )
{
Long point;
(void)args;
if ( CUR.top < CUR.GS.loop )
{
CUR.error = TT_Err_Too_Few_Arguments;
return;
}
while ( CUR.GS.loop > 0 )
{
CUR.args--;
point = CUR.stack[CUR.args];
if ( BOUNDS( point, CUR.pts.n_points ) )
{
CUR.error = TT_Err_Invalid_Reference;
return;
}
CUR.pts.touch[point] ^= TT_Flag_On_Curve;
CUR.GS.loop--;
}
CUR.GS.loop = 1;
CUR.new_top = CUR.args;
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,278
|
static void Ins_FLIPRGON( INS_ARG )
{
Long I, K, L;
K = args[1];
L = args[0];
if ( BOUNDS( K, CUR.pts.n_points ) ||
BOUNDS( L, CUR.pts.n_points ) )
{
CUR.error = TT_Err_Invalid_Reference;
return;
}
for ( I = L; I <= K; I++ )
CUR.pts.touch[I] |= TT_Flag_On_Curve;
}
|
DoS
| 0
|
static void Ins_FLIPRGON( INS_ARG )
{
Long I, K, L;
K = args[1];
L = args[0];
if ( BOUNDS( K, CUR.pts.n_points ) ||
BOUNDS( L, CUR.pts.n_points ) )
{
CUR.error = TT_Err_Invalid_Reference;
return;
}
for ( I = L; I <= K; I++ )
CUR.pts.touch[I] |= TT_Flag_On_Curve;
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,279
|
static void Ins_GETINFO( INS_ARG )
{
Long K;
K = 0;
/* We return then Windows 3.1 version number */
/* for the font scaler */
if ( (args[0] & 1) != 0 )
K = 3;
/* Has the glyph been rotated ? */
if ( CUR.metrics.rotated )
K |= 0x80;
/* Has the glyph been stretched ? */
if ( CUR.metrics.stretched )
K |= 0x100;
args[0] = K;
}
|
DoS
| 0
|
static void Ins_GETINFO( INS_ARG )
{
Long K;
K = 0;
/* We return then Windows 3.1 version number */
/* for the font scaler */
if ( (args[0] & 1) != 0 )
K = 3;
/* Has the glyph been rotated ? */
if ( CUR.metrics.rotated )
K |= 0x80;
/* Has the glyph been stretched ? */
if ( CUR.metrics.stretched )
K |= 0x100;
args[0] = K;
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,280
|
static void Ins_GFV( INS_ARG )
{
args[0] = CUR.GS.freeVector.x;
args[1] = CUR.GS.freeVector.y;
}
|
DoS
| 0
|
static void Ins_GFV( INS_ARG )
{
args[0] = CUR.GS.freeVector.x;
args[1] = CUR.GS.freeVector.y;
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,281
|
static void Ins_GPV( INS_ARG )
{
args[0] = CUR.GS.projVector.x;
args[1] = CUR.GS.projVector.y;
}
|
DoS
| 0
|
static void Ins_GPV( INS_ARG )
{
args[0] = CUR.GS.projVector.x;
args[1] = CUR.GS.projVector.y;
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,282
|
static void Ins_GT( INS_ARG )
{ (void)exc;
if ( args[0] > args[1] )
args[0] = 1;
else
args[0] = 0;
}
|
DoS
| 0
|
static void Ins_GT( INS_ARG )
{ (void)exc;
if ( args[0] > args[1] )
args[0] = 1;
else
args[0] = 0;
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,283
|
static void Ins_GTEQ( INS_ARG )
{ (void)exc;
if ( args[0] >= args[1] )
args[0] = 1;
else
args[0] = 0;
}
|
DoS
| 0
|
static void Ins_GTEQ( INS_ARG )
{ (void)exc;
if ( args[0] >= args[1] )
args[0] = 1;
else
args[0] = 0;
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,284
|
static Bool Ins_Goto_CodeRange( EXEC_OPS Int aRange, Int aIP )
{
TCodeRange* WITH;
if ( aRange < 1 || aRange > 3 )
{
CUR.error = TT_Err_Bad_Argument;
return FAILURE;
}
WITH = &CUR.codeRangeTable[aRange - 1];
if ( WITH->Base == NULL ) /* invalid coderange */
{
CUR.error = TT_Err_Invalid_CodeRange;
return FAILURE;
}
/* NOTE: Because the last instruction of a program may be a CALL */
/* which will return to the first byte *after* the code */
/* range, we test for AIP <= Size, instead of AIP < Size. */
if ( aIP > WITH->Size )
{
CUR.error = TT_Err_Code_Overflow;
return FAILURE;
}
CUR.code = WITH->Base;
CUR.codeSize = WITH->Size;
CUR.IP = aIP;
CUR.curRange = aRange;
return SUCCESS;
}
|
DoS
| 0
|
static Bool Ins_Goto_CodeRange( EXEC_OPS Int aRange, Int aIP )
{
TCodeRange* WITH;
if ( aRange < 1 || aRange > 3 )
{
CUR.error = TT_Err_Bad_Argument;
return FAILURE;
}
WITH = &CUR.codeRangeTable[aRange - 1];
if ( WITH->Base == NULL ) /* invalid coderange */
{
CUR.error = TT_Err_Invalid_CodeRange;
return FAILURE;
}
/* NOTE: Because the last instruction of a program may be a CALL */
/* which will return to the first byte *after* the code */
/* range, we test for AIP <= Size, instead of AIP < Size. */
if ( aIP > WITH->Size )
{
CUR.error = TT_Err_Code_Overflow;
return FAILURE;
}
CUR.code = WITH->Base;
CUR.codeSize = WITH->Size;
CUR.IP = aIP;
CUR.curRange = aRange;
return SUCCESS;
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,285
|
static void Ins_IDEF( INS_ARG )
{
if (CUR.countIDefs >= CUR.numIDefs || args[0] > 255)
CUR.error = TT_Err_Storage_Overflow;
else
{
PDefRecord pTDR;
CUR.IDefPtr[(Byte)(args[0])] = CUR.countIDefs;
pTDR = &CUR.IDefs[CUR.countIDefs++];
pTDR->Opc = (Byte)(args[0]);
pTDR->Start = CUR.IP + 1;
pTDR->Range = CUR.curRange;
pTDR->Active = TRUE;
skip_FDEF(EXEC_ARG);
}
}
|
DoS
| 0
|
static void Ins_IDEF( INS_ARG )
{
if (CUR.countIDefs >= CUR.numIDefs || args[0] > 255)
CUR.error = TT_Err_Storage_Overflow;
else
{
PDefRecord pTDR;
CUR.IDefPtr[(Byte)(args[0])] = CUR.countIDefs;
pTDR = &CUR.IDefs[CUR.countIDefs++];
pTDR->Opc = (Byte)(args[0]);
pTDR->Start = CUR.IP + 1;
pTDR->Range = CUR.curRange;
pTDR->Active = TRUE;
skip_FDEF(EXEC_ARG);
}
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,286
|
static void Ins_IF( INS_ARG )
{
Int nIfs;
Bool Out;
if ( args[0] != 0 )
return;
nIfs = 1;
Out = 0;
do
{
if ( SKIP_Code() == FAILURE )
return;
switch ( CUR.opcode )
{
case 0x58: /* IF */
nIfs++;
break;
case 0x1b: /* ELSE */
Out = (nIfs == 1);
break;
case 0x59: /* EIF */
nIfs--;
Out = (nIfs == 0);
break;
}
} while ( Out == 0 );
}
|
DoS
| 0
|
static void Ins_IF( INS_ARG )
{
Int nIfs;
Bool Out;
if ( args[0] != 0 )
return;
nIfs = 1;
Out = 0;
do
{
if ( SKIP_Code() == FAILURE )
return;
switch ( CUR.opcode )
{
case 0x58: /* IF */
nIfs++;
break;
case 0x1b: /* ELSE */
Out = (nIfs == 1);
break;
case 0x59: /* EIF */
nIfs--;
Out = (nIfs == 0);
break;
}
} while ( Out == 0 );
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,287
|
static void Ins_INSTCTRL( INS_ARG )
{
Long K, L;
K = args[1];
L = args[0];
if ( K < 0 || K > 3 )
{
CUR.error = TT_Err_Invalid_Reference;
return;
}
CUR.GS.instruct_control = (Int)((CUR.GS.instruct_control & (~K)) | (L & K));
}
|
DoS
| 0
|
static void Ins_INSTCTRL( INS_ARG )
{
Long K, L;
K = args[1];
L = args[0];
if ( K < 0 || K > 3 )
{
CUR.error = TT_Err_Invalid_Reference;
return;
}
CUR.GS.instruct_control = (Int)((CUR.GS.instruct_control & (~K)) | (L & K));
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,288
|
static void Ins_ISECT( INS_ARG )
{
Long point, /* are these Ints or Longs? */
a0, a1,
b0, b1;
TT_F26Dot6 discriminant;
TT_F26Dot6 dx, dy,
dax, day,
dbx, dby;
TT_F26Dot6 val;
TT_Vector R;
point = args[0];
a0 = args[1];
a1 = args[2];
b0 = args[3];
b1 = args[4];
if ( BOUNDS( b0, CUR.zp0.n_points ) ||
BOUNDS( b1, CUR.zp0.n_points ) ||
BOUNDS( a0, CUR.zp1.n_points ) ||
BOUNDS( a1, CUR.zp1.n_points ) )
{
CUR.error = TT_Err_Invalid_Reference;
return;
}
dbx = CUR.zp0.cur_x[b1] - CUR.zp0.cur_x[b0];
dby = CUR.zp0.cur_y[b1] - CUR.zp0.cur_y[b0];
dax = CUR.zp1.cur_x[a1] - CUR.zp1.cur_x[a0];
day = CUR.zp1.cur_y[a1] - CUR.zp1.cur_y[a0];
dx = CUR.zp0.cur_x[b0] - CUR.zp1.cur_x[a0];
dy = CUR.zp0.cur_y[b0] - CUR.zp1.cur_y[a0];
CUR.zp2.touch[point] |= TT_Flag_Touched_Both;
discriminant = MulDiv_Round( dax, -dby, 0x40L ) +
MulDiv_Round( day, dbx, 0x40L );
if ( ABS( discriminant ) >= 0x40 )
{
val = MulDiv_Round( dx, -dby, 0x40L ) + MulDiv_Round( dy, dbx, 0x40L );
R.x = MulDiv_Round( val, dax, discriminant );
R.y = MulDiv_Round( val, day, discriminant );
CUR.zp2.cur_x[point] = CUR.zp1.cur_x[a0] + R.x;
CUR.zp2.cur_y[point] = CUR.zp1.cur_y[a0] + R.y;
}
else
{
/* else, take the middle of the middles of A and B */
CUR.zp2.cur_x[point] = ( CUR.zp1.cur_x[a0] +
CUR.zp1.cur_x[a1] +
CUR.zp0.cur_x[b0] +
CUR.zp1.cur_x[b1] ) / 4;
CUR.zp2.cur_y[point] = ( CUR.zp1.cur_y[a0] +
CUR.zp1.cur_y[a1] +
CUR.zp0.cur_y[b0] +
CUR.zp1.cur_y[b1] ) / 4;
}
}
|
DoS
| 0
|
static void Ins_ISECT( INS_ARG )
{
Long point, /* are these Ints or Longs? */
a0, a1,
b0, b1;
TT_F26Dot6 discriminant;
TT_F26Dot6 dx, dy,
dax, day,
dbx, dby;
TT_F26Dot6 val;
TT_Vector R;
point = args[0];
a0 = args[1];
a1 = args[2];
b0 = args[3];
b1 = args[4];
if ( BOUNDS( b0, CUR.zp0.n_points ) ||
BOUNDS( b1, CUR.zp0.n_points ) ||
BOUNDS( a0, CUR.zp1.n_points ) ||
BOUNDS( a1, CUR.zp1.n_points ) )
{
CUR.error = TT_Err_Invalid_Reference;
return;
}
dbx = CUR.zp0.cur_x[b1] - CUR.zp0.cur_x[b0];
dby = CUR.zp0.cur_y[b1] - CUR.zp0.cur_y[b0];
dax = CUR.zp1.cur_x[a1] - CUR.zp1.cur_x[a0];
day = CUR.zp1.cur_y[a1] - CUR.zp1.cur_y[a0];
dx = CUR.zp0.cur_x[b0] - CUR.zp1.cur_x[a0];
dy = CUR.zp0.cur_y[b0] - CUR.zp1.cur_y[a0];
CUR.zp2.touch[point] |= TT_Flag_Touched_Both;
discriminant = MulDiv_Round( dax, -dby, 0x40L ) +
MulDiv_Round( day, dbx, 0x40L );
if ( ABS( discriminant ) >= 0x40 )
{
val = MulDiv_Round( dx, -dby, 0x40L ) + MulDiv_Round( dy, dbx, 0x40L );
R.x = MulDiv_Round( val, dax, discriminant );
R.y = MulDiv_Round( val, day, discriminant );
CUR.zp2.cur_x[point] = CUR.zp1.cur_x[a0] + R.x;
CUR.zp2.cur_y[point] = CUR.zp1.cur_y[a0] + R.y;
}
else
{
/* else, take the middle of the middles of A and B */
CUR.zp2.cur_x[point] = ( CUR.zp1.cur_x[a0] +
CUR.zp1.cur_x[a1] +
CUR.zp0.cur_x[b0] +
CUR.zp1.cur_x[b1] ) / 4;
CUR.zp2.cur_y[point] = ( CUR.zp1.cur_y[a0] +
CUR.zp1.cur_y[a1] +
CUR.zp0.cur_y[b0] +
CUR.zp1.cur_y[b1] ) / 4;
}
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,289
|
static void Ins_IUP( INS_ARG )
{
struct LOC_Ins_IUP V;
unsigned char mask;
Long first_point; /* first point of contour */
Long end_point; /* end point (last+1) of contour */
Long first_touched; /* first touched point in contour */
Long cur_touched; /* current touched point in contour */
Long point; /* current point */
Long contour; /* current contour */
(void)args;
if ( CUR.opcode & 1 )
{
mask = TT_Flag_Touched_X;
V.orgs = CUR.pts.org_x;
V.curs = CUR.pts.cur_x;
}
else
{
mask = TT_Flag_Touched_Y;
V.orgs = CUR.pts.org_y;
V.curs = CUR.pts.cur_y;
}
contour = 0;
point = 0;
do
{
end_point = CUR.pts.contours[contour];
first_point = point;
while ( point <= end_point && (CUR.pts.touch[point] & mask) == 0 )
point++;
if ( point <= end_point )
{
first_touched = point;
cur_touched = point;
point++;
while ( point <= end_point )
{
if ( (CUR.pts.touch[point] & mask) != 0 )
{
Interp( (Int)(cur_touched + 1),
(Int)(point - 1),
(Int)cur_touched,
(Int)point,
&V );
cur_touched = point;
}
point++;
}
if ( cur_touched == first_touched )
Shift( (Int)first_point, (Int)end_point, (Int)cur_touched, &V );
else
{
Interp((Int)(cur_touched + 1),
(Int)(end_point),
(Int)(cur_touched),
(Int)(first_touched),
&V );
Interp((Int)(first_point),
(Int)(first_touched - 1),
(Int)(cur_touched),
(Int)(first_touched),
&V );
}
}
contour++;
} while ( contour < CUR.pts.n_contours );
}
|
DoS
| 0
|
static void Ins_IUP( INS_ARG )
{
struct LOC_Ins_IUP V;
unsigned char mask;
Long first_point; /* first point of contour */
Long end_point; /* end point (last+1) of contour */
Long first_touched; /* first touched point in contour */
Long cur_touched; /* current touched point in contour */
Long point; /* current point */
Long contour; /* current contour */
(void)args;
if ( CUR.opcode & 1 )
{
mask = TT_Flag_Touched_X;
V.orgs = CUR.pts.org_x;
V.curs = CUR.pts.cur_x;
}
else
{
mask = TT_Flag_Touched_Y;
V.orgs = CUR.pts.org_y;
V.curs = CUR.pts.cur_y;
}
contour = 0;
point = 0;
do
{
end_point = CUR.pts.contours[contour];
first_point = point;
while ( point <= end_point && (CUR.pts.touch[point] & mask) == 0 )
point++;
if ( point <= end_point )
{
first_touched = point;
cur_touched = point;
point++;
while ( point <= end_point )
{
if ( (CUR.pts.touch[point] & mask) != 0 )
{
Interp( (Int)(cur_touched + 1),
(Int)(point - 1),
(Int)cur_touched,
(Int)point,
&V );
cur_touched = point;
}
point++;
}
if ( cur_touched == first_touched )
Shift( (Int)first_point, (Int)end_point, (Int)cur_touched, &V );
else
{
Interp((Int)(cur_touched + 1),
(Int)(end_point),
(Int)(cur_touched),
(Int)(first_touched),
&V );
Interp((Int)(first_point),
(Int)(first_touched - 1),
(Int)(cur_touched),
(Int)(first_touched),
&V );
}
}
contour++;
} while ( contour < CUR.pts.n_contours );
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,290
|
static void Ins_JROT( INS_ARG )
{
if ( args[1] != 0 )
{
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
/* See JMPR below */
if(CUR.IP > CUR.codeSize ||
(CUR.code[CUR.IP] != 0x2D && CUR.code[CUR.IP - 1] == 0x2D))
CUR.IP -= 1;
}
}
|
DoS
| 0
|
static void Ins_JROT( INS_ARG )
{
if ( args[1] != 0 )
{
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
/* See JMPR below */
if(CUR.IP > CUR.codeSize ||
(CUR.code[CUR.IP] != 0x2D && CUR.code[CUR.IP - 1] == 0x2D))
CUR.IP -= 1;
}
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,291
|
static void Ins_LOOPCALL( INS_ARG )
{
PCallRecord pTCR;
if ( BOUNDS( args[1], CUR.numFDefs ) || !CUR.FDefs[args[1]].Active )
{
CUR.error = TT_Err_Invalid_Reference;
return;
}
if ( CUR.callTop >= CUR.callSize )
{
CUR.error = TT_Err_Stack_Overflow;
return;
}
if ( args[0] > 0 )
{
pTCR = &CUR.callStack[CUR.callTop];
pTCR->Caller_Range = CUR.curRange;
pTCR->Caller_IP = CUR.IP + 1;
pTCR->Cur_Count = (Int)(args[0]);
pTCR->Cur_Restart = CUR.FDefs[args[1]].Start;
CUR.callTop++;
INS_Goto_CodeRange( CUR.FDefs[args[1]].Range,
CUR.FDefs[args[1]].Start );
CUR.step_ins = FALSE;
}
}
|
DoS
| 0
|
static void Ins_LOOPCALL( INS_ARG )
{
PCallRecord pTCR;
if ( BOUNDS( args[1], CUR.numFDefs ) || !CUR.FDefs[args[1]].Active )
{
CUR.error = TT_Err_Invalid_Reference;
return;
}
if ( CUR.callTop >= CUR.callSize )
{
CUR.error = TT_Err_Stack_Overflow;
return;
}
if ( args[0] > 0 )
{
pTCR = &CUR.callStack[CUR.callTop];
pTCR->Caller_Range = CUR.curRange;
pTCR->Caller_IP = CUR.IP + 1;
pTCR->Cur_Count = (Int)(args[0]);
pTCR->Cur_Restart = CUR.FDefs[args[1]].Start;
CUR.callTop++;
INS_Goto_CodeRange( CUR.FDefs[args[1]].Range,
CUR.FDefs[args[1]].Start );
CUR.step_ins = FALSE;
}
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,292
|
static void Ins_LT( INS_ARG )
{ (void)exc;
if ( args[0] < args[1] )
args[0] = 1;
else
args[0] = 0;
}
|
DoS
| 0
|
static void Ins_LT( INS_ARG )
{ (void)exc;
if ( args[0] < args[1] )
args[0] = 1;
else
args[0] = 0;
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,293
|
static void Ins_LTEQ( INS_ARG )
{ (void)exc;
if ( args[0] <= args[1] )
args[0] = 1;
else
args[0] = 0;
}
|
DoS
| 0
|
static void Ins_LTEQ( INS_ARG )
{ (void)exc;
if ( args[0] <= args[1] )
args[0] = 1;
else
args[0] = 0;
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,294
|
static void Ins_MAX( INS_ARG )
{ (void)exc;
if ( args[1] > args[0] )
args[0] = args[1];
}
|
DoS
| 0
|
static void Ins_MAX( INS_ARG )
{ (void)exc;
if ( args[1] > args[0] )
args[0] = args[1];
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,295
|
static void Ins_MD( INS_ARG )
{
Long K, L;
TT_F26Dot6 D;
K = args[1];
L = args[0];
if( BOUNDS( args[0], CUR.zp2.n_points ) ||
BOUNDS( args[1], CUR.zp1.n_points ) )
{
CUR.error = TT_Err_Invalid_Reference;
return;
}
if ( CUR.opcode & 1 )
D = CUR_Func_project( CUR.zp2.cur_x[L] - CUR.zp1.cur_x[K],
CUR.zp2.cur_y[L] - CUR.zp1.cur_y[K] );
else
D = CUR_Func_dualproj( CUR.zp2.org_x[L] - CUR.zp1.org_x[K],
CUR.zp2.org_y[L] - CUR.zp1.org_y[K] );
args[0] = D;
}
|
DoS
| 0
|
static void Ins_MD( INS_ARG )
{
Long K, L;
TT_F26Dot6 D;
K = args[1];
L = args[0];
if( BOUNDS( args[0], CUR.zp2.n_points ) ||
BOUNDS( args[1], CUR.zp1.n_points ) )
{
CUR.error = TT_Err_Invalid_Reference;
return;
}
if ( CUR.opcode & 1 )
D = CUR_Func_project( CUR.zp2.cur_x[L] - CUR.zp1.cur_x[K],
CUR.zp2.cur_y[L] - CUR.zp1.cur_y[K] );
else
D = CUR_Func_dualproj( CUR.zp2.org_x[L] - CUR.zp1.org_x[K],
CUR.zp2.org_y[L] - CUR.zp1.org_y[K] );
args[0] = D;
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,296
|
static void Ins_MDAP( INS_ARG )
{
Int point;
TT_F26Dot6 cur_dist,
distance;
point = (Int)args[0];
if ( BOUNDS( args[0], CUR.zp0.n_points ) )
{
CUR.error = TT_Err_Invalid_Reference;
return;
}
/* XXX: Is there some undocumented feature while in the */
/* twilight zone? ? */
if ( (CUR.opcode & 1) != 0 )
{
cur_dist = CUR_Func_project( CUR.zp0.cur_x[point],
CUR.zp0.cur_y[point] );
distance = CUR_Func_round( cur_dist,
CUR.metrics.compensations[0] ) - cur_dist;
}
else
distance = 0;
CUR_Func_move( &CUR.zp0, point, distance );
CUR.GS.rp0 = point;
CUR.GS.rp1 = point;
}
|
DoS
| 0
|
static void Ins_MDAP( INS_ARG )
{
Int point;
TT_F26Dot6 cur_dist,
distance;
point = (Int)args[0];
if ( BOUNDS( args[0], CUR.zp0.n_points ) )
{
CUR.error = TT_Err_Invalid_Reference;
return;
}
/* XXX: Is there some undocumented feature while in the */
/* twilight zone? ? */
if ( (CUR.opcode & 1) != 0 )
{
cur_dist = CUR_Func_project( CUR.zp0.cur_x[point],
CUR.zp0.cur_y[point] );
distance = CUR_Func_round( cur_dist,
CUR.metrics.compensations[0] ) - cur_dist;
}
else
distance = 0;
CUR_Func_move( &CUR.zp0, point, distance );
CUR.GS.rp0 = point;
CUR.GS.rp1 = point;
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,297
|
static void Ins_MINDEX( INS_ARG )
{
Long L, K;
L = args[0];
if (L == 0)
return;
if ( L<0 || L > CUR.args )
{
CUR.error = TT_Err_Invalid_Reference;
return;
}
K = CUR.stack[CUR.args - L];
memmove( (&CUR.stack[CUR.args - L ]),
(&CUR.stack[CUR.args - L + 1]),
(L - 1) * sizeof ( Long ) );
CUR.stack[ CUR.args-1 ] = K;
}
|
DoS
| 0
|
static void Ins_MINDEX( INS_ARG )
{
Long L, K;
L = args[0];
if (L == 0)
return;
if ( L<0 || L > CUR.args )
{
CUR.error = TT_Err_Invalid_Reference;
return;
}
K = CUR.stack[CUR.args - L];
memmove( (&CUR.stack[CUR.args - L ]),
(&CUR.stack[CUR.args - L + 1]),
(L - 1) * sizeof ( Long ) );
CUR.stack[ CUR.args-1 ] = K;
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,298
|
static void Ins_MIRP( INS_ARG )
{
Int point,
cvtEntry;
TT_F26Dot6 cvt_dist,
distance,
cur_dist,
org_dist;
point = (Int)args[0];
cvtEntry = (Int)args[1];
/* XXX: UNDOCUMENTED! cvt[-1] = 0 always */
if ( BOUNDS( args[0], CUR.zp1.n_points ) ||
BOUNDS( args[1]+1, CUR.cvtSize+1 ) ||
BOUNDS(CUR.GS.rp0, CUR.zp0.n_points) )
{
CUR.error = TT_Err_Invalid_Reference;
return;
}
if ( args[1] < 0 )
cvt_dist = 0;
else
cvt_dist = CUR_Func_read_cvt( cvtEntry );
/* single width test */
if ( ABS( cvt_dist ) < CUR.GS.single_width_cutin )
{
if ( cvt_dist >= 0 )
cvt_dist = CUR.GS.single_width_value;
else
cvt_dist = -CUR.GS.single_width_value;
}
/* XXX : Undocumented - twilight zone */
if ( CUR.GS.gep1 == 0 )
{
CUR.zp1.org_x[point] = CUR.zp0.org_x[CUR.GS.rp0] +
MulDiv_Round( cvt_dist,
CUR.GS.freeVector.x,
0x4000 );
CUR.zp1.org_y[point] = CUR.zp0.org_y[CUR.GS.rp0] +
MulDiv_Round( cvt_dist,
CUR.GS.freeVector.y,
0x4000 );
CUR.zp1.cur_x[point] = CUR.zp1.org_x[point];
CUR.zp1.cur_y[point] = CUR.zp1.org_y[point];
}
org_dist = CUR_Func_dualproj( CUR.zp1.org_x[point] -
CUR.zp0.org_x[CUR.GS.rp0],
CUR.zp1.org_y[point] -
CUR.zp0.org_y[CUR.GS.rp0] );
cur_dist = CUR_Func_project( CUR.zp1.cur_x[point] -
CUR.zp0.cur_x[CUR.GS.rp0],
CUR.zp1.cur_y[point] -
CUR.zp0.cur_y[CUR.GS.rp0] );
/* auto-flip test */
if ( CUR.GS.auto_flip )
{
if ( (org_dist ^ cvt_dist) < 0 )
cvt_dist = -cvt_dist;
}
/* control value cutin and round */
if ( (CUR.opcode & 4) != 0 )
{
/* XXX: Undocumented : only perform cut-in test when both points */
/* refer to the same zone. */
if ( CUR.GS.gep0 == CUR.GS.gep1 )
if ( ABS( cvt_dist - org_dist ) >= CUR.GS.control_value_cutin )
cvt_dist = org_dist;
distance = CUR_Func_round( cvt_dist,
CUR.metrics.compensations[CUR.opcode & 3] );
}
else
distance = Round_None( EXEC_ARGS
cvt_dist,
CUR.metrics.compensations[CUR.opcode & 3] );
/* minimum distance test */
if ( (CUR.opcode & 8) != 0 )
{
if ( org_dist >= 0 )
{
if ( distance < CUR.GS.minimum_distance )
distance = CUR.GS.minimum_distance;
}
else
{
if ( distance > -CUR.GS.minimum_distance )
distance = -CUR.GS.minimum_distance;
}
}
CUR_Func_move( &CUR.zp1, point, distance - cur_dist );
CUR.GS.rp1 = CUR.GS.rp0;
if ( (CUR.opcode & 16) != 0 )
CUR.GS.rp0 = point;
/* UNDOCUMENTED! */
CUR.GS.rp2 = point;
}
|
DoS
| 0
|
static void Ins_MIRP( INS_ARG )
{
Int point,
cvtEntry;
TT_F26Dot6 cvt_dist,
distance,
cur_dist,
org_dist;
point = (Int)args[0];
cvtEntry = (Int)args[1];
/* XXX: UNDOCUMENTED! cvt[-1] = 0 always */
if ( BOUNDS( args[0], CUR.zp1.n_points ) ||
BOUNDS( args[1]+1, CUR.cvtSize+1 ) ||
BOUNDS(CUR.GS.rp0, CUR.zp0.n_points) )
{
CUR.error = TT_Err_Invalid_Reference;
return;
}
if ( args[1] < 0 )
cvt_dist = 0;
else
cvt_dist = CUR_Func_read_cvt( cvtEntry );
/* single width test */
if ( ABS( cvt_dist ) < CUR.GS.single_width_cutin )
{
if ( cvt_dist >= 0 )
cvt_dist = CUR.GS.single_width_value;
else
cvt_dist = -CUR.GS.single_width_value;
}
/* XXX : Undocumented - twilight zone */
if ( CUR.GS.gep1 == 0 )
{
CUR.zp1.org_x[point] = CUR.zp0.org_x[CUR.GS.rp0] +
MulDiv_Round( cvt_dist,
CUR.GS.freeVector.x,
0x4000 );
CUR.zp1.org_y[point] = CUR.zp0.org_y[CUR.GS.rp0] +
MulDiv_Round( cvt_dist,
CUR.GS.freeVector.y,
0x4000 );
CUR.zp1.cur_x[point] = CUR.zp1.org_x[point];
CUR.zp1.cur_y[point] = CUR.zp1.org_y[point];
}
org_dist = CUR_Func_dualproj( CUR.zp1.org_x[point] -
CUR.zp0.org_x[CUR.GS.rp0],
CUR.zp1.org_y[point] -
CUR.zp0.org_y[CUR.GS.rp0] );
cur_dist = CUR_Func_project( CUR.zp1.cur_x[point] -
CUR.zp0.cur_x[CUR.GS.rp0],
CUR.zp1.cur_y[point] -
CUR.zp0.cur_y[CUR.GS.rp0] );
/* auto-flip test */
if ( CUR.GS.auto_flip )
{
if ( (org_dist ^ cvt_dist) < 0 )
cvt_dist = -cvt_dist;
}
/* control value cutin and round */
if ( (CUR.opcode & 4) != 0 )
{
/* XXX: Undocumented : only perform cut-in test when both points */
/* refer to the same zone. */
if ( CUR.GS.gep0 == CUR.GS.gep1 )
if ( ABS( cvt_dist - org_dist ) >= CUR.GS.control_value_cutin )
cvt_dist = org_dist;
distance = CUR_Func_round( cvt_dist,
CUR.metrics.compensations[CUR.opcode & 3] );
}
else
distance = Round_None( EXEC_ARGS
cvt_dist,
CUR.metrics.compensations[CUR.opcode & 3] );
/* minimum distance test */
if ( (CUR.opcode & 8) != 0 )
{
if ( org_dist >= 0 )
{
if ( distance < CUR.GS.minimum_distance )
distance = CUR.GS.minimum_distance;
}
else
{
if ( distance > -CUR.GS.minimum_distance )
distance = -CUR.GS.minimum_distance;
}
}
CUR_Func_move( &CUR.zp1, point, distance - cur_dist );
CUR.GS.rp1 = CUR.GS.rp0;
if ( (CUR.opcode & 16) != 0 )
CUR.GS.rp0 = point;
/* UNDOCUMENTED! */
CUR.GS.rp2 = point;
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
4,299
|
static void Ins_MPPEM( INS_ARG )
{
args[0] = CURRENT_Ppem();
DBG_PRINT1(" %d", args[0]);
}
|
DoS
| 0
|
static void Ins_MPPEM( INS_ARG )
{
args[0] = CURRENT_Ppem();
DBG_PRINT1(" %d", args[0]);
}
|
@@ -1794,6 +1794,12 @@ static int nInstrCount=0;
static void Ins_JMPR( INS_ARG )
{
+ if ( BOUNDS(CUR.IP + args[0], CUR.codeSize ) )
+ {
+ CUR.error = TT_Err_Invalid_Reference;
+ return;
+ }
+
CUR.IP += (Int)(args[0]);
CUR.step_ins = FALSE;
|
CWE-125
| null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.