project
stringclasses 633
values | commit_id
stringlengths 7
81
| target
int64 0
1
| func
stringlengths 5
484k
| cwe
stringclasses 131
values | big_vul_idx
float64 0
189k
⌀ | idx
int64 0
522k
| hash
stringlengths 34
39
| size
float64 1
24k
⌀ | message
stringlengths 0
11.5k
⌀ | dataset
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|
savannah
|
cb07844454d8cc9fb21f53ace75975f91185a120
| 0 |
check_data_region (struct tar_sparse_file *file, size_t i)
{
off_t size_left;
if (!lseek_or_error (file, file->stat_info->sparse_map[i].offset))
return false;
size_left = file->stat_info->sparse_map[i].numbytes;
mv_size_left (file->stat_info->archive_file_size - file->dumped_size);
while (size_left > 0)
{
size_t bytes_read;
size_t rdsize = (size_left > BLOCKSIZE) ? BLOCKSIZE : size_left;
char diff_buffer[BLOCKSIZE];
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;
bytes_read = safe_read (file->fd, diff_buffer, rdsize);
if (bytes_read == SAFE_READ_ERROR)
{
read_diag_details (file->stat_info->orig_file_name,
(file->stat_info->sparse_map[i].offset
+ file->stat_info->sparse_map[i].numbytes
- size_left),
rdsize);
return false;
}
else if (bytes_read == 0)
{
report_difference (¤t_stat_info, _("Size differs"));
return false;
}
size_left -= bytes_read;
mv_size_left (file->stat_info->archive_file_size - file->dumped_size);
if (memcmp (blk->buffer, diff_buffer, rdsize))
{
report_difference (file->stat_info, _("Contents differ"));
return false;
}
}
return true;
}
|
CWE-476
| 5,295 | 14,356 |
5526048496546705912174779796530787438
| null | null | null |
savannah
|
cb07844454d8cc9fb21f53ace75975f91185a120
| 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;
}
|
CWE-476
| 5,296 | 14,357 |
222458617585500939251068067438181374656
| null | null | null |
savannah
|
cb07844454d8cc9fb21f53ace75975f91185a120
| 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;
}
|
CWE-476
| 5,297 | 14,358 |
63324700854714390650251395195727219488
| null | null | null |
savannah
|
cb07844454d8cc9fb21f53ace75975f91185a120
| 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;
}
|
CWE-476
| 5,298 | 14,359 |
74407608565405095646722665396522746827
| null | null | null |
savannah
|
cb07844454d8cc9fb21f53ace75975f91185a120
| 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;
}
|
CWE-476
| 5,299 | 14,360 |
245423478404266936406294074632361851493
| null | null | null |
savannah
|
cb07844454d8cc9fb21f53ace75975f91185a120
| 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;
}
|
CWE-476
| 5,301 | 14,361 |
24413034332985274089585541005938781908
| null | null | null |
savannah
|
cb07844454d8cc9fb21f53ace75975f91185a120
| 0 |
oldgnu_sparse_member_p (struct tar_sparse_file *file __attribute__ ((unused)))
{
return current_header->header.typeflag == GNUTYPE_SPARSE;
}
|
CWE-476
| 5,302 | 14,362 |
275652842725951577660951493389196256950
| null | null | null |
savannah
|
cb07844454d8cc9fb21f53ace75975f91185a120
| 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);
}
}
|
CWE-476
| 5,303 | 14,363 |
215810348784289794140233262845135764203
| null | null | null |
savannah
|
cb07844454d8cc9fb21f53ace75975f91185a120
| 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);
}
|
CWE-476
| 5,304 | 14,364 |
24802498478482725753412966261943932331
| null | null | null |
savannah
|
cb07844454d8cc9fb21f53ace75975f91185a120
| 0 |
pax_dump_header_0 (struct tar_sparse_file *file)
{
off_t block_ordinal = current_block_ordinal ();
union block *blk;
size_t i;
char nbuf[UINTMAX_STRSIZE_BOUND];
struct sp_array *map = file->stat_info->sparse_map;
char *save_file_name = NULL;
/* Store the real file size */
xheader_store ("GNU.sparse.size", file->stat_info, NULL);
xheader_store ("GNU.sparse.numblocks", file->stat_info, NULL);
if (xheader_keyword_deleted_p ("GNU.sparse.map")
|| tar_sparse_minor == 0)
{
for (i = 0; i < file->stat_info->sparse_map_avail; i++)
{
xheader_store ("GNU.sparse.offset", file->stat_info, &i);
xheader_store ("GNU.sparse.numbytes", file->stat_info, &i);
}
}
else
{
xheader_store ("GNU.sparse.name", file->stat_info, NULL);
save_file_name = file->stat_info->file_name;
file->stat_info->file_name = xheader_format_name (file->stat_info,
"%d/GNUSparseFile.%p/%f", 0);
xheader_string_begin (&file->stat_info->xhdr);
for (i = 0; i < file->stat_info->sparse_map_avail; i++)
{
if (i)
xheader_string_add (&file->stat_info->xhdr, ",");
xheader_string_add (&file->stat_info->xhdr,
umaxtostr (map[i].offset, nbuf));
xheader_string_add (&file->stat_info->xhdr, ",");
xheader_string_add (&file->stat_info->xhdr,
umaxtostr (map[i].numbytes, nbuf));
}
if (!xheader_string_end (&file->stat_info->xhdr,
"GNU.sparse.map"))
{
free (file->stat_info->file_name);
file->stat_info->file_name = save_file_name;
return false;
}
}
blk = pax_start_header (file->stat_info);
finish_header (file->stat_info, blk, block_ordinal);
if (save_file_name)
{
free (file->stat_info->file_name);
file->stat_info->file_name = save_file_name;
}
return true;
}
|
CWE-476
| 5,305 | 14,365 |
41796229012369011059277355364685421402
| null | null | null |
savannah
|
cb07844454d8cc9fb21f53ace75975f91185a120
| 0 |
pax_sparse_member_p (struct tar_sparse_file *file)
{
return file->stat_info->sparse_map_avail > 0
|| file->stat_info->sparse_major > 0;
}
|
CWE-476
| 5,307 | 14,366 |
7279484723444561516190225991288647870
| null | null | null |
savannah
|
cb07844454d8cc9fb21f53ace75975f91185a120
| 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;
}
|
CWE-476
| 5,308 | 14,367 |
180789592159917444359724952756354662378
| null | null | null |
savannah
|
cb07844454d8cc9fb21f53ace75975f91185a120
| 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;
}
|
CWE-476
| 5,309 | 14,368 |
8974954236323522610159613738862188919
| null | null | null |
savannah
|
cb07844454d8cc9fb21f53ace75975f91185a120
| 0 |
sparse_dump_file (int fd, struct tar_stat_info *st)
{
bool rc;
struct tar_sparse_file file;
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 dump to work */
rc = sparse_scan_file (&file);
if (rc && file.optab->dump_region)
{
tar_sparse_dump_header (&file);
if (fd >= 0)
{
size_t i;
mv_begin_write (file.stat_info->file_name,
file.stat_info->stat.st_size,
file.stat_info->archive_file_size - file.dumped_size);
for (i = 0; rc && i < file.stat_info->sparse_map_avail; i++)
rc = tar_sparse_dump_region (&file, i);
}
}
pad_archive (file.stat_info->archive_file_size - file.dumped_size);
return (tar_sparse_done (&file) && rc) ? dump_status_ok : dump_status_short;
}
|
CWE-476
| 5,310 | 14,369 |
298479498932788040075153952451508523928
| null | null | null |
savannah
|
cb07844454d8cc9fb21f53ace75975f91185a120
| 0 |
sparse_dump_region (struct tar_sparse_file *file, size_t i)
{
union block *blk;
off_t bytes_left = file->stat_info->sparse_map[i].numbytes;
if (!lseek_or_error (file, file->stat_info->sparse_map[i].offset))
return false;
while (bytes_left > 0)
{
size_t bufsize = (bytes_left > BLOCKSIZE) ? BLOCKSIZE : bytes_left;
size_t bytes_read;
blk = find_next_block ();
bytes_read = safe_read (file->fd, blk->buffer, bufsize);
if (bytes_read == SAFE_READ_ERROR)
{
read_diag_details (file->stat_info->orig_file_name,
(file->stat_info->sparse_map[i].offset
+ file->stat_info->sparse_map[i].numbytes
- bytes_left),
bufsize);
return false;
}
else if (bytes_read == 0)
{
char buf[UINTMAX_STRSIZE_BOUND];
struct stat st;
size_t n;
if (fstat (file->fd, &st) == 0)
n = file->stat_info->stat.st_size - st.st_size;
else
n = file->stat_info->stat.st_size
- (file->stat_info->sparse_map[i].offset
+ file->stat_info->sparse_map[i].numbytes
- bytes_left);
WARNOPT (WARN_FILE_SHRANK,
(0, 0,
ngettext ("%s: File shrank by %s byte; padding with zeros",
"%s: File shrank by %s bytes; padding with zeros",
n),
quotearg_colon (file->stat_info->orig_file_name),
STRINGIFY_BIGINT (n, buf)));
if (! ignore_failed_read_option)
set_exit_status (TAREXIT_DIFFERS);
return false;
}
memset (blk->buffer + bytes_read, 0, BLOCKSIZE - bytes_read);
bytes_left -= bytes_read;
file->dumped_size += bytes_read;
set_next_block_after (blk);
}
return true;
}
|
CWE-476
| 5,311 | 14,370 |
149311081653364363542901657006764270903
| null | null | null |
savannah
|
cb07844454d8cc9fb21f53ace75975f91185a120
| 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;
}
|
CWE-476
| 5,312 | 14,371 |
107608456604416188571976199146799851871
| null | null | null |
savannah
|
cb07844454d8cc9fb21f53ace75975f91185a120
| 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;
}
|
CWE-476
| 5,314 | 14,372 |
95556342580482672048985610850815793314
| null | null | null |
savannah
|
cb07844454d8cc9fb21f53ace75975f91185a120
| 0 |
star_sparse_member_p (struct tar_sparse_file *file __attribute__ ((unused)))
{
return current_header->header.typeflag == GNUTYPE_SPARSE;
}
|
CWE-476
| 5,315 | 14,373 |
67249748667062763457467155668534287116
| null | null | null |
ghostscript
|
961b10cdd71403072fb99401a45f3bef6ce53626
| 0 |
static inline int s16(byte *p)
{
return (signed short)( (p[0] << 8) | p[1] );
}
|
CWE-125
| 5,336 | 14,392 |
331037985417771106886725352111200096459
| null | null | null |
ghostscript
|
961b10cdd71403072fb99401a45f3bef6ce53626
| 0 |
static inline int u16(byte *p)
{
return (p[0] << 8) | p[1];
}
|
CWE-125
| 5,337 | 14,393 |
70313692716440668587080624438572108258
| null | null | null |
ghostscript
|
961b10cdd71403072fb99401a45f3bef6ce53626
| 0 |
static inline int u24(byte *p)
{
return (p[0] << 16) | (p[1] << 8) | p[2];
}
|
CWE-125
| 5,338 | 14,394 |
167238634167240258553105006090779038985
| null | null | null |
ghostscript
|
961b10cdd71403072fb99401a45f3bef6ce53626
| 0 |
static inline int u32(byte *p)
{
return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
}
|
CWE-125
| 5,339 | 14,395 |
164005817604969293041973921078693639865
| null | null | null |
ghostscript
|
961b10cdd71403072fb99401a45f3bef6ce53626
| 0 |
xps_count_font_encodings(xps_font_t *font)
{
return font->cmapsubcount;
}
|
CWE-125
| 5,340 | 14,396 |
62738717690887715881203768460080778849
| null | null | null |
ghostscript
|
961b10cdd71403072fb99401a45f3bef6ce53626
| 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;
}
|
CWE-125
| 5,341 | 14,397 |
149369545525733000745006749123893491999
| null | null | null |
ghostscript
|
961b10cdd71403072fb99401a45f3bef6ce53626
| 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;
}
}
}
}
}
|
CWE-125
| 5,344 | 14,398 |
325261375591148453797851909805587231064
| null | null | null |
ghostscript
|
961b10cdd71403072fb99401a45f3bef6ce53626
| 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;
}
|
CWE-125
| 5,345 | 14,399 |
136363984996029393649118706643471885364
| null | null | null |
ghostscript
|
961b10cdd71403072fb99401a45f3bef6ce53626
| 0 |
xps_select_font_encoding(xps_font_t *font, int idx)
{
byte *cmapdata, *entry;
int pid, eid;
if (idx < 0 || idx >= font->cmapsubcount)
return 0;
cmapdata = font->data + font->cmaptable;
entry = cmapdata + 4 + idx * 8;
pid = u16(entry + 0);
eid = u16(entry + 2);
font->cmapsubtable = font->cmaptable + u32(entry + 4);
if (font->cmapsubtable >= font->length) {
font->cmapsubtable = 0;
return 0;
}
font->usepua = (pid == 3 && eid == 0);
return 1;
}
|
CWE-125
| 5,346 | 14,400 |
130047091764416356227325008496953850258
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static Bool Calc_Length( EXEC_OP )
{
CUR.opcode = CUR.code[CUR.IP];
switch ( CUR.opcode )
{
case 0x40:
if ( CUR.IP + 1 >= CUR.codeSize )
return FAILURE;
CUR.length = CUR.code[CUR.IP + 1] + 2;
break;
case 0x41:
if ( CUR.IP + 1 >= CUR.codeSize )
return FAILURE;
CUR.length = CUR.code[CUR.IP + 1] * 2 + 2;
break;
case 0xB0:
case 0xB1:
case 0xB2:
case 0xB3:
case 0xB4:
case 0xB5:
case 0xB6:
case 0xB7:
CUR.length = CUR.opcode - 0xB0 + 2;
break;
case 0xB8:
case 0xB9:
case 0xBA:
case 0xBB:
case 0xBC:
case 0xBD:
case 0xBE:
case 0xBF:
CUR.length = (CUR.opcode - 0xB8) * 2 + 3;
break;
default:
CUR.length = 1;
break;
}
/* make sure result is in range */
if ( CUR.IP + CUR.length > CUR.codeSize )
return FAILURE;
return SUCCESS;
}
|
CWE-125
| 5,347 | 14,401 |
112577454586979856366474901115066237812
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 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;
}
|
CWE-125
| 5,348 | 14,402 |
232893983865036176338837081531662719093
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 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;
}
|
CWE-125
| 5,349 | 14,403 |
287882677423104721589683290311465282564
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 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;
}
}
|
CWE-125
| 5,350 | 14,404 |
7484615955509031315928207657434099492
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 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;
}
|
CWE-125
| 5,352 | 14,405 |
270235289471057749211719829894507305216
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 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;
}
}
|
CWE-125
| 5,353 | 14,406 |
129869091916840898851532252261774542436
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 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;
}
|
CWE-125
| 5,354 | 14,407 |
287242273403862472519347383462897899040
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Direct_Move_Y( EXEC_OPS PGlyph_Zone zone,
Int point,
TT_F26Dot6 distance )
{ (void)exc;
zone->cur_y[point] += distance;
zone->touch[point] |= TT_Flag_Touched_Y;
}
|
CWE-125
| 5,355 | 14,408 |
166915658342818797327066608133115756685
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static TT_F26Dot6 Dual_Project( EXEC_OPS TT_F26Dot6 Vx, TT_F26Dot6 Vy )
{
THROW_PATENTED;
return 0;
}
|
CWE-125
| 5,356 | 14,409 |
130892856462500466508929196797543609448
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static TT_F26Dot6 FUnits_To_Pixels( EXEC_OPS Int distance )
{
return MulDiv_Round( distance,
CUR.metrics.scale1,
CUR.metrics.scale2 );
}
|
CWE-125
| 5,357 | 14,410 |
181243311668467637115561229021784974158
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static TT_F26Dot6 Free_Project( EXEC_OPS TT_F26Dot6 Vx, TT_F26Dot6 Vy )
{
THROW_PATENTED;
return 0;
}
|
CWE-125
| 5,358 | 14,411 |
251159287294344170838406069627141277897
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 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];
}
|
CWE-125
| 5,359 | 14,412 |
43953055151561115033678145308009460412
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_AA( INS_ARG )
{ (void)exc; (void)args;
/* Intentional - no longer supported */
}
|
CWE-125
| 5,360 | 14,413 |
316334211290102698153992193525770409657
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_ABS( INS_ARG )
{ (void)exc;
args[0] = ABS( args[0] );
}
|
CWE-125
| 5,361 | 14,414 |
139994646317824519442469934117529399239
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_ADD( INS_ARG )
{ (void)exc;
args[0] += args[1];
}
|
CWE-125
| 5,362 | 14,415 |
248310338118490751183917556100235405442
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 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 );
}
|
CWE-125
| 5,363 | 14,416 |
5641549676838549264461208063391725671
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_ALIGNRP( INS_ARG )
{
Int point;
TT_F26Dot6 distance;
(void)args;
if ( CUR.top < CUR.GS.loop )
{
CUR.error = TT_Err_Invalid_Reference;
return;
}
while ( CUR.GS.loop > 0 )
{
CUR.args--;
point = (Int)CUR.stack[CUR.args];
if ( BOUNDS( point, CUR.zp1.n_points ) )
{
CUR.error = TT_Err_Invalid_Reference;
return;
}
distance = 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] );
CUR_Func_move( &CUR.zp1, point, -distance );
CUR.GS.loop--;
}
CUR.GS.loop = 1;
CUR.new_top = CUR.args;
}
|
CWE-125
| 5,364 | 14,417 |
301253683469405031760623091818439411715
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_AND( INS_ARG )
{ (void)exc;
if ( args[0] != 0 && args[1] != 0 )
args[0] = 1;
else
args[0] = 0;
}
|
CWE-125
| 5,365 | 14,418 |
208428179294701692990161217193181894284
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 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;
}
|
CWE-125
| 5,366 | 14,419 |
56048214110338384028463167742766685063
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_CEILING( INS_ARG )
{ (void)exc;
args[0] = (args[0] + 63) & (-64);
}
|
CWE-125
| 5,367 | 14,420 |
142876912607697728761053238935771733851
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_CINDEX( INS_ARG )
{
Long L;
L = args[0];
if ( L<0 || L > CUR.args )
CUR.error = TT_Err_Invalid_Reference;
else
args[0] = CUR.stack[CUR.args - L];
}
|
CWE-125
| 5,368 | 14,421 |
147734490619761310564610413860893568015
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_CLEAR( INS_ARG )
{ (void)args;
CUR.new_top = 0;
}
|
CWE-125
| 5,369 | 14,422 |
59307315405978207155066805667263829026
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_DEBUG( INS_ARG )
{ (void)args;
CUR.error = TT_Err_Debug_OpCode;
}
|
CWE-125
| 5,370 | 14,423 |
120553848060043003761095504358194605173
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 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;
}
|
CWE-125
| 5,371 | 14,424 |
206935054898363343266580466640204009550
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 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;
}
|
CWE-125
| 5,372 | 14,425 |
76473349090415375375280844264165056270
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_DEPTH( INS_ARG )
{
args[0] = CUR.top;
}
|
CWE-125
| 5,373 | 14,426 |
57053433026326348602408852579046840067
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 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]);
}
|
CWE-125
| 5,374 | 14,427 |
233533966853551119168764870432275707792
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_DUP( INS_ARG )
{ (void)exc;
args[1] = args[0];
}
|
CWE-125
| 5,375 | 14,428 |
51499664176492945929106859075501109133
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_EIF( INS_ARG )
{ (void)exc; (void)args;
/* nothing to do */
}
|
CWE-125
| 5,376 | 14,429 |
331431245235897154299575610613995211574
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 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 );
}
|
CWE-125
| 5,377 | 14,430 |
55773617842796008720192836307005597741
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_ENDF( INS_ARG )
{
PCallRecord pRec;
(void)args;
if ( CUR.callTop <= 0 ) /* We encountered an ENDF without a call */
{
CUR.error = TT_Err_ENDF_In_Exec_Stream;
return;
}
CUR.callTop--;
pRec = &CUR.callStack[CUR.callTop];
pRec->Cur_Count--;
CUR.step_ins = FALSE;
if ( pRec->Cur_Count > 0 )
{
CUR.callTop++;
CUR.IP = pRec->Cur_Restart;
}
else
/* Loop through the current function */
INS_Goto_CodeRange( pRec->Caller_Range,
pRec->Caller_IP );
/* Exit the current call frame. */
/* NOTE: When the last intruction of a program */
/* is a CALL or LOOPCALL, the return address */
/* is always out of the code range. This is */
/* a valid address, and it's why we do not test */
/* the result of Ins_Goto_CodeRange() here! */
}
|
CWE-125
| 5,378 | 14,431 |
123825729373029686431335071076611041901
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_EQ( INS_ARG )
{ (void)exc;
if ( args[0] == args[1] )
args[0] = 1;
else
args[0] = 0;
}
|
CWE-125
| 5,379 | 14,432 |
35322659608240855192527440228213408037
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_EVEN( INS_ARG )
{
if ( (CUR_Func_round( args[0], 0L ) & 127) == 0 )
args[0] = 1;
else
args[0] = 0;
}
|
CWE-125
| 5,380 | 14,433 |
24172464422358357284456580714646163558
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 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);
}
|
CWE-125
| 5,381 | 14,434 |
95630302802270972716093132916202148731
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_FLIPOFF( INS_ARG )
{ (void)args;
CUR.GS.auto_flip = FALSE;
}
|
CWE-125
| 5,382 | 14,435 |
15854285820354400062307664871268882313
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_FLIPON( INS_ARG )
{ (void)args;
CUR.GS.auto_flip = TRUE;
}
|
CWE-125
| 5,383 | 14,436 |
275407057814495582774819651504657541231
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 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;
}
|
CWE-125
| 5,385 | 14,437 |
155224313175218374993783801265115474974
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_FLOOR( INS_ARG )
{ (void)exc;
args[0] &= -64;
}
|
CWE-125
| 5,386 | 14,438 |
277880419403934023313630350746691953370
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_GC( INS_ARG )
{
Long L;
L = args[0];
if ( BOUNDS( L, CUR.zp2.n_points ) )
{
CUR.error = TT_Err_Invalid_Reference;
return;
}
switch ( CUR.opcode & 1 )
{
case 0:
L = CUR_Func_project( CUR.zp2.cur_x[L],
CUR.zp2.cur_y[L] );
break;
case 1:
L = CUR_Func_dualproj( CUR.zp2.org_x[L],
CUR.zp2.org_y[L] );
break;
}
args[0] = L;
}
|
CWE-125
| 5,387 | 14,439 |
301480656963225258274793729535368718988
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_GFV( INS_ARG )
{
args[0] = CUR.GS.freeVector.x;
args[1] = CUR.GS.freeVector.y;
}
|
CWE-125
| 5,389 | 14,440 |
115739652296497196657507347961146618469
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_GPV( INS_ARG )
{
args[0] = CUR.GS.projVector.x;
args[1] = CUR.GS.projVector.y;
}
|
CWE-125
| 5,390 | 14,441 |
222441896574937424411067101977553929962
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_GT( INS_ARG )
{ (void)exc;
if ( args[0] > args[1] )
args[0] = 1;
else
args[0] = 0;
}
|
CWE-125
| 5,391 | 14,442 |
332062630633343882477045298980207805607
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_GTEQ( INS_ARG )
{ (void)exc;
if ( args[0] >= args[1] )
args[0] = 1;
else
args[0] = 0;
}
|
CWE-125
| 5,392 | 14,443 |
331403327419854732517430666070069553304
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 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;
}
|
CWE-125
| 5,393 | 14,444 |
312088440994411607486450990537215202281
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 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);
}
}
|
CWE-125
| 5,394 | 14,445 |
245046248932865021870243345802026013545
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 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 );
}
|
CWE-125
| 5,395 | 14,446 |
84900707593551900160291927707756985467
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 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));
}
|
CWE-125
| 5,396 | 14,447 |
295668471617596663194891625966333960013
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_IP( INS_ARG )
{
TT_F26Dot6 org_a, org_b, org_x,
cur_a, cur_b, cur_x,
distance;
Int point;
(void)args;
if ( CUR.top < CUR.GS.loop ||
BOUNDS(CUR.GS.rp1, CUR.zp0.n_points) ||
BOUNDS(CUR.GS.rp2, CUR.zp1.n_points))
{
CUR.error = TT_Err_Invalid_Reference;
return;
}
org_a = CUR_Func_dualproj( CUR.zp0.org_x[CUR.GS.rp1],
CUR.zp0.org_y[CUR.GS.rp1] );
org_b = CUR_Func_dualproj( CUR.zp1.org_x[CUR.GS.rp2],
CUR.zp1.org_y[CUR.GS.rp2] );
cur_a = CUR_Func_project( CUR.zp0.cur_x[CUR.GS.rp1],
CUR.zp0.cur_y[CUR.GS.rp1] );
cur_b = CUR_Func_project( CUR.zp1.cur_x[CUR.GS.rp2],
CUR.zp1.cur_y[CUR.GS.rp2] );
while ( CUR.GS.loop > 0 )
{
CUR.args--;
point = (Int)CUR.stack[CUR.args];
if ( BOUNDS( point, CUR.zp2.n_points ) )
{
CUR.error = TT_Err_Invalid_Reference;
return;
}
org_x = CUR_Func_dualproj( CUR.zp2.org_x[point],
CUR.zp2.org_y[point] );
cur_x = CUR_Func_project( CUR.zp2.cur_x[point],
CUR.zp2.cur_y[point] );
if ( ( org_a <= org_b && org_x <= org_a ) ||
( org_a > org_b && org_x >= org_a ) )
distance = ( cur_a - org_a ) + ( org_x - cur_x );
else if ( ( org_a <= org_b && org_x >= org_b ) ||
( org_a > org_b && org_x < org_b ) )
distance = ( cur_b - org_b ) + ( org_x - cur_x );
else
/* note: it seems that rounding this value isn't a good */
/* idea (cf. width of capital 'S' in Times) */
distance = MulDiv_Round( cur_b - cur_a,
org_x - org_a,
org_b - org_a ) + ( cur_a - cur_x );
CUR_Func_move( &CUR.zp2, point, distance );
CUR.GS.loop--;
}
CUR.GS.loop = 1;
CUR.new_top = CUR.args;
}
|
CWE-125
| 5,397 | 14,448 |
182601607540285189838115308785920018350
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 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;
}
}
|
CWE-125
| 5,398 | 14,449 |
82181783434404973701628518185530750026
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 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 );
}
|
CWE-125
| 5,399 | 14,450 |
22162722561741582181001494866866377561
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 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;
}
}
|
CWE-125
| 5,401 | 14,451 |
262916535602627025992720153205366226510
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 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;
}
}
|
CWE-125
| 5,402 | 14,452 |
105670859021685032650472602067937768081
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_LT( INS_ARG )
{ (void)exc;
if ( args[0] < args[1] )
args[0] = 1;
else
args[0] = 0;
}
|
CWE-125
| 5,403 | 14,453 |
137999184880285695228582347262990251167
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_LTEQ( INS_ARG )
{ (void)exc;
if ( args[0] <= args[1] )
args[0] = 1;
else
args[0] = 0;
}
|
CWE-125
| 5,404 | 14,454 |
138626552672208181777553108350651168211
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_MAX( INS_ARG )
{ (void)exc;
if ( args[1] > args[0] )
args[0] = args[1];
}
|
CWE-125
| 5,405 | 14,455 |
114277236983453770504640740105504798071
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 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;
}
|
CWE-125
| 5,406 | 14,456 |
186050444122027664306238619684916655340
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_MDRP( INS_ARG )
{
Int point;
TT_F26Dot6 distance,
org_dist;
point = (Int)args[0];
if ( BOUNDS( args[0], CUR.zp1.n_points ) ||
BOUNDS( CUR.GS.rp0, CUR.zp0.n_points) )
{
/* Current version of FreeType silently ignores this out of bounds error
* and drops the instruction, see bug #691121
CUR.error = TT_Err_Invalid_Reference; */
return;
}
/* XXX: Is there some undocumented feature while in the */
/* twilight zone? */
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] );
/* single width cutin test */
if ( ABS(org_dist) < CUR.GS.single_width_cutin )
{
if ( org_dist >= 0 )
org_dist = CUR.GS.single_width_value;
else
org_dist = -CUR.GS.single_width_value;
}
/* round flag */
if ( (CUR.opcode & 4) != 0 )
distance = CUR_Func_round( org_dist,
CUR.metrics.compensations[CUR.opcode & 3] );
else
distance = Round_None( EXEC_ARGS
org_dist,
CUR.metrics.compensations[CUR.opcode & 3] );
/* minimum distance flag */
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;
}
}
/* now move the point */
org_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] );
CUR_Func_move( &CUR.zp1, point, distance - org_dist );
CUR.GS.rp1 = CUR.GS.rp0;
CUR.GS.rp2 = point;
if ( (CUR.opcode & 16) != 0 )
CUR.GS.rp0 = point;
}
|
CWE-125
| 5,408 | 14,457 |
286795312573774333632712579384001974189
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_MIAP( INS_ARG )
{
Int cvtEntry, point;
TT_F26Dot6 distance,
org_dist;
cvtEntry = (Int)args[1];
point = (Int)args[0];
if ( BOUNDS( args[0], CUR.zp0.n_points ) ||
BOUNDS( args[1], CUR.cvtSize ) )
{
/* Ignore these errors, abort the instruction
* and continue. This restores the FreeType
* behaviour when pedantic_hinting is false. For bug
* #689471, see also Ins_SHC above and bug #688501.
*/
return;
}
/* Undocumented: */
/* */
/* The behaviour of an MIAP instruction is quite */
/* different when used in the twilight zone. */
/* */
/* First, no control value cutin test is performed */
/* as it would fail anyway. Second, the original */
/* point, i.e. (org_x,org_y) of zp0.point, is set */
/* to the absolute, unrounded distance found in */
/* the CVT. */
/* */
/* This is used in the CVT programs of the Microsoft */
/* fonts Arial, Times, etc., in order to re-adjust */
/* some key font heights. It allows the use of the */
/* IP instruction in the twilight zone, which */
/* otherwise would be "illegal" according to the */
/* specs :) */
/* */
/* We implement it with a special sequence for the */
/* twilight zone. This is a bad hack, but it seems */
/* to work. */
distance = CUR_Func_read_cvt( cvtEntry );
DBG_PRINT3(" cvtEntry=%d point=%d distance=%d", cvtEntry, point, distance);
if ( CUR.GS.gep0 == 0 ) /* If in twilight zone */
{
CUR.zp0.org_x[point] = MulDiv_Round( CUR.GS.freeVector.x,
distance, 0x4000L );
CUR.zp0.cur_x[point] = CUR.zp0.org_x[point];
CUR.zp0.org_y[point] = MulDiv_Round( CUR.GS.freeVector.y,
distance, 0x4000L );
CUR.zp0.cur_y[point] = CUR.zp0.org_y[point];
}
org_dist = CUR_Func_project( CUR.zp0.cur_x[point],
CUR.zp0.cur_y[point] );
if ( (CUR.opcode & 1) != 0 ) /* rounding and control cutin flag */
{
if ( ABS(distance - org_dist) > CUR.GS.control_value_cutin )
distance = org_dist;
distance = CUR_Func_round( distance, CUR.metrics.compensations[0] );
}
CUR_Func_move( &CUR.zp0, point, distance - org_dist );
CUR.GS.rp0 = point;
CUR.GS.rp1 = point;
}
|
CWE-125
| 5,409 | 14,458 |
58001255515255552404417971122376257764
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_MIN( INS_ARG )
{ (void)exc;
if ( args[1] < args[0] )
args[0] = args[1];
}
|
CWE-125
| 5,410 | 14,459 |
41310686306388194617649331887577292743
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 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;
}
|
CWE-125
| 5,411 | 14,460 |
11979375147929569995269777787889994675
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 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;
}
|
CWE-125
| 5,412 | 14,461 |
28280744426354865598641751513517931746
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_MPPEM( INS_ARG )
{
args[0] = CURRENT_Ppem();
DBG_PRINT1(" %d", args[0]);
}
|
CWE-125
| 5,413 | 14,462 |
244827583211804959293775285349293655652
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_MPS( INS_ARG )
{
args[0] = CUR.metrics.pointSize;
}
|
CWE-125
| 5,414 | 14,463 |
266299255296799971596145120032062782088
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_MSIRP( INS_ARG )
{
Int point;
TT_F26Dot6 distance;
point = (Int)args[0];
if ( BOUNDS( args[0], CUR.zp1.n_points ) )
{
CUR.error = TT_Err_Invalid_Reference;
return;
}
/* XXX: Undocumented behaviour */
if ( CUR.GS.gep0 == 0 ) /* if in twilight zone */
{
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.zp1.cur_x[point] = CUR.zp1.org_x[point];
CUR.zp1.cur_y[point] = CUR.zp1.org_y[point];
}
distance = 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] );
CUR_Func_move( &CUR.zp1, point, args[1] - distance );
CUR.GS.rp1 = CUR.GS.rp0;
CUR.GS.rp2 = point;
if ( (CUR.opcode & 1) != 0 )
CUR.GS.rp0 = point;
}
|
CWE-125
| 5,415 | 14,464 |
330260299773812088749899526228376823939
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_NEG( INS_ARG )
{ (void)exc;
args[0] = -args[0];
}
|
CWE-125
| 5,417 | 14,465 |
154001593689945078054002147212879525637
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_NEQ( INS_ARG )
{ (void)exc;
if ( args[0] != args[1] )
args[0] = 1;
else
args[0] = 0;
}
|
CWE-125
| 5,418 | 14,466 |
131763823443033700321726034607029553903
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_NOT( INS_ARG )
{ (void)exc;
if ( args[0] != 0 )
args[0] = 0;
else
args[0] = 1;
}
|
CWE-125
| 5,419 | 14,467 |
224828454586099348760771799454721367874
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_NPUSHW( INS_ARG )
{
Int L, K;
L = (Int)CUR.code[CUR.IP + 1];
if ( BOUNDS( L, CUR.stackSize+1-CUR.top ) )
{
CUR.error = TT_Err_Stack_Overflow;
return;
}
CUR.IP += 2;
for ( K = 0; K < L; K++ )
{ args[K] = GET_ShortIns();
DBG_PRINT1(" %d", args[K]);
}
CUR.step_ins = FALSE;
CUR.new_top += L;
}
|
CWE-125
| 5,421 | 14,468 |
239110308587050314656135543921438031681
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_ODD( INS_ARG )
{
if ( (CUR_Func_round( args[0], 0L ) & 127) == 64 )
args[0] = 1;
else
args[0] = 0;
}
|
CWE-125
| 5,423 | 14,469 |
304469038975411153741859032219068979359
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_OR( INS_ARG )
{ (void)exc;
if ( args[0] != 0 || args[1] != 0 )
args[0] = 1;
else
args[0] = 0;
}
|
CWE-125
| 5,424 | 14,470 |
32715707547274114843250539059708423740
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_POP( INS_ARG )
{ (void)exc; (void)args;
/* nothing to do */
}
|
CWE-125
| 5,425 | 14,471 |
193102936131170968995137209331961879169
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_PUSHB( INS_ARG )
{
Int L, K;
L = ((Int)CUR.opcode - 0xB0 + 1);
if ( BOUNDS( L, CUR.stackSize+1-CUR.top ) )
{
CUR.error = TT_Err_Stack_Overflow;
return;
}
for ( K = 1; K <= L; K++ )
{ args[K - 1] = CUR.code[CUR.IP + K];
DBG_PRINT1(" %d", args[K - 1]);
}
}
|
CWE-125
| 5,426 | 14,472 |
53139116385856230408225862568507425308
| null | null | null |
ghostscript
|
c501a58f8d5650c8ba21d447c0d6f07eafcb0f15
| 0 |
static void Ins_PUSHW( INS_ARG )
{
Int L, K;
L = CUR.opcode - 0xB8 + 1;
if ( BOUNDS( L, CUR.stackSize+1-CUR.top ) )
{
CUR.error = TT_Err_Stack_Overflow;
return;
}
CUR.IP++;
for ( K = 0; K < L; K++ )
{ args[K] = GET_ShortIns();
DBG_PRINT1(" %d", args[K]);
}
CUR.step_ins = FALSE;
}
|
CWE-125
| 5,427 | 14,473 |
226449248663310192299107887769530696523
| null | null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.