idx
int64
func_before
string
Vulnerability Classification
string
vul
int64
func_after
string
patch
string
CWE ID
string
lines_before
string
lines_after
string
8,400
iscsi_process_read(void *arg) { IscsiLun *iscsilun = arg; struct iscsi_context *iscsi = iscsilun->iscsi; iscsi_service(iscsi, POLLIN); iscsi_set_events(iscsilun); }
DoS Exec Code Overflow
0
iscsi_process_read(void *arg) { IscsiLun *iscsilun = arg; struct iscsi_context *iscsi = iscsilun->iscsi; iscsi_service(iscsi, POLLIN); iscsi_set_events(iscsilun); }
@@ -833,6 +833,13 @@ static BlockAIOCB *iscsi_aio_ioctl(BlockDriverState *bs, return &acb->common; } + if (acb->ioh->cmd_len > SCSI_CDB_MAX_SIZE) { + error_report("iSCSI: ioctl error CDB exceeds max size (%d > %d)", + acb->ioh->cmd_len, SCSI_CDB_MAX_SIZE); + qemu_aio_unref(acb); + return NULL; + } + acb->task = malloc(sizeof(struct scsi_task)); if (acb->task == NULL) { error_report("iSCSI: Failed to allocate task for scsi command. %s",
CWE-119
null
null
8,401
static void iscsi_readcapacity_sync(IscsiLun *iscsilun, Error **errp) { struct scsi_task *task = NULL; struct scsi_readcapacity10 *rc10 = NULL; struct scsi_readcapacity16 *rc16 = NULL; int retries = ISCSI_CMD_RETRIES; do { if (task != NULL) { scsi_free_scsi_task(task); task = NULL; } switch (iscsilun->type) { case TYPE_DISK: task = iscsi_readcapacity16_sync(iscsilun->iscsi, iscsilun->lun); if (task != NULL && task->status == SCSI_STATUS_GOOD) { rc16 = scsi_datain_unmarshall(task); if (rc16 == NULL) { error_setg(errp, "iSCSI: Failed to unmarshall readcapacity16 data."); } else { iscsilun->block_size = rc16->block_length; iscsilun->num_blocks = rc16->returned_lba + 1; iscsilun->lbpme = !!rc16->lbpme; iscsilun->lbprz = !!rc16->lbprz; iscsilun->use_16_for_rw = (rc16->returned_lba > 0xffffffff); } break; } if (task != NULL && task->status == SCSI_STATUS_CHECK_CONDITION && task->sense.key == SCSI_SENSE_UNIT_ATTENTION) { break; } /* Fall through and try READ CAPACITY(10) instead. */ case TYPE_ROM: task = iscsi_readcapacity10_sync(iscsilun->iscsi, iscsilun->lun, 0, 0); if (task != NULL && task->status == SCSI_STATUS_GOOD) { rc10 = scsi_datain_unmarshall(task); if (rc10 == NULL) { error_setg(errp, "iSCSI: Failed to unmarshall readcapacity10 data."); } else { iscsilun->block_size = rc10->block_size; if (rc10->lba == 0) { /* blank disk loaded */ iscsilun->num_blocks = 0; } else { iscsilun->num_blocks = rc10->lba + 1; } } } break; default: return; } } while (task != NULL && task->status == SCSI_STATUS_CHECK_CONDITION && task->sense.key == SCSI_SENSE_UNIT_ATTENTION && retries-- > 0); if (task == NULL || task->status != SCSI_STATUS_GOOD) { error_setg(errp, "iSCSI: failed to send readcapacity10/16 command"); } else if (!iscsilun->block_size || iscsilun->block_size % BDRV_SECTOR_SIZE) { error_setg(errp, "iSCSI: the target returned an invalid " "block size of %d.", iscsilun->block_size); } if (task) { scsi_free_scsi_task(task); } }
DoS Exec Code Overflow
0
static void iscsi_readcapacity_sync(IscsiLun *iscsilun, Error **errp) { struct scsi_task *task = NULL; struct scsi_readcapacity10 *rc10 = NULL; struct scsi_readcapacity16 *rc16 = NULL; int retries = ISCSI_CMD_RETRIES; do { if (task != NULL) { scsi_free_scsi_task(task); task = NULL; } switch (iscsilun->type) { case TYPE_DISK: task = iscsi_readcapacity16_sync(iscsilun->iscsi, iscsilun->lun); if (task != NULL && task->status == SCSI_STATUS_GOOD) { rc16 = scsi_datain_unmarshall(task); if (rc16 == NULL) { error_setg(errp, "iSCSI: Failed to unmarshall readcapacity16 data."); } else { iscsilun->block_size = rc16->block_length; iscsilun->num_blocks = rc16->returned_lba + 1; iscsilun->lbpme = !!rc16->lbpme; iscsilun->lbprz = !!rc16->lbprz; iscsilun->use_16_for_rw = (rc16->returned_lba > 0xffffffff); } break; } if (task != NULL && task->status == SCSI_STATUS_CHECK_CONDITION && task->sense.key == SCSI_SENSE_UNIT_ATTENTION) { break; } /* Fall through and try READ CAPACITY(10) instead. */ case TYPE_ROM: task = iscsi_readcapacity10_sync(iscsilun->iscsi, iscsilun->lun, 0, 0); if (task != NULL && task->status == SCSI_STATUS_GOOD) { rc10 = scsi_datain_unmarshall(task); if (rc10 == NULL) { error_setg(errp, "iSCSI: Failed to unmarshall readcapacity10 data."); } else { iscsilun->block_size = rc10->block_size; if (rc10->lba == 0) { /* blank disk loaded */ iscsilun->num_blocks = 0; } else { iscsilun->num_blocks = rc10->lba + 1; } } } break; default: return; } } while (task != NULL && task->status == SCSI_STATUS_CHECK_CONDITION && task->sense.key == SCSI_SENSE_UNIT_ATTENTION && retries-- > 0); if (task == NULL || task->status != SCSI_STATUS_GOOD) { error_setg(errp, "iSCSI: failed to send readcapacity10/16 command"); } else if (!iscsilun->block_size || iscsilun->block_size % BDRV_SECTOR_SIZE) { error_setg(errp, "iSCSI: the target returned an invalid " "block size of %d.", iscsilun->block_size); } if (task) { scsi_free_scsi_task(task); } }
@@ -833,6 +833,13 @@ static BlockAIOCB *iscsi_aio_ioctl(BlockDriverState *bs, return &acb->common; } + if (acb->ioh->cmd_len > SCSI_CDB_MAX_SIZE) { + error_report("iSCSI: ioctl error CDB exceeds max size (%d > %d)", + acb->ioh->cmd_len, SCSI_CDB_MAX_SIZE); + qemu_aio_unref(acb); + return NULL; + } + acb->task = malloc(sizeof(struct scsi_task)); if (acb->task == NULL) { error_report("iSCSI: Failed to allocate task for scsi command. %s",
CWE-119
null
null
8,402
static int iscsi_reopen_prepare(BDRVReopenState *state, BlockReopenQueue *queue, Error **errp) { IscsiLun *iscsilun = state->bs->opaque; if (state->flags & BDRV_O_RDWR && iscsilun->write_protected) { error_setg(errp, "Cannot open a write protected LUN as read-write"); return -EACCES; } return 0; }
DoS Exec Code Overflow
0
static int iscsi_reopen_prepare(BDRVReopenState *state, BlockReopenQueue *queue, Error **errp) { IscsiLun *iscsilun = state->bs->opaque; if (state->flags & BDRV_O_RDWR && iscsilun->write_protected) { error_setg(errp, "Cannot open a write protected LUN as read-write"); return -EACCES; } return 0; }
@@ -833,6 +833,13 @@ static BlockAIOCB *iscsi_aio_ioctl(BlockDriverState *bs, return &acb->common; } + if (acb->ioh->cmd_len > SCSI_CDB_MAX_SIZE) { + error_report("iSCSI: ioctl error CDB exceeds max size (%d > %d)", + acb->ioh->cmd_len, SCSI_CDB_MAX_SIZE); + qemu_aio_unref(acb); + return NULL; + } + acb->task = malloc(sizeof(struct scsi_task)); if (acb->task == NULL) { error_report("iSCSI: Failed to allocate task for scsi command. %s",
CWE-119
null
null
8,403
static void iscsi_retry_timer_expired(void *opaque) { struct IscsiTask *iTask = opaque; iTask->complete = 1; if (iTask->co) { qemu_coroutine_enter(iTask->co, NULL); } }
DoS Exec Code Overflow
0
static void iscsi_retry_timer_expired(void *opaque) { struct IscsiTask *iTask = opaque; iTask->complete = 1; if (iTask->co) { qemu_coroutine_enter(iTask->co, NULL); } }
@@ -833,6 +833,13 @@ static BlockAIOCB *iscsi_aio_ioctl(BlockDriverState *bs, return &acb->common; } + if (acb->ioh->cmd_len > SCSI_CDB_MAX_SIZE) { + error_report("iSCSI: ioctl error CDB exceeds max size (%d > %d)", + acb->ioh->cmd_len, SCSI_CDB_MAX_SIZE); + qemu_aio_unref(acb); + return NULL; + } + acb->task = malloc(sizeof(struct scsi_task)); if (acb->task == NULL) { error_report("iSCSI: Failed to allocate task for scsi command. %s",
CWE-119
null
null
8,404
iscsi_set_events(IscsiLun *iscsilun) { struct iscsi_context *iscsi = iscsilun->iscsi; int ev = iscsi_which_events(iscsi); if (ev != iscsilun->events) { aio_set_fd_handler(iscsilun->aio_context, iscsi_get_fd(iscsi), false, (ev & POLLIN) ? iscsi_process_read : NULL, (ev & POLLOUT) ? iscsi_process_write : NULL, iscsilun); iscsilun->events = ev; } }
DoS Exec Code Overflow
0
iscsi_set_events(IscsiLun *iscsilun) { struct iscsi_context *iscsi = iscsilun->iscsi; int ev = iscsi_which_events(iscsi); if (ev != iscsilun->events) { aio_set_fd_handler(iscsilun->aio_context, iscsi_get_fd(iscsi), false, (ev & POLLIN) ? iscsi_process_read : NULL, (ev & POLLOUT) ? iscsi_process_write : NULL, iscsilun); iscsilun->events = ev; } }
@@ -833,6 +833,13 @@ static BlockAIOCB *iscsi_aio_ioctl(BlockDriverState *bs, return &acb->common; } + if (acb->ioh->cmd_len > SCSI_CDB_MAX_SIZE) { + error_report("iSCSI: ioctl error CDB exceeds max size (%d > %d)", + acb->ioh->cmd_len, SCSI_CDB_MAX_SIZE); + qemu_aio_unref(acb); + return NULL; + } + acb->task = malloc(sizeof(struct scsi_task)); if (acb->task == NULL) { error_report("iSCSI: Failed to allocate task for scsi command. %s",
CWE-119
null
null
8,405
static int iscsi_truncate(BlockDriverState *bs, int64_t offset) { IscsiLun *iscsilun = bs->opaque; Error *local_err = NULL; if (iscsilun->type != TYPE_DISK) { return -ENOTSUP; } iscsi_readcapacity_sync(iscsilun, &local_err); if (local_err != NULL) { error_free(local_err); return -EIO; } if (offset > iscsi_getlength(bs)) { return -EINVAL; } if (iscsilun->allocationmap != NULL) { g_free(iscsilun->allocationmap); iscsilun->allocationmap = iscsi_allocationmap_init(iscsilun); } return 0; }
DoS Exec Code Overflow
0
static int iscsi_truncate(BlockDriverState *bs, int64_t offset) { IscsiLun *iscsilun = bs->opaque; Error *local_err = NULL; if (iscsilun->type != TYPE_DISK) { return -ENOTSUP; } iscsi_readcapacity_sync(iscsilun, &local_err); if (local_err != NULL) { error_free(local_err); return -EIO; } if (offset > iscsi_getlength(bs)) { return -EINVAL; } if (iscsilun->allocationmap != NULL) { g_free(iscsilun->allocationmap); iscsilun->allocationmap = iscsi_allocationmap_init(iscsilun); } return 0; }
@@ -833,6 +833,13 @@ static BlockAIOCB *iscsi_aio_ioctl(BlockDriverState *bs, return &acb->common; } + if (acb->ioh->cmd_len > SCSI_CDB_MAX_SIZE) { + error_report("iSCSI: ioctl error CDB exceeds max size (%d > %d)", + acb->ioh->cmd_len, SCSI_CDB_MAX_SIZE); + qemu_aio_unref(acb); + return NULL; + } + acb->task = malloc(sizeof(struct scsi_task)); if (acb->task == NULL) { error_report("iSCSI: Failed to allocate task for scsi command. %s",
CWE-119
null
null
8,406
static void parse_chap(struct iscsi_context *iscsi, const char *target, Error **errp) { QemuOptsList *list; QemuOpts *opts; const char *user = NULL; const char *password = NULL; const char *secretid; char *secret = NULL; list = qemu_find_opts("iscsi"); if (!list) { return; } opts = qemu_opts_find(list, target); if (opts == NULL) { opts = QTAILQ_FIRST(&list->head); if (!opts) { return; } } user = qemu_opt_get(opts, "user"); if (!user) { return; } secretid = qemu_opt_get(opts, "password-secret"); password = qemu_opt_get(opts, "password"); if (secretid && password) { error_setg(errp, "'password' and 'password-secret' properties are " "mutually exclusive"); return; } if (secretid) { secret = qcrypto_secret_lookup_as_utf8(secretid, errp); if (!secret) { return; } password = secret; } else if (!password) { error_setg(errp, "CHAP username specified but no password was given"); return; } if (iscsi_set_initiator_username_pwd(iscsi, user, password)) { error_setg(errp, "Failed to set initiator username and password"); } g_free(secret); }
DoS Exec Code Overflow
0
static void parse_chap(struct iscsi_context *iscsi, const char *target, Error **errp) { QemuOptsList *list; QemuOpts *opts; const char *user = NULL; const char *password = NULL; const char *secretid; char *secret = NULL; list = qemu_find_opts("iscsi"); if (!list) { return; } opts = qemu_opts_find(list, target); if (opts == NULL) { opts = QTAILQ_FIRST(&list->head); if (!opts) { return; } } user = qemu_opt_get(opts, "user"); if (!user) { return; } secretid = qemu_opt_get(opts, "password-secret"); password = qemu_opt_get(opts, "password"); if (secretid && password) { error_setg(errp, "'password' and 'password-secret' properties are " "mutually exclusive"); return; } if (secretid) { secret = qcrypto_secret_lookup_as_utf8(secretid, errp); if (!secret) { return; } password = secret; } else if (!password) { error_setg(errp, "CHAP username specified but no password was given"); return; } if (iscsi_set_initiator_username_pwd(iscsi, user, password)) { error_setg(errp, "Failed to set initiator username and password"); } g_free(secret); }
@@ -833,6 +833,13 @@ static BlockAIOCB *iscsi_aio_ioctl(BlockDriverState *bs, return &acb->common; } + if (acb->ioh->cmd_len > SCSI_CDB_MAX_SIZE) { + error_report("iSCSI: ioctl error CDB exceeds max size (%d > %d)", + acb->ioh->cmd_len, SCSI_CDB_MAX_SIZE); + qemu_aio_unref(acb); + return NULL; + } + acb->task = malloc(sizeof(struct scsi_task)); if (acb->task == NULL) { error_report("iSCSI: Failed to allocate task for scsi command. %s",
CWE-119
null
null
8,407
static char *parse_initiator_name(const char *target) { QemuOptsList *list; QemuOpts *opts; const char *name; char *iscsi_name; UuidInfo *uuid_info; list = qemu_find_opts("iscsi"); if (list) { opts = qemu_opts_find(list, target); if (!opts) { opts = QTAILQ_FIRST(&list->head); } if (opts) { name = qemu_opt_get(opts, "initiator-name"); if (name) { return g_strdup(name); } } } uuid_info = qmp_query_uuid(NULL); if (strcmp(uuid_info->UUID, UUID_NONE) == 0) { name = qemu_get_vm_name(); } else { name = uuid_info->UUID; } iscsi_name = g_strdup_printf("iqn.2008-11.org.linux-kvm%s%s", name ? ":" : "", name ? name : ""); qapi_free_UuidInfo(uuid_info); return iscsi_name; }
DoS Exec Code Overflow
0
static char *parse_initiator_name(const char *target) { QemuOptsList *list; QemuOpts *opts; const char *name; char *iscsi_name; UuidInfo *uuid_info; list = qemu_find_opts("iscsi"); if (list) { opts = qemu_opts_find(list, target); if (!opts) { opts = QTAILQ_FIRST(&list->head); } if (opts) { name = qemu_opt_get(opts, "initiator-name"); if (name) { return g_strdup(name); } } } uuid_info = qmp_query_uuid(NULL); if (strcmp(uuid_info->UUID, UUID_NONE) == 0) { name = qemu_get_vm_name(); } else { name = uuid_info->UUID; } iscsi_name = g_strdup_printf("iqn.2008-11.org.linux-kvm%s%s", name ? ":" : "", name ? name : ""); qapi_free_UuidInfo(uuid_info); return iscsi_name; }
@@ -833,6 +833,13 @@ static BlockAIOCB *iscsi_aio_ioctl(BlockDriverState *bs, return &acb->common; } + if (acb->ioh->cmd_len > SCSI_CDB_MAX_SIZE) { + error_report("iSCSI: ioctl error CDB exceeds max size (%d > %d)", + acb->ioh->cmd_len, SCSI_CDB_MAX_SIZE); + qemu_aio_unref(acb); + return NULL; + } + acb->task = malloc(sizeof(struct scsi_task)); if (acb->task == NULL) { error_report("iSCSI: Failed to allocate task for scsi command. %s",
CWE-119
null
null
8,408
static int64_t sector_lun2qemu(int64_t sector, IscsiLun *iscsilun) { return sector * iscsilun->block_size / BDRV_SECTOR_SIZE; }
DoS Exec Code Overflow
0
static int64_t sector_lun2qemu(int64_t sector, IscsiLun *iscsilun) { return sector * iscsilun->block_size / BDRV_SECTOR_SIZE; }
@@ -833,6 +833,13 @@ static BlockAIOCB *iscsi_aio_ioctl(BlockDriverState *bs, return &acb->common; } + if (acb->ioh->cmd_len > SCSI_CDB_MAX_SIZE) { + error_report("iSCSI: ioctl error CDB exceeds max size (%d > %d)", + acb->ioh->cmd_len, SCSI_CDB_MAX_SIZE); + qemu_aio_unref(acb); + return NULL; + } + acb->task = malloc(sizeof(struct scsi_task)); if (acb->task == NULL) { error_report("iSCSI: Failed to allocate task for scsi command. %s",
CWE-119
null
null
8,409
static int64_t sector_qemu2lun(int64_t sector, IscsiLun *iscsilun) { return sector * BDRV_SECTOR_SIZE / iscsilun->block_size; }
DoS Exec Code Overflow
0
static int64_t sector_qemu2lun(int64_t sector, IscsiLun *iscsilun) { return sector * BDRV_SECTOR_SIZE / iscsilun->block_size; }
@@ -833,6 +833,13 @@ static BlockAIOCB *iscsi_aio_ioctl(BlockDriverState *bs, return &acb->common; } + if (acb->ioh->cmd_len > SCSI_CDB_MAX_SIZE) { + error_report("iSCSI: ioctl error CDB exceeds max size (%d > %d)", + acb->ioh->cmd_len, SCSI_CDB_MAX_SIZE); + qemu_aio_unref(acb); + return NULL; + } + acb->task = malloc(sizeof(struct scsi_task)); if (acb->task == NULL) { error_report("iSCSI: Failed to allocate task for scsi command. %s",
CWE-119
null
null
8,410
fd_read_body (const char *downloaded_filename, int fd, FILE *out, wgint toread, wgint startpos, wgint *qtyread, wgint *qtywritten, double *elapsed, int flags, FILE *out2) { int ret = 0; #undef max #define max(a,b) ((a) > (b) ? (a) : (b)) int dlbufsize = max (BUFSIZ, 8 * 1024); char *dlbuf = xmalloc (dlbufsize); struct ptimer *timer = NULL; double last_successful_read_tm = 0; /* The progress gauge, set according to the user preferences. */ void *progress = NULL; /* Non-zero if the progress gauge is interactive, i.e. if it can continually update the display. When true, smaller timeout values are used so that the gauge can update the display when data arrives slowly. */ bool progress_interactive = false; bool exact = !!(flags & rb_read_exactly); /* Used only by HTTP/HTTPS chunked transfer encoding. */ bool chunked = flags & rb_chunked_transfer_encoding; wgint skip = 0; /* How much data we've read/written. */ wgint sum_read = 0; wgint sum_written = 0; wgint remaining_chunk_size = 0; if (flags & rb_skip_startpos) skip = startpos; if (opt.show_progress) { const char *filename_progress; /* If we're skipping STARTPOS bytes, pass 0 as the INITIAL argument to progress_create because the indicator doesn't (yet) know about "skipping" data. */ wgint start = skip ? 0 : startpos; if (opt.dir_prefix) filename_progress = downloaded_filename + strlen (opt.dir_prefix) + 1; else filename_progress = downloaded_filename; progress = progress_create (filename_progress, start, start + toread); progress_interactive = progress_interactive_p (progress); } if (opt.limit_rate) limit_bandwidth_reset (); /* A timer is needed for tracking progress, for throttling, and for tracking elapsed time. If either of these are requested, start the timer. */ if (progress || opt.limit_rate || elapsed) { timer = ptimer_new (); last_successful_read_tm = 0; } /* Use a smaller buffer for low requested bandwidths. For example, with --limit-rate=2k, it doesn't make sense to slurp in 16K of data and then sleep for 8s. With buffer size equal to the limit, we never have to sleep for more than one second. */ if (opt.limit_rate && opt.limit_rate < dlbufsize) dlbufsize = opt.limit_rate; /* Read from FD while there is data to read. Normally toread==0 means that it is unknown how much data is to arrive. However, if EXACT is set, then toread==0 means what it says: that no data should be read. */ while (!exact || (sum_read < toread)) { int rdsize; double tmout = opt.read_timeout; if (chunked) { if (remaining_chunk_size == 0) { char *line = fd_read_line (fd); char *endl; if (line == NULL) { ret = -1; break; } else if (out2 != NULL) fwrite (line, 1, strlen (line), out2); remaining_chunk_size = strtol (line, &endl, 16); xfree (line); if (remaining_chunk_size == 0) { ret = 0; line = fd_read_line (fd); if (line == NULL) ret = -1; else { if (out2 != NULL) fwrite (line, 1, strlen (line), out2); xfree (line); } break; } } rdsize = MIN (remaining_chunk_size, dlbufsize); } else rdsize = exact ? MIN (toread - sum_read, dlbufsize) : dlbufsize; if (progress_interactive) { /* For interactive progress gauges, always specify a ~1s timeout, so that the gauge can be updated regularly even when the data arrives very slowly or stalls. */ tmout = 0.95; if (opt.read_timeout) { double waittm; waittm = ptimer_read (timer) - last_successful_read_tm; if (waittm + tmout > opt.read_timeout) { /* Don't let total idle time exceed read timeout. */ tmout = opt.read_timeout - waittm; if (tmout < 0) { /* We've already exceeded the timeout. */ ret = -1, errno = ETIMEDOUT; break; } } } } ret = fd_read (fd, dlbuf, rdsize, tmout); if (progress_interactive && ret < 0 && errno == ETIMEDOUT) ret = 0; /* interactive timeout, handled above */ else if (ret <= 0) break; /* EOF or read error */ if (progress || opt.limit_rate || elapsed) { ptimer_measure (timer); if (ret > 0) last_successful_read_tm = ptimer_read (timer); } if (ret > 0) { int write_res; sum_read += ret; write_res = write_data (out, out2, dlbuf, ret, &skip, &sum_written); if (write_res < 0) { ret = (write_res == -3) ? -3 : -2; goto out; } if (chunked) { remaining_chunk_size -= ret; if (remaining_chunk_size == 0) { char *line = fd_read_line (fd); if (line == NULL) { ret = -1; break; } else { if (out2 != NULL) fwrite (line, 1, strlen (line), out2); xfree (line); } } } } if (opt.limit_rate) limit_bandwidth (ret, timer); if (progress) progress_update (progress, ret, ptimer_read (timer)); #ifdef WINDOWS if (toread > 0 && opt.show_progress) ws_percenttitle (100.0 * (startpos + sum_read) / (startpos + toread)); #endif } if (ret < -1) ret = -1; out: if (progress) progress_finish (progress, ptimer_read (timer)); if (elapsed) *elapsed = ptimer_read (timer); if (timer) ptimer_destroy (timer); if (qtyread) *qtyread += sum_read; if (qtywritten) *qtywritten += sum_written; xfree (dlbuf); return ret; }
null
0
fd_read_body (const char *downloaded_filename, int fd, FILE *out, wgint toread, wgint startpos, wgint *qtyread, wgint *qtywritten, double *elapsed, int flags, FILE *out2) { int ret = 0; #undef max #define max(a,b) ((a) > (b) ? (a) : (b)) int dlbufsize = max (BUFSIZ, 8 * 1024); char *dlbuf = xmalloc (dlbufsize); struct ptimer *timer = NULL; double last_successful_read_tm = 0; /* The progress gauge, set according to the user preferences. */ void *progress = NULL; /* Non-zero if the progress gauge is interactive, i.e. if it can continually update the display. When true, smaller timeout values are used so that the gauge can update the display when data arrives slowly. */ bool progress_interactive = false; bool exact = !!(flags & rb_read_exactly); /* Used only by HTTP/HTTPS chunked transfer encoding. */ bool chunked = flags & rb_chunked_transfer_encoding; wgint skip = 0; /* How much data we've read/written. */ wgint sum_read = 0; wgint sum_written = 0; wgint remaining_chunk_size = 0; if (flags & rb_skip_startpos) skip = startpos; if (opt.show_progress) { const char *filename_progress; /* If we're skipping STARTPOS bytes, pass 0 as the INITIAL argument to progress_create because the indicator doesn't (yet) know about "skipping" data. */ wgint start = skip ? 0 : startpos; if (opt.dir_prefix) filename_progress = downloaded_filename + strlen (opt.dir_prefix) + 1; else filename_progress = downloaded_filename; progress = progress_create (filename_progress, start, start + toread); progress_interactive = progress_interactive_p (progress); } if (opt.limit_rate) limit_bandwidth_reset (); /* A timer is needed for tracking progress, for throttling, and for tracking elapsed time. If either of these are requested, start the timer. */ if (progress || opt.limit_rate || elapsed) { timer = ptimer_new (); last_successful_read_tm = 0; } /* Use a smaller buffer for low requested bandwidths. For example, with --limit-rate=2k, it doesn't make sense to slurp in 16K of data and then sleep for 8s. With buffer size equal to the limit, we never have to sleep for more than one second. */ if (opt.limit_rate && opt.limit_rate < dlbufsize) dlbufsize = opt.limit_rate; /* Read from FD while there is data to read. Normally toread==0 means that it is unknown how much data is to arrive. However, if EXACT is set, then toread==0 means what it says: that no data should be read. */ while (!exact || (sum_read < toread)) { int rdsize; double tmout = opt.read_timeout; if (chunked) { if (remaining_chunk_size == 0) { char *line = fd_read_line (fd); char *endl; if (line == NULL) { ret = -1; break; } else if (out2 != NULL) fwrite (line, 1, strlen (line), out2); remaining_chunk_size = strtol (line, &endl, 16); xfree (line); if (remaining_chunk_size == 0) { ret = 0; line = fd_read_line (fd); if (line == NULL) ret = -1; else { if (out2 != NULL) fwrite (line, 1, strlen (line), out2); xfree (line); } break; } } rdsize = MIN (remaining_chunk_size, dlbufsize); } else rdsize = exact ? MIN (toread - sum_read, dlbufsize) : dlbufsize; if (progress_interactive) { /* For interactive progress gauges, always specify a ~1s timeout, so that the gauge can be updated regularly even when the data arrives very slowly or stalls. */ tmout = 0.95; if (opt.read_timeout) { double waittm; waittm = ptimer_read (timer) - last_successful_read_tm; if (waittm + tmout > opt.read_timeout) { /* Don't let total idle time exceed read timeout. */ tmout = opt.read_timeout - waittm; if (tmout < 0) { /* We've already exceeded the timeout. */ ret = -1, errno = ETIMEDOUT; break; } } } } ret = fd_read (fd, dlbuf, rdsize, tmout); if (progress_interactive && ret < 0 && errno == ETIMEDOUT) ret = 0; /* interactive timeout, handled above */ else if (ret <= 0) break; /* EOF or read error */ if (progress || opt.limit_rate || elapsed) { ptimer_measure (timer); if (ret > 0) last_successful_read_tm = ptimer_read (timer); } if (ret > 0) { int write_res; sum_read += ret; write_res = write_data (out, out2, dlbuf, ret, &skip, &sum_written); if (write_res < 0) { ret = (write_res == -3) ? -3 : -2; goto out; } if (chunked) { remaining_chunk_size -= ret; if (remaining_chunk_size == 0) { char *line = fd_read_line (fd); if (line == NULL) { ret = -1; break; } else { if (out2 != NULL) fwrite (line, 1, strlen (line), out2); xfree (line); } } } } if (opt.limit_rate) limit_bandwidth (ret, timer); if (progress) progress_update (progress, ret, ptimer_read (timer)); #ifdef WINDOWS if (toread > 0 && opt.show_progress) ws_percenttitle (100.0 * (startpos + sum_read) / (startpos + toread)); #endif } if (ret < -1) ret = -1; out: if (progress) progress_finish (progress, ptimer_read (timer)); if (elapsed) *elapsed = ptimer_read (timer); if (timer) ptimer_destroy (timer); if (qtyread) *qtyread += sum_read; if (qtywritten) *qtywritten += sum_written; xfree (dlbuf); return ret; }
@@ -830,7 +830,8 @@ retrieve_url (struct url * orig_parsed, const char *origurl, char **file, if (redirection_count) oldrec = glob = false; - result = ftp_loop (u, &local_file, dt, proxy_url, recursive, glob); + result = ftp_loop (u, orig_parsed, &local_file, dt, proxy_url, + recursive, glob); recursive = oldrec; /* There is a possibility of having HTTP being redirected to
CWE-254
null
null
8,411
retr_rate (wgint bytes, double secs) { static char res[20]; static const char *rate_names[] = {"B/s", "KB/s", "MB/s", "GB/s" }; static const char *rate_names_bits[] = {"b/s", "Kb/s", "Mb/s", "Gb/s" }; int units; double dlrate = calc_rate (bytes, secs, &units); /* Use more digits for smaller numbers (regardless of unit used), e.g. "1022", "247", "12.5", "2.38". */ sprintf (res, "%.*f %s", dlrate >= 99.95 ? 0 : dlrate >= 9.995 ? 1 : 2, dlrate, !opt.report_bps ? rate_names[units]: rate_names_bits[units]); return res; }
null
0
retr_rate (wgint bytes, double secs) { static char res[20]; static const char *rate_names[] = {"B/s", "KB/s", "MB/s", "GB/s" }; static const char *rate_names_bits[] = {"b/s", "Kb/s", "Mb/s", "Gb/s" }; int units; double dlrate = calc_rate (bytes, secs, &units); /* Use more digits for smaller numbers (regardless of unit used), e.g. "1022", "247", "12.5", "2.38". */ sprintf (res, "%.*f %s", dlrate >= 99.95 ? 0 : dlrate >= 9.995 ? 1 : 2, dlrate, !opt.report_bps ? rate_names[units]: rate_names_bits[units]); return res; }
@@ -830,7 +830,8 @@ retrieve_url (struct url * orig_parsed, const char *origurl, char **file, if (redirection_count) oldrec = glob = false; - result = ftp_loop (u, &local_file, dt, proxy_url, recursive, glob); + result = ftp_loop (u, orig_parsed, &local_file, dt, proxy_url, + recursive, glob); recursive = oldrec; /* There is a possibility of having HTTP being redirected to
CWE-254
null
null
8,412
retrieve_from_file (const char *file, bool html, int *count) { uerr_t status; struct urlpos *url_list, *cur_url; struct iri *iri = iri_new(); char *input_file, *url_file = NULL; const char *url = file; status = RETROK; /* Suppose everything is OK. */ *count = 0; /* Reset the URL count. */ /* sXXXav : Assume filename and links in the file are in the locale */ set_uri_encoding (iri, opt.locale, true); set_content_encoding (iri, opt.locale); if (url_valid_scheme (url)) { int dt,url_err; struct url *url_parsed = url_parse (url, &url_err, iri, true); if (!url_parsed) { char *error = url_error (url, url_err); logprintf (LOG_NOTQUIET, "%s: %s.\n", url, error); xfree (error); iri_free (iri); return URLERROR; } if (!opt.base_href) opt.base_href = xstrdup (url); status = retrieve_url (url_parsed, url, &url_file, NULL, NULL, &dt, false, iri, true); url_free (url_parsed); if (!url_file || (status != RETROK)) return status; if (dt & TEXTHTML) html = true; #ifdef ENABLE_IRI /* If we have a found a content encoding, use it. * ( == is okay, because we're checking for identical object) */ if (iri->content_encoding != opt.locale) set_uri_encoding (iri, iri->content_encoding, false); #endif /* Reset UTF-8 encode status */ iri->utf8_encode = opt.enable_iri; xfree (iri->orig_url); input_file = url_file; } else input_file = (char *) file; url_list = (html ? get_urls_html (input_file, NULL, NULL, iri) : get_urls_file (input_file)); xfree (url_file); for (cur_url = url_list; cur_url; cur_url = cur_url->next, ++*count) { char *filename = NULL, *new_file = NULL, *proxy; int dt = 0; struct iri *tmpiri = iri_dup (iri); struct url *parsed_url = NULL; if (cur_url->ignore_when_downloading) continue; if (opt.quota && total_downloaded_bytes > opt.quota) { status = QUOTEXC; break; } parsed_url = url_parse (cur_url->url->url, NULL, tmpiri, true); proxy = getproxy (cur_url->url); if ((opt.recursive || opt.page_requisites) && ((cur_url->url->scheme != SCHEME_FTP #ifdef HAVE_SSL && cur_url->url->scheme != SCHEME_FTPS #endif ) || proxy)) { int old_follow_ftp = opt.follow_ftp; /* Turn opt.follow_ftp on in case of recursive FTP retrieval */ if (cur_url->url->scheme == SCHEME_FTP #ifdef HAVE_SSL || cur_url->url->scheme == SCHEME_FTPS #endif ) opt.follow_ftp = 1; status = retrieve_tree (parsed_url ? parsed_url : cur_url->url, tmpiri); opt.follow_ftp = old_follow_ftp; } else status = retrieve_url (parsed_url ? parsed_url : cur_url->url, cur_url->url->url, &filename, &new_file, NULL, &dt, opt.recursive, tmpiri, true); xfree (proxy); if (parsed_url) url_free (parsed_url); if (filename && opt.delete_after && file_exists_p (filename)) { DEBUGP (("\ Removing file due to --delete-after in retrieve_from_file():\n")); logprintf (LOG_VERBOSE, _("Removing %s.\n"), filename); if (unlink (filename)) logprintf (LOG_NOTQUIET, "unlink: %s\n", strerror (errno)); dt &= ~RETROKF; } xfree (new_file); xfree (filename); iri_free (tmpiri); } /* Free the linked list of URL-s. */ free_urlpos (url_list); iri_free (iri); return status; }
null
0
retrieve_from_file (const char *file, bool html, int *count) { uerr_t status; struct urlpos *url_list, *cur_url; struct iri *iri = iri_new(); char *input_file, *url_file = NULL; const char *url = file; status = RETROK; /* Suppose everything is OK. */ *count = 0; /* Reset the URL count. */ /* sXXXav : Assume filename and links in the file are in the locale */ set_uri_encoding (iri, opt.locale, true); set_content_encoding (iri, opt.locale); if (url_valid_scheme (url)) { int dt,url_err; struct url *url_parsed = url_parse (url, &url_err, iri, true); if (!url_parsed) { char *error = url_error (url, url_err); logprintf (LOG_NOTQUIET, "%s: %s.\n", url, error); xfree (error); iri_free (iri); return URLERROR; } if (!opt.base_href) opt.base_href = xstrdup (url); status = retrieve_url (url_parsed, url, &url_file, NULL, NULL, &dt, false, iri, true); url_free (url_parsed); if (!url_file || (status != RETROK)) return status; if (dt & TEXTHTML) html = true; #ifdef ENABLE_IRI /* If we have a found a content encoding, use it. * ( == is okay, because we're checking for identical object) */ if (iri->content_encoding != opt.locale) set_uri_encoding (iri, iri->content_encoding, false); #endif /* Reset UTF-8 encode status */ iri->utf8_encode = opt.enable_iri; xfree (iri->orig_url); input_file = url_file; } else input_file = (char *) file; url_list = (html ? get_urls_html (input_file, NULL, NULL, iri) : get_urls_file (input_file)); xfree (url_file); for (cur_url = url_list; cur_url; cur_url = cur_url->next, ++*count) { char *filename = NULL, *new_file = NULL, *proxy; int dt = 0; struct iri *tmpiri = iri_dup (iri); struct url *parsed_url = NULL; if (cur_url->ignore_when_downloading) continue; if (opt.quota && total_downloaded_bytes > opt.quota) { status = QUOTEXC; break; } parsed_url = url_parse (cur_url->url->url, NULL, tmpiri, true); proxy = getproxy (cur_url->url); if ((opt.recursive || opt.page_requisites) && ((cur_url->url->scheme != SCHEME_FTP #ifdef HAVE_SSL && cur_url->url->scheme != SCHEME_FTPS #endif ) || proxy)) { int old_follow_ftp = opt.follow_ftp; /* Turn opt.follow_ftp on in case of recursive FTP retrieval */ if (cur_url->url->scheme == SCHEME_FTP #ifdef HAVE_SSL || cur_url->url->scheme == SCHEME_FTPS #endif ) opt.follow_ftp = 1; status = retrieve_tree (parsed_url ? parsed_url : cur_url->url, tmpiri); opt.follow_ftp = old_follow_ftp; } else status = retrieve_url (parsed_url ? parsed_url : cur_url->url, cur_url->url->url, &filename, &new_file, NULL, &dt, opt.recursive, tmpiri, true); xfree (proxy); if (parsed_url) url_free (parsed_url); if (filename && opt.delete_after && file_exists_p (filename)) { DEBUGP (("\ Removing file due to --delete-after in retrieve_from_file():\n")); logprintf (LOG_VERBOSE, _("Removing %s.\n"), filename); if (unlink (filename)) logprintf (LOG_NOTQUIET, "unlink: %s\n", strerror (errno)); dt &= ~RETROKF; } xfree (new_file); xfree (filename); iri_free (tmpiri); } /* Free the linked list of URL-s. */ free_urlpos (url_list); iri_free (iri); return status; }
@@ -830,7 +830,8 @@ retrieve_url (struct url * orig_parsed, const char *origurl, char **file, if (redirection_count) oldrec = glob = false; - result = ftp_loop (u, &local_file, dt, proxy_url, recursive, glob); + result = ftp_loop (u, orig_parsed, &local_file, dt, proxy_url, + recursive, glob); recursive = oldrec; /* There is a possibility of having HTTP being redirected to
CWE-254
null
null
8,413
rotate_backups(const char *fname) { #ifdef __VMS # define SEP "_" # define AVS ";*" /* All-version suffix. */ # define AVSL (sizeof (AVS) - 1) #else # define SEP "." # define AVSL 0 #endif int maxlen = strlen (fname) + sizeof (SEP) + numdigit (opt.backups) + AVSL; char *from = (char *)alloca (maxlen); char *to = (char *)alloca (maxlen); struct_stat sb; int i; if (stat (fname, &sb) == 0) if (S_ISREG (sb.st_mode) == 0) return; for (i = opt.backups; i > 1; i--) { #ifdef VMS /* Delete (all versions of) any existing max-suffix file, to avoid * creating multiple versions of it. (On VMS, rename() will * create a new version of an existing destination file, not * destroy/overwrite it.) */ if (i == opt.backups) { sprintf (to, "%s%s%d%s", fname, SEP, i, AVS); delete (to); } #endif sprintf (to, "%s%s%d", fname, SEP, i); sprintf (from, "%s%s%d", fname, SEP, i - 1); rename (from, to); } sprintf (to, "%s%s%d", fname, SEP, 1); rename(fname, to); }
null
0
rotate_backups(const char *fname) { #ifdef __VMS # define SEP "_" # define AVS ";*" /* All-version suffix. */ # define AVSL (sizeof (AVS) - 1) #else # define SEP "." # define AVSL 0 #endif int maxlen = strlen (fname) + sizeof (SEP) + numdigit (opt.backups) + AVSL; char *from = (char *)alloca (maxlen); char *to = (char *)alloca (maxlen); struct_stat sb; int i; if (stat (fname, &sb) == 0) if (S_ISREG (sb.st_mode) == 0) return; for (i = opt.backups; i > 1; i--) { #ifdef VMS /* Delete (all versions of) any existing max-suffix file, to avoid * creating multiple versions of it. (On VMS, rename() will * create a new version of an existing destination file, not * destroy/overwrite it.) */ if (i == opt.backups) { sprintf (to, "%s%s%d%s", fname, SEP, i, AVS); delete (to); } #endif sprintf (to, "%s%s%d", fname, SEP, i); sprintf (from, "%s%s%d", fname, SEP, i - 1); rename (from, to); } sprintf (to, "%s%s%d", fname, SEP, 1); rename(fname, to); }
@@ -830,7 +830,8 @@ retrieve_url (struct url * orig_parsed, const char *origurl, char **file, if (redirection_count) oldrec = glob = false; - result = ftp_loop (u, &local_file, dt, proxy_url, recursive, glob); + result = ftp_loop (u, orig_parsed, &local_file, dt, proxy_url, + recursive, glob); recursive = oldrec; /* There is a possibility of having HTTP being redirected to
CWE-254
null
null
8,414
static int mptsas_process_scsi_io_request(MPTSASState *s, MPIMsgSCSIIORequest *scsi_io, hwaddr addr) { MPTSASRequest *req; MPIMsgSCSIIOReply reply; SCSIDevice *sdev; int status; mptsas_fix_scsi_io_endianness(scsi_io); trace_mptsas_process_scsi_io_request(s, scsi_io->Bus, scsi_io->TargetID, scsi_io->LUN[1], scsi_io->DataLength); status = mptsas_scsi_device_find(s, scsi_io->Bus, scsi_io->TargetID, scsi_io->LUN, &sdev); if (status) { goto bad; } req = g_new(MPTSASRequest, 1); QTAILQ_INSERT_TAIL(&s->pending, req, next); req->scsi_io = *scsi_io; req->dev = s; status = mptsas_build_sgl(s, req, addr); if (status) { goto free_bad; } if (req->qsg.size < scsi_io->DataLength) { trace_mptsas_sgl_overflow(s, scsi_io->MsgContext, scsi_io->DataLength, req->qsg.size); status = MPI_IOCSTATUS_INVALID_SGL; goto free_bad; } req->sreq = scsi_req_new(sdev, scsi_io->MsgContext, scsi_io->LUN[1], scsi_io->CDB, req); if (req->sreq->cmd.xfer > scsi_io->DataLength) { goto overrun; } switch (scsi_io->Control & MPI_SCSIIO_CONTROL_DATADIRECTION_MASK) { case MPI_SCSIIO_CONTROL_NODATATRANSFER: if (req->sreq->cmd.mode != SCSI_XFER_NONE) { goto overrun; } break; case MPI_SCSIIO_CONTROL_WRITE: if (req->sreq->cmd.mode != SCSI_XFER_TO_DEV) { goto overrun; } break; case MPI_SCSIIO_CONTROL_READ: if (req->sreq->cmd.mode != SCSI_XFER_FROM_DEV) { goto overrun; } break; } if (scsi_req_enqueue(req->sreq)) { scsi_req_continue(req->sreq); } return 0; overrun: trace_mptsas_scsi_overflow(s, scsi_io->MsgContext, req->sreq->cmd.xfer, scsi_io->DataLength); status = MPI_IOCSTATUS_SCSI_DATA_OVERRUN; free_bad: mptsas_free_request(req); bad: memset(&reply, 0, sizeof(reply)); reply.TargetID = scsi_io->TargetID; reply.Bus = scsi_io->Bus; reply.MsgLength = sizeof(reply) / 4; reply.Function = scsi_io->Function; reply.CDBLength = scsi_io->CDBLength; reply.SenseBufferLength = scsi_io->SenseBufferLength; reply.MsgContext = scsi_io->MsgContext; reply.SCSIState = MPI_SCSI_STATE_NO_SCSI_STATUS; reply.IOCStatus = status; mptsas_fix_scsi_io_reply_endianness(&reply); mptsas_reply(s, (MPIDefaultReply *)&reply); return 0; }
DoS
0
static int mptsas_process_scsi_io_request(MPTSASState *s, MPIMsgSCSIIORequest *scsi_io, hwaddr addr) { MPTSASRequest *req; MPIMsgSCSIIOReply reply; SCSIDevice *sdev; int status; mptsas_fix_scsi_io_endianness(scsi_io); trace_mptsas_process_scsi_io_request(s, scsi_io->Bus, scsi_io->TargetID, scsi_io->LUN[1], scsi_io->DataLength); status = mptsas_scsi_device_find(s, scsi_io->Bus, scsi_io->TargetID, scsi_io->LUN, &sdev); if (status) { goto bad; } req = g_new(MPTSASRequest, 1); QTAILQ_INSERT_TAIL(&s->pending, req, next); req->scsi_io = *scsi_io; req->dev = s; status = mptsas_build_sgl(s, req, addr); if (status) { goto free_bad; } if (req->qsg.size < scsi_io->DataLength) { trace_mptsas_sgl_overflow(s, scsi_io->MsgContext, scsi_io->DataLength, req->qsg.size); status = MPI_IOCSTATUS_INVALID_SGL; goto free_bad; } req->sreq = scsi_req_new(sdev, scsi_io->MsgContext, scsi_io->LUN[1], scsi_io->CDB, req); if (req->sreq->cmd.xfer > scsi_io->DataLength) { goto overrun; } switch (scsi_io->Control & MPI_SCSIIO_CONTROL_DATADIRECTION_MASK) { case MPI_SCSIIO_CONTROL_NODATATRANSFER: if (req->sreq->cmd.mode != SCSI_XFER_NONE) { goto overrun; } break; case MPI_SCSIIO_CONTROL_WRITE: if (req->sreq->cmd.mode != SCSI_XFER_TO_DEV) { goto overrun; } break; case MPI_SCSIIO_CONTROL_READ: if (req->sreq->cmd.mode != SCSI_XFER_FROM_DEV) { goto overrun; } break; } if (scsi_req_enqueue(req->sreq)) { scsi_req_continue(req->sreq); } return 0; overrun: trace_mptsas_scsi_overflow(s, scsi_io->MsgContext, req->sreq->cmd.xfer, scsi_io->DataLength); status = MPI_IOCSTATUS_SCSI_DATA_OVERRUN; free_bad: mptsas_free_request(req); bad: memset(&reply, 0, sizeof(reply)); reply.TargetID = scsi_io->TargetID; reply.Bus = scsi_io->Bus; reply.MsgLength = sizeof(reply) / 4; reply.Function = scsi_io->Function; reply.CDBLength = scsi_io->CDBLength; reply.SenseBufferLength = scsi_io->SenseBufferLength; reply.MsgContext = scsi_io->MsgContext; reply.SCSIState = MPI_SCSI_STATE_NO_SCSI_STATUS; reply.IOCStatus = status; mptsas_fix_scsi_io_reply_endianness(&reply); mptsas_reply(s, (MPIDefaultReply *)&reply); return 0; }
@@ -754,11 +754,6 @@ static void mptsas_fetch_request(MPTSASState *s) hwaddr addr; int size; - if (s->state != MPI_IOC_STATE_OPERATIONAL) { - mptsas_set_fault(s, MPI_IOCSTATUS_INVALID_STATE); - return; - } - /* Read the message header from the guest first. */ addr = s->host_mfa_high_addr | MPTSAS_FIFO_GET(s, request_post); pci_dma_read(pci, addr, req, sizeof(hdr)); @@ -789,6 +784,10 @@ static void mptsas_fetch_requests(void *opaque) { MPTSASState *s = opaque; + if (s->state != MPI_IOC_STATE_OPERATIONAL) { + mptsas_set_fault(s, MPI_IOCSTATUS_INVALID_STATE); + return; + } while (!MPTSAS_FIFO_EMPTY(s, request_post)) { mptsas_fetch_request(s); }
CWE-20
null
null
8,415
static void mptsas_scsi_init(PCIDevice *dev, Error **errp) { DeviceState *d = DEVICE(dev); MPTSASState *s = MPT_SAS(dev); dev->config[PCI_LATENCY_TIMER] = 0; dev->config[PCI_INTERRUPT_PIN] = 0x01; memory_region_init_io(&s->mmio_io, OBJECT(s), &mptsas_mmio_ops, s, "mptsas-mmio", 0x4000); memory_region_init_io(&s->port_io, OBJECT(s), &mptsas_port_ops, s, "mptsas-io", 256); memory_region_init_io(&s->diag_io, OBJECT(s), &mptsas_diag_ops, s, "mptsas-diag", 0x10000); if (s->msi_available && msi_init(dev, 0, 1, true, false) >= 0) { s->msi_in_use = true; } pci_register_bar(dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &s->port_io); pci_register_bar(dev, 1, PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_32, &s->mmio_io); pci_register_bar(dev, 2, PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_32, &s->diag_io); if (!s->sas_addr) { s->sas_addr = ((NAA_LOCALLY_ASSIGNED_ID << 24) | IEEE_COMPANY_LOCALLY_ASSIGNED) << 36; s->sas_addr |= (pci_bus_num(dev->bus) << 16); s->sas_addr |= (PCI_SLOT(dev->devfn) << 8); s->sas_addr |= PCI_FUNC(dev->devfn); } s->max_devices = MPTSAS_NUM_PORTS; s->request_bh = qemu_bh_new(mptsas_fetch_requests, s); QTAILQ_INIT(&s->pending); scsi_bus_new(&s->bus, sizeof(s->bus), &dev->qdev, &mptsas_scsi_info, NULL); if (!d->hotplugged) { scsi_bus_legacy_handle_cmdline(&s->bus, errp); } }
DoS
0
static void mptsas_scsi_init(PCIDevice *dev, Error **errp) { DeviceState *d = DEVICE(dev); MPTSASState *s = MPT_SAS(dev); dev->config[PCI_LATENCY_TIMER] = 0; dev->config[PCI_INTERRUPT_PIN] = 0x01; memory_region_init_io(&s->mmio_io, OBJECT(s), &mptsas_mmio_ops, s, "mptsas-mmio", 0x4000); memory_region_init_io(&s->port_io, OBJECT(s), &mptsas_port_ops, s, "mptsas-io", 256); memory_region_init_io(&s->diag_io, OBJECT(s), &mptsas_diag_ops, s, "mptsas-diag", 0x10000); if (s->msi_available && msi_init(dev, 0, 1, true, false) >= 0) { s->msi_in_use = true; } pci_register_bar(dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &s->port_io); pci_register_bar(dev, 1, PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_32, &s->mmio_io); pci_register_bar(dev, 2, PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_32, &s->diag_io); if (!s->sas_addr) { s->sas_addr = ((NAA_LOCALLY_ASSIGNED_ID << 24) | IEEE_COMPANY_LOCALLY_ASSIGNED) << 36; s->sas_addr |= (pci_bus_num(dev->bus) << 16); s->sas_addr |= (PCI_SLOT(dev->devfn) << 8); s->sas_addr |= PCI_FUNC(dev->devfn); } s->max_devices = MPTSAS_NUM_PORTS; s->request_bh = qemu_bh_new(mptsas_fetch_requests, s); QTAILQ_INIT(&s->pending); scsi_bus_new(&s->bus, sizeof(s->bus), &dev->qdev, &mptsas_scsi_info, NULL); if (!d->hotplugged) { scsi_bus_legacy_handle_cmdline(&s->bus, errp); } }
@@ -754,11 +754,6 @@ static void mptsas_fetch_request(MPTSASState *s) hwaddr addr; int size; - if (s->state != MPI_IOC_STATE_OPERATIONAL) { - mptsas_set_fault(s, MPI_IOCSTATUS_INVALID_STATE); - return; - } - /* Read the message header from the guest first. */ addr = s->host_mfa_high_addr | MPTSAS_FIFO_GET(s, request_post); pci_dma_read(pci, addr, req, sizeof(hdr)); @@ -789,6 +784,10 @@ static void mptsas_fetch_requests(void *opaque) { MPTSASState *s = opaque; + if (s->state != MPI_IOC_STATE_OPERATIONAL) { + mptsas_set_fault(s, MPI_IOCSTATUS_INVALID_STATE); + return; + } while (!MPTSAS_FIFO_EMPTY(s, request_post)) { mptsas_fetch_request(s); }
CWE-20
null
null
8,416
static void mptsas_update_interrupt(MPTSASState *s) { PCIDevice *pci = (PCIDevice *) s; uint32_t state = s->intr_status & ~(s->intr_mask | MPI_HIS_IOP_DOORBELL_STATUS); if (s->msi_in_use && msi_enabled(pci)) { if (state) { trace_mptsas_irq_msi(s); msi_notify(pci, 0); } } trace_mptsas_irq_intx(s, !!state); pci_set_irq(pci, !!state); }
DoS
0
static void mptsas_update_interrupt(MPTSASState *s) { PCIDevice *pci = (PCIDevice *) s; uint32_t state = s->intr_status & ~(s->intr_mask | MPI_HIS_IOP_DOORBELL_STATUS); if (s->msi_in_use && msi_enabled(pci)) { if (state) { trace_mptsas_irq_msi(s); msi_notify(pci, 0); } } trace_mptsas_irq_intx(s, !!state); pci_set_irq(pci, !!state); }
@@ -754,11 +754,6 @@ static void mptsas_fetch_request(MPTSASState *s) hwaddr addr; int size; - if (s->state != MPI_IOC_STATE_OPERATIONAL) { - mptsas_set_fault(s, MPI_IOCSTATUS_INVALID_STATE); - return; - } - /* Read the message header from the guest first. */ addr = s->host_mfa_high_addr | MPTSAS_FIFO_GET(s, request_post); pci_dma_read(pci, addr, req, sizeof(hdr)); @@ -789,6 +784,10 @@ static void mptsas_fetch_requests(void *opaque) { MPTSASState *s = opaque; + if (s->state != MPI_IOC_STATE_OPERATIONAL) { + mptsas_set_fault(s, MPI_IOCSTATUS_INVALID_STATE); + return; + } while (!MPTSAS_FIFO_EMPTY(s, request_post)) { mptsas_fetch_request(s); }
CWE-20
null
null
8,417
int phar_is_tar(char *buf, char *fname) /* {{{ */ { tar_header *header = (tar_header *) buf; php_uint32 checksum = phar_tar_number(header->checksum, sizeof(header->checksum)); php_uint32 ret; char save[sizeof(header->checksum)]; /* assume that the first filename in a tar won't begin with <?php */ if (!strncmp(buf, "<?php", sizeof("<?php")-1)) { return 0; } memcpy(save, header->checksum, sizeof(header->checksum)); memset(header->checksum, ' ', sizeof(header->checksum)); ret = (checksum == phar_tar_checksum(buf, 512)); memcpy(header->checksum, save, sizeof(header->checksum)); if (!ret && strstr(fname, ".tar")) { /* probably a corrupted tar - so we will pretend it is one */ return 1; } return ret; } /* }}} */
DoS Exec Code Overflow
0
int phar_is_tar(char *buf, char *fname) /* {{{ */ { tar_header *header = (tar_header *) buf; php_uint32 checksum = phar_tar_number(header->checksum, sizeof(header->checksum)); php_uint32 ret; char save[sizeof(header->checksum)]; /* assume that the first filename in a tar won't begin with <?php */ if (!strncmp(buf, "<?php", sizeof("<?php")-1)) { return 0; } memcpy(save, header->checksum, sizeof(header->checksum)); memset(header->checksum, ' ', sizeof(header->checksum)); ret = (checksum == phar_tar_checksum(buf, 512)); memcpy(header->checksum, save, sizeof(header->checksum)); if (!ret && strstr(fname, ".tar")) { /* probably a corrupted tar - so we will pretend it is one */ return 1; } return ret; } /* }}} */
@@ -38,7 +38,7 @@ static php_uint32 phar_tar_number(char *buf, int len) /* {{{ */ /* }}} */ /* adapted from format_octal() in libarchive - * + * * Copyright (c) 2003-2009 Tim Kientzle * All rights reserved. * @@ -161,7 +161,7 @@ static int phar_tar_process_metadata(phar_entry_info *entry, php_stream *fp TSRM size_t save = php_stream_tell(fp), read; phar_entry_info *mentry; - metadata = (char *) emalloc(entry->uncompressed_filesize + 1); + metadata = (char *) safe_emalloc(1, entry->uncompressed_filesize, 1); read = php_stream_read(fp, metadata, entry->uncompressed_filesize); if (read != entry->uncompressed_filesize) { @@ -377,7 +377,7 @@ bail: } read = php_stream_read(fp, buf, sizeof(buf)); - + if (read != sizeof(buf)) { efree(entry.filename); if (error) {
CWE-189
null
null
8,418
int phar_open_or_create_tar(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error TSRMLS_DC) /* {{{ */ { phar_archive_data *phar; int ret = phar_create_or_parse_filename(fname, fname_len, alias, alias_len, is_data, options, &phar, error TSRMLS_CC); if (FAILURE == ret) { return FAILURE; } if (pphar) { *pphar = phar; } phar->is_data = is_data; if (phar->is_tar) { return ret; } if (phar->is_brandnew) { phar->is_tar = 1; phar->is_zip = 0; phar->internal_file_start = 0; return SUCCESS; } /* we've reached here - the phar exists and is a regular phar */ if (error) { spprintf(error, 4096, "phar tar error: \"%s\" already exists as a regular phar and must be deleted from disk prior to creating as a tar-based phar", fname); } return FAILURE; } /* }}} */
DoS Exec Code Overflow
0
int phar_open_or_create_tar(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error TSRMLS_DC) /* {{{ */ { phar_archive_data *phar; int ret = phar_create_or_parse_filename(fname, fname_len, alias, alias_len, is_data, options, &phar, error TSRMLS_CC); if (FAILURE == ret) { return FAILURE; } if (pphar) { *pphar = phar; } phar->is_data = is_data; if (phar->is_tar) { return ret; } if (phar->is_brandnew) { phar->is_tar = 1; phar->is_zip = 0; phar->internal_file_start = 0; return SUCCESS; } /* we've reached here - the phar exists and is a regular phar */ if (error) { spprintf(error, 4096, "phar tar error: \"%s\" already exists as a regular phar and must be deleted from disk prior to creating as a tar-based phar", fname); } return FAILURE; } /* }}} */
@@ -38,7 +38,7 @@ static php_uint32 phar_tar_number(char *buf, int len) /* {{{ */ /* }}} */ /* adapted from format_octal() in libarchive - * + * * Copyright (c) 2003-2009 Tim Kientzle * All rights reserved. * @@ -161,7 +161,7 @@ static int phar_tar_process_metadata(phar_entry_info *entry, php_stream *fp TSRM size_t save = php_stream_tell(fp), read; phar_entry_info *mentry; - metadata = (char *) emalloc(entry->uncompressed_filesize + 1); + metadata = (char *) safe_emalloc(1, entry->uncompressed_filesize, 1); read = php_stream_read(fp, metadata, entry->uncompressed_filesize); if (read != entry->uncompressed_filesize) { @@ -377,7 +377,7 @@ bail: } read = php_stream_read(fp, buf, sizeof(buf)); - + if (read != sizeof(buf)) { efree(entry.filename); if (error) {
CWE-189
null
null
8,419
void acpi_pcihp_device_plug_cb(ACPIREGS *ar, qemu_irq irq, AcpiPciHpState *s, DeviceState *dev, Error **errp) { PCIDevice *pdev = PCI_DEVICE(dev); int slot = PCI_SLOT(pdev->devfn); int bsel = acpi_pcihp_get_bsel(pdev->bus); if (bsel < 0) { error_setg(errp, "Unsupported bus. Bus doesn't have property '" ACPI_PCIHP_PROP_BSEL "' set"); return; } /* Don't send event when device is enabled during qemu machine creation: * it is present on boot, no hotplug event is necessary. We do send an * event when the device is disabled later. */ if (!dev->hotplugged) { return; } s->acpi_pcihp_pci_status[bsel].up |= (1U << slot); ar->gpe.sts[0] |= ACPI_PCI_HOTPLUG_STATUS; acpi_update_sci(ar, irq); }
Overflow Mem. Corr. +Info
0
void acpi_pcihp_device_plug_cb(ACPIREGS *ar, qemu_irq irq, AcpiPciHpState *s, DeviceState *dev, Error **errp) { PCIDevice *pdev = PCI_DEVICE(dev); int slot = PCI_SLOT(pdev->devfn); int bsel = acpi_pcihp_get_bsel(pdev->bus); if (bsel < 0) { error_setg(errp, "Unsupported bus. Bus doesn't have property '" ACPI_PCIHP_PROP_BSEL "' set"); return; } /* Don't send event when device is enabled during qemu machine creation: * it is present on boot, no hotplug event is necessary. We do send an * event when the device is disabled later. */ if (!dev->hotplugged) { return; } s->acpi_pcihp_pci_status[bsel].up |= (1U << slot); ar->gpe.sts[0] |= ACPI_PCI_HOTPLUG_STATUS; acpi_update_sci(ar, irq); }
@@ -231,7 +231,7 @@ static uint64_t pci_read(void *opaque, hwaddr addr, unsigned int size) uint32_t val = 0; int bsel = s->hotplug_select; - if (bsel < 0 || bsel > ACPI_PCIHP_MAX_HOTPLUG_BUS) { + if (bsel < 0 || bsel >= ACPI_PCIHP_MAX_HOTPLUG_BUS) { return 0; }
CWE-119
null
null
8,420
void acpi_pcihp_device_unplug_cb(ACPIREGS *ar, qemu_irq irq, AcpiPciHpState *s, DeviceState *dev, Error **errp) { PCIDevice *pdev = PCI_DEVICE(dev); int slot = PCI_SLOT(pdev->devfn); int bsel = acpi_pcihp_get_bsel(pdev->bus); if (bsel < 0) { error_setg(errp, "Unsupported bus. Bus doesn't have property '" ACPI_PCIHP_PROP_BSEL "' set"); return; } s->acpi_pcihp_pci_status[bsel].down |= (1U << slot); ar->gpe.sts[0] |= ACPI_PCI_HOTPLUG_STATUS; acpi_update_sci(ar, irq); }
Overflow Mem. Corr. +Info
0
void acpi_pcihp_device_unplug_cb(ACPIREGS *ar, qemu_irq irq, AcpiPciHpState *s, DeviceState *dev, Error **errp) { PCIDevice *pdev = PCI_DEVICE(dev); int slot = PCI_SLOT(pdev->devfn); int bsel = acpi_pcihp_get_bsel(pdev->bus); if (bsel < 0) { error_setg(errp, "Unsupported bus. Bus doesn't have property '" ACPI_PCIHP_PROP_BSEL "' set"); return; } s->acpi_pcihp_pci_status[bsel].down |= (1U << slot); ar->gpe.sts[0] |= ACPI_PCI_HOTPLUG_STATUS; acpi_update_sci(ar, irq); }
@@ -231,7 +231,7 @@ static uint64_t pci_read(void *opaque, hwaddr addr, unsigned int size) uint32_t val = 0; int bsel = s->hotplug_select; - if (bsel < 0 || bsel > ACPI_PCIHP_MAX_HOTPLUG_BUS) { + if (bsel < 0 || bsel >= ACPI_PCIHP_MAX_HOTPLUG_BUS) { return 0; }
CWE-119
null
null
8,421
static void acpi_pcihp_eject_slot(AcpiPciHpState *s, unsigned bsel, unsigned slots) { BusChild *kid, *next; int slot = ffs(slots) - 1; PCIBus *bus = acpi_pcihp_find_hotplug_bus(s, bsel); if (!bus) { return; } /* Mark request as complete */ s->acpi_pcihp_pci_status[bsel].down &= ~(1U << slot); s->acpi_pcihp_pci_status[bsel].up &= ~(1U << slot); QTAILQ_FOREACH_SAFE(kid, &bus->qbus.children, sibling, next) { DeviceState *qdev = kid->child; PCIDevice *dev = PCI_DEVICE(qdev); if (PCI_SLOT(dev->devfn) == slot) { if (!acpi_pcihp_pc_no_hotplug(s, dev)) { object_unparent(OBJECT(qdev)); } } } }
Overflow Mem. Corr. +Info
0
static void acpi_pcihp_eject_slot(AcpiPciHpState *s, unsigned bsel, unsigned slots) { BusChild *kid, *next; int slot = ffs(slots) - 1; PCIBus *bus = acpi_pcihp_find_hotplug_bus(s, bsel); if (!bus) { return; } /* Mark request as complete */ s->acpi_pcihp_pci_status[bsel].down &= ~(1U << slot); s->acpi_pcihp_pci_status[bsel].up &= ~(1U << slot); QTAILQ_FOREACH_SAFE(kid, &bus->qbus.children, sibling, next) { DeviceState *qdev = kid->child; PCIDevice *dev = PCI_DEVICE(qdev); if (PCI_SLOT(dev->devfn) == slot) { if (!acpi_pcihp_pc_no_hotplug(s, dev)) { object_unparent(OBJECT(qdev)); } } } }
@@ -231,7 +231,7 @@ static uint64_t pci_read(void *opaque, hwaddr addr, unsigned int size) uint32_t val = 0; int bsel = s->hotplug_select; - if (bsel < 0 || bsel > ACPI_PCIHP_MAX_HOTPLUG_BUS) { + if (bsel < 0 || bsel >= ACPI_PCIHP_MAX_HOTPLUG_BUS) { return 0; }
CWE-119
null
null
8,422
static int acpi_pcihp_get_bsel(PCIBus *bus) { Error *local_err = NULL; int64_t bsel = object_property_get_int(OBJECT(bus), ACPI_PCIHP_PROP_BSEL, &local_err); if (local_err || bsel < 0 || bsel >= ACPI_PCIHP_MAX_HOTPLUG_BUS) { if (local_err) { error_free(local_err); } return -1; } else { return bsel; } }
Overflow Mem. Corr. +Info
0
static int acpi_pcihp_get_bsel(PCIBus *bus) { Error *local_err = NULL; int64_t bsel = object_property_get_int(OBJECT(bus), ACPI_PCIHP_PROP_BSEL, &local_err); if (local_err || bsel < 0 || bsel >= ACPI_PCIHP_MAX_HOTPLUG_BUS) { if (local_err) { error_free(local_err); } return -1; } else { return bsel; } }
@@ -231,7 +231,7 @@ static uint64_t pci_read(void *opaque, hwaddr addr, unsigned int size) uint32_t val = 0; int bsel = s->hotplug_select; - if (bsel < 0 || bsel > ACPI_PCIHP_MAX_HOTPLUG_BUS) { + if (bsel < 0 || bsel >= ACPI_PCIHP_MAX_HOTPLUG_BUS) { return 0; }
CWE-119
null
null
8,423
static bool acpi_pcihp_pc_no_hotplug(AcpiPciHpState *s, PCIDevice *dev) { PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(dev); DeviceClass *dc = DEVICE_GET_CLASS(dev); /* * ACPI doesn't allow hotplug of bridge devices. Don't allow * hot-unplug of bridge devices unless they were added by hotplug * (and so, not described by acpi). */ return (pc->is_bridge && !dev->qdev.hotplugged) || !dc->hotpluggable; }
Overflow Mem. Corr. +Info
0
static bool acpi_pcihp_pc_no_hotplug(AcpiPciHpState *s, PCIDevice *dev) { PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(dev); DeviceClass *dc = DEVICE_GET_CLASS(dev); /* * ACPI doesn't allow hotplug of bridge devices. Don't allow * hot-unplug of bridge devices unless they were added by hotplug * (and so, not described by acpi). */ return (pc->is_bridge && !dev->qdev.hotplugged) || !dc->hotpluggable; }
@@ -231,7 +231,7 @@ static uint64_t pci_read(void *opaque, hwaddr addr, unsigned int size) uint32_t val = 0; int bsel = s->hotplug_select; - if (bsel < 0 || bsel > ACPI_PCIHP_MAX_HOTPLUG_BUS) { + if (bsel < 0 || bsel >= ACPI_PCIHP_MAX_HOTPLUG_BUS) { return 0; }
CWE-119
null
null
8,424
void acpi_pcihp_reset(AcpiPciHpState *s) { acpi_pcihp_update(s); }
Overflow Mem. Corr. +Info
0
void acpi_pcihp_reset(AcpiPciHpState *s) { acpi_pcihp_update(s); }
@@ -231,7 +231,7 @@ static uint64_t pci_read(void *opaque, hwaddr addr, unsigned int size) uint32_t val = 0; int bsel = s->hotplug_select; - if (bsel < 0 || bsel > ACPI_PCIHP_MAX_HOTPLUG_BUS) { + if (bsel < 0 || bsel >= ACPI_PCIHP_MAX_HOTPLUG_BUS) { return 0; }
CWE-119
null
null
8,425
static void acpi_pcihp_test_hotplug_bus(PCIBus *bus, void *opaque) { AcpiPciHpFind *find = opaque; if (find->bsel == acpi_pcihp_get_bsel(bus)) { find->bus = bus; } }
Overflow Mem. Corr. +Info
0
static void acpi_pcihp_test_hotplug_bus(PCIBus *bus, void *opaque) { AcpiPciHpFind *find = opaque; if (find->bsel == acpi_pcihp_get_bsel(bus)) { find->bus = bus; } }
@@ -231,7 +231,7 @@ static uint64_t pci_read(void *opaque, hwaddr addr, unsigned int size) uint32_t val = 0; int bsel = s->hotplug_select; - if (bsel < 0 || bsel > ACPI_PCIHP_MAX_HOTPLUG_BUS) { + if (bsel < 0 || bsel >= ACPI_PCIHP_MAX_HOTPLUG_BUS) { return 0; }
CWE-119
null
null
8,426
static void acpi_pcihp_update(AcpiPciHpState *s) { int i; for (i = 0; i < ACPI_PCIHP_MAX_HOTPLUG_BUS; ++i) { acpi_pcihp_update_hotplug_bus(s, i); } }
Overflow Mem. Corr. +Info
0
static void acpi_pcihp_update(AcpiPciHpState *s) { int i; for (i = 0; i < ACPI_PCIHP_MAX_HOTPLUG_BUS; ++i) { acpi_pcihp_update_hotplug_bus(s, i); } }
@@ -231,7 +231,7 @@ static uint64_t pci_read(void *opaque, hwaddr addr, unsigned int size) uint32_t val = 0; int bsel = s->hotplug_select; - if (bsel < 0 || bsel > ACPI_PCIHP_MAX_HOTPLUG_BUS) { + if (bsel < 0 || bsel >= ACPI_PCIHP_MAX_HOTPLUG_BUS) { return 0; }
CWE-119
null
null
8,427
static void acpi_pcihp_update_hotplug_bus(AcpiPciHpState *s, int bsel) { BusChild *kid, *next; PCIBus *bus = acpi_pcihp_find_hotplug_bus(s, bsel); /* Execute any pending removes during reset */ while (s->acpi_pcihp_pci_status[bsel].down) { acpi_pcihp_eject_slot(s, bsel, s->acpi_pcihp_pci_status[bsel].down); } s->acpi_pcihp_pci_status[bsel].hotplug_enable = ~0; if (!bus) { return; } QTAILQ_FOREACH_SAFE(kid, &bus->qbus.children, sibling, next) { DeviceState *qdev = kid->child; PCIDevice *pdev = PCI_DEVICE(qdev); int slot = PCI_SLOT(pdev->devfn); if (acpi_pcihp_pc_no_hotplug(s, pdev)) { s->acpi_pcihp_pci_status[bsel].hotplug_enable &= ~(1U << slot); } } }
Overflow Mem. Corr. +Info
0
static void acpi_pcihp_update_hotplug_bus(AcpiPciHpState *s, int bsel) { BusChild *kid, *next; PCIBus *bus = acpi_pcihp_find_hotplug_bus(s, bsel); /* Execute any pending removes during reset */ while (s->acpi_pcihp_pci_status[bsel].down) { acpi_pcihp_eject_slot(s, bsel, s->acpi_pcihp_pci_status[bsel].down); } s->acpi_pcihp_pci_status[bsel].hotplug_enable = ~0; if (!bus) { return; } QTAILQ_FOREACH_SAFE(kid, &bus->qbus.children, sibling, next) { DeviceState *qdev = kid->child; PCIDevice *pdev = PCI_DEVICE(qdev); int slot = PCI_SLOT(pdev->devfn); if (acpi_pcihp_pc_no_hotplug(s, pdev)) { s->acpi_pcihp_pci_status[bsel].hotplug_enable &= ~(1U << slot); } } }
@@ -231,7 +231,7 @@ static uint64_t pci_read(void *opaque, hwaddr addr, unsigned int size) uint32_t val = 0; int bsel = s->hotplug_select; - if (bsel < 0 || bsel > ACPI_PCIHP_MAX_HOTPLUG_BUS) { + if (bsel < 0 || bsel >= ACPI_PCIHP_MAX_HOTPLUG_BUS) { return 0; }
CWE-119
null
null
8,428
static void pci_write(void *opaque, hwaddr addr, uint64_t data, unsigned int size) { AcpiPciHpState *s = opaque; switch (addr) { case PCI_EJ_BASE: if (s->hotplug_select >= ACPI_PCIHP_MAX_HOTPLUG_BUS) { break; } acpi_pcihp_eject_slot(s, s->hotplug_select, data); ACPI_PCIHP_DPRINTF("pciej write %" HWADDR_PRIx " <== %" PRIu64 "\n", addr, data); break; case PCI_SEL_BASE: s->hotplug_select = data; ACPI_PCIHP_DPRINTF("pcisel write %" HWADDR_PRIx " <== %" PRIu64 "\n", addr, data); default: break; } }
Overflow Mem. Corr. +Info
0
static void pci_write(void *opaque, hwaddr addr, uint64_t data, unsigned int size) { AcpiPciHpState *s = opaque; switch (addr) { case PCI_EJ_BASE: if (s->hotplug_select >= ACPI_PCIHP_MAX_HOTPLUG_BUS) { break; } acpi_pcihp_eject_slot(s, s->hotplug_select, data); ACPI_PCIHP_DPRINTF("pciej write %" HWADDR_PRIx " <== %" PRIu64 "\n", addr, data); break; case PCI_SEL_BASE: s->hotplug_select = data; ACPI_PCIHP_DPRINTF("pcisel write %" HWADDR_PRIx " <== %" PRIu64 "\n", addr, data); default: break; } }
@@ -231,7 +231,7 @@ static uint64_t pci_read(void *opaque, hwaddr addr, unsigned int size) uint32_t val = 0; int bsel = s->hotplug_select; - if (bsel < 0 || bsel > ACPI_PCIHP_MAX_HOTPLUG_BUS) { + if (bsel < 0 || bsel >= ACPI_PCIHP_MAX_HOTPLUG_BUS) { return 0; }
CWE-119
null
null
8,429
do_ed_script (char const *inname, char const *outname, bool *outname_needs_removal, FILE *ofp) { static char const editor_program[] = EDITOR_PROGRAM; file_offset beginning_of_this_line; FILE *pipefp = 0; size_t chars_read; if (! dry_run && ! skip_rest_of_patch) { int exclusive = *outname_needs_removal ? 0 : O_EXCL; assert (! inerrno); *outname_needs_removal = true; copy_file (inname, outname, 0, exclusive, instat.st_mode, true); sprintf (buf, "%s %s%s", editor_program, verbosity == VERBOSE ? "" : "- ", outname); fflush (stdout); pipefp = popen(buf, binary_transput ? "wb" : "w"); if (!pipefp) pfatal ("Can't open pipe to %s", quotearg (buf)); } for (;;) { char ed_command_letter; beginning_of_this_line = file_tell (pfp); chars_read = get_line (); if (! chars_read) { next_intuit_at(beginning_of_this_line,p_input_line); break; } ed_command_letter = get_ed_command_letter (buf); if (ed_command_letter) { if (pipefp) if (! fwrite (buf, sizeof *buf, chars_read, pipefp)) write_fatal (); if (ed_command_letter != 'd' && ed_command_letter != 's') { p_pass_comments_through = true; while ((chars_read = get_line ()) != 0) { if (pipefp) if (! fwrite (buf, sizeof *buf, chars_read, pipefp)) write_fatal (); if (chars_read == 2 && strEQ (buf, ".\n")) break; } p_pass_comments_through = false; } } else { next_intuit_at(beginning_of_this_line,p_input_line); break; } } if (!pipefp) return; if (fwrite ("w\nq\n", sizeof (char), (size_t) 4, pipefp) == 0 || fflush (pipefp) != 0) write_fatal (); if (pclose (pipefp) != 0) fatal ("%s FAILED", editor_program); if (ofp) { FILE *ifp = fopen (outname, binary_transput ? "rb" : "r"); int c; if (!ifp) pfatal ("can't open '%s'", outname); while ((c = getc (ifp)) != EOF) if (putc (c, ofp) == EOF) write_fatal (); if (ferror (ifp) || fclose (ifp) != 0) read_fatal (); } }
DoS
0
do_ed_script (char const *inname, char const *outname, bool *outname_needs_removal, FILE *ofp) { static char const editor_program[] = EDITOR_PROGRAM; file_offset beginning_of_this_line; FILE *pipefp = 0; size_t chars_read; if (! dry_run && ! skip_rest_of_patch) { int exclusive = *outname_needs_removal ? 0 : O_EXCL; assert (! inerrno); *outname_needs_removal = true; copy_file (inname, outname, 0, exclusive, instat.st_mode, true); sprintf (buf, "%s %s%s", editor_program, verbosity == VERBOSE ? "" : "- ", outname); fflush (stdout); pipefp = popen(buf, binary_transput ? "wb" : "w"); if (!pipefp) pfatal ("Can't open pipe to %s", quotearg (buf)); } for (;;) { char ed_command_letter; beginning_of_this_line = file_tell (pfp); chars_read = get_line (); if (! chars_read) { next_intuit_at(beginning_of_this_line,p_input_line); break; } ed_command_letter = get_ed_command_letter (buf); if (ed_command_letter) { if (pipefp) if (! fwrite (buf, sizeof *buf, chars_read, pipefp)) write_fatal (); if (ed_command_letter != 'd' && ed_command_letter != 's') { p_pass_comments_through = true; while ((chars_read = get_line ()) != 0) { if (pipefp) if (! fwrite (buf, sizeof *buf, chars_read, pipefp)) write_fatal (); if (chars_read == 2 && strEQ (buf, ".\n")) break; } p_pass_comments_through = false; } } else { next_intuit_at(beginning_of_this_line,p_input_line); break; } } if (!pipefp) return; if (fwrite ("w\nq\n", sizeof (char), (size_t) 4, pipefp) == 0 || fflush (pipefp) != 0) write_fatal (); if (pclose (pipefp) != 0) fatal ("%s FAILED", editor_program); if (ofp) { FILE *ifp = fopen (outname, binary_transput ? "rb" : "r"); int c; if (!ifp) pfatal ("can't open '%s'", outname); while ((c = getc (ifp)) != EOF) if (putc (c, ofp) == EOF) write_fatal (); if (ferror (ifp) || fclose (ifp) != 0) read_fatal (); } }
@@ -974,7 +974,8 @@ intuit_diff_type (bool need_header, mode_t *p_file_type) if ((pch_rename () || pch_copy ()) && ! inname && ! ((i == OLD || i == NEW) && - p_name[! reverse] && + p_name[reverse] && p_name[! reverse] && + name_is_valid (p_name[reverse]) && name_is_valid (p_name[! reverse]))) { say ("Cannot %s file without two valid file names\n", pch_rename () ? "rename" : "copy");
CWE-476
null
null
8,430
Compute_Funcs( TT_ExecContext exc ) { if ( exc->GS.freeVector.x == 0x4000 ) exc->F_dot_P = exc->GS.projVector.x; else if ( exc->GS.freeVector.y == 0x4000 ) exc->F_dot_P = exc->GS.projVector.y; else exc->F_dot_P = ( (FT_Long)exc->GS.projVector.x * exc->GS.freeVector.x + (FT_Long)exc->GS.projVector.y * exc->GS.freeVector.y ) >> 14; if ( exc->GS.projVector.x == 0x4000 ) exc->func_project = (TT_Project_Func)Project_x; else if ( exc->GS.projVector.y == 0x4000 ) exc->func_project = (TT_Project_Func)Project_y; else exc->func_project = (TT_Project_Func)Project; if ( exc->GS.dualVector.x == 0x4000 ) exc->func_dualproj = (TT_Project_Func)Project_x; else if ( exc->GS.dualVector.y == 0x4000 ) exc->func_dualproj = (TT_Project_Func)Project_y; else exc->func_dualproj = (TT_Project_Func)Dual_Project; exc->func_move = (TT_Move_Func)Direct_Move; exc->func_move_orig = (TT_Move_Func)Direct_Move_Orig; if ( exc->F_dot_P == 0x4000L ) { if ( exc->GS.freeVector.x == 0x4000 ) { exc->func_move = (TT_Move_Func)Direct_Move_X; exc->func_move_orig = (TT_Move_Func)Direct_Move_Orig_X; } else if ( exc->GS.freeVector.y == 0x4000 ) { exc->func_move = (TT_Move_Func)Direct_Move_Y; exc->func_move_orig = (TT_Move_Func)Direct_Move_Orig_Y; } } /* at small sizes, F_dot_P can become too small, resulting */ /* in overflows and `spikes' in a number of glyphs like `w'. */ if ( FT_ABS( exc->F_dot_P ) < 0x400L ) exc->F_dot_P = 0x4000L; /* Disable cached aspect ratio */ exc->tt_metrics.ratio = 0; }
null
0
Compute_Funcs( TT_ExecContext exc ) { if ( exc->GS.freeVector.x == 0x4000 ) exc->F_dot_P = exc->GS.projVector.x; else if ( exc->GS.freeVector.y == 0x4000 ) exc->F_dot_P = exc->GS.projVector.y; else exc->F_dot_P = ( (FT_Long)exc->GS.projVector.x * exc->GS.freeVector.x + (FT_Long)exc->GS.projVector.y * exc->GS.freeVector.y ) >> 14; if ( exc->GS.projVector.x == 0x4000 ) exc->func_project = (TT_Project_Func)Project_x; else if ( exc->GS.projVector.y == 0x4000 ) exc->func_project = (TT_Project_Func)Project_y; else exc->func_project = (TT_Project_Func)Project; if ( exc->GS.dualVector.x == 0x4000 ) exc->func_dualproj = (TT_Project_Func)Project_x; else if ( exc->GS.dualVector.y == 0x4000 ) exc->func_dualproj = (TT_Project_Func)Project_y; else exc->func_dualproj = (TT_Project_Func)Dual_Project; exc->func_move = (TT_Move_Func)Direct_Move; exc->func_move_orig = (TT_Move_Func)Direct_Move_Orig; if ( exc->F_dot_P == 0x4000L ) { if ( exc->GS.freeVector.x == 0x4000 ) { exc->func_move = (TT_Move_Func)Direct_Move_X; exc->func_move_orig = (TT_Move_Func)Direct_Move_Orig_X; } else if ( exc->GS.freeVector.y == 0x4000 ) { exc->func_move = (TT_Move_Func)Direct_Move_Y; exc->func_move_orig = (TT_Move_Func)Direct_Move_Orig_Y; } } /* at small sizes, F_dot_P can become too small, resulting */ /* in overflows and `spikes' in a number of glyphs like `w'. */ if ( FT_ABS( exc->F_dot_P ) < 0x400L ) exc->F_dot_P = 0x4000L; /* Disable cached aspect ratio */ exc->tt_metrics.ratio = 0; }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,431
Compute_Point_Displacement( TT_ExecContext exc, FT_F26Dot6* x, FT_F26Dot6* y, TT_GlyphZone zone, FT_UShort* refp ) { TT_GlyphZoneRec zp; FT_UShort p; FT_F26Dot6 d; if ( exc->opcode & 1 ) { zp = exc->zp0; p = exc->GS.rp1; } else { zp = exc->zp1; p = exc->GS.rp2; } if ( BOUNDS( p, zp.n_points ) ) { if ( exc->pedantic_hinting ) exc->error = FT_THROW( Invalid_Reference ); *refp = 0; return FAILURE; } *zone = zp; *refp = p; d = PROJECT( zp.cur + p, zp.org + p ); *x = FT_MulDiv( d, (FT_Long)exc->GS.freeVector.x, exc->F_dot_P ); *y = FT_MulDiv( d, (FT_Long)exc->GS.freeVector.y, exc->F_dot_P ); return SUCCESS; }
null
0
Compute_Point_Displacement( TT_ExecContext exc, FT_F26Dot6* x, FT_F26Dot6* y, TT_GlyphZone zone, FT_UShort* refp ) { TT_GlyphZoneRec zp; FT_UShort p; FT_F26Dot6 d; if ( exc->opcode & 1 ) { zp = exc->zp0; p = exc->GS.rp1; } else { zp = exc->zp1; p = exc->GS.rp2; } if ( BOUNDS( p, zp.n_points ) ) { if ( exc->pedantic_hinting ) exc->error = FT_THROW( Invalid_Reference ); *refp = 0; return FAILURE; } *zone = zp; *refp = p; d = PROJECT( zp.cur + p, zp.org + p ); *x = FT_MulDiv( d, (FT_Long)exc->GS.freeVector.x, exc->F_dot_P ); *y = FT_MulDiv( d, (FT_Long)exc->GS.freeVector.y, exc->F_dot_P ); return SUCCESS; }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,432
Compute_Round( TT_ExecContext exc, FT_Byte round_mode ) { switch ( round_mode ) { case TT_Round_Off: exc->func_round = (TT_Round_Func)Round_None; break; case TT_Round_To_Grid: exc->func_round = (TT_Round_Func)Round_To_Grid; break; case TT_Round_Up_To_Grid: exc->func_round = (TT_Round_Func)Round_Up_To_Grid; break; case TT_Round_Down_To_Grid: exc->func_round = (TT_Round_Func)Round_Down_To_Grid; break; case TT_Round_To_Half_Grid: exc->func_round = (TT_Round_Func)Round_To_Half_Grid; break; case TT_Round_To_Double_Grid: exc->func_round = (TT_Round_Func)Round_To_Double_Grid; break; case TT_Round_Super: exc->func_round = (TT_Round_Func)Round_Super; break; case TT_Round_Super_45: exc->func_round = (TT_Round_Func)Round_Super_45; break; } }
null
0
Compute_Round( TT_ExecContext exc, FT_Byte round_mode ) { switch ( round_mode ) { case TT_Round_Off: exc->func_round = (TT_Round_Func)Round_None; break; case TT_Round_To_Grid: exc->func_round = (TT_Round_Func)Round_To_Grid; break; case TT_Round_Up_To_Grid: exc->func_round = (TT_Round_Func)Round_Up_To_Grid; break; case TT_Round_Down_To_Grid: exc->func_round = (TT_Round_Func)Round_Down_To_Grid; break; case TT_Round_To_Half_Grid: exc->func_round = (TT_Round_Func)Round_To_Half_Grid; break; case TT_Round_To_Double_Grid: exc->func_round = (TT_Round_Func)Round_To_Double_Grid; break; case TT_Round_Super: exc->func_round = (TT_Round_Func)Round_Super; break; case TT_Round_Super_45: exc->func_round = (TT_Round_Func)Round_Super_45; break; } }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,433
Current_Ratio( TT_ExecContext exc ) { if ( !exc->tt_metrics.ratio ) { if ( exc->GS.projVector.y == 0 ) exc->tt_metrics.ratio = exc->tt_metrics.x_ratio; else if ( exc->GS.projVector.x == 0 ) exc->tt_metrics.ratio = exc->tt_metrics.y_ratio; else { FT_F26Dot6 x, y; x = TT_MulFix14( exc->tt_metrics.x_ratio, exc->GS.projVector.x ); y = TT_MulFix14( exc->tt_metrics.y_ratio, exc->GS.projVector.y ); exc->tt_metrics.ratio = FT_Hypot( x, y ); } } return exc->tt_metrics.ratio; }
null
0
Current_Ratio( TT_ExecContext exc ) { if ( !exc->tt_metrics.ratio ) { if ( exc->GS.projVector.y == 0 ) exc->tt_metrics.ratio = exc->tt_metrics.x_ratio; else if ( exc->GS.projVector.x == 0 ) exc->tt_metrics.ratio = exc->tt_metrics.y_ratio; else { FT_F26Dot6 x, y; x = TT_MulFix14( exc->tt_metrics.x_ratio, exc->GS.projVector.x ); y = TT_MulFix14( exc->tt_metrics.y_ratio, exc->GS.projVector.y ); exc->tt_metrics.ratio = FT_Hypot( x, y ); } } return exc->tt_metrics.ratio; }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,434
Direct_Move_Orig( TT_ExecContext exc, TT_GlyphZone zone, FT_UShort point, FT_F26Dot6 distance ) { FT_F26Dot6 v; v = exc->GS.freeVector.x; if ( v != 0 ) zone->org[point].x = ADD_LONG( zone->org[point].x, FT_MulDiv( distance, v, exc->F_dot_P ) ); v = exc->GS.freeVector.y; if ( v != 0 ) zone->org[point].y = ADD_LONG( zone->org[point].y, FT_MulDiv( distance, v, exc->F_dot_P ) ); }
null
0
Direct_Move_Orig( TT_ExecContext exc, TT_GlyphZone zone, FT_UShort point, FT_F26Dot6 distance ) { FT_F26Dot6 v; v = exc->GS.freeVector.x; if ( v != 0 ) zone->org[point].x = ADD_LONG( zone->org[point].x, FT_MulDiv( distance, v, exc->F_dot_P ) ); v = exc->GS.freeVector.y; if ( v != 0 ) zone->org[point].y = ADD_LONG( zone->org[point].y, FT_MulDiv( distance, v, exc->F_dot_P ) ); }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,435
Direct_Move_X( TT_ExecContext exc, TT_GlyphZone zone, FT_UShort point, FT_F26Dot6 distance ) { #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY if ( SUBPIXEL_HINTING_INFINALITY && !exc->ignore_x_mode ) zone->cur[point].x = ADD_LONG( zone->cur[point].x, distance ); else #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL if ( SUBPIXEL_HINTING_MINIMAL && !exc->backward_compatibility ) zone->cur[point].x = ADD_LONG( zone->cur[point].x, distance ); else #endif if ( NO_SUBPIXEL_HINTING ) zone->cur[point].x = ADD_LONG( zone->cur[point].x, distance ); zone->tags[point] |= FT_CURVE_TAG_TOUCH_X; }
null
0
Direct_Move_X( TT_ExecContext exc, TT_GlyphZone zone, FT_UShort point, FT_F26Dot6 distance ) { #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY if ( SUBPIXEL_HINTING_INFINALITY && !exc->ignore_x_mode ) zone->cur[point].x = ADD_LONG( zone->cur[point].x, distance ); else #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL if ( SUBPIXEL_HINTING_MINIMAL && !exc->backward_compatibility ) zone->cur[point].x = ADD_LONG( zone->cur[point].x, distance ); else #endif if ( NO_SUBPIXEL_HINTING ) zone->cur[point].x = ADD_LONG( zone->cur[point].x, distance ); zone->tags[point] |= FT_CURVE_TAG_TOUCH_X; }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,436
Direct_Move_Y( TT_ExecContext exc, TT_GlyphZone zone, FT_UShort point, FT_F26Dot6 distance ) { FT_UNUSED( exc ); #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL if ( !( SUBPIXEL_HINTING_MINIMAL && exc->backward_compatibility && exc->iupx_called && exc->iupy_called ) ) #endif zone->cur[point].y = ADD_LONG( zone->cur[point].y, distance ); zone->tags[point] |= FT_CURVE_TAG_TOUCH_Y; }
null
0
Direct_Move_Y( TT_ExecContext exc, TT_GlyphZone zone, FT_UShort point, FT_F26Dot6 distance ) { FT_UNUSED( exc ); #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL if ( !( SUBPIXEL_HINTING_MINIMAL && exc->backward_compatibility && exc->iupx_called && exc->iupy_called ) ) #endif zone->cur[point].y = ADD_LONG( zone->cur[point].y, distance ); zone->tags[point] |= FT_CURVE_TAG_TOUCH_Y; }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,437
Dual_Project( TT_ExecContext exc, FT_Pos dx, FT_Pos dy ) { return TT_DotFix14( dx, dy, exc->GS.dualVector.x, exc->GS.dualVector.y ); }
null
0
Dual_Project( TT_ExecContext exc, FT_Pos dx, FT_Pos dy ) { return TT_DotFix14( dx, dy, exc->GS.dualVector.x, exc->GS.dualVector.y ); }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,438
GetShortIns( TT_ExecContext exc ) { /* Reading a byte stream so there is no endianness (DaveP) */ exc->IP += 2; return (FT_Short)( ( exc->code[exc->IP - 2] << 8 ) + exc->code[exc->IP - 1] ); }
null
0
GetShortIns( TT_ExecContext exc ) { /* Reading a byte stream so there is no endianness (DaveP) */ exc->IP += 2; return (FT_Short)( ( exc->code[exc->IP - 2] << 8 ) + exc->code[exc->IP - 1] ); }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,439
Init_Context( TT_ExecContext exec, FT_Memory memory ) { FT_Error error; FT_TRACE1(( "Init_Context: new object at 0x%08p\n", exec )); exec->memory = memory; exec->callSize = 32; if ( FT_NEW_ARRAY( exec->callStack, exec->callSize ) ) goto Fail_Memory; /* all values in the context are set to 0 already, but this is */ /* here as a remainder */ exec->maxPoints = 0; exec->maxContours = 0; exec->stackSize = 0; exec->glyphSize = 0; exec->stack = NULL; exec->glyphIns = NULL; exec->face = NULL; exec->size = NULL; return FT_Err_Ok; Fail_Memory: FT_ERROR(( "Init_Context: not enough memory for %p\n", exec )); TT_Done_Context( exec ); return error; }
null
0
Init_Context( TT_ExecContext exec, FT_Memory memory ) { FT_Error error; FT_TRACE1(( "Init_Context: new object at 0x%08p\n", exec )); exec->memory = memory; exec->callSize = 32; if ( FT_NEW_ARRAY( exec->callStack, exec->callSize ) ) goto Fail_Memory; /* all values in the context are set to 0 already, but this is */ /* here as a remainder */ exec->maxPoints = 0; exec->maxContours = 0; exec->stackSize = 0; exec->glyphSize = 0; exec->stack = NULL; exec->glyphIns = NULL; exec->face = NULL; exec->size = NULL; return FT_Err_Ok; Fail_Memory: FT_ERROR(( "Init_Context: not enough memory for %p\n", exec )); TT_Done_Context( exec ); return error; }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,440
Ins_AA( void ) { /* intentionally no longer supported */ }
null
0
Ins_AA( void ) { /* intentionally no longer supported */ }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,441
Ins_ABS( FT_Long* args ) { if ( args[0] < 0 ) args[0] = NEG_LONG( args[0] ); }
null
0
Ins_ABS( FT_Long* args ) { if ( args[0] < 0 ) args[0] = NEG_LONG( args[0] ); }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,442
Ins_ADD( FT_Long* args ) { args[0] = ADD_LONG( args[0], args[1] ); }
null
0
Ins_ADD( FT_Long* args ) { args[0] = ADD_LONG( args[0], args[1] ); }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,443
Ins_ALIGNPTS( TT_ExecContext exc, FT_Long* args ) { FT_UShort p1, p2; FT_F26Dot6 distance; p1 = (FT_UShort)args[0]; p2 = (FT_UShort)args[1]; if ( BOUNDS( p1, exc->zp1.n_points ) || BOUNDS( p2, exc->zp0.n_points ) ) { if ( exc->pedantic_hinting ) exc->error = FT_THROW( Invalid_Reference ); return; } distance = PROJECT( exc->zp0.cur + p2, exc->zp1.cur + p1 ) / 2; exc->func_move( exc, &exc->zp1, p1, distance ); exc->func_move( exc, &exc->zp0, p2, NEG_LONG( distance ) ); }
null
0
Ins_ALIGNPTS( TT_ExecContext exc, FT_Long* args ) { FT_UShort p1, p2; FT_F26Dot6 distance; p1 = (FT_UShort)args[0]; p2 = (FT_UShort)args[1]; if ( BOUNDS( p1, exc->zp1.n_points ) || BOUNDS( p2, exc->zp0.n_points ) ) { if ( exc->pedantic_hinting ) exc->error = FT_THROW( Invalid_Reference ); return; } distance = PROJECT( exc->zp0.cur + p2, exc->zp1.cur + p1 ) / 2; exc->func_move( exc, &exc->zp1, p1, distance ); exc->func_move( exc, &exc->zp0, p2, NEG_LONG( distance ) ); }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,444
Ins_ALIGNRP( TT_ExecContext exc ) { FT_UShort point; FT_F26Dot6 distance; #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY if ( SUBPIXEL_HINTING_INFINALITY && exc->ignore_x_mode && exc->iup_called && ( exc->sph_tweak_flags & SPH_TWEAK_NO_ALIGNRP_AFTER_IUP ) ) { exc->error = FT_THROW( Invalid_Reference ); goto Fail; } #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ if ( exc->top < exc->GS.loop || BOUNDS( exc->GS.rp0, exc->zp0.n_points ) ) { if ( exc->pedantic_hinting ) exc->error = FT_THROW( Invalid_Reference ); goto Fail; } while ( exc->GS.loop > 0 ) { exc->args--; point = (FT_UShort)exc->stack[exc->args]; if ( BOUNDS( point, exc->zp1.n_points ) ) { if ( exc->pedantic_hinting ) { exc->error = FT_THROW( Invalid_Reference ); return; } } else { distance = PROJECT( exc->zp1.cur + point, exc->zp0.cur + exc->GS.rp0 ); exc->func_move( exc, &exc->zp1, point, NEG_LONG( distance ) ); } exc->GS.loop--; } Fail: exc->GS.loop = 1; exc->new_top = exc->args; }
null
0
Ins_ALIGNRP( TT_ExecContext exc ) { FT_UShort point; FT_F26Dot6 distance; #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY if ( SUBPIXEL_HINTING_INFINALITY && exc->ignore_x_mode && exc->iup_called && ( exc->sph_tweak_flags & SPH_TWEAK_NO_ALIGNRP_AFTER_IUP ) ) { exc->error = FT_THROW( Invalid_Reference ); goto Fail; } #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ if ( exc->top < exc->GS.loop || BOUNDS( exc->GS.rp0, exc->zp0.n_points ) ) { if ( exc->pedantic_hinting ) exc->error = FT_THROW( Invalid_Reference ); goto Fail; } while ( exc->GS.loop > 0 ) { exc->args--; point = (FT_UShort)exc->stack[exc->args]; if ( BOUNDS( point, exc->zp1.n_points ) ) { if ( exc->pedantic_hinting ) { exc->error = FT_THROW( Invalid_Reference ); return; } } else { distance = PROJECT( exc->zp1.cur + point, exc->zp0.cur + exc->GS.rp0 ); exc->func_move( exc, &exc->zp1, point, NEG_LONG( distance ) ); } exc->GS.loop--; } Fail: exc->GS.loop = 1; exc->new_top = exc->args; }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,445
Ins_CALL( TT_ExecContext exc, FT_Long* args ) { FT_ULong F; TT_CallRec* pCrec; TT_DefRecord* def; /* first of all, check the index */ F = (FT_ULong)args[0]; if ( BOUNDSL( F, exc->maxFunc + 1 ) ) goto Fail; /* Except for some old Apple fonts, all functions in a TrueType */ /* font are defined in increasing order, starting from 0. This */ /* means that we normally have */ /* */ /* exc->maxFunc+1 == exc->numFDefs */ /* exc->FDefs[n].opc == n for n in 0..exc->maxFunc */ /* */ /* If this isn't true, we need to look up the function table. */ def = exc->FDefs + F; if ( exc->maxFunc + 1 != exc->numFDefs || def->opc != F ) { /* look up the FDefs table */ TT_DefRecord* limit; def = exc->FDefs; limit = def + exc->numFDefs; while ( def < limit && def->opc != F ) def++; if ( def == limit ) goto Fail; } /* check that the function is active */ if ( !def->active ) goto Fail; #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY if ( SUBPIXEL_HINTING_INFINALITY && exc->ignore_x_mode && ( ( exc->iup_called && ( exc->sph_tweak_flags & SPH_TWEAK_NO_CALL_AFTER_IUP ) ) || ( def->sph_fdef_flags & SPH_FDEF_VACUFORM_ROUND_1 ) ) ) goto Fail; else exc->sph_in_func_flags = def->sph_fdef_flags; #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ /* check the call stack */ if ( exc->callTop >= exc->callSize ) { exc->error = FT_THROW( Stack_Overflow ); return; } pCrec = exc->callStack + exc->callTop; pCrec->Caller_Range = exc->curRange; pCrec->Caller_IP = exc->IP + 1; pCrec->Cur_Count = 1; pCrec->Def = def; exc->callTop++; Ins_Goto_CodeRange( exc, def->range, def->start ); exc->step_ins = FALSE; return; Fail: exc->error = FT_THROW( Invalid_Reference ); }
null
0
Ins_CALL( TT_ExecContext exc, FT_Long* args ) { FT_ULong F; TT_CallRec* pCrec; TT_DefRecord* def; /* first of all, check the index */ F = (FT_ULong)args[0]; if ( BOUNDSL( F, exc->maxFunc + 1 ) ) goto Fail; /* Except for some old Apple fonts, all functions in a TrueType */ /* font are defined in increasing order, starting from 0. This */ /* means that we normally have */ /* */ /* exc->maxFunc+1 == exc->numFDefs */ /* exc->FDefs[n].opc == n for n in 0..exc->maxFunc */ /* */ /* If this isn't true, we need to look up the function table. */ def = exc->FDefs + F; if ( exc->maxFunc + 1 != exc->numFDefs || def->opc != F ) { /* look up the FDefs table */ TT_DefRecord* limit; def = exc->FDefs; limit = def + exc->numFDefs; while ( def < limit && def->opc != F ) def++; if ( def == limit ) goto Fail; } /* check that the function is active */ if ( !def->active ) goto Fail; #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY if ( SUBPIXEL_HINTING_INFINALITY && exc->ignore_x_mode && ( ( exc->iup_called && ( exc->sph_tweak_flags & SPH_TWEAK_NO_CALL_AFTER_IUP ) ) || ( def->sph_fdef_flags & SPH_FDEF_VACUFORM_ROUND_1 ) ) ) goto Fail; else exc->sph_in_func_flags = def->sph_fdef_flags; #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ /* check the call stack */ if ( exc->callTop >= exc->callSize ) { exc->error = FT_THROW( Stack_Overflow ); return; } pCrec = exc->callStack + exc->callTop; pCrec->Caller_Range = exc->curRange; pCrec->Caller_IP = exc->IP + 1; pCrec->Cur_Count = 1; pCrec->Def = def; exc->callTop++; Ins_Goto_CodeRange( exc, def->range, def->start ); exc->step_ins = FALSE; return; Fail: exc->error = FT_THROW( Invalid_Reference ); }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,446
Ins_CEILING( FT_Long* args ) { args[0] = FT_PIX_CEIL( args[0] ); }
null
0
Ins_CEILING( FT_Long* args ) { args[0] = FT_PIX_CEIL( args[0] ); }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,447
Ins_CINDEX( TT_ExecContext exc, FT_Long* args ) { FT_Long L; L = args[0]; if ( L <= 0 || L > exc->args ) { if ( exc->pedantic_hinting ) exc->error = FT_THROW( Invalid_Reference ); args[0] = 0; } else args[0] = exc->stack[exc->args - L]; }
null
0
Ins_CINDEX( TT_ExecContext exc, FT_Long* args ) { FT_Long L; L = args[0]; if ( L <= 0 || L > exc->args ) { if ( exc->pedantic_hinting ) exc->error = FT_THROW( Invalid_Reference ); args[0] = 0; } else args[0] = exc->stack[exc->args - L]; }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,448
Ins_CLEAR( TT_ExecContext exc ) { exc->new_top = 0; }
null
0
Ins_CLEAR( TT_ExecContext exc ) { exc->new_top = 0; }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,449
Ins_DEBUG( TT_ExecContext exc ) { exc->error = FT_THROW( Debug_OpCode ); }
null
0
Ins_DEBUG( TT_ExecContext exc ) { exc->error = FT_THROW( Debug_OpCode ); }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,450
Ins_DELTAC( TT_ExecContext exc, FT_Long* args ) { FT_ULong nump, k; FT_ULong A, C, P; FT_Long B; P = (FT_ULong)exc->func_cur_ppem( exc ); nump = (FT_ULong)args[0]; for ( k = 1; k <= nump; k++ ) { if ( exc->args < 2 ) { if ( exc->pedantic_hinting ) exc->error = FT_THROW( Too_Few_Arguments ); exc->args = 0; goto Fail; } exc->args -= 2; A = (FT_ULong)exc->stack[exc->args + 1]; B = exc->stack[exc->args]; if ( BOUNDSL( A, exc->cvtSize ) ) { if ( exc->pedantic_hinting ) { exc->error = FT_THROW( Invalid_Reference ); return; } } else { C = ( (FT_ULong)B & 0xF0 ) >> 4; switch ( exc->opcode ) { case 0x73: break; case 0x74: C += 16; break; case 0x75: C += 32; break; } C += exc->GS.delta_base; if ( P == C ) { B = ( (FT_ULong)B & 0xF ) - 8; if ( B >= 0 ) B++; B *= 1L << ( 6 - exc->GS.delta_shift ); exc->func_move_cvt( exc, A, B ); } } } Fail: exc->new_top = exc->args; }
null
0
Ins_DELTAC( TT_ExecContext exc, FT_Long* args ) { FT_ULong nump, k; FT_ULong A, C, P; FT_Long B; P = (FT_ULong)exc->func_cur_ppem( exc ); nump = (FT_ULong)args[0]; for ( k = 1; k <= nump; k++ ) { if ( exc->args < 2 ) { if ( exc->pedantic_hinting ) exc->error = FT_THROW( Too_Few_Arguments ); exc->args = 0; goto Fail; } exc->args -= 2; A = (FT_ULong)exc->stack[exc->args + 1]; B = exc->stack[exc->args]; if ( BOUNDSL( A, exc->cvtSize ) ) { if ( exc->pedantic_hinting ) { exc->error = FT_THROW( Invalid_Reference ); return; } } else { C = ( (FT_ULong)B & 0xF0 ) >> 4; switch ( exc->opcode ) { case 0x73: break; case 0x74: C += 16; break; case 0x75: C += 32; break; } C += exc->GS.delta_base; if ( P == C ) { B = ( (FT_ULong)B & 0xF ) - 8; if ( B >= 0 ) B++; B *= 1L << ( 6 - exc->GS.delta_shift ); exc->func_move_cvt( exc, A, B ); } } } Fail: exc->new_top = exc->args; }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,451
Ins_DELTAP( TT_ExecContext exc, FT_Long* args ) { FT_ULong nump, k; FT_UShort A; FT_ULong C, P; FT_Long B; #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY FT_UShort B1, B2; if ( SUBPIXEL_HINTING_INFINALITY && exc->ignore_x_mode && exc->iup_called && ( exc->sph_tweak_flags & SPH_TWEAK_NO_DELTAP_AFTER_IUP ) ) goto Fail; #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ P = (FT_ULong)exc->func_cur_ppem( exc ); nump = (FT_ULong)args[0]; /* some points theoretically may occur more than once, thus UShort isn't enough */ for ( k = 1; k <= nump; k++ ) { if ( exc->args < 2 ) { if ( exc->pedantic_hinting ) exc->error = FT_THROW( Too_Few_Arguments ); exc->args = 0; goto Fail; } exc->args -= 2; A = (FT_UShort)exc->stack[exc->args + 1]; B = exc->stack[exc->args]; /* XXX: Because some popular fonts contain some invalid DeltaP */ /* instructions, we simply ignore them when the stacked */ /* point reference is off limit, rather than returning an */ /* error. As a delta instruction doesn't change a glyph */ /* in great ways, this shouldn't be a problem. */ if ( !BOUNDS( A, exc->zp0.n_points ) ) { C = ( (FT_ULong)B & 0xF0 ) >> 4; switch ( exc->opcode ) { case 0x5D: break; case 0x71: C += 16; break; case 0x72: C += 32; break; } C += exc->GS.delta_base; if ( P == C ) { B = ( (FT_ULong)B & 0xF ) - 8; if ( B >= 0 ) B++; B *= 1L << ( 6 - exc->GS.delta_shift ); #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY if ( SUBPIXEL_HINTING_INFINALITY ) { /* * Allow delta move if * * - not using ignore_x_mode rendering, * - glyph is specifically set to allow it, or * - glyph is composite and freedom vector is not in subpixel * direction. */ if ( !exc->ignore_x_mode || ( exc->sph_tweak_flags & SPH_TWEAK_ALWAYS_DO_DELTAP ) || ( exc->is_composite && exc->GS.freeVector.y != 0 ) ) exc->func_move( exc, &exc->zp0, A, B ); /* Otherwise, apply subpixel hinting and compatibility mode */ /* rules, always skipping deltas in subpixel direction. */ else if ( exc->ignore_x_mode && exc->GS.freeVector.y != 0 ) { /* save the y value of the point now; compare after move */ B1 = (FT_UShort)exc->zp0.cur[A].y; /* Standard subpixel hinting: Allow y move for y-touched */ /* points. This messes up DejaVu ... */ if ( !exc->face->sph_compatibility_mode && ( exc->zp0.tags[A] & FT_CURVE_TAG_TOUCH_Y ) ) exc->func_move( exc, &exc->zp0, A, B ); /* compatibility mode */ else if ( exc->face->sph_compatibility_mode && !( exc->sph_tweak_flags & SPH_TWEAK_ALWAYS_SKIP_DELTAP ) ) { if ( exc->sph_tweak_flags & SPH_TWEAK_ROUND_NONPIXEL_Y_MOVES ) B = FT_PIX_ROUND( B1 + B ) - B1; /* Allow delta move if using sph_compatibility_mode, */ /* IUP has not been called, and point is touched on Y. */ if ( !exc->iup_called && ( exc->zp0.tags[A] & FT_CURVE_TAG_TOUCH_Y ) ) exc->func_move( exc, &exc->zp0, A, B ); } B2 = (FT_UShort)exc->zp0.cur[A].y; /* Reverse this move if it results in a disallowed move */ if ( exc->GS.freeVector.y != 0 && ( ( exc->face->sph_compatibility_mode && ( B1 & 63 ) == 0 && ( B2 & 63 ) != 0 ) || ( ( exc->sph_tweak_flags & SPH_TWEAK_SKIP_NONPIXEL_Y_MOVES_DELTAP ) && ( B1 & 63 ) != 0 && ( B2 & 63 ) != 0 ) ) ) exc->func_move( exc, &exc->zp0, A, NEG_LONG( B ) ); } } else #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ { #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL /* See `ttinterp.h' for details on backward compatibility */ /* mode. */ if ( SUBPIXEL_HINTING_MINIMAL && exc->backward_compatibility ) { if ( !( exc->iupx_called && exc->iupy_called ) && ( ( exc->is_composite && exc->GS.freeVector.y != 0 ) || ( exc->zp0.tags[A] & FT_CURVE_TAG_TOUCH_Y ) ) ) exc->func_move( exc, &exc->zp0, A, B ); } else #endif exc->func_move( exc, &exc->zp0, A, B ); } } } else if ( exc->pedantic_hinting ) exc->error = FT_THROW( Invalid_Reference ); } Fail: exc->new_top = exc->args; }
null
0
Ins_DELTAP( TT_ExecContext exc, FT_Long* args ) { FT_ULong nump, k; FT_UShort A; FT_ULong C, P; FT_Long B; #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY FT_UShort B1, B2; if ( SUBPIXEL_HINTING_INFINALITY && exc->ignore_x_mode && exc->iup_called && ( exc->sph_tweak_flags & SPH_TWEAK_NO_DELTAP_AFTER_IUP ) ) goto Fail; #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ P = (FT_ULong)exc->func_cur_ppem( exc ); nump = (FT_ULong)args[0]; /* some points theoretically may occur more than once, thus UShort isn't enough */ for ( k = 1; k <= nump; k++ ) { if ( exc->args < 2 ) { if ( exc->pedantic_hinting ) exc->error = FT_THROW( Too_Few_Arguments ); exc->args = 0; goto Fail; } exc->args -= 2; A = (FT_UShort)exc->stack[exc->args + 1]; B = exc->stack[exc->args]; /* XXX: Because some popular fonts contain some invalid DeltaP */ /* instructions, we simply ignore them when the stacked */ /* point reference is off limit, rather than returning an */ /* error. As a delta instruction doesn't change a glyph */ /* in great ways, this shouldn't be a problem. */ if ( !BOUNDS( A, exc->zp0.n_points ) ) { C = ( (FT_ULong)B & 0xF0 ) >> 4; switch ( exc->opcode ) { case 0x5D: break; case 0x71: C += 16; break; case 0x72: C += 32; break; } C += exc->GS.delta_base; if ( P == C ) { B = ( (FT_ULong)B & 0xF ) - 8; if ( B >= 0 ) B++; B *= 1L << ( 6 - exc->GS.delta_shift ); #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY if ( SUBPIXEL_HINTING_INFINALITY ) { /* * Allow delta move if * * - not using ignore_x_mode rendering, * - glyph is specifically set to allow it, or * - glyph is composite and freedom vector is not in subpixel * direction. */ if ( !exc->ignore_x_mode || ( exc->sph_tweak_flags & SPH_TWEAK_ALWAYS_DO_DELTAP ) || ( exc->is_composite && exc->GS.freeVector.y != 0 ) ) exc->func_move( exc, &exc->zp0, A, B ); /* Otherwise, apply subpixel hinting and compatibility mode */ /* rules, always skipping deltas in subpixel direction. */ else if ( exc->ignore_x_mode && exc->GS.freeVector.y != 0 ) { /* save the y value of the point now; compare after move */ B1 = (FT_UShort)exc->zp0.cur[A].y; /* Standard subpixel hinting: Allow y move for y-touched */ /* points. This messes up DejaVu ... */ if ( !exc->face->sph_compatibility_mode && ( exc->zp0.tags[A] & FT_CURVE_TAG_TOUCH_Y ) ) exc->func_move( exc, &exc->zp0, A, B ); /* compatibility mode */ else if ( exc->face->sph_compatibility_mode && !( exc->sph_tweak_flags & SPH_TWEAK_ALWAYS_SKIP_DELTAP ) ) { if ( exc->sph_tweak_flags & SPH_TWEAK_ROUND_NONPIXEL_Y_MOVES ) B = FT_PIX_ROUND( B1 + B ) - B1; /* Allow delta move if using sph_compatibility_mode, */ /* IUP has not been called, and point is touched on Y. */ if ( !exc->iup_called && ( exc->zp0.tags[A] & FT_CURVE_TAG_TOUCH_Y ) ) exc->func_move( exc, &exc->zp0, A, B ); } B2 = (FT_UShort)exc->zp0.cur[A].y; /* Reverse this move if it results in a disallowed move */ if ( exc->GS.freeVector.y != 0 && ( ( exc->face->sph_compatibility_mode && ( B1 & 63 ) == 0 && ( B2 & 63 ) != 0 ) || ( ( exc->sph_tweak_flags & SPH_TWEAK_SKIP_NONPIXEL_Y_MOVES_DELTAP ) && ( B1 & 63 ) != 0 && ( B2 & 63 ) != 0 ) ) ) exc->func_move( exc, &exc->zp0, A, NEG_LONG( B ) ); } } else #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ { #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL /* See `ttinterp.h' for details on backward compatibility */ /* mode. */ if ( SUBPIXEL_HINTING_MINIMAL && exc->backward_compatibility ) { if ( !( exc->iupx_called && exc->iupy_called ) && ( ( exc->is_composite && exc->GS.freeVector.y != 0 ) || ( exc->zp0.tags[A] & FT_CURVE_TAG_TOUCH_Y ) ) ) exc->func_move( exc, &exc->zp0, A, B ); } else #endif exc->func_move( exc, &exc->zp0, A, B ); } } } else if ( exc->pedantic_hinting ) exc->error = FT_THROW( Invalid_Reference ); } Fail: exc->new_top = exc->args; }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,452
Ins_DUP( FT_Long* args ) { args[1] = args[0]; }
null
0
Ins_DUP( FT_Long* args ) { args[1] = args[0]; }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,453
Ins_EIF( void ) { /* nothing to do */ }
null
0
Ins_EIF( void ) { /* nothing to do */ }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,454
Ins_ELSE( TT_ExecContext exc ) { FT_Int nIfs; nIfs = 1; do { if ( SkipCode( exc ) == FAILURE ) return; switch ( exc->opcode ) { case 0x58: /* IF */ nIfs++; break; case 0x59: /* EIF */ nIfs--; break; } } while ( nIfs != 0 ); }
null
0
Ins_ELSE( TT_ExecContext exc ) { FT_Int nIfs; nIfs = 1; do { if ( SkipCode( exc ) == FAILURE ) return; switch ( exc->opcode ) { case 0x58: /* IF */ nIfs++; break; case 0x59: /* EIF */ nIfs--; break; } } while ( nIfs != 0 ); }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,455
Ins_ENDF( TT_ExecContext exc ) { TT_CallRec* pRec; #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY exc->sph_in_func_flags = 0x0000; #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ if ( exc->callTop <= 0 ) /* We encountered an ENDF without a call */ { exc->error = FT_THROW( ENDF_In_Exec_Stream ); return; } exc->callTop--; pRec = &exc->callStack[exc->callTop]; pRec->Cur_Count--; exc->step_ins = FALSE; if ( pRec->Cur_Count > 0 ) { exc->callTop++; exc->IP = pRec->Def->start; } else /* Loop through the current function */ Ins_Goto_CodeRange( exc, pRec->Caller_Range, pRec->Caller_IP ); /* Exit the current call frame. */ /* NOTE: If the last instruction 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 is why we do not test */ /* the result of Ins_Goto_CodeRange() here! */ }
null
0
Ins_ENDF( TT_ExecContext exc ) { TT_CallRec* pRec; #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY exc->sph_in_func_flags = 0x0000; #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ if ( exc->callTop <= 0 ) /* We encountered an ENDF without a call */ { exc->error = FT_THROW( ENDF_In_Exec_Stream ); return; } exc->callTop--; pRec = &exc->callStack[exc->callTop]; pRec->Cur_Count--; exc->step_ins = FALSE; if ( pRec->Cur_Count > 0 ) { exc->callTop++; exc->IP = pRec->Def->start; } else /* Loop through the current function */ Ins_Goto_CodeRange( exc, pRec->Caller_Range, pRec->Caller_IP ); /* Exit the current call frame. */ /* NOTE: If the last instruction 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 is why we do not test */ /* the result of Ins_Goto_CodeRange() here! */ }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,456
Ins_EQ( FT_Long* args ) { args[0] = ( args[0] == args[1] ); }
null
0
Ins_EQ( FT_Long* args ) { args[0] = ( args[0] == args[1] ); }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,457
Ins_EVEN( TT_ExecContext exc, FT_Long* args ) { args[0] = ( ( exc->func_round( exc, args[0], 0 ) & 127 ) == 0 ); }
null
0
Ins_EVEN( TT_ExecContext exc, FT_Long* args ) { args[0] = ( ( exc->func_round( exc, args[0], 0 ) & 127 ) == 0 ); }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,458
Ins_FDEF( TT_ExecContext exc, FT_Long* args ) { FT_ULong n; TT_DefRecord* rec; TT_DefRecord* limit; #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY /* arguments to opcodes are skipped by `SKIP_Code' */ FT_Byte opcode_pattern[9][12] = { /* #0 inline delta function 1 */ { 0x4B, /* PPEM */ 0x53, /* GTEQ */ 0x23, /* SWAP */ 0x4B, /* PPEM */ 0x51, /* LTEQ */ 0x5A, /* AND */ 0x58, /* IF */ 0x38, /* SHPIX */ 0x1B, /* ELSE */ 0x21, /* POP */ 0x21, /* POP */ 0x59 /* EIF */ }, /* #1 inline delta function 2 */ { 0x4B, /* PPEM */ 0x54, /* EQ */ 0x58, /* IF */ 0x38, /* SHPIX */ 0x1B, /* ELSE */ 0x21, /* POP */ 0x21, /* POP */ 0x59 /* EIF */ }, /* #2 diagonal stroke function */ { 0x20, /* DUP */ 0x20, /* DUP */ 0xB0, /* PUSHB_1 */ /* 1 */ 0x60, /* ADD */ 0x46, /* GC_cur */ 0xB0, /* PUSHB_1 */ /* 64 */ 0x23, /* SWAP */ 0x42 /* WS */ }, /* #3 VacuFormRound function */ { 0x45, /* RCVT */ 0x23, /* SWAP */ 0x46, /* GC_cur */ 0x60, /* ADD */ 0x20, /* DUP */ 0xB0 /* PUSHB_1 */ /* 38 */ }, /* #4 TTFautohint bytecode (old) */ { 0x20, /* DUP */ 0x64, /* ABS */ 0xB0, /* PUSHB_1 */ /* 32 */ 0x60, /* ADD */ 0x66, /* FLOOR */ 0x23, /* SWAP */ 0xB0 /* PUSHB_1 */ }, /* #5 spacing function 1 */ { 0x01, /* SVTCA_x */ 0xB0, /* PUSHB_1 */ /* 24 */ 0x43, /* RS */ 0x58 /* IF */ }, /* #6 spacing function 2 */ { 0x01, /* SVTCA_x */ 0x18, /* RTG */ 0xB0, /* PUSHB_1 */ /* 24 */ 0x43, /* RS */ 0x58 /* IF */ }, /* #7 TypeMan Talk DiagEndCtrl function */ { 0x01, /* SVTCA_x */ 0x20, /* DUP */ 0xB0, /* PUSHB_1 */ /* 3 */ 0x25, /* CINDEX */ }, /* #8 TypeMan Talk Align */ { 0x06, /* SPVTL */ 0x7D, /* RDTG */ }, }; FT_UShort opcode_patterns = 9; FT_UShort opcode_pointer[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; FT_UShort opcode_size[9] = { 12, 8, 8, 6, 7, 4, 5, 4, 2 }; FT_UShort i; #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ /* FDEF is only allowed in `prep' or `fpgm' */ if ( exc->curRange == tt_coderange_glyph ) { exc->error = FT_THROW( DEF_In_Glyf_Bytecode ); return; } /* some font programs are broken enough to redefine functions! */ /* We will then parse the current table. */ rec = exc->FDefs; limit = rec + exc->numFDefs; n = (FT_ULong)args[0]; for ( ; rec < limit; rec++ ) { if ( rec->opc == n ) break; } if ( rec == limit ) { /* check that there is enough room for new functions */ if ( exc->numFDefs >= exc->maxFDefs ) { exc->error = FT_THROW( Too_Many_Function_Defs ); return; } exc->numFDefs++; } /* Although FDEF takes unsigned 32-bit integer, */ /* func # must be within unsigned 16-bit integer */ if ( n > 0xFFFFU ) { exc->error = FT_THROW( Too_Many_Function_Defs ); return; } rec->range = exc->curRange; rec->opc = (FT_UInt16)n; rec->start = exc->IP + 1; rec->active = TRUE; rec->inline_delta = FALSE; rec->sph_fdef_flags = 0x0000; if ( n > exc->maxFunc ) exc->maxFunc = (FT_UInt16)n; #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY /* We don't know for sure these are typeman functions, */ /* however they are only active when RS 22 is called */ if ( n >= 64 && n <= 66 ) rec->sph_fdef_flags |= SPH_FDEF_TYPEMAN_STROKES; #endif /* Now skip the whole function definition. */ /* We don't allow nested IDEFS & FDEFs. */ while ( SkipCode( exc ) == SUCCESS ) { #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY if ( SUBPIXEL_HINTING_INFINALITY ) { for ( i = 0; i < opcode_patterns; i++ ) { if ( opcode_pointer[i] < opcode_size[i] && exc->opcode == opcode_pattern[i][opcode_pointer[i]] ) { opcode_pointer[i] += 1; if ( opcode_pointer[i] == opcode_size[i] ) { FT_TRACE6(( "sph: Function %d, opcode ptrn: %d, %s %s\n", i, n, exc->face->root.family_name, exc->face->root.style_name )); switch ( i ) { case 0: rec->sph_fdef_flags |= SPH_FDEF_INLINE_DELTA_1; exc->face->sph_found_func_flags |= SPH_FDEF_INLINE_DELTA_1; break; case 1: rec->sph_fdef_flags |= SPH_FDEF_INLINE_DELTA_2; exc->face->sph_found_func_flags |= SPH_FDEF_INLINE_DELTA_2; break; case 2: switch ( n ) { /* needs to be implemented still */ case 58: rec->sph_fdef_flags |= SPH_FDEF_DIAGONAL_STROKE; exc->face->sph_found_func_flags |= SPH_FDEF_DIAGONAL_STROKE; } break; case 3: switch ( n ) { case 0: rec->sph_fdef_flags |= SPH_FDEF_VACUFORM_ROUND_1; exc->face->sph_found_func_flags |= SPH_FDEF_VACUFORM_ROUND_1; } break; case 4: /* probably not necessary to detect anymore */ rec->sph_fdef_flags |= SPH_FDEF_TTFAUTOHINT_1; exc->face->sph_found_func_flags |= SPH_FDEF_TTFAUTOHINT_1; break; case 5: switch ( n ) { case 0: case 1: case 2: case 4: case 7: case 8: rec->sph_fdef_flags |= SPH_FDEF_SPACING_1; exc->face->sph_found_func_flags |= SPH_FDEF_SPACING_1; } break; case 6: switch ( n ) { case 0: case 1: case 2: case 4: case 7: case 8: rec->sph_fdef_flags |= SPH_FDEF_SPACING_2; exc->face->sph_found_func_flags |= SPH_FDEF_SPACING_2; } break; case 7: rec->sph_fdef_flags |= SPH_FDEF_TYPEMAN_DIAGENDCTRL; exc->face->sph_found_func_flags |= SPH_FDEF_TYPEMAN_DIAGENDCTRL; break; case 8: #if 0 rec->sph_fdef_flags |= SPH_FDEF_TYPEMAN_DIAGENDCTRL; exc->face->sph_found_func_flags |= SPH_FDEF_TYPEMAN_DIAGENDCTRL; #endif break; } opcode_pointer[i] = 0; } } else opcode_pointer[i] = 0; } /* Set sph_compatibility_mode only when deltas are detected */ exc->face->sph_compatibility_mode = ( ( exc->face->sph_found_func_flags & SPH_FDEF_INLINE_DELTA_1 ) | ( exc->face->sph_found_func_flags & SPH_FDEF_INLINE_DELTA_2 ) ); } #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ switch ( exc->opcode ) { case 0x89: /* IDEF */ case 0x2C: /* FDEF */ exc->error = FT_THROW( Nested_DEFS ); return; case 0x2D: /* ENDF */ rec->end = exc->IP; return; } } }
null
0
Ins_FDEF( TT_ExecContext exc, FT_Long* args ) { FT_ULong n; TT_DefRecord* rec; TT_DefRecord* limit; #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY /* arguments to opcodes are skipped by `SKIP_Code' */ FT_Byte opcode_pattern[9][12] = { /* #0 inline delta function 1 */ { 0x4B, /* PPEM */ 0x53, /* GTEQ */ 0x23, /* SWAP */ 0x4B, /* PPEM */ 0x51, /* LTEQ */ 0x5A, /* AND */ 0x58, /* IF */ 0x38, /* SHPIX */ 0x1B, /* ELSE */ 0x21, /* POP */ 0x21, /* POP */ 0x59 /* EIF */ }, /* #1 inline delta function 2 */ { 0x4B, /* PPEM */ 0x54, /* EQ */ 0x58, /* IF */ 0x38, /* SHPIX */ 0x1B, /* ELSE */ 0x21, /* POP */ 0x21, /* POP */ 0x59 /* EIF */ }, /* #2 diagonal stroke function */ { 0x20, /* DUP */ 0x20, /* DUP */ 0xB0, /* PUSHB_1 */ /* 1 */ 0x60, /* ADD */ 0x46, /* GC_cur */ 0xB0, /* PUSHB_1 */ /* 64 */ 0x23, /* SWAP */ 0x42 /* WS */ }, /* #3 VacuFormRound function */ { 0x45, /* RCVT */ 0x23, /* SWAP */ 0x46, /* GC_cur */ 0x60, /* ADD */ 0x20, /* DUP */ 0xB0 /* PUSHB_1 */ /* 38 */ }, /* #4 TTFautohint bytecode (old) */ { 0x20, /* DUP */ 0x64, /* ABS */ 0xB0, /* PUSHB_1 */ /* 32 */ 0x60, /* ADD */ 0x66, /* FLOOR */ 0x23, /* SWAP */ 0xB0 /* PUSHB_1 */ }, /* #5 spacing function 1 */ { 0x01, /* SVTCA_x */ 0xB0, /* PUSHB_1 */ /* 24 */ 0x43, /* RS */ 0x58 /* IF */ }, /* #6 spacing function 2 */ { 0x01, /* SVTCA_x */ 0x18, /* RTG */ 0xB0, /* PUSHB_1 */ /* 24 */ 0x43, /* RS */ 0x58 /* IF */ }, /* #7 TypeMan Talk DiagEndCtrl function */ { 0x01, /* SVTCA_x */ 0x20, /* DUP */ 0xB0, /* PUSHB_1 */ /* 3 */ 0x25, /* CINDEX */ }, /* #8 TypeMan Talk Align */ { 0x06, /* SPVTL */ 0x7D, /* RDTG */ }, }; FT_UShort opcode_patterns = 9; FT_UShort opcode_pointer[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; FT_UShort opcode_size[9] = { 12, 8, 8, 6, 7, 4, 5, 4, 2 }; FT_UShort i; #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ /* FDEF is only allowed in `prep' or `fpgm' */ if ( exc->curRange == tt_coderange_glyph ) { exc->error = FT_THROW( DEF_In_Glyf_Bytecode ); return; } /* some font programs are broken enough to redefine functions! */ /* We will then parse the current table. */ rec = exc->FDefs; limit = rec + exc->numFDefs; n = (FT_ULong)args[0]; for ( ; rec < limit; rec++ ) { if ( rec->opc == n ) break; } if ( rec == limit ) { /* check that there is enough room for new functions */ if ( exc->numFDefs >= exc->maxFDefs ) { exc->error = FT_THROW( Too_Many_Function_Defs ); return; } exc->numFDefs++; } /* Although FDEF takes unsigned 32-bit integer, */ /* func # must be within unsigned 16-bit integer */ if ( n > 0xFFFFU ) { exc->error = FT_THROW( Too_Many_Function_Defs ); return; } rec->range = exc->curRange; rec->opc = (FT_UInt16)n; rec->start = exc->IP + 1; rec->active = TRUE; rec->inline_delta = FALSE; rec->sph_fdef_flags = 0x0000; if ( n > exc->maxFunc ) exc->maxFunc = (FT_UInt16)n; #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY /* We don't know for sure these are typeman functions, */ /* however they are only active when RS 22 is called */ if ( n >= 64 && n <= 66 ) rec->sph_fdef_flags |= SPH_FDEF_TYPEMAN_STROKES; #endif /* Now skip the whole function definition. */ /* We don't allow nested IDEFS & FDEFs. */ while ( SkipCode( exc ) == SUCCESS ) { #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY if ( SUBPIXEL_HINTING_INFINALITY ) { for ( i = 0; i < opcode_patterns; i++ ) { if ( opcode_pointer[i] < opcode_size[i] && exc->opcode == opcode_pattern[i][opcode_pointer[i]] ) { opcode_pointer[i] += 1; if ( opcode_pointer[i] == opcode_size[i] ) { FT_TRACE6(( "sph: Function %d, opcode ptrn: %d, %s %s\n", i, n, exc->face->root.family_name, exc->face->root.style_name )); switch ( i ) { case 0: rec->sph_fdef_flags |= SPH_FDEF_INLINE_DELTA_1; exc->face->sph_found_func_flags |= SPH_FDEF_INLINE_DELTA_1; break; case 1: rec->sph_fdef_flags |= SPH_FDEF_INLINE_DELTA_2; exc->face->sph_found_func_flags |= SPH_FDEF_INLINE_DELTA_2; break; case 2: switch ( n ) { /* needs to be implemented still */ case 58: rec->sph_fdef_flags |= SPH_FDEF_DIAGONAL_STROKE; exc->face->sph_found_func_flags |= SPH_FDEF_DIAGONAL_STROKE; } break; case 3: switch ( n ) { case 0: rec->sph_fdef_flags |= SPH_FDEF_VACUFORM_ROUND_1; exc->face->sph_found_func_flags |= SPH_FDEF_VACUFORM_ROUND_1; } break; case 4: /* probably not necessary to detect anymore */ rec->sph_fdef_flags |= SPH_FDEF_TTFAUTOHINT_1; exc->face->sph_found_func_flags |= SPH_FDEF_TTFAUTOHINT_1; break; case 5: switch ( n ) { case 0: case 1: case 2: case 4: case 7: case 8: rec->sph_fdef_flags |= SPH_FDEF_SPACING_1; exc->face->sph_found_func_flags |= SPH_FDEF_SPACING_1; } break; case 6: switch ( n ) { case 0: case 1: case 2: case 4: case 7: case 8: rec->sph_fdef_flags |= SPH_FDEF_SPACING_2; exc->face->sph_found_func_flags |= SPH_FDEF_SPACING_2; } break; case 7: rec->sph_fdef_flags |= SPH_FDEF_TYPEMAN_DIAGENDCTRL; exc->face->sph_found_func_flags |= SPH_FDEF_TYPEMAN_DIAGENDCTRL; break; case 8: #if 0 rec->sph_fdef_flags |= SPH_FDEF_TYPEMAN_DIAGENDCTRL; exc->face->sph_found_func_flags |= SPH_FDEF_TYPEMAN_DIAGENDCTRL; #endif break; } opcode_pointer[i] = 0; } } else opcode_pointer[i] = 0; } /* Set sph_compatibility_mode only when deltas are detected */ exc->face->sph_compatibility_mode = ( ( exc->face->sph_found_func_flags & SPH_FDEF_INLINE_DELTA_1 ) | ( exc->face->sph_found_func_flags & SPH_FDEF_INLINE_DELTA_2 ) ); } #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ switch ( exc->opcode ) { case 0x89: /* IDEF */ case 0x2C: /* FDEF */ exc->error = FT_THROW( Nested_DEFS ); return; case 0x2D: /* ENDF */ rec->end = exc->IP; return; } } }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,459
Ins_FLIPOFF( TT_ExecContext exc ) { exc->GS.auto_flip = FALSE; }
null
0
Ins_FLIPOFF( TT_ExecContext exc ) { exc->GS.auto_flip = FALSE; }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,460
Ins_FLIPON( TT_ExecContext exc ) { exc->GS.auto_flip = TRUE; }
null
0
Ins_FLIPON( TT_ExecContext exc ) { exc->GS.auto_flip = TRUE; }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,461
Ins_FLIPRGON( TT_ExecContext exc, FT_Long* args ) { FT_UShort I, K, L; #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL /* See `ttinterp.h' for details on backward compatibility mode. */ if ( SUBPIXEL_HINTING_MINIMAL && exc->backward_compatibility && exc->iupx_called && exc->iupy_called ) return; #endif K = (FT_UShort)args[1]; L = (FT_UShort)args[0]; if ( BOUNDS( K, exc->pts.n_points ) || BOUNDS( L, exc->pts.n_points ) ) { if ( exc->pedantic_hinting ) exc->error = FT_THROW( Invalid_Reference ); return; } for ( I = L; I <= K; I++ ) exc->pts.tags[I] |= FT_CURVE_TAG_ON; }
null
0
Ins_FLIPRGON( TT_ExecContext exc, FT_Long* args ) { FT_UShort I, K, L; #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL /* See `ttinterp.h' for details on backward compatibility mode. */ if ( SUBPIXEL_HINTING_MINIMAL && exc->backward_compatibility && exc->iupx_called && exc->iupy_called ) return; #endif K = (FT_UShort)args[1]; L = (FT_UShort)args[0]; if ( BOUNDS( K, exc->pts.n_points ) || BOUNDS( L, exc->pts.n_points ) ) { if ( exc->pedantic_hinting ) exc->error = FT_THROW( Invalid_Reference ); return; } for ( I = L; I <= K; I++ ) exc->pts.tags[I] |= FT_CURVE_TAG_ON; }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,462
Ins_FLOOR( FT_Long* args ) { args[0] = FT_PIX_FLOOR( args[0] ); }
null
0
Ins_FLOOR( FT_Long* args ) { args[0] = FT_PIX_FLOOR( args[0] ); }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,463
Ins_GC( TT_ExecContext exc, FT_Long* args ) { FT_ULong L; FT_F26Dot6 R; L = (FT_ULong)args[0]; if ( BOUNDSL( L, exc->zp2.n_points ) ) { if ( exc->pedantic_hinting ) exc->error = FT_THROW( Invalid_Reference ); R = 0; } else { if ( exc->opcode & 1 ) R = FAST_DUALPROJ( &exc->zp2.org[L] ); else R = FAST_PROJECT( &exc->zp2.cur[L] ); } args[0] = R; }
null
0
Ins_GC( TT_ExecContext exc, FT_Long* args ) { FT_ULong L; FT_F26Dot6 R; L = (FT_ULong)args[0]; if ( BOUNDSL( L, exc->zp2.n_points ) ) { if ( exc->pedantic_hinting ) exc->error = FT_THROW( Invalid_Reference ); R = 0; } else { if ( exc->opcode & 1 ) R = FAST_DUALPROJ( &exc->zp2.org[L] ); else R = FAST_PROJECT( &exc->zp2.cur[L] ); } args[0] = R; }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,464
Ins_GETDATA( FT_Long* args ) { args[0] = 17; }
null
0
Ins_GETDATA( FT_Long* args ) { args[0] = 17; }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,465
Ins_GETINFO( TT_ExecContext exc, FT_Long* args ) { FT_Long K; TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( exc->face ); K = 0; #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY /********************************/ /* RASTERIZER VERSION */ /* Selector Bit: 0 */ /* Return Bit(s): 0-7 */ /* */ if ( SUBPIXEL_HINTING_INFINALITY && ( args[0] & 1 ) != 0 && exc->subpixel_hinting ) { if ( exc->ignore_x_mode ) { /* if in ClearType backward compatibility mode, */ /* we sometimes change the TrueType version dynamically */ K = exc->rasterizer_version; FT_TRACE6(( "Setting rasterizer version %d\n", exc->rasterizer_version )); } else K = TT_INTERPRETER_VERSION_38; } else #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ if ( ( args[0] & 1 ) != 0 ) K = driver->interpreter_version; /********************************/ /* GLYPH ROTATED */ /* Selector Bit: 1 */ /* Return Bit(s): 8 */ /* */ if ( ( args[0] & 2 ) != 0 && exc->tt_metrics.rotated ) K |= 1 << 8; /********************************/ /* GLYPH STRETCHED */ /* Selector Bit: 2 */ /* Return Bit(s): 9 */ /* */ if ( ( args[0] & 4 ) != 0 && exc->tt_metrics.stretched ) K |= 1 << 9; #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT /********************************/ /* VARIATION GLYPH */ /* Selector Bit: 3 */ /* Return Bit(s): 10 */ /* */ /* XXX: UNDOCUMENTED! */ if ( (args[0] & 8 ) != 0 && exc->face->blend ) K |= 1 << 10; #endif /********************************/ /* BI-LEVEL HINTING AND */ /* GRAYSCALE RENDERING */ /* Selector Bit: 5 */ /* Return Bit(s): 12 */ /* */ if ( ( args[0] & 32 ) != 0 && exc->grayscale ) K |= 1 << 12; #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL /* Toggle the following flags only outside of monochrome mode. */ /* Otherwise, instructions may behave weirdly and rendering results */ /* may differ between v35 and v40 mode, e.g., in `Times New Roman */ /* Bold Italic'. */ if ( SUBPIXEL_HINTING_MINIMAL && exc->subpixel_hinting_lean ) { /********************************/ /* HINTING FOR SUBPIXEL */ /* Selector Bit: 6 */ /* Return Bit(s): 13 */ /* */ /* v40 does subpixel hinting by default. */ if ( ( args[0] & 64 ) != 0 ) K |= 1 << 13; /********************************/ /* VERTICAL LCD SUBPIXELS? */ /* Selector Bit: 8 */ /* Return Bit(s): 15 */ /* */ if ( ( args[0] & 256 ) != 0 && exc->vertical_lcd_lean ) K |= 1 << 15; /********************************/ /* SUBPIXEL POSITIONED? */ /* Selector Bit: 10 */ /* Return Bit(s): 17 */ /* */ /* XXX: FreeType supports it, dependent on what client does? */ if ( ( args[0] & 1024 ) != 0 ) K |= 1 << 17; /********************************/ /* SYMMETRICAL SMOOTHING */ /* Selector Bit: 11 */ /* Return Bit(s): 18 */ /* */ /* The only smoothing method FreeType supports unless someone sets */ /* FT_LOAD_TARGET_MONO. */ if ( ( args[0] & 2048 ) != 0 && exc->subpixel_hinting_lean ) K |= 1 << 18; /********************************/ /* CLEARTYPE HINTING AND */ /* GRAYSCALE RENDERING */ /* Selector Bit: 12 */ /* Return Bit(s): 19 */ /* */ /* Grayscale rendering is what FreeType does anyway unless someone */ /* sets FT_LOAD_TARGET_MONO or FT_LOAD_TARGET_LCD(_V) */ if ( ( args[0] & 4096 ) != 0 && exc->grayscale_cleartype ) K |= 1 << 19; } #endif #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY if ( SUBPIXEL_HINTING_INFINALITY && exc->rasterizer_version >= TT_INTERPRETER_VERSION_35 ) { if ( exc->rasterizer_version >= 37 ) { /********************************/ /* HINTING FOR SUBPIXEL */ /* Selector Bit: 6 */ /* Return Bit(s): 13 */ /* */ if ( ( args[0] & 64 ) != 0 && exc->subpixel_hinting ) K |= 1 << 13; /********************************/ /* COMPATIBLE WIDTHS ENABLED */ /* Selector Bit: 7 */ /* Return Bit(s): 14 */ /* */ /* Functionality still needs to be added */ if ( ( args[0] & 128 ) != 0 && exc->compatible_widths ) K |= 1 << 14; /********************************/ /* VERTICAL LCD SUBPIXELS? */ /* Selector Bit: 8 */ /* Return Bit(s): 15 */ /* */ /* Functionality still needs to be added */ if ( ( args[0] & 256 ) != 0 && exc->vertical_lcd ) K |= 1 << 15; /********************************/ /* HINTING FOR BGR? */ /* Selector Bit: 9 */ /* Return Bit(s): 16 */ /* */ /* Functionality still needs to be added */ if ( ( args[0] & 512 ) != 0 && exc->bgr ) K |= 1 << 16; if ( exc->rasterizer_version >= 38 ) { /********************************/ /* SUBPIXEL POSITIONED? */ /* Selector Bit: 10 */ /* Return Bit(s): 17 */ /* */ /* Functionality still needs to be added */ if ( ( args[0] & 1024 ) != 0 && exc->subpixel_positioned ) K |= 1 << 17; /********************************/ /* SYMMETRICAL SMOOTHING */ /* Selector Bit: 11 */ /* Return Bit(s): 18 */ /* */ /* Functionality still needs to be added */ if ( ( args[0] & 2048 ) != 0 && exc->symmetrical_smoothing ) K |= 1 << 18; /********************************/ /* GRAY CLEARTYPE */ /* Selector Bit: 12 */ /* Return Bit(s): 19 */ /* */ /* Functionality still needs to be added */ if ( ( args[0] & 4096 ) != 0 && exc->gray_cleartype ) K |= 1 << 19; } } } #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ args[0] = K; }
null
0
Ins_GETINFO( TT_ExecContext exc, FT_Long* args ) { FT_Long K; TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( exc->face ); K = 0; #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY /********************************/ /* RASTERIZER VERSION */ /* Selector Bit: 0 */ /* Return Bit(s): 0-7 */ /* */ if ( SUBPIXEL_HINTING_INFINALITY && ( args[0] & 1 ) != 0 && exc->subpixel_hinting ) { if ( exc->ignore_x_mode ) { /* if in ClearType backward compatibility mode, */ /* we sometimes change the TrueType version dynamically */ K = exc->rasterizer_version; FT_TRACE6(( "Setting rasterizer version %d\n", exc->rasterizer_version )); } else K = TT_INTERPRETER_VERSION_38; } else #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ if ( ( args[0] & 1 ) != 0 ) K = driver->interpreter_version; /********************************/ /* GLYPH ROTATED */ /* Selector Bit: 1 */ /* Return Bit(s): 8 */ /* */ if ( ( args[0] & 2 ) != 0 && exc->tt_metrics.rotated ) K |= 1 << 8; /********************************/ /* GLYPH STRETCHED */ /* Selector Bit: 2 */ /* Return Bit(s): 9 */ /* */ if ( ( args[0] & 4 ) != 0 && exc->tt_metrics.stretched ) K |= 1 << 9; #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT /********************************/ /* VARIATION GLYPH */ /* Selector Bit: 3 */ /* Return Bit(s): 10 */ /* */ /* XXX: UNDOCUMENTED! */ if ( (args[0] & 8 ) != 0 && exc->face->blend ) K |= 1 << 10; #endif /********************************/ /* BI-LEVEL HINTING AND */ /* GRAYSCALE RENDERING */ /* Selector Bit: 5 */ /* Return Bit(s): 12 */ /* */ if ( ( args[0] & 32 ) != 0 && exc->grayscale ) K |= 1 << 12; #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL /* Toggle the following flags only outside of monochrome mode. */ /* Otherwise, instructions may behave weirdly and rendering results */ /* may differ between v35 and v40 mode, e.g., in `Times New Roman */ /* Bold Italic'. */ if ( SUBPIXEL_HINTING_MINIMAL && exc->subpixel_hinting_lean ) { /********************************/ /* HINTING FOR SUBPIXEL */ /* Selector Bit: 6 */ /* Return Bit(s): 13 */ /* */ /* v40 does subpixel hinting by default. */ if ( ( args[0] & 64 ) != 0 ) K |= 1 << 13; /********************************/ /* VERTICAL LCD SUBPIXELS? */ /* Selector Bit: 8 */ /* Return Bit(s): 15 */ /* */ if ( ( args[0] & 256 ) != 0 && exc->vertical_lcd_lean ) K |= 1 << 15; /********************************/ /* SUBPIXEL POSITIONED? */ /* Selector Bit: 10 */ /* Return Bit(s): 17 */ /* */ /* XXX: FreeType supports it, dependent on what client does? */ if ( ( args[0] & 1024 ) != 0 ) K |= 1 << 17; /********************************/ /* SYMMETRICAL SMOOTHING */ /* Selector Bit: 11 */ /* Return Bit(s): 18 */ /* */ /* The only smoothing method FreeType supports unless someone sets */ /* FT_LOAD_TARGET_MONO. */ if ( ( args[0] & 2048 ) != 0 && exc->subpixel_hinting_lean ) K |= 1 << 18; /********************************/ /* CLEARTYPE HINTING AND */ /* GRAYSCALE RENDERING */ /* Selector Bit: 12 */ /* Return Bit(s): 19 */ /* */ /* Grayscale rendering is what FreeType does anyway unless someone */ /* sets FT_LOAD_TARGET_MONO or FT_LOAD_TARGET_LCD(_V) */ if ( ( args[0] & 4096 ) != 0 && exc->grayscale_cleartype ) K |= 1 << 19; } #endif #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY if ( SUBPIXEL_HINTING_INFINALITY && exc->rasterizer_version >= TT_INTERPRETER_VERSION_35 ) { if ( exc->rasterizer_version >= 37 ) { /********************************/ /* HINTING FOR SUBPIXEL */ /* Selector Bit: 6 */ /* Return Bit(s): 13 */ /* */ if ( ( args[0] & 64 ) != 0 && exc->subpixel_hinting ) K |= 1 << 13; /********************************/ /* COMPATIBLE WIDTHS ENABLED */ /* Selector Bit: 7 */ /* Return Bit(s): 14 */ /* */ /* Functionality still needs to be added */ if ( ( args[0] & 128 ) != 0 && exc->compatible_widths ) K |= 1 << 14; /********************************/ /* VERTICAL LCD SUBPIXELS? */ /* Selector Bit: 8 */ /* Return Bit(s): 15 */ /* */ /* Functionality still needs to be added */ if ( ( args[0] & 256 ) != 0 && exc->vertical_lcd ) K |= 1 << 15; /********************************/ /* HINTING FOR BGR? */ /* Selector Bit: 9 */ /* Return Bit(s): 16 */ /* */ /* Functionality still needs to be added */ if ( ( args[0] & 512 ) != 0 && exc->bgr ) K |= 1 << 16; if ( exc->rasterizer_version >= 38 ) { /********************************/ /* SUBPIXEL POSITIONED? */ /* Selector Bit: 10 */ /* Return Bit(s): 17 */ /* */ /* Functionality still needs to be added */ if ( ( args[0] & 1024 ) != 0 && exc->subpixel_positioned ) K |= 1 << 17; /********************************/ /* SYMMETRICAL SMOOTHING */ /* Selector Bit: 11 */ /* Return Bit(s): 18 */ /* */ /* Functionality still needs to be added */ if ( ( args[0] & 2048 ) != 0 && exc->symmetrical_smoothing ) K |= 1 << 18; /********************************/ /* GRAY CLEARTYPE */ /* Selector Bit: 12 */ /* Return Bit(s): 19 */ /* */ /* Functionality still needs to be added */ if ( ( args[0] & 4096 ) != 0 && exc->gray_cleartype ) K |= 1 << 19; } } } #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ args[0] = K; }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,466
Ins_GFV( TT_ExecContext exc, FT_Long* args ) { args[0] = exc->GS.freeVector.x; args[1] = exc->GS.freeVector.y; }
null
0
Ins_GFV( TT_ExecContext exc, FT_Long* args ) { args[0] = exc->GS.freeVector.x; args[1] = exc->GS.freeVector.y; }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,467
Ins_GPV( TT_ExecContext exc, FT_Long* args ) { args[0] = exc->GS.projVector.x; args[1] = exc->GS.projVector.y; }
null
0
Ins_GPV( TT_ExecContext exc, FT_Long* args ) { args[0] = exc->GS.projVector.x; args[1] = exc->GS.projVector.y; }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,468
Ins_GT( FT_Long* args ) { args[0] = ( args[0] > args[1] ); }
null
0
Ins_GT( FT_Long* args ) { args[0] = ( args[0] > args[1] ); }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,469
Ins_GTEQ( FT_Long* args ) { args[0] = ( args[0] >= args[1] ); }
null
0
Ins_GTEQ( FT_Long* args ) { args[0] = ( args[0] >= args[1] ); }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,470
Ins_Goto_CodeRange( TT_ExecContext exc, FT_Int aRange, FT_Long aIP ) { TT_CodeRange* range; if ( aRange < 1 || aRange > 3 ) { exc->error = FT_THROW( Bad_Argument ); return FAILURE; } range = &exc->codeRangeTable[aRange - 1]; if ( !range->base ) /* invalid coderange */ { exc->error = FT_THROW( 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 > range->size ) { exc->error = FT_THROW( Code_Overflow ); return FAILURE; } exc->code = range->base; exc->codeSize = range->size; exc->IP = aIP; exc->curRange = aRange; return SUCCESS; }
null
0
Ins_Goto_CodeRange( TT_ExecContext exc, FT_Int aRange, FT_Long aIP ) { TT_CodeRange* range; if ( aRange < 1 || aRange > 3 ) { exc->error = FT_THROW( Bad_Argument ); return FAILURE; } range = &exc->codeRangeTable[aRange - 1]; if ( !range->base ) /* invalid coderange */ { exc->error = FT_THROW( 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 > range->size ) { exc->error = FT_THROW( Code_Overflow ); return FAILURE; } exc->code = range->base; exc->codeSize = range->size; exc->IP = aIP; exc->curRange = aRange; return SUCCESS; }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,471
Ins_IDEF( TT_ExecContext exc, FT_Long* args ) { TT_DefRecord* def; TT_DefRecord* limit; /* we enable IDEF only in `prep' or `fpgm' */ if ( exc->curRange == tt_coderange_glyph ) { exc->error = FT_THROW( DEF_In_Glyf_Bytecode ); return; } /* First of all, look for the same function in our table */ def = exc->IDefs; limit = def + exc->numIDefs; for ( ; def < limit; def++ ) if ( def->opc == (FT_ULong)args[0] ) break; if ( def == limit ) { /* check that there is enough room for a new instruction */ if ( exc->numIDefs >= exc->maxIDefs ) { exc->error = FT_THROW( Too_Many_Instruction_Defs ); return; } exc->numIDefs++; } /* opcode must be unsigned 8-bit integer */ if ( 0 > args[0] || args[0] > 0x00FF ) { exc->error = FT_THROW( Too_Many_Instruction_Defs ); return; } def->opc = (FT_Byte)args[0]; def->start = exc->IP + 1; def->range = exc->curRange; def->active = TRUE; if ( (FT_ULong)args[0] > exc->maxIns ) exc->maxIns = (FT_Byte)args[0]; /* Now skip the whole function definition. */ /* We don't allow nested IDEFs & FDEFs. */ while ( SkipCode( exc ) == SUCCESS ) { switch ( exc->opcode ) { case 0x89: /* IDEF */ case 0x2C: /* FDEF */ exc->error = FT_THROW( Nested_DEFS ); return; case 0x2D: /* ENDF */ def->end = exc->IP; return; } } }
null
0
Ins_IDEF( TT_ExecContext exc, FT_Long* args ) { TT_DefRecord* def; TT_DefRecord* limit; /* we enable IDEF only in `prep' or `fpgm' */ if ( exc->curRange == tt_coderange_glyph ) { exc->error = FT_THROW( DEF_In_Glyf_Bytecode ); return; } /* First of all, look for the same function in our table */ def = exc->IDefs; limit = def + exc->numIDefs; for ( ; def < limit; def++ ) if ( def->opc == (FT_ULong)args[0] ) break; if ( def == limit ) { /* check that there is enough room for a new instruction */ if ( exc->numIDefs >= exc->maxIDefs ) { exc->error = FT_THROW( Too_Many_Instruction_Defs ); return; } exc->numIDefs++; } /* opcode must be unsigned 8-bit integer */ if ( 0 > args[0] || args[0] > 0x00FF ) { exc->error = FT_THROW( Too_Many_Instruction_Defs ); return; } def->opc = (FT_Byte)args[0]; def->start = exc->IP + 1; def->range = exc->curRange; def->active = TRUE; if ( (FT_ULong)args[0] > exc->maxIns ) exc->maxIns = (FT_Byte)args[0]; /* Now skip the whole function definition. */ /* We don't allow nested IDEFs & FDEFs. */ while ( SkipCode( exc ) == SUCCESS ) { switch ( exc->opcode ) { case 0x89: /* IDEF */ case 0x2C: /* FDEF */ exc->error = FT_THROW( Nested_DEFS ); return; case 0x2D: /* ENDF */ def->end = exc->IP; return; } } }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,472
Ins_IF( TT_ExecContext exc, FT_Long* args ) { FT_Int nIfs; FT_Bool Out; if ( args[0] != 0 ) return; nIfs = 1; Out = 0; do { if ( SkipCode( exc ) == FAILURE ) return; switch ( exc->opcode ) { case 0x58: /* IF */ nIfs++; break; case 0x1B: /* ELSE */ Out = FT_BOOL( nIfs == 1 ); break; case 0x59: /* EIF */ nIfs--; Out = FT_BOOL( nIfs == 0 ); break; } } while ( Out == 0 ); }
null
0
Ins_IF( TT_ExecContext exc, FT_Long* args ) { FT_Int nIfs; FT_Bool Out; if ( args[0] != 0 ) return; nIfs = 1; Out = 0; do { if ( SkipCode( exc ) == FAILURE ) return; switch ( exc->opcode ) { case 0x58: /* IF */ nIfs++; break; case 0x1B: /* ELSE */ Out = FT_BOOL( nIfs == 1 ); break; case 0x59: /* EIF */ nIfs--; Out = FT_BOOL( nIfs == 0 ); break; } } while ( Out == 0 ); }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,473
Ins_INSTCTRL( TT_ExecContext exc, FT_Long* args ) { FT_ULong K, L, Kf; K = (FT_ULong)args[1]; L = (FT_ULong)args[0]; /* selector values cannot be `OR'ed; */ /* they are indices starting with index 1, not flags */ if ( K < 1 || K > 3 ) { if ( exc->pedantic_hinting ) exc->error = FT_THROW( Invalid_Reference ); return; } /* convert index to flag value */ Kf = 1 << ( K - 1 ); if ( L != 0 ) { /* arguments to selectors look like flag values */ if ( L != Kf ) { if ( exc->pedantic_hinting ) exc->error = FT_THROW( Invalid_Reference ); return; } } exc->GS.instruct_control &= ~(FT_Byte)Kf; exc->GS.instruct_control |= (FT_Byte)L; if ( K == 3 ) { #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY /* INSTCTRL modifying flag 3 also has an effect */ /* outside of the CVT program */ if ( SUBPIXEL_HINTING_INFINALITY ) exc->ignore_x_mode = FT_BOOL( L == 4 ); #endif #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL /* Native ClearType fonts sign a waiver that turns off all backward */ /* compatibility hacks and lets them program points to the grid like */ /* it's 1996. They might sign a waiver for just one glyph, though. */ if ( SUBPIXEL_HINTING_MINIMAL ) exc->backward_compatibility = !FT_BOOL( L == 4 ); #endif } }
null
0
Ins_INSTCTRL( TT_ExecContext exc, FT_Long* args ) { FT_ULong K, L, Kf; K = (FT_ULong)args[1]; L = (FT_ULong)args[0]; /* selector values cannot be `OR'ed; */ /* they are indices starting with index 1, not flags */ if ( K < 1 || K > 3 ) { if ( exc->pedantic_hinting ) exc->error = FT_THROW( Invalid_Reference ); return; } /* convert index to flag value */ Kf = 1 << ( K - 1 ); if ( L != 0 ) { /* arguments to selectors look like flag values */ if ( L != Kf ) { if ( exc->pedantic_hinting ) exc->error = FT_THROW( Invalid_Reference ); return; } } exc->GS.instruct_control &= ~(FT_Byte)Kf; exc->GS.instruct_control |= (FT_Byte)L; if ( K == 3 ) { #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY /* INSTCTRL modifying flag 3 also has an effect */ /* outside of the CVT program */ if ( SUBPIXEL_HINTING_INFINALITY ) exc->ignore_x_mode = FT_BOOL( L == 4 ); #endif #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL /* Native ClearType fonts sign a waiver that turns off all backward */ /* compatibility hacks and lets them program points to the grid like */ /* it's 1996. They might sign a waiver for just one glyph, though. */ if ( SUBPIXEL_HINTING_MINIMAL ) exc->backward_compatibility = !FT_BOOL( L == 4 ); #endif } }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,474
Ins_IP( TT_ExecContext exc ) { FT_F26Dot6 old_range, cur_range; FT_Vector* orus_base; FT_Vector* cur_base; FT_Int twilight; if ( exc->top < exc->GS.loop ) { if ( exc->pedantic_hinting ) exc->error = FT_THROW( Invalid_Reference ); goto Fail; } /* * We need to deal in a special way with the twilight zone. * Otherwise, by definition, the value of exc->twilight.orus[n] is (0,0), * for every n. */ twilight = ( exc->GS.gep0 == 0 || exc->GS.gep1 == 0 || exc->GS.gep2 == 0 ); if ( BOUNDS( exc->GS.rp1, exc->zp0.n_points ) ) { if ( exc->pedantic_hinting ) exc->error = FT_THROW( Invalid_Reference ); goto Fail; } if ( twilight ) orus_base = &exc->zp0.org[exc->GS.rp1]; else orus_base = &exc->zp0.orus[exc->GS.rp1]; cur_base = &exc->zp0.cur[exc->GS.rp1]; /* XXX: There are some glyphs in some braindead but popular */ /* fonts out there (e.g. [aeu]grave in monotype.ttf) */ /* calling IP[] with bad values of rp[12]. */ /* Do something sane when this odd thing happens. */ if ( BOUNDS( exc->GS.rp1, exc->zp0.n_points ) || BOUNDS( exc->GS.rp2, exc->zp1.n_points ) ) { old_range = 0; cur_range = 0; } else { if ( twilight ) old_range = DUALPROJ( &exc->zp1.org[exc->GS.rp2], orus_base ); else if ( exc->metrics.x_scale == exc->metrics.y_scale ) old_range = DUALPROJ( &exc->zp1.orus[exc->GS.rp2], orus_base ); else { FT_Vector vec; vec.x = FT_MulFix( SUB_LONG( exc->zp1.orus[exc->GS.rp2].x, orus_base->x ), exc->metrics.x_scale ); vec.y = FT_MulFix( SUB_LONG( exc->zp1.orus[exc->GS.rp2].y, orus_base->y ), exc->metrics.y_scale ); old_range = FAST_DUALPROJ( &vec ); } cur_range = PROJECT( &exc->zp1.cur[exc->GS.rp2], cur_base ); } for ( ; exc->GS.loop > 0; exc->GS.loop-- ) { FT_UInt point = (FT_UInt)exc->stack[--exc->args]; FT_F26Dot6 org_dist, cur_dist, new_dist; /* check point bounds */ if ( BOUNDS( point, exc->zp2.n_points ) ) { if ( exc->pedantic_hinting ) { exc->error = FT_THROW( Invalid_Reference ); return; } continue; } if ( twilight ) org_dist = DUALPROJ( &exc->zp2.org[point], orus_base ); else if ( exc->metrics.x_scale == exc->metrics.y_scale ) org_dist = DUALPROJ( &exc->zp2.orus[point], orus_base ); else { FT_Vector vec; vec.x = FT_MulFix( SUB_LONG( exc->zp2.orus[point].x, orus_base->x ), exc->metrics.x_scale ); vec.y = FT_MulFix( SUB_LONG( exc->zp2.orus[point].y, orus_base->y ), exc->metrics.y_scale ); org_dist = FAST_DUALPROJ( &vec ); } cur_dist = PROJECT( &exc->zp2.cur[point], cur_base ); if ( org_dist ) { if ( old_range ) new_dist = FT_MulDiv( org_dist, cur_range, old_range ); else { /* This is the same as what MS does for the invalid case: */ /* */ /* delta = (Original_Pt - Original_RP1) - */ /* (Current_Pt - Current_RP1) ; */ /* */ /* In FreeType speak: */ /* */ /* delta = org_dist - cur_dist . */ /* */ /* We move `point' by `new_dist - cur_dist' after leaving */ /* this block, thus we have */ /* */ /* new_dist - cur_dist = delta , */ /* new_dist - cur_dist = org_dist - cur_dist , */ /* new_dist = org_dist . */ new_dist = org_dist; } } else new_dist = 0; exc->func_move( exc, &exc->zp2, (FT_UShort)point, SUB_LONG( new_dist, cur_dist ) ); } Fail: exc->GS.loop = 1; exc->new_top = exc->args; }
null
0
Ins_IP( TT_ExecContext exc ) { FT_F26Dot6 old_range, cur_range; FT_Vector* orus_base; FT_Vector* cur_base; FT_Int twilight; if ( exc->top < exc->GS.loop ) { if ( exc->pedantic_hinting ) exc->error = FT_THROW( Invalid_Reference ); goto Fail; } /* * We need to deal in a special way with the twilight zone. * Otherwise, by definition, the value of exc->twilight.orus[n] is (0,0), * for every n. */ twilight = ( exc->GS.gep0 == 0 || exc->GS.gep1 == 0 || exc->GS.gep2 == 0 ); if ( BOUNDS( exc->GS.rp1, exc->zp0.n_points ) ) { if ( exc->pedantic_hinting ) exc->error = FT_THROW( Invalid_Reference ); goto Fail; } if ( twilight ) orus_base = &exc->zp0.org[exc->GS.rp1]; else orus_base = &exc->zp0.orus[exc->GS.rp1]; cur_base = &exc->zp0.cur[exc->GS.rp1]; /* XXX: There are some glyphs in some braindead but popular */ /* fonts out there (e.g. [aeu]grave in monotype.ttf) */ /* calling IP[] with bad values of rp[12]. */ /* Do something sane when this odd thing happens. */ if ( BOUNDS( exc->GS.rp1, exc->zp0.n_points ) || BOUNDS( exc->GS.rp2, exc->zp1.n_points ) ) { old_range = 0; cur_range = 0; } else { if ( twilight ) old_range = DUALPROJ( &exc->zp1.org[exc->GS.rp2], orus_base ); else if ( exc->metrics.x_scale == exc->metrics.y_scale ) old_range = DUALPROJ( &exc->zp1.orus[exc->GS.rp2], orus_base ); else { FT_Vector vec; vec.x = FT_MulFix( SUB_LONG( exc->zp1.orus[exc->GS.rp2].x, orus_base->x ), exc->metrics.x_scale ); vec.y = FT_MulFix( SUB_LONG( exc->zp1.orus[exc->GS.rp2].y, orus_base->y ), exc->metrics.y_scale ); old_range = FAST_DUALPROJ( &vec ); } cur_range = PROJECT( &exc->zp1.cur[exc->GS.rp2], cur_base ); } for ( ; exc->GS.loop > 0; exc->GS.loop-- ) { FT_UInt point = (FT_UInt)exc->stack[--exc->args]; FT_F26Dot6 org_dist, cur_dist, new_dist; /* check point bounds */ if ( BOUNDS( point, exc->zp2.n_points ) ) { if ( exc->pedantic_hinting ) { exc->error = FT_THROW( Invalid_Reference ); return; } continue; } if ( twilight ) org_dist = DUALPROJ( &exc->zp2.org[point], orus_base ); else if ( exc->metrics.x_scale == exc->metrics.y_scale ) org_dist = DUALPROJ( &exc->zp2.orus[point], orus_base ); else { FT_Vector vec; vec.x = FT_MulFix( SUB_LONG( exc->zp2.orus[point].x, orus_base->x ), exc->metrics.x_scale ); vec.y = FT_MulFix( SUB_LONG( exc->zp2.orus[point].y, orus_base->y ), exc->metrics.y_scale ); org_dist = FAST_DUALPROJ( &vec ); } cur_dist = PROJECT( &exc->zp2.cur[point], cur_base ); if ( org_dist ) { if ( old_range ) new_dist = FT_MulDiv( org_dist, cur_range, old_range ); else { /* This is the same as what MS does for the invalid case: */ /* */ /* delta = (Original_Pt - Original_RP1) - */ /* (Current_Pt - Current_RP1) ; */ /* */ /* In FreeType speak: */ /* */ /* delta = org_dist - cur_dist . */ /* */ /* We move `point' by `new_dist - cur_dist' after leaving */ /* this block, thus we have */ /* */ /* new_dist - cur_dist = delta , */ /* new_dist - cur_dist = org_dist - cur_dist , */ /* new_dist = org_dist . */ new_dist = org_dist; } } else new_dist = 0; exc->func_move( exc, &exc->zp2, (FT_UShort)point, SUB_LONG( new_dist, cur_dist ) ); } Fail: exc->GS.loop = 1; exc->new_top = exc->args; }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,475
Ins_ISECT( TT_ExecContext exc, FT_Long* args ) { FT_UShort point, a0, a1, b0, b1; FT_F26Dot6 discriminant, dotproduct; FT_F26Dot6 dx, dy, dax, day, dbx, dby; FT_F26Dot6 val; FT_Vector R; point = (FT_UShort)args[0]; a0 = (FT_UShort)args[1]; a1 = (FT_UShort)args[2]; b0 = (FT_UShort)args[3]; b1 = (FT_UShort)args[4]; if ( BOUNDS( b0, exc->zp0.n_points ) || BOUNDS( b1, exc->zp0.n_points ) || BOUNDS( a0, exc->zp1.n_points ) || BOUNDS( a1, exc->zp1.n_points ) || BOUNDS( point, exc->zp2.n_points ) ) { if ( exc->pedantic_hinting ) exc->error = FT_THROW( Invalid_Reference ); return; } /* Cramer's rule */ dbx = SUB_LONG( exc->zp0.cur[b1].x, exc->zp0.cur[b0].x ); dby = SUB_LONG( exc->zp0.cur[b1].y, exc->zp0.cur[b0].y ); dax = SUB_LONG( exc->zp1.cur[a1].x, exc->zp1.cur[a0].x ); day = SUB_LONG( exc->zp1.cur[a1].y, exc->zp1.cur[a0].y ); dx = SUB_LONG( exc->zp0.cur[b0].x, exc->zp1.cur[a0].x ); dy = SUB_LONG( exc->zp0.cur[b0].y, exc->zp1.cur[a0].y ); discriminant = ADD_LONG( FT_MulDiv( dax, NEG_LONG( dby ), 0x40 ), FT_MulDiv( day, dbx, 0x40 ) ); dotproduct = ADD_LONG( FT_MulDiv( dax, dbx, 0x40 ), FT_MulDiv( day, dby, 0x40 ) ); /* The discriminant above is actually a cross product of vectors */ /* da and db. Together with the dot product, they can be used as */ /* surrogates for sine and cosine of the angle between the vectors. */ /* Indeed, */ /* dotproduct = |da||db|cos(angle) */ /* discriminant = |da||db|sin(angle) . */ /* We use these equations to reject grazing intersections by */ /* thresholding abs(tan(angle)) at 1/19, corresponding to 3 degrees. */ if ( MUL_LONG( 19, FT_ABS( discriminant ) ) > FT_ABS( dotproduct ) ) { val = ADD_LONG( FT_MulDiv( dx, NEG_LONG( dby ), 0x40 ), FT_MulDiv( dy, dbx, 0x40 ) ); R.x = FT_MulDiv( val, dax, discriminant ); R.y = FT_MulDiv( val, day, discriminant ); /* XXX: Block in backward_compatibility and/or post-IUP? */ exc->zp2.cur[point].x = ADD_LONG( exc->zp1.cur[a0].x, R.x ); exc->zp2.cur[point].y = ADD_LONG( exc->zp1.cur[a0].y, R.y ); } else { /* else, take the middle of the middles of A and B */ /* XXX: Block in backward_compatibility and/or post-IUP? */ exc->zp2.cur[point].x = ADD_LONG( ADD_LONG( exc->zp1.cur[a0].x, exc->zp1.cur[a1].x ), ADD_LONG( exc->zp0.cur[b0].x, exc->zp0.cur[b1].x ) ) / 4; exc->zp2.cur[point].y = ADD_LONG( ADD_LONG( exc->zp1.cur[a0].y, exc->zp1.cur[a1].y ), ADD_LONG( exc->zp0.cur[b0].y, exc->zp0.cur[b1].y ) ) / 4; } exc->zp2.tags[point] |= FT_CURVE_TAG_TOUCH_BOTH; }
null
0
Ins_ISECT( TT_ExecContext exc, FT_Long* args ) { FT_UShort point, a0, a1, b0, b1; FT_F26Dot6 discriminant, dotproduct; FT_F26Dot6 dx, dy, dax, day, dbx, dby; FT_F26Dot6 val; FT_Vector R; point = (FT_UShort)args[0]; a0 = (FT_UShort)args[1]; a1 = (FT_UShort)args[2]; b0 = (FT_UShort)args[3]; b1 = (FT_UShort)args[4]; if ( BOUNDS( b0, exc->zp0.n_points ) || BOUNDS( b1, exc->zp0.n_points ) || BOUNDS( a0, exc->zp1.n_points ) || BOUNDS( a1, exc->zp1.n_points ) || BOUNDS( point, exc->zp2.n_points ) ) { if ( exc->pedantic_hinting ) exc->error = FT_THROW( Invalid_Reference ); return; } /* Cramer's rule */ dbx = SUB_LONG( exc->zp0.cur[b1].x, exc->zp0.cur[b0].x ); dby = SUB_LONG( exc->zp0.cur[b1].y, exc->zp0.cur[b0].y ); dax = SUB_LONG( exc->zp1.cur[a1].x, exc->zp1.cur[a0].x ); day = SUB_LONG( exc->zp1.cur[a1].y, exc->zp1.cur[a0].y ); dx = SUB_LONG( exc->zp0.cur[b0].x, exc->zp1.cur[a0].x ); dy = SUB_LONG( exc->zp0.cur[b0].y, exc->zp1.cur[a0].y ); discriminant = ADD_LONG( FT_MulDiv( dax, NEG_LONG( dby ), 0x40 ), FT_MulDiv( day, dbx, 0x40 ) ); dotproduct = ADD_LONG( FT_MulDiv( dax, dbx, 0x40 ), FT_MulDiv( day, dby, 0x40 ) ); /* The discriminant above is actually a cross product of vectors */ /* da and db. Together with the dot product, they can be used as */ /* surrogates for sine and cosine of the angle between the vectors. */ /* Indeed, */ /* dotproduct = |da||db|cos(angle) */ /* discriminant = |da||db|sin(angle) . */ /* We use these equations to reject grazing intersections by */ /* thresholding abs(tan(angle)) at 1/19, corresponding to 3 degrees. */ if ( MUL_LONG( 19, FT_ABS( discriminant ) ) > FT_ABS( dotproduct ) ) { val = ADD_LONG( FT_MulDiv( dx, NEG_LONG( dby ), 0x40 ), FT_MulDiv( dy, dbx, 0x40 ) ); R.x = FT_MulDiv( val, dax, discriminant ); R.y = FT_MulDiv( val, day, discriminant ); /* XXX: Block in backward_compatibility and/or post-IUP? */ exc->zp2.cur[point].x = ADD_LONG( exc->zp1.cur[a0].x, R.x ); exc->zp2.cur[point].y = ADD_LONG( exc->zp1.cur[a0].y, R.y ); } else { /* else, take the middle of the middles of A and B */ /* XXX: Block in backward_compatibility and/or post-IUP? */ exc->zp2.cur[point].x = ADD_LONG( ADD_LONG( exc->zp1.cur[a0].x, exc->zp1.cur[a1].x ), ADD_LONG( exc->zp0.cur[b0].x, exc->zp0.cur[b1].x ) ) / 4; exc->zp2.cur[point].y = ADD_LONG( ADD_LONG( exc->zp1.cur[a0].y, exc->zp1.cur[a1].y ), ADD_LONG( exc->zp0.cur[b0].y, exc->zp0.cur[b1].y ) ) / 4; } exc->zp2.tags[point] |= FT_CURVE_TAG_TOUCH_BOTH; }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,476
Ins_IUP( TT_ExecContext exc ) { IUP_WorkerRec V; FT_Byte mask; FT_UInt first_point; /* first point of contour */ FT_UInt end_point; /* end point (last+1) of contour */ FT_UInt first_touched; /* first touched point in contour */ FT_UInt cur_touched; /* current touched point in contour */ FT_UInt point; /* current point */ FT_Short contour; /* current contour */ #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL /* See `ttinterp.h' for details on backward compatibility mode. */ /* Allow IUP until it has been called on both axes. Immediately */ /* return on subsequent ones. */ if ( SUBPIXEL_HINTING_MINIMAL && exc->backward_compatibility ) { if ( exc->iupx_called && exc->iupy_called ) return; if ( exc->opcode & 1 ) exc->iupx_called = TRUE; else exc->iupy_called = TRUE; } #endif /* ignore empty outlines */ if ( exc->pts.n_contours == 0 ) return; if ( exc->opcode & 1 ) { mask = FT_CURVE_TAG_TOUCH_X; V.orgs = exc->pts.org; V.curs = exc->pts.cur; V.orus = exc->pts.orus; } else { mask = FT_CURVE_TAG_TOUCH_Y; V.orgs = (FT_Vector*)( (FT_Pos*)exc->pts.org + 1 ); V.curs = (FT_Vector*)( (FT_Pos*)exc->pts.cur + 1 ); V.orus = (FT_Vector*)( (FT_Pos*)exc->pts.orus + 1 ); } V.max_points = exc->pts.n_points; contour = 0; point = 0; #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY if ( SUBPIXEL_HINTING_INFINALITY && exc->ignore_x_mode ) { exc->iup_called = TRUE; if ( exc->sph_tweak_flags & SPH_TWEAK_SKIP_IUP ) return; } #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ do { end_point = exc->pts.contours[contour] - exc->pts.first_point; first_point = point; if ( BOUNDS( end_point, exc->pts.n_points ) ) end_point = exc->pts.n_points - 1; while ( point <= end_point && ( exc->pts.tags[point] & mask ) == 0 ) point++; if ( point <= end_point ) { first_touched = point; cur_touched = point; point++; while ( point <= end_point ) { if ( ( exc->pts.tags[point] & mask ) != 0 ) { _iup_worker_interpolate( &V, cur_touched + 1, point - 1, cur_touched, point ); cur_touched = point; } point++; } if ( cur_touched == first_touched ) _iup_worker_shift( &V, first_point, end_point, cur_touched ); else { _iup_worker_interpolate( &V, (FT_UShort)( cur_touched + 1 ), end_point, cur_touched, first_touched ); if ( first_touched > 0 ) _iup_worker_interpolate( &V, first_point, first_touched - 1, cur_touched, first_touched ); } } contour++; } while ( contour < exc->pts.n_contours ); }
null
0
Ins_IUP( TT_ExecContext exc ) { IUP_WorkerRec V; FT_Byte mask; FT_UInt first_point; /* first point of contour */ FT_UInt end_point; /* end point (last+1) of contour */ FT_UInt first_touched; /* first touched point in contour */ FT_UInt cur_touched; /* current touched point in contour */ FT_UInt point; /* current point */ FT_Short contour; /* current contour */ #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL /* See `ttinterp.h' for details on backward compatibility mode. */ /* Allow IUP until it has been called on both axes. Immediately */ /* return on subsequent ones. */ if ( SUBPIXEL_HINTING_MINIMAL && exc->backward_compatibility ) { if ( exc->iupx_called && exc->iupy_called ) return; if ( exc->opcode & 1 ) exc->iupx_called = TRUE; else exc->iupy_called = TRUE; } #endif /* ignore empty outlines */ if ( exc->pts.n_contours == 0 ) return; if ( exc->opcode & 1 ) { mask = FT_CURVE_TAG_TOUCH_X; V.orgs = exc->pts.org; V.curs = exc->pts.cur; V.orus = exc->pts.orus; } else { mask = FT_CURVE_TAG_TOUCH_Y; V.orgs = (FT_Vector*)( (FT_Pos*)exc->pts.org + 1 ); V.curs = (FT_Vector*)( (FT_Pos*)exc->pts.cur + 1 ); V.orus = (FT_Vector*)( (FT_Pos*)exc->pts.orus + 1 ); } V.max_points = exc->pts.n_points; contour = 0; point = 0; #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY if ( SUBPIXEL_HINTING_INFINALITY && exc->ignore_x_mode ) { exc->iup_called = TRUE; if ( exc->sph_tweak_flags & SPH_TWEAK_SKIP_IUP ) return; } #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ do { end_point = exc->pts.contours[contour] - exc->pts.first_point; first_point = point; if ( BOUNDS( end_point, exc->pts.n_points ) ) end_point = exc->pts.n_points - 1; while ( point <= end_point && ( exc->pts.tags[point] & mask ) == 0 ) point++; if ( point <= end_point ) { first_touched = point; cur_touched = point; point++; while ( point <= end_point ) { if ( ( exc->pts.tags[point] & mask ) != 0 ) { _iup_worker_interpolate( &V, cur_touched + 1, point - 1, cur_touched, point ); cur_touched = point; } point++; } if ( cur_touched == first_touched ) _iup_worker_shift( &V, first_point, end_point, cur_touched ); else { _iup_worker_interpolate( &V, (FT_UShort)( cur_touched + 1 ), end_point, cur_touched, first_touched ); if ( first_touched > 0 ) _iup_worker_interpolate( &V, first_point, first_touched - 1, cur_touched, first_touched ); } } contour++; } while ( contour < exc->pts.n_contours ); }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,477
Ins_JROF( TT_ExecContext exc, FT_Long* args ) { if ( args[1] == 0 ) Ins_JMPR( exc, args ); }
null
0
Ins_JROF( TT_ExecContext exc, FT_Long* args ) { if ( args[1] == 0 ) Ins_JMPR( exc, args ); }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,478
Ins_LT( FT_Long* args ) { args[0] = ( args[0] < args[1] ); }
null
0
Ins_LT( FT_Long* args ) { args[0] = ( args[0] < args[1] ); }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,479
Ins_LTEQ( FT_Long* args ) { args[0] = ( args[0] <= args[1] ); }
null
0
Ins_LTEQ( FT_Long* args ) { args[0] = ( args[0] <= args[1] ); }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,480
Ins_MAX( FT_Long* args ) { if ( args[1] > args[0] ) args[0] = args[1]; }
null
0
Ins_MAX( FT_Long* args ) { if ( args[1] > args[0] ) args[0] = args[1]; }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,481
Ins_MD( TT_ExecContext exc, FT_Long* args ) { FT_UShort K, L; FT_F26Dot6 D; K = (FT_UShort)args[1]; L = (FT_UShort)args[0]; if ( BOUNDS( L, exc->zp0.n_points ) || BOUNDS( K, exc->zp1.n_points ) ) { if ( exc->pedantic_hinting ) exc->error = FT_THROW( Invalid_Reference ); D = 0; } else { if ( exc->opcode & 1 ) D = PROJECT( exc->zp0.cur + L, exc->zp1.cur + K ); else { /* XXX: UNDOCUMENTED: twilight zone special case */ if ( exc->GS.gep0 == 0 || exc->GS.gep1 == 0 ) { FT_Vector* vec1 = exc->zp0.org + L; FT_Vector* vec2 = exc->zp1.org + K; D = DUALPROJ( vec1, vec2 ); } else { FT_Vector* vec1 = exc->zp0.orus + L; FT_Vector* vec2 = exc->zp1.orus + K; if ( exc->metrics.x_scale == exc->metrics.y_scale ) { /* this should be faster */ D = DUALPROJ( vec1, vec2 ); D = FT_MulFix( D, exc->metrics.x_scale ); } else { FT_Vector vec; vec.x = FT_MulFix( vec1->x - vec2->x, exc->metrics.x_scale ); vec.y = FT_MulFix( vec1->y - vec2->y, exc->metrics.y_scale ); D = FAST_DUALPROJ( &vec ); } } } } #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY /* Disable Type 2 Vacuform Rounds - e.g. Arial Narrow */ if ( SUBPIXEL_HINTING_INFINALITY && exc->ignore_x_mode && FT_ABS( D ) == 64 ) D += 1; #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ args[0] = D; }
null
0
Ins_MD( TT_ExecContext exc, FT_Long* args ) { FT_UShort K, L; FT_F26Dot6 D; K = (FT_UShort)args[1]; L = (FT_UShort)args[0]; if ( BOUNDS( L, exc->zp0.n_points ) || BOUNDS( K, exc->zp1.n_points ) ) { if ( exc->pedantic_hinting ) exc->error = FT_THROW( Invalid_Reference ); D = 0; } else { if ( exc->opcode & 1 ) D = PROJECT( exc->zp0.cur + L, exc->zp1.cur + K ); else { /* XXX: UNDOCUMENTED: twilight zone special case */ if ( exc->GS.gep0 == 0 || exc->GS.gep1 == 0 ) { FT_Vector* vec1 = exc->zp0.org + L; FT_Vector* vec2 = exc->zp1.org + K; D = DUALPROJ( vec1, vec2 ); } else { FT_Vector* vec1 = exc->zp0.orus + L; FT_Vector* vec2 = exc->zp1.orus + K; if ( exc->metrics.x_scale == exc->metrics.y_scale ) { /* this should be faster */ D = DUALPROJ( vec1, vec2 ); D = FT_MulFix( D, exc->metrics.x_scale ); } else { FT_Vector vec; vec.x = FT_MulFix( vec1->x - vec2->x, exc->metrics.x_scale ); vec.y = FT_MulFix( vec1->y - vec2->y, exc->metrics.y_scale ); D = FAST_DUALPROJ( &vec ); } } } } #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY /* Disable Type 2 Vacuform Rounds - e.g. Arial Narrow */ if ( SUBPIXEL_HINTING_INFINALITY && exc->ignore_x_mode && FT_ABS( D ) == 64 ) D += 1; #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ args[0] = D; }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,482
Ins_MDRP( TT_ExecContext exc, FT_Long* args ) { FT_UShort point = 0; FT_F26Dot6 org_dist, distance, minimum_distance; minimum_distance = exc->GS.minimum_distance; #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY if ( SUBPIXEL_HINTING_INFINALITY && exc->ignore_x_mode && exc->GS.freeVector.x != 0 && !( exc->sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) ) minimum_distance = 0; #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ point = (FT_UShort)args[0]; if ( BOUNDS( point, exc->zp1.n_points ) || BOUNDS( exc->GS.rp0, exc->zp0.n_points ) ) { if ( exc->pedantic_hinting ) exc->error = FT_THROW( Invalid_Reference ); goto Fail; } /* XXX: Is there some undocumented feature while in the */ /* twilight zone? */ /* XXX: UNDOCUMENTED: twilight zone special case */ if ( exc->GS.gep0 == 0 || exc->GS.gep1 == 0 ) { FT_Vector* vec1 = &exc->zp1.org[point]; FT_Vector* vec2 = &exc->zp0.org[exc->GS.rp0]; org_dist = DUALPROJ( vec1, vec2 ); } else { FT_Vector* vec1 = &exc->zp1.orus[point]; FT_Vector* vec2 = &exc->zp0.orus[exc->GS.rp0]; if ( exc->metrics.x_scale == exc->metrics.y_scale ) { /* this should be faster */ org_dist = DUALPROJ( vec1, vec2 ); org_dist = FT_MulFix( org_dist, exc->metrics.x_scale ); } else { FT_Vector vec; vec.x = FT_MulFix( SUB_LONG( vec1->x, vec2->x ), exc->metrics.x_scale ); vec.y = FT_MulFix( SUB_LONG( vec1->y, vec2->y ), exc->metrics.y_scale ); org_dist = FAST_DUALPROJ( &vec ); } } /* single width cut-in test */ /* |org_dist - single_width_value| < single_width_cutin */ if ( exc->GS.single_width_cutin > 0 && org_dist < exc->GS.single_width_value + exc->GS.single_width_cutin && org_dist > exc->GS.single_width_value - exc->GS.single_width_cutin ) { if ( org_dist >= 0 ) org_dist = exc->GS.single_width_value; else org_dist = -exc->GS.single_width_value; } /* round flag */ if ( ( exc->opcode & 4 ) != 0 ) { #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY if ( SUBPIXEL_HINTING_INFINALITY && exc->ignore_x_mode && exc->GS.freeVector.x != 0 ) distance = Round_None( exc, org_dist, exc->tt_metrics.compensations[exc->opcode & 3] ); else #endif distance = exc->func_round( exc, org_dist, exc->tt_metrics.compensations[exc->opcode & 3] ); } else distance = Round_None( exc, org_dist, exc->tt_metrics.compensations[exc->opcode & 3] ); /* minimum distance flag */ if ( ( exc->opcode & 8 ) != 0 ) { if ( org_dist >= 0 ) { if ( distance < minimum_distance ) distance = minimum_distance; } else { if ( distance > NEG_LONG( minimum_distance ) ) distance = NEG_LONG( minimum_distance ); } } /* now move the point */ org_dist = PROJECT( exc->zp1.cur + point, exc->zp0.cur + exc->GS.rp0 ); exc->func_move( exc, &exc->zp1, point, SUB_LONG( distance, org_dist ) ); Fail: exc->GS.rp1 = exc->GS.rp0; exc->GS.rp2 = point; if ( ( exc->opcode & 16 ) != 0 ) exc->GS.rp0 = point; }
null
0
Ins_MDRP( TT_ExecContext exc, FT_Long* args ) { FT_UShort point = 0; FT_F26Dot6 org_dist, distance, minimum_distance; minimum_distance = exc->GS.minimum_distance; #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY if ( SUBPIXEL_HINTING_INFINALITY && exc->ignore_x_mode && exc->GS.freeVector.x != 0 && !( exc->sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) ) minimum_distance = 0; #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ point = (FT_UShort)args[0]; if ( BOUNDS( point, exc->zp1.n_points ) || BOUNDS( exc->GS.rp0, exc->zp0.n_points ) ) { if ( exc->pedantic_hinting ) exc->error = FT_THROW( Invalid_Reference ); goto Fail; } /* XXX: Is there some undocumented feature while in the */ /* twilight zone? */ /* XXX: UNDOCUMENTED: twilight zone special case */ if ( exc->GS.gep0 == 0 || exc->GS.gep1 == 0 ) { FT_Vector* vec1 = &exc->zp1.org[point]; FT_Vector* vec2 = &exc->zp0.org[exc->GS.rp0]; org_dist = DUALPROJ( vec1, vec2 ); } else { FT_Vector* vec1 = &exc->zp1.orus[point]; FT_Vector* vec2 = &exc->zp0.orus[exc->GS.rp0]; if ( exc->metrics.x_scale == exc->metrics.y_scale ) { /* this should be faster */ org_dist = DUALPROJ( vec1, vec2 ); org_dist = FT_MulFix( org_dist, exc->metrics.x_scale ); } else { FT_Vector vec; vec.x = FT_MulFix( SUB_LONG( vec1->x, vec2->x ), exc->metrics.x_scale ); vec.y = FT_MulFix( SUB_LONG( vec1->y, vec2->y ), exc->metrics.y_scale ); org_dist = FAST_DUALPROJ( &vec ); } } /* single width cut-in test */ /* |org_dist - single_width_value| < single_width_cutin */ if ( exc->GS.single_width_cutin > 0 && org_dist < exc->GS.single_width_value + exc->GS.single_width_cutin && org_dist > exc->GS.single_width_value - exc->GS.single_width_cutin ) { if ( org_dist >= 0 ) org_dist = exc->GS.single_width_value; else org_dist = -exc->GS.single_width_value; } /* round flag */ if ( ( exc->opcode & 4 ) != 0 ) { #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY if ( SUBPIXEL_HINTING_INFINALITY && exc->ignore_x_mode && exc->GS.freeVector.x != 0 ) distance = Round_None( exc, org_dist, exc->tt_metrics.compensations[exc->opcode & 3] ); else #endif distance = exc->func_round( exc, org_dist, exc->tt_metrics.compensations[exc->opcode & 3] ); } else distance = Round_None( exc, org_dist, exc->tt_metrics.compensations[exc->opcode & 3] ); /* minimum distance flag */ if ( ( exc->opcode & 8 ) != 0 ) { if ( org_dist >= 0 ) { if ( distance < minimum_distance ) distance = minimum_distance; } else { if ( distance > NEG_LONG( minimum_distance ) ) distance = NEG_LONG( minimum_distance ); } } /* now move the point */ org_dist = PROJECT( exc->zp1.cur + point, exc->zp0.cur + exc->GS.rp0 ); exc->func_move( exc, &exc->zp1, point, SUB_LONG( distance, org_dist ) ); Fail: exc->GS.rp1 = exc->GS.rp0; exc->GS.rp2 = point; if ( ( exc->opcode & 16 ) != 0 ) exc->GS.rp0 = point; }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,483
Ins_MIAP( TT_ExecContext exc, FT_Long* args ) { FT_ULong cvtEntry; FT_UShort point; FT_F26Dot6 distance; FT_F26Dot6 org_dist; FT_F26Dot6 control_value_cutin; control_value_cutin = exc->GS.control_value_cutin; cvtEntry = (FT_ULong)args[1]; point = (FT_UShort)args[0]; #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY if ( SUBPIXEL_HINTING_INFINALITY && exc->ignore_x_mode && exc->GS.freeVector.x != 0 && exc->GS.freeVector.y == 0 && !( exc->sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) ) control_value_cutin = 0; #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ if ( BOUNDS( point, exc->zp0.n_points ) || BOUNDSL( cvtEntry, exc->cvtSize ) ) { if ( exc->pedantic_hinting ) exc->error = FT_THROW( Invalid_Reference ); goto Fail; } /* UNDOCUMENTED! */ /* */ /* The behaviour of an MIAP instruction is quite different when used */ /* in the twilight zone. */ /* */ /* First, no control value cut-in 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 invalid according to the specification. */ /* */ /* We implement it with a special sequence for the twilight zone. */ /* This is a bad hack, but it seems to work. */ /* */ /* Confirmed by Greg Hitchcock. */ distance = exc->func_read_cvt( exc, cvtEntry ); if ( exc->GS.gep0 == 0 ) /* If in twilight zone */ { #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY /* Only adjust if not in sph_compatibility_mode or ignore_x_mode. */ /* Determined via experimentation and may be incorrect... */ if ( !( SUBPIXEL_HINTING_INFINALITY && ( exc->ignore_x_mode && exc->face->sph_compatibility_mode ) ) ) #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ exc->zp0.org[point].x = TT_MulFix14( distance, exc->GS.freeVector.x ); exc->zp0.org[point].y = TT_MulFix14( distance, exc->GS.freeVector.y ), exc->zp0.cur[point] = exc->zp0.org[point]; } #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY if ( SUBPIXEL_HINTING_INFINALITY && exc->ignore_x_mode && ( exc->sph_tweak_flags & SPH_TWEAK_MIAP_HACK ) && distance > 0 && exc->GS.freeVector.y != 0 ) distance = 0; #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ org_dist = FAST_PROJECT( &exc->zp0.cur[point] ); if ( ( exc->opcode & 1 ) != 0 ) /* rounding and control cut-in flag */ { if ( FT_ABS( distance - org_dist ) > control_value_cutin ) distance = org_dist; #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY if ( SUBPIXEL_HINTING_INFINALITY && exc->ignore_x_mode && exc->GS.freeVector.x != 0 ) distance = Round_None( exc, distance, exc->tt_metrics.compensations[0] ); else #endif distance = exc->func_round( exc, distance, exc->tt_metrics.compensations[0] ); } exc->func_move( exc, &exc->zp0, point, SUB_LONG( distance, org_dist ) ); Fail: exc->GS.rp0 = point; exc->GS.rp1 = point; }
null
0
Ins_MIAP( TT_ExecContext exc, FT_Long* args ) { FT_ULong cvtEntry; FT_UShort point; FT_F26Dot6 distance; FT_F26Dot6 org_dist; FT_F26Dot6 control_value_cutin; control_value_cutin = exc->GS.control_value_cutin; cvtEntry = (FT_ULong)args[1]; point = (FT_UShort)args[0]; #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY if ( SUBPIXEL_HINTING_INFINALITY && exc->ignore_x_mode && exc->GS.freeVector.x != 0 && exc->GS.freeVector.y == 0 && !( exc->sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) ) control_value_cutin = 0; #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ if ( BOUNDS( point, exc->zp0.n_points ) || BOUNDSL( cvtEntry, exc->cvtSize ) ) { if ( exc->pedantic_hinting ) exc->error = FT_THROW( Invalid_Reference ); goto Fail; } /* UNDOCUMENTED! */ /* */ /* The behaviour of an MIAP instruction is quite different when used */ /* in the twilight zone. */ /* */ /* First, no control value cut-in 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 invalid according to the specification. */ /* */ /* We implement it with a special sequence for the twilight zone. */ /* This is a bad hack, but it seems to work. */ /* */ /* Confirmed by Greg Hitchcock. */ distance = exc->func_read_cvt( exc, cvtEntry ); if ( exc->GS.gep0 == 0 ) /* If in twilight zone */ { #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY /* Only adjust if not in sph_compatibility_mode or ignore_x_mode. */ /* Determined via experimentation and may be incorrect... */ if ( !( SUBPIXEL_HINTING_INFINALITY && ( exc->ignore_x_mode && exc->face->sph_compatibility_mode ) ) ) #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ exc->zp0.org[point].x = TT_MulFix14( distance, exc->GS.freeVector.x ); exc->zp0.org[point].y = TT_MulFix14( distance, exc->GS.freeVector.y ), exc->zp0.cur[point] = exc->zp0.org[point]; } #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY if ( SUBPIXEL_HINTING_INFINALITY && exc->ignore_x_mode && ( exc->sph_tweak_flags & SPH_TWEAK_MIAP_HACK ) && distance > 0 && exc->GS.freeVector.y != 0 ) distance = 0; #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ org_dist = FAST_PROJECT( &exc->zp0.cur[point] ); if ( ( exc->opcode & 1 ) != 0 ) /* rounding and control cut-in flag */ { if ( FT_ABS( distance - org_dist ) > control_value_cutin ) distance = org_dist; #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY if ( SUBPIXEL_HINTING_INFINALITY && exc->ignore_x_mode && exc->GS.freeVector.x != 0 ) distance = Round_None( exc, distance, exc->tt_metrics.compensations[0] ); else #endif distance = exc->func_round( exc, distance, exc->tt_metrics.compensations[0] ); } exc->func_move( exc, &exc->zp0, point, SUB_LONG( distance, org_dist ) ); Fail: exc->GS.rp0 = point; exc->GS.rp1 = point; }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,484
Ins_MIN( FT_Long* args ) { if ( args[1] < args[0] ) args[0] = args[1]; }
null
0
Ins_MIN( FT_Long* args ) { if ( args[1] < args[0] ) args[0] = args[1]; }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,485
Ins_MINDEX( TT_ExecContext exc, FT_Long* args ) { FT_Long L, K; L = args[0]; if ( L <= 0 || L > exc->args ) { if ( exc->pedantic_hinting ) exc->error = FT_THROW( Invalid_Reference ); } else { K = exc->stack[exc->args - L]; FT_ARRAY_MOVE( &exc->stack[exc->args - L ], &exc->stack[exc->args - L + 1], ( L - 1 ) ); exc->stack[exc->args - 1] = K; } }
null
0
Ins_MINDEX( TT_ExecContext exc, FT_Long* args ) { FT_Long L, K; L = args[0]; if ( L <= 0 || L > exc->args ) { if ( exc->pedantic_hinting ) exc->error = FT_THROW( Invalid_Reference ); } else { K = exc->stack[exc->args - L]; FT_ARRAY_MOVE( &exc->stack[exc->args - L ], &exc->stack[exc->args - L + 1], ( L - 1 ) ); exc->stack[exc->args - 1] = K; } }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,486
Ins_MIRP( TT_ExecContext exc, FT_Long* args ) { FT_UShort point; FT_ULong cvtEntry; FT_F26Dot6 cvt_dist, distance, cur_dist, org_dist, control_value_cutin, minimum_distance; #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY FT_Int B1 = 0; /* pacify compiler */ FT_Int B2 = 0; FT_Bool reverse_move = FALSE; #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ minimum_distance = exc->GS.minimum_distance; control_value_cutin = exc->GS.control_value_cutin; point = (FT_UShort)args[0]; cvtEntry = (FT_ULong)( args[1] + 1 ); #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY if ( SUBPIXEL_HINTING_INFINALITY && exc->ignore_x_mode && exc->GS.freeVector.x != 0 && !( exc->sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) ) control_value_cutin = minimum_distance = 0; #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ /* XXX: UNDOCUMENTED! cvt[-1] = 0 always */ if ( BOUNDS( point, exc->zp1.n_points ) || BOUNDSL( cvtEntry, exc->cvtSize + 1 ) || BOUNDS( exc->GS.rp0, exc->zp0.n_points ) ) { if ( exc->pedantic_hinting ) exc->error = FT_THROW( Invalid_Reference ); goto Fail; } if ( !cvtEntry ) cvt_dist = 0; else cvt_dist = exc->func_read_cvt( exc, cvtEntry - 1 ); /* single width test */ if ( FT_ABS( cvt_dist - exc->GS.single_width_value ) < exc->GS.single_width_cutin ) { if ( cvt_dist >= 0 ) cvt_dist = exc->GS.single_width_value; else cvt_dist = -exc->GS.single_width_value; } /* UNDOCUMENTED! The MS rasterizer does that with */ /* twilight points (confirmed by Greg Hitchcock) */ if ( exc->GS.gep1 == 0 ) { exc->zp1.org[point].x = exc->zp0.org[exc->GS.rp0].x + TT_MulFix14( cvt_dist, exc->GS.freeVector.x ); exc->zp1.org[point].y = exc->zp0.org[exc->GS.rp0].y + TT_MulFix14( cvt_dist, exc->GS.freeVector.y ); exc->zp1.cur[point] = exc->zp1.org[point]; } org_dist = DUALPROJ( &exc->zp1.org[point], &exc->zp0.org[exc->GS.rp0] ); cur_dist = PROJECT ( &exc->zp1.cur[point], &exc->zp0.cur[exc->GS.rp0] ); /* auto-flip test */ if ( exc->GS.auto_flip ) { if ( ( org_dist ^ cvt_dist ) < 0 ) cvt_dist = -cvt_dist; } #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY if ( SUBPIXEL_HINTING_INFINALITY && exc->ignore_x_mode && exc->GS.freeVector.y != 0 && ( exc->sph_tweak_flags & SPH_TWEAK_TIMES_NEW_ROMAN_HACK ) ) { if ( cur_dist < -64 ) cvt_dist -= 16; else if ( cur_dist > 64 && cur_dist < 84 ) cvt_dist += 32; } #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ /* control value cut-in and round */ if ( ( exc->opcode & 4 ) != 0 ) { /* XXX: UNDOCUMENTED! Only perform cut-in test when both points */ /* refer to the same zone. */ if ( exc->GS.gep0 == exc->GS.gep1 ) { /* XXX: According to Greg Hitchcock, the following wording is */ /* the right one: */ /* */ /* When the absolute difference between the value in */ /* the table [CVT] and the measurement directly from */ /* the outline is _greater_ than the cut_in value, the */ /* outline measurement is used. */ /* */ /* This is from `instgly.doc'. The description in */ /* `ttinst2.doc', version 1.66, is thus incorrect since */ /* it implies `>=' instead of `>'. */ if ( FT_ABS( cvt_dist - org_dist ) > control_value_cutin ) cvt_dist = org_dist; } distance = exc->func_round( exc, cvt_dist, exc->tt_metrics.compensations[exc->opcode & 3] ); } else { #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY /* do cvt cut-in always in MIRP for sph */ if ( SUBPIXEL_HINTING_INFINALITY && exc->ignore_x_mode && exc->GS.gep0 == exc->GS.gep1 ) { if ( FT_ABS( cvt_dist - org_dist ) > control_value_cutin ) cvt_dist = org_dist; } #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ distance = Round_None( exc, cvt_dist, exc->tt_metrics.compensations[exc->opcode & 3] ); } /* minimum distance test */ if ( ( exc->opcode & 8 ) != 0 ) { if ( org_dist >= 0 ) { if ( distance < minimum_distance ) distance = minimum_distance; } else { if ( distance > NEG_LONG( minimum_distance ) ) distance = NEG_LONG( minimum_distance ); } } #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY if ( SUBPIXEL_HINTING_INFINALITY ) { B1 = exc->zp1.cur[point].y; /* Round moves if necessary */ if ( exc->ignore_x_mode && exc->GS.freeVector.y != 0 && ( exc->sph_tweak_flags & SPH_TWEAK_ROUND_NONPIXEL_Y_MOVES ) ) distance = FT_PIX_ROUND( B1 + distance - cur_dist ) - B1 + cur_dist; if ( exc->ignore_x_mode && exc->GS.freeVector.y != 0 && ( exc->opcode & 16 ) == 0 && ( exc->opcode & 8 ) == 0 && ( exc->sph_tweak_flags & SPH_TWEAK_COURIER_NEW_2_HACK ) ) distance += 64; } #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ exc->func_move( exc, &exc->zp1, point, SUB_LONG( distance, cur_dist ) ); #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY if ( SUBPIXEL_HINTING_INFINALITY ) { B2 = exc->zp1.cur[point].y; /* Reverse move if necessary */ if ( exc->ignore_x_mode ) { if ( exc->face->sph_compatibility_mode && exc->GS.freeVector.y != 0 && ( B1 & 63 ) == 0 && ( B2 & 63 ) != 0 ) reverse_move = TRUE; if ( ( exc->sph_tweak_flags & SPH_TWEAK_SKIP_NONPIXEL_Y_MOVES ) && exc->GS.freeVector.y != 0 && ( B2 & 63 ) != 0 && ( B1 & 63 ) != 0 ) reverse_move = TRUE; } if ( reverse_move ) exc->func_move( exc, &exc->zp1, point, SUB_LONG( cur_dist, distance ) ); } #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ Fail: exc->GS.rp1 = exc->GS.rp0; if ( ( exc->opcode & 16 ) != 0 ) exc->GS.rp0 = point; exc->GS.rp2 = point; }
null
0
Ins_MIRP( TT_ExecContext exc, FT_Long* args ) { FT_UShort point; FT_ULong cvtEntry; FT_F26Dot6 cvt_dist, distance, cur_dist, org_dist, control_value_cutin, minimum_distance; #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY FT_Int B1 = 0; /* pacify compiler */ FT_Int B2 = 0; FT_Bool reverse_move = FALSE; #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ minimum_distance = exc->GS.minimum_distance; control_value_cutin = exc->GS.control_value_cutin; point = (FT_UShort)args[0]; cvtEntry = (FT_ULong)( args[1] + 1 ); #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY if ( SUBPIXEL_HINTING_INFINALITY && exc->ignore_x_mode && exc->GS.freeVector.x != 0 && !( exc->sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) ) control_value_cutin = minimum_distance = 0; #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ /* XXX: UNDOCUMENTED! cvt[-1] = 0 always */ if ( BOUNDS( point, exc->zp1.n_points ) || BOUNDSL( cvtEntry, exc->cvtSize + 1 ) || BOUNDS( exc->GS.rp0, exc->zp0.n_points ) ) { if ( exc->pedantic_hinting ) exc->error = FT_THROW( Invalid_Reference ); goto Fail; } if ( !cvtEntry ) cvt_dist = 0; else cvt_dist = exc->func_read_cvt( exc, cvtEntry - 1 ); /* single width test */ if ( FT_ABS( cvt_dist - exc->GS.single_width_value ) < exc->GS.single_width_cutin ) { if ( cvt_dist >= 0 ) cvt_dist = exc->GS.single_width_value; else cvt_dist = -exc->GS.single_width_value; } /* UNDOCUMENTED! The MS rasterizer does that with */ /* twilight points (confirmed by Greg Hitchcock) */ if ( exc->GS.gep1 == 0 ) { exc->zp1.org[point].x = exc->zp0.org[exc->GS.rp0].x + TT_MulFix14( cvt_dist, exc->GS.freeVector.x ); exc->zp1.org[point].y = exc->zp0.org[exc->GS.rp0].y + TT_MulFix14( cvt_dist, exc->GS.freeVector.y ); exc->zp1.cur[point] = exc->zp1.org[point]; } org_dist = DUALPROJ( &exc->zp1.org[point], &exc->zp0.org[exc->GS.rp0] ); cur_dist = PROJECT ( &exc->zp1.cur[point], &exc->zp0.cur[exc->GS.rp0] ); /* auto-flip test */ if ( exc->GS.auto_flip ) { if ( ( org_dist ^ cvt_dist ) < 0 ) cvt_dist = -cvt_dist; } #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY if ( SUBPIXEL_HINTING_INFINALITY && exc->ignore_x_mode && exc->GS.freeVector.y != 0 && ( exc->sph_tweak_flags & SPH_TWEAK_TIMES_NEW_ROMAN_HACK ) ) { if ( cur_dist < -64 ) cvt_dist -= 16; else if ( cur_dist > 64 && cur_dist < 84 ) cvt_dist += 32; } #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ /* control value cut-in and round */ if ( ( exc->opcode & 4 ) != 0 ) { /* XXX: UNDOCUMENTED! Only perform cut-in test when both points */ /* refer to the same zone. */ if ( exc->GS.gep0 == exc->GS.gep1 ) { /* XXX: According to Greg Hitchcock, the following wording is */ /* the right one: */ /* */ /* When the absolute difference between the value in */ /* the table [CVT] and the measurement directly from */ /* the outline is _greater_ than the cut_in value, the */ /* outline measurement is used. */ /* */ /* This is from `instgly.doc'. The description in */ /* `ttinst2.doc', version 1.66, is thus incorrect since */ /* it implies `>=' instead of `>'. */ if ( FT_ABS( cvt_dist - org_dist ) > control_value_cutin ) cvt_dist = org_dist; } distance = exc->func_round( exc, cvt_dist, exc->tt_metrics.compensations[exc->opcode & 3] ); } else { #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY /* do cvt cut-in always in MIRP for sph */ if ( SUBPIXEL_HINTING_INFINALITY && exc->ignore_x_mode && exc->GS.gep0 == exc->GS.gep1 ) { if ( FT_ABS( cvt_dist - org_dist ) > control_value_cutin ) cvt_dist = org_dist; } #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ distance = Round_None( exc, cvt_dist, exc->tt_metrics.compensations[exc->opcode & 3] ); } /* minimum distance test */ if ( ( exc->opcode & 8 ) != 0 ) { if ( org_dist >= 0 ) { if ( distance < minimum_distance ) distance = minimum_distance; } else { if ( distance > NEG_LONG( minimum_distance ) ) distance = NEG_LONG( minimum_distance ); } } #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY if ( SUBPIXEL_HINTING_INFINALITY ) { B1 = exc->zp1.cur[point].y; /* Round moves if necessary */ if ( exc->ignore_x_mode && exc->GS.freeVector.y != 0 && ( exc->sph_tweak_flags & SPH_TWEAK_ROUND_NONPIXEL_Y_MOVES ) ) distance = FT_PIX_ROUND( B1 + distance - cur_dist ) - B1 + cur_dist; if ( exc->ignore_x_mode && exc->GS.freeVector.y != 0 && ( exc->opcode & 16 ) == 0 && ( exc->opcode & 8 ) == 0 && ( exc->sph_tweak_flags & SPH_TWEAK_COURIER_NEW_2_HACK ) ) distance += 64; } #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ exc->func_move( exc, &exc->zp1, point, SUB_LONG( distance, cur_dist ) ); #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY if ( SUBPIXEL_HINTING_INFINALITY ) { B2 = exc->zp1.cur[point].y; /* Reverse move if necessary */ if ( exc->ignore_x_mode ) { if ( exc->face->sph_compatibility_mode && exc->GS.freeVector.y != 0 && ( B1 & 63 ) == 0 && ( B2 & 63 ) != 0 ) reverse_move = TRUE; if ( ( exc->sph_tweak_flags & SPH_TWEAK_SKIP_NONPIXEL_Y_MOVES ) && exc->GS.freeVector.y != 0 && ( B2 & 63 ) != 0 && ( B1 & 63 ) != 0 ) reverse_move = TRUE; } if ( reverse_move ) exc->func_move( exc, &exc->zp1, point, SUB_LONG( cur_dist, distance ) ); } #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ Fail: exc->GS.rp1 = exc->GS.rp0; if ( ( exc->opcode & 16 ) != 0 ) exc->GS.rp0 = point; exc->GS.rp2 = point; }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,487
Ins_MPPEM( TT_ExecContext exc, FT_Long* args ) { args[0] = exc->func_cur_ppem( exc ); }
null
0
Ins_MPPEM( TT_ExecContext exc, FT_Long* args ) { args[0] = exc->func_cur_ppem( exc ); }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,488
Ins_MPS( TT_ExecContext exc, FT_Long* args ) { if ( NO_SUBPIXEL_HINTING ) { /* Microsoft's GDI bytecode interpreter always returns value 12; */ /* we return the current PPEM value instead. */ args[0] = exc->func_cur_ppem( exc ); } else { /* A possible practical application of the MPS instruction is to */ /* implement optical scaling and similar features, which should be */ /* based on perceptual attributes, thus independent of the */ /* resolution. */ args[0] = exc->pointSize; } }
null
0
Ins_MPS( TT_ExecContext exc, FT_Long* args ) { if ( NO_SUBPIXEL_HINTING ) { /* Microsoft's GDI bytecode interpreter always returns value 12; */ /* we return the current PPEM value instead. */ args[0] = exc->func_cur_ppem( exc ); } else { /* A possible practical application of the MPS instruction is to */ /* implement optical scaling and similar features, which should be */ /* based on perceptual attributes, thus independent of the */ /* resolution. */ args[0] = exc->pointSize; } }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,489
Ins_MSIRP( TT_ExecContext exc, FT_Long* args ) { FT_UShort point = 0; FT_F26Dot6 distance; #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY FT_F26Dot6 control_value_cutin = 0; if ( SUBPIXEL_HINTING_INFINALITY ) { control_value_cutin = exc->GS.control_value_cutin; if ( exc->ignore_x_mode && exc->GS.freeVector.x != 0 && !( exc->sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) ) control_value_cutin = 0; } #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ point = (FT_UShort)args[0]; if ( BOUNDS( point, exc->zp1.n_points ) || BOUNDS( exc->GS.rp0, exc->zp0.n_points ) ) { if ( exc->pedantic_hinting ) exc->error = FT_THROW( Invalid_Reference ); return; } /* UNDOCUMENTED! The MS rasterizer does that with */ /* twilight points (confirmed by Greg Hitchcock) */ if ( exc->GS.gep1 == 0 ) { exc->zp1.org[point] = exc->zp0.org[exc->GS.rp0]; exc->func_move_orig( exc, &exc->zp1, point, args[1] ); exc->zp1.cur[point] = exc->zp1.org[point]; } distance = PROJECT( exc->zp1.cur + point, exc->zp0.cur + exc->GS.rp0 ); #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY /* subpixel hinting - make MSIRP respect CVT cut-in; */ if ( SUBPIXEL_HINTING_INFINALITY && exc->ignore_x_mode && exc->GS.freeVector.x != 0 && FT_ABS( SUB_LONG( distance, args[1] ) ) >= control_value_cutin ) distance = args[1]; #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ exc->func_move( exc, &exc->zp1, point, SUB_LONG( args[1], distance ) ); exc->GS.rp1 = exc->GS.rp0; exc->GS.rp2 = point; if ( ( exc->opcode & 1 ) != 0 ) exc->GS.rp0 = point; }
null
0
Ins_MSIRP( TT_ExecContext exc, FT_Long* args ) { FT_UShort point = 0; FT_F26Dot6 distance; #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY FT_F26Dot6 control_value_cutin = 0; if ( SUBPIXEL_HINTING_INFINALITY ) { control_value_cutin = exc->GS.control_value_cutin; if ( exc->ignore_x_mode && exc->GS.freeVector.x != 0 && !( exc->sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) ) control_value_cutin = 0; } #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ point = (FT_UShort)args[0]; if ( BOUNDS( point, exc->zp1.n_points ) || BOUNDS( exc->GS.rp0, exc->zp0.n_points ) ) { if ( exc->pedantic_hinting ) exc->error = FT_THROW( Invalid_Reference ); return; } /* UNDOCUMENTED! The MS rasterizer does that with */ /* twilight points (confirmed by Greg Hitchcock) */ if ( exc->GS.gep1 == 0 ) { exc->zp1.org[point] = exc->zp0.org[exc->GS.rp0]; exc->func_move_orig( exc, &exc->zp1, point, args[1] ); exc->zp1.cur[point] = exc->zp1.org[point]; } distance = PROJECT( exc->zp1.cur + point, exc->zp0.cur + exc->GS.rp0 ); #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY /* subpixel hinting - make MSIRP respect CVT cut-in; */ if ( SUBPIXEL_HINTING_INFINALITY && exc->ignore_x_mode && exc->GS.freeVector.x != 0 && FT_ABS( SUB_LONG( distance, args[1] ) ) >= control_value_cutin ) distance = args[1]; #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ exc->func_move( exc, &exc->zp1, point, SUB_LONG( args[1], distance ) ); exc->GS.rp1 = exc->GS.rp0; exc->GS.rp2 = point; if ( ( exc->opcode & 1 ) != 0 ) exc->GS.rp0 = point; }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,490
Ins_MUL( FT_Long* args ) { args[0] = FT_MulDiv( args[0], args[1], 64L ); }
null
0
Ins_MUL( FT_Long* args ) { args[0] = FT_MulDiv( args[0], args[1], 64L ); }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,491
Ins_NEG( FT_Long* args ) { args[0] = NEG_LONG( args[0] ); }
null
0
Ins_NEG( FT_Long* args ) { args[0] = NEG_LONG( args[0] ); }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,492
Ins_NEQ( FT_Long* args ) { args[0] = ( args[0] != args[1] ); }
null
0
Ins_NEQ( FT_Long* args ) { args[0] = ( args[0] != args[1] ); }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,493
Ins_NOT( FT_Long* args ) { args[0] = !args[0]; }
null
0
Ins_NOT( FT_Long* args ) { args[0] = !args[0]; }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,494
Ins_NPUSHW( TT_ExecContext exc, FT_Long* args ) { FT_UShort L, K; L = (FT_UShort)exc->code[exc->IP + 1]; if ( BOUNDS( L, exc->stackSize + 1 - exc->top ) ) { exc->error = FT_THROW( Stack_Overflow ); return; } exc->IP += 2; for ( K = 0; K < L; K++ ) args[K] = GetShortIns( exc ); exc->step_ins = FALSE; exc->new_top += L; }
null
0
Ins_NPUSHW( TT_ExecContext exc, FT_Long* args ) { FT_UShort L, K; L = (FT_UShort)exc->code[exc->IP + 1]; if ( BOUNDS( L, exc->stackSize + 1 - exc->top ) ) { exc->error = FT_THROW( Stack_Overflow ); return; } exc->IP += 2; for ( K = 0; K < L; K++ ) args[K] = GetShortIns( exc ); exc->step_ins = FALSE; exc->new_top += L; }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,495
Ins_ODD( TT_ExecContext exc, FT_Long* args ) { args[0] = ( ( exc->func_round( exc, args[0], 0 ) & 127 ) == 64 ); }
null
0
Ins_ODD( TT_ExecContext exc, FT_Long* args ) { args[0] = ( ( exc->func_round( exc, args[0], 0 ) & 127 ) == 64 ); }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,496
Ins_OR( FT_Long* args ) { args[0] = ( args[0] || args[1] ); }
null
0
Ins_OR( FT_Long* args ) { args[0] = ( args[0] || args[1] ); }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,497
Ins_POP( void ) { /* nothing to do */ }
null
0
Ins_POP( void ) { /* nothing to do */ }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,498
Ins_PUSHB( TT_ExecContext exc, FT_Long* args ) { FT_UShort L, K; L = (FT_UShort)( exc->opcode - 0xB0 + 1 ); if ( BOUNDS( L, exc->stackSize + 1 - exc->top ) ) { exc->error = FT_THROW( Stack_Overflow ); return; } for ( K = 1; K <= L; K++ ) args[K - 1] = exc->code[exc->IP + K]; }
null
0
Ins_PUSHB( TT_ExecContext exc, FT_Long* args ) { FT_UShort L, K; L = (FT_UShort)( exc->opcode - 0xB0 + 1 ); if ( BOUNDS( L, exc->stackSize + 1 - exc->top ) ) { exc->error = FT_THROW( Stack_Overflow ); return; } for ( K = 1; K <= L; K++ ) args[K - 1] = exc->code[exc->IP + K]; }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null
8,499
Ins_PUSHW( TT_ExecContext exc, FT_Long* args ) { FT_UShort L, K; L = (FT_UShort)( exc->opcode - 0xB8 + 1 ); if ( BOUNDS( L, exc->stackSize + 1 - exc->top ) ) { exc->error = FT_THROW( Stack_Overflow ); return; } exc->IP++; for ( K = 0; K < L; K++ ) args[K] = GetShortIns( exc ); exc->step_ins = FALSE; }
null
0
Ins_PUSHW( TT_ExecContext exc, FT_Long* args ) { FT_UShort L, K; L = (FT_UShort)( exc->opcode - 0xB8 + 1 ); if ( BOUNDS( L, exc->stackSize + 1 - exc->top ) ) { exc->error = FT_THROW( Stack_Overflow ); return; } exc->IP++; for ( K = 0; K < L; K++ ) args[K] = GetShortIns( exc ); exc->step_ins = FALSE; }
@@ -7532,8 +7532,16 @@ return; } - for ( i = 0; i < num_axes; i++ ) - args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + if ( coords ) + { + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + else + { + for ( i = 0; i < num_axes; i++ ) + args[i] = 0; + } }
CWE-476
null
null