project
stringclasses
633 values
commit_id
stringlengths
7
81
target
int64
0
1
func
stringlengths
5
484k
cwe
stringclasses
131 values
big_vul_idx
float64
0
189k
idx
int64
0
522k
hash
stringlengths
34
39
size
float64
1
24k
message
stringlengths
0
11.5k
dataset
stringclasses
1 value
haproxy
58df5aea0a0c926b2238f65908f5e9f83d1cca25
0
static int dns_build_query(int query_id, int query_type, unsigned int accepted_payload_size, char *hostname_dn, int hostname_dn_len, char *buf, int bufsize) { struct dns_header dns_hdr; struct dns_question qinfo; struct dns_additional_record edns; char *p = buf; if (sizeof(dns_hdr) + sizeof(qinfo) + sizeof(edns) + hostname_dn_len >= bufsize) return -1; memset(buf, 0, bufsize); /* Set dns query headers */ dns_hdr.id = (unsigned short) htons(query_id); dns_hdr.flags = htons(0x0100); /* qr=0, opcode=0, aa=0, tc=0, rd=1, ra=0, z=0, rcode=0 */ dns_hdr.qdcount = htons(1); /* 1 question */ dns_hdr.ancount = 0; dns_hdr.nscount = 0; dns_hdr.arcount = htons(1); memcpy(p, &dns_hdr, sizeof(dns_hdr)); p += sizeof(dns_hdr); /* Set up query hostname */ memcpy(p, hostname_dn, hostname_dn_len); p += hostname_dn_len; *p++ = 0; /* Set up query info (type and class) */ qinfo.qtype = htons(query_type); qinfo.qclass = htons(DNS_RCLASS_IN); memcpy(p, &qinfo, sizeof(qinfo)); p += sizeof(qinfo); /* Set the DNS extension */ edns.name = 0; edns.type = htons(DNS_RTYPE_OPT); edns.udp_payload_size = htons(accepted_payload_size); edns.extension = 0; edns.data_length = 0; memcpy(p, &edns, sizeof(edns)); p += sizeof(edns); return (p - buf); }
CWE-835
704
11,334
264170279913195981685692742444108647276
null
null
null
haproxy
58df5aea0a0c926b2238f65908f5e9f83d1cca25
0
static void dns_check_dns_response(struct dns_resolution *res) { struct dns_resolvers *resolvers = res->resolvers; struct dns_requester *req, *reqback; struct dns_answer_item *item, *itemback; struct server *srv; struct dns_srvrq *srvrq; list_for_each_entry_safe(item, itemback, &res->response.answer_list, list) { /* Remove obsolete items */ if ((item->last_seen + resolvers->hold.obsolete / 1000) < now.tv_sec) { if (item->type != DNS_RTYPE_SRV) goto rm_obselete_item; list_for_each_entry_safe(req, reqback, &res->requesters, list) { if ((srvrq = objt_dns_srvrq(req->owner)) == NULL) continue; /* Remove any associated server */ for (srv = srvrq->proxy->srv; srv != NULL; srv = srv->next) { HA_SPIN_LOCK(SERVER_LOCK, &srv->lock); if (srv->srvrq == srvrq && srv->svc_port == item->port && item->data_len == srv->hostname_dn_len && !memcmp(srv->hostname_dn, item->target, item->data_len)) { snr_update_srv_status(srv, 1); free(srv->hostname); free(srv->hostname_dn); srv->hostname = NULL; srv->hostname_dn = NULL; srv->hostname_dn_len = 0; dns_unlink_resolution(srv->dns_requester); } HA_SPIN_UNLOCK(SERVER_LOCK, &srv->lock); } } rm_obselete_item: LIST_DEL(&item->list); pool_free(dns_answer_item_pool, item); continue; } if (item->type != DNS_RTYPE_SRV) continue; /* Now process SRV records */ list_for_each_entry_safe(req, reqback, &res->requesters, list) { if ((srvrq = objt_dns_srvrq(req->owner)) == NULL) continue; /* Check if a server already uses that hostname */ for (srv = srvrq->proxy->srv; srv != NULL; srv = srv->next) { HA_SPIN_LOCK(SERVER_LOCK, &srv->lock); if (srv->srvrq == srvrq && srv->svc_port == item->port && item->data_len == srv->hostname_dn_len && !memcmp(srv->hostname_dn, item->target, item->data_len)) { int ha_weight; /* Make sure weight is at least 1, so * that the server will be used. */ ha_weight = item->weight / 256 + 1; if (srv->uweight != ha_weight) { char weight[9]; snprintf(weight, sizeof(weight), "%d", ha_weight); server_parse_weight_change_request(srv, weight); } HA_SPIN_UNLOCK(SERVER_LOCK, &srv->lock); break; } HA_SPIN_UNLOCK(SERVER_LOCK, &srv->lock); } if (srv) continue; /* If not, try to find a server with undefined hostname */ for (srv = srvrq->proxy->srv; srv != NULL; srv = srv->next) { HA_SPIN_LOCK(SERVER_LOCK, &srv->lock); if (srv->srvrq == srvrq && !srv->hostname_dn) break; HA_SPIN_UNLOCK(SERVER_LOCK, &srv->lock); } /* And update this server, if found */ if (srv) { const char *msg = NULL; char weight[9]; int ha_weight; char hostname[DNS_MAX_NAME_SIZE]; if (dns_dn_label_to_str(item->target, item->data_len+1, hostname, DNS_MAX_NAME_SIZE) == -1) { HA_SPIN_UNLOCK(SERVER_LOCK, &srv->lock); continue; } msg = update_server_fqdn(srv, hostname, "SRV record", 1); if (msg) send_log(srv->proxy, LOG_NOTICE, "%s", msg); srv->svc_port = item->port; srv->flags &= ~SRV_F_MAPPORTS; if ((srv->check.state & CHK_ST_CONFIGURED) && !(srv->flags & SRV_F_CHECKPORT)) srv->check.port = item->port; /* Make sure weight is at least 1, so * that the server will be used. */ ha_weight = item->weight / 256 + 1; snprintf(weight, sizeof(weight), "%d", ha_weight); server_parse_weight_change_request(srv, weight); HA_SPIN_UNLOCK(SERVER_LOCK, &srv->lock); } } } }
CWE-835
705
11,335
226713531637717284329823792279686984466
null
null
null
haproxy
58df5aea0a0c926b2238f65908f5e9f83d1cca25
0
static void dns_reset_resolution(struct dns_resolution *resolution) { /* update resolution status */ resolution->step = RSLV_STEP_NONE; resolution->try = 0; resolution->last_resolution = now_ms; resolution->nb_queries = 0; resolution->nb_responses = 0; resolution->query_type = resolution->prefered_query_type; /* clean up query id */ eb32_delete(&resolution->qid); resolution->query_id = 0; resolution->qid.key = 0; }
CWE-835
706
11,336
12001898397661579628774039256819104809
null
null
null
haproxy
58df5aea0a0c926b2238f65908f5e9f83d1cca25
0
static inline int dns_resolution_timeout(struct dns_resolution *res) { switch (res->status) { case RSLV_STATUS_VALID: return res->resolvers->hold.valid; default: return res->resolvers->timeout.resolve; } }
CWE-835
707
11,337
288482937427703124552961958848755926906
null
null
null
haproxy
58df5aea0a0c926b2238f65908f5e9f83d1cca25
0
static inline unsigned short dns_response_get_query_id(unsigned char *resp) { return resp[0] * 256 + resp[1]; }
CWE-835
708
11,338
45821685141851379721351538206010544713
null
null
null
haproxy
58df5aea0a0c926b2238f65908f5e9f83d1cca25
0
dns_run_resolution(struct dns_resolution *resolution) { struct dns_resolvers *resolvers = resolution->resolvers; int query_id, i; /* Avoid sending requests for resolutions that don't yet have an * hostname, ie resolutions linked to servers that do not yet have an * fqdn */ if (!resolution->hostname_dn) return 0; /* Check if a resolution has already been started for this server return * directly to avoid resolution pill up. */ if (resolution->step != RSLV_STEP_NONE) return 0; /* Generates a new query id. We try at most 100 times to find a free * query id */ for (i = 0; i < 100; ++i) { query_id = dns_rnd16(); if (!eb32_lookup(&resolvers->query_ids, query_id)) break; query_id = -1; } if (query_id == -1) { send_log(NULL, LOG_NOTICE, "could not generate a query id for %s, in resolvers %s.\n", resolution->hostname_dn, resolvers->id); return -1; } /* Update resolution parameters */ resolution->query_id = query_id; resolution->qid.key = query_id; resolution->step = RSLV_STEP_RUNNING; resolution->query_type = resolution->prefered_query_type; resolution->try = resolvers->resolve_retries; eb32_insert(&resolvers->query_ids, &resolution->qid); /* Send the DNS query */ resolution->try -= 1; dns_send_query(resolution); return 1; }
CWE-835
710
11,339
101462500114453044524078474035637935547
null
null
null
haproxy
58df5aea0a0c926b2238f65908f5e9f83d1cca25
0
static int dns_send_query(struct dns_resolution *resolution) { struct dns_resolvers *resolvers = resolution->resolvers; struct dns_nameserver *ns; list_for_each_entry(ns, &resolvers->nameservers, list) { int fd = ns->dgram->t.sock.fd; if (fd == -1) { if (dns_connect_namesaver(ns) == -1) continue; fd = ns->dgram->t.sock.fd; resolvers->nb_nameservers++; } fd_want_send(fd); } /* Update resolution */ resolution->nb_queries = 0; resolution->nb_responses = 0; resolution->last_query = now_ms; /* Push the resolution at the end of the active list */ LIST_DEL(&resolution->list); LIST_ADDQ(&resolvers->resolutions.curr, &resolution->list); return 0; }
CWE-835
711
11,340
265511182553347406046853847593439247698
null
null
null
haproxy
58df5aea0a0c926b2238f65908f5e9f83d1cca25
0
void dns_trigger_resolution(struct dns_requester *req) { struct dns_resolvers *resolvers; struct dns_resolution *res; int exp; if (!req || !req->resolution) return; res = req->resolution; resolvers = res->resolvers; /* The resolution must not be triggered yet. Use the cached response, if * valid */ exp = tick_add(res->last_resolution, resolvers->hold.valid); if (resolvers->t && (res->status != RSLV_STATUS_VALID || !tick_isset(res->last_resolution) || tick_is_expired(exp, now_ms))) task_wakeup(resolvers->t, TASK_WOKEN_OTHER); }
CWE-835
712
11,341
204159347190264983012313456430338228402
null
null
null
haproxy
58df5aea0a0c926b2238f65908f5e9f83d1cca25
0
static void dns_update_resolvers_timeout(struct dns_resolvers *resolvers) { struct dns_resolution *res; int next; next = tick_add(now_ms, resolvers->timeout.resolve); if (!LIST_ISEMPTY(&resolvers->resolutions.curr)) { res = LIST_NEXT(&resolvers->resolutions.curr, struct dns_resolution *, list); next = MIN(next, tick_add(res->last_query, resolvers->timeout.retry)); } list_for_each_entry(res, &resolvers->resolutions.wait, list) next = MIN(next, tick_add(res->last_resolution, dns_resolution_timeout(res))); resolvers->t->expire = next; task_queue(resolvers->t); }
CWE-835
713
11,342
208332645144909976098625152187700653983
null
null
null
haproxy
efbbdf72992cd20458259962346044cafd9331c0
0
static int cli_io_handler_dump_resolvers_to_buffer(struct appctx *appctx) { struct stream_interface *si = appctx->owner; struct dns_resolvers *resolvers; struct dns_nameserver *ns; chunk_reset(&trash); switch (appctx->st2) { case STAT_ST_INIT: appctx->st2 = STAT_ST_LIST; /* let's start producing data */ /* fall through */ case STAT_ST_LIST: if (LIST_ISEMPTY(&dns_resolvers)) { chunk_appendf(&trash, "No resolvers found\n"); } else { list_for_each_entry(resolvers, &dns_resolvers, list) { if (appctx->ctx.cli.p0 != NULL && appctx->ctx.cli.p0 != resolvers) continue; chunk_appendf(&trash, "Resolvers section %s\n", resolvers->id); list_for_each_entry(ns, &resolvers->nameservers, list) { chunk_appendf(&trash, " nameserver %s:\n", ns->id); chunk_appendf(&trash, " sent: %lld\n", ns->counters.sent); chunk_appendf(&trash, " snd_error: %lld\n", ns->counters.snd_error); chunk_appendf(&trash, " valid: %lld\n", ns->counters.valid); chunk_appendf(&trash, " update: %lld\n", ns->counters.update); chunk_appendf(&trash, " cname: %lld\n", ns->counters.cname); chunk_appendf(&trash, " cname_error: %lld\n", ns->counters.cname_error); chunk_appendf(&trash, " any_err: %lld\n", ns->counters.any_err); chunk_appendf(&trash, " nx: %lld\n", ns->counters.nx); chunk_appendf(&trash, " timeout: %lld\n", ns->counters.timeout); chunk_appendf(&trash, " refused: %lld\n", ns->counters.refused); chunk_appendf(&trash, " other: %lld\n", ns->counters.other); chunk_appendf(&trash, " invalid: %lld\n", ns->counters.invalid); chunk_appendf(&trash, " too_big: %lld\n", ns->counters.too_big); chunk_appendf(&trash, " truncated: %lld\n", ns->counters.truncated); chunk_appendf(&trash, " outdated: %lld\n", ns->counters.outdated); } chunk_appendf(&trash, "\n"); } } /* display response */ if (ci_putchk(si_ic(si), &trash) == -1) { /* let's try again later from this session. We add ourselves into * this session's users so that it can remove us upon termination. */ si_rx_room_blk(si); return 0; } /* fall through */ default: appctx->st2 = STAT_ST_FIN; return 1; } }
CWE-125
714
11,343
29690963073120524208126260519733306052
null
null
null
haproxy
efbbdf72992cd20458259962346044cafd9331c0
0
static int cli_parse_stat_resolvers(char **args, char *payload, struct appctx *appctx, void *private) { struct dns_resolvers *presolvers; if (*args[2]) { list_for_each_entry(presolvers, &dns_resolvers, list) { if (strcmp(presolvers->id, args[2]) == 0) { appctx->ctx.cli.p0 = presolvers; break; } } if (appctx->ctx.cli.p0 == NULL) { appctx->ctx.cli.severity = LOG_ERR; appctx->ctx.cli.msg = "Can't find that resolvers section\n"; appctx->st0 = CLI_ST_PRINT; return 1; } } return 0; }
CWE-125
715
11,344
155149799893331134967636967626537504924
null
null
null
haproxy
efbbdf72992cd20458259962346044cafd9331c0
0
static void dns_deinit(void) { struct dns_resolvers *resolvers, *resolversback; struct dns_nameserver *ns, *nsback; struct dns_resolution *res, *resback; struct dns_requester *req, *reqback; struct dns_srvrq *srvrq, *srvrqback; list_for_each_entry_safe(resolvers, resolversback, &dns_resolvers, list) { list_for_each_entry_safe(ns, nsback, &resolvers->nameservers, list) { free(ns->id); free((char *)ns->conf.file); if (ns->dgram && ns->dgram->t.sock.fd != -1) fd_delete(ns->dgram->t.sock.fd); free(ns->dgram); LIST_DEL(&ns->list); free(ns); } list_for_each_entry_safe(res, resback, &resolvers->resolutions.curr, list) { list_for_each_entry_safe(req, reqback, &res->requesters, list) { LIST_DEL(&req->list); free(req); } dns_free_resolution(res); } list_for_each_entry_safe(res, resback, &resolvers->resolutions.wait, list) { list_for_each_entry_safe(req, reqback, &res->requesters, list) { LIST_DEL(&req->list); free(req); } dns_free_resolution(res); } free(resolvers->id); free((char *)resolvers->conf.file); task_delete(resolvers->t); task_free(resolvers->t); LIST_DEL(&resolvers->list); free(resolvers); } list_for_each_entry_safe(srvrq, srvrqback, &dns_srvrq_list, list) { free(srvrq->name); free(srvrq->hostname_dn); LIST_DEL(&srvrq->list); free(srvrq); } }
CWE-125
716
11,345
266841229674249509774590462464706570020
null
null
null
haproxy
efbbdf72992cd20458259962346044cafd9331c0
0
int dns_dn_label_to_str(const char *dn, int dn_len, char *str, int str_len) { char *ptr; int i, sz; if (str_len < dn_len - 1) return -1; ptr = str; for (i = 0; i < dn_len-1; ++i) { sz = dn[i]; if (i) *ptr++ = '.'; memcpy(ptr, dn+i+1, sz); ptr += sz; i += sz; } *ptr++ = '\0'; return (ptr - str); }
CWE-125
717
11,346
219689839149688955301896115160677606415
null
null
null
haproxy
efbbdf72992cd20458259962346044cafd9331c0
0
static int dns_finalize_config(void) { struct dns_resolvers *resolvers; struct proxy *px; int err_code = 0; /* allocate pool of resolution per resolvers */ list_for_each_entry(resolvers, &dns_resolvers, list) { struct dns_nameserver *ns; struct task *t; /* Check if we can create the socket with nameservers info */ list_for_each_entry(ns, &resolvers->nameservers, list) { struct dgram_conn *dgram = NULL; int fd; /* Check nameserver info */ if ((fd = socket(ns->addr.ss_family, SOCK_DGRAM, IPPROTO_UDP)) == -1) { ha_alert("config : resolvers '%s': can't create socket for nameserver '%s'.\n", resolvers->id, ns->id); err_code |= (ERR_ALERT|ERR_ABORT); continue; } if (connect(fd, (struct sockaddr*)&ns->addr, get_addr_len(&ns->addr)) == -1) { ha_alert("config : resolvers '%s': can't connect socket for nameserver '%s'.\n", resolvers->id, ns->id); close(fd); err_code |= (ERR_ALERT|ERR_ABORT); continue; } close(fd); /* Create dgram structure that will hold the UPD socket * and attach it on the current nameserver */ if ((dgram = calloc(1, sizeof(*dgram))) == NULL) { ha_alert("config: resolvers '%s' : out of memory.\n", resolvers->id); err_code |= (ERR_ALERT|ERR_ABORT); goto err; } /* Leave dgram partially initialized, no FD attached for * now. */ dgram->owner = ns; dgram->data = &resolve_dgram_cb; dgram->t.sock.fd = -1; ns->dgram = dgram; } /* Create the task associated to the resolvers section */ if ((t = task_new(MAX_THREADS_MASK)) == NULL) { ha_alert("config : resolvers '%s' : out of memory.\n", resolvers->id); err_code |= (ERR_ALERT|ERR_ABORT); goto err; } /* Update task's parameters */ t->process = dns_process_resolvers; t->context = resolvers; resolvers->t = t; task_wakeup(t, TASK_WOKEN_INIT); } for (px = proxies_list; px; px = px->next) { struct server *srv; for (srv = px->srv; srv; srv = srv->next) { struct dns_resolvers *resolvers; if (!srv->resolvers_id) continue; if ((resolvers = find_resolvers_by_id(srv->resolvers_id)) == NULL) { ha_alert("config : %s '%s', server '%s': unable to find required resolvers '%s'\n", proxy_type_str(px), px->id, srv->id, srv->resolvers_id); err_code |= (ERR_ALERT|ERR_ABORT); continue; } srv->resolvers = resolvers; if (srv->srvrq && !srv->srvrq->resolvers) { srv->srvrq->resolvers = srv->resolvers; if (dns_link_resolution(srv->srvrq, OBJ_TYPE_SRVRQ, 0) == -1) { ha_alert("config : %s '%s' : unable to set DNS resolution for server '%s'.\n", proxy_type_str(px), px->id, srv->id); err_code |= (ERR_ALERT|ERR_ABORT); continue; } } if (dns_link_resolution(srv, OBJ_TYPE_SERVER, 0) == -1) { ha_alert("config : %s '%s', unable to set DNS resolution for server '%s'.\n", proxy_type_str(px), px->id, srv->id); err_code |= (ERR_ALERT|ERR_ABORT); continue; } } } if (err_code & (ERR_ALERT|ERR_ABORT)) goto err; return err_code; err: dns_deinit(); return err_code; }
CWE-125
718
11,347
89351816692946886854174937944039164945
null
null
null
haproxy
efbbdf72992cd20458259962346044cafd9331c0
0
static void dns_free_resolution(struct dns_resolution *resolution) { struct dns_requester *req, *reqback; /* clean up configuration */ dns_reset_resolution(resolution); resolution->hostname_dn = NULL; resolution->hostname_dn_len = 0; list_for_each_entry_safe(req, reqback, &resolution->requesters, list) { LIST_DEL(&req->list); req->resolution = NULL; } LIST_DEL(&resolution->list); pool_free(dns_resolution_pool, resolution); }
CWE-125
719
11,348
164699896954419930137021760186753216813
null
null
null
haproxy
efbbdf72992cd20458259962346044cafd9331c0
0
int dns_get_ip_from_response(struct dns_response_packet *dns_p, struct dns_options *dns_opts, void *currentip, short currentip_sin_family, void **newip, short *newip_sin_family, void *owner) { struct dns_answer_item *record; int family_priority; int currentip_found; unsigned char *newip4, *newip6; int currentip_sel; int j; int score, max_score; int allowed_duplicated_ip; family_priority = dns_opts->family_prio; allowed_duplicated_ip = dns_opts->accept_duplicate_ip; *newip = newip4 = newip6 = NULL; currentip_found = 0; *newip_sin_family = AF_UNSPEC; max_score = -1; /* Select an IP regarding configuration preference. * Top priority is the preferred network ip version, * second priority is the preferred network. * the last priority is the currently used IP, * * For these three priorities, a score is calculated. The * weight are: * 8 - preferred ip version. * 4 - preferred network. * 2 - if the ip in the record is not affected to any other server in the same backend (duplication) * 1 - current ip. * The result with the biggest score is returned. */ list_for_each_entry(record, &dns_p->answer_list, list) { void *ip; unsigned char ip_type; if (record->type == DNS_RTYPE_A) { ip = &(((struct sockaddr_in *)&record->address)->sin_addr); ip_type = AF_INET; } else if (record->type == DNS_RTYPE_AAAA) { ip_type = AF_INET6; ip = &(((struct sockaddr_in6 *)&record->address)->sin6_addr); } else continue; score = 0; /* Check for preferred ip protocol. */ if (ip_type == family_priority) score += 8; /* Check for preferred network. */ for (j = 0; j < dns_opts->pref_net_nb; j++) { /* Compare only the same adresses class. */ if (dns_opts->pref_net[j].family != ip_type) continue; if ((ip_type == AF_INET && in_net_ipv4(ip, &dns_opts->pref_net[j].mask.in4, &dns_opts->pref_net[j].addr.in4)) || (ip_type == AF_INET6 && in_net_ipv6(ip, &dns_opts->pref_net[j].mask.in6, &dns_opts->pref_net[j].addr.in6))) { score += 4; break; } } /* Check if the IP found in the record is already affected to a * member of a group. If not, the score should be incremented * by 2. */ if (owner && snr_check_ip_callback(owner, ip, &ip_type)) { if (!allowed_duplicated_ip) { continue; } } else { score += 2; } /* Check for current ip matching. */ if (ip_type == currentip_sin_family && ((currentip_sin_family == AF_INET && !memcmp(ip, currentip, 4)) || (currentip_sin_family == AF_INET6 && !memcmp(ip, currentip, 16)))) { score++; currentip_sel = 1; } else currentip_sel = 0; /* Keep the address if the score is better than the previous * score. The maximum score is 15, if this value is reached, we * break the parsing. Implicitly, this score is reached the ip * selected is the current ip. */ if (score > max_score) { if (ip_type == AF_INET) newip4 = ip; else newip6 = ip; currentip_found = currentip_sel; if (score == 15) return DNS_UPD_NO; max_score = score; } } /* list for each record entries */ /* No IP found in the response */ if (!newip4 && !newip6) return DNS_UPD_NO_IP_FOUND; /* Case when the caller looks first for an IPv4 address */ if (family_priority == AF_INET) { if (newip4) { *newip = newip4; *newip_sin_family = AF_INET; } else if (newip6) { *newip = newip6; *newip_sin_family = AF_INET6; } if (!currentip_found) goto not_found; } /* Case when the caller looks first for an IPv6 address */ else if (family_priority == AF_INET6) { if (newip6) { *newip = newip6; *newip_sin_family = AF_INET6; } else if (newip4) { *newip = newip4; *newip_sin_family = AF_INET; } if (!currentip_found) goto not_found; } /* Case when the caller have no preference (we prefer IPv6) */ else if (family_priority == AF_UNSPEC) { if (newip6) { *newip = newip6; *newip_sin_family = AF_INET6; } else if (newip4) { *newip = newip4; *newip_sin_family = AF_INET; } if (!currentip_found) goto not_found; } /* No reason why we should change the server's IP address */ return DNS_UPD_NO; not_found: list_for_each_entry(record, &dns_p->answer_list, list) { /* Move the first record to the end of the list, for internal * round robin */ LIST_DEL(&record->list); LIST_ADDQ(&dns_p->answer_list, &record->list); break; } return DNS_UPD_SRVIP_NOT_FOUND; }
CWE-125
720
11,349
80512598506839601241711224869529181046
null
null
null
haproxy
efbbdf72992cd20458259962346044cafd9331c0
0
int dns_hostname_validation(const char *string, char **err) { const char *c, *d; int i; if (strlen(string) > DNS_MAX_NAME_SIZE) { if (err) *err = DNS_TOO_LONG_FQDN; return 0; } c = string; while (*c) { d = c; i = 0; while (*d != '.' && *d && i <= DNS_MAX_LABEL_SIZE) { i++; if (!((*d == '-') || (*d == '_') || ((*d >= 'a') && (*d <= 'z')) || ((*d >= 'A') && (*d <= 'Z')) || ((*d >= '0') && (*d <= '9')))) { if (err) *err = DNS_INVALID_CHARACTER; return 0; } d++; } if ((i >= DNS_MAX_LABEL_SIZE) && (d[i] != '.')) { if (err) *err = DNS_LABEL_TOO_LONG; return 0; } if (*d == '\0') goto out; c = ++d; } out: return 1; }
CWE-125
721
11,350
321979582100669125024616004966502573868
null
null
null
haproxy
efbbdf72992cd20458259962346044cafd9331c0
0
int dns_link_resolution(void *requester, int requester_type, int requester_locked) { struct dns_resolution *res = NULL; struct dns_requester *req; struct dns_resolvers *resolvers; struct server *srv = NULL; struct dns_srvrq *srvrq = NULL; char **hostname_dn; int hostname_dn_len, query_type; switch (requester_type) { case OBJ_TYPE_SERVER: srv = (struct server *)requester; hostname_dn = &srv->hostname_dn; hostname_dn_len = srv->hostname_dn_len; resolvers = srv->resolvers; query_type = ((srv->dns_opts.family_prio == AF_INET) ? DNS_RTYPE_A : DNS_RTYPE_AAAA); break; case OBJ_TYPE_SRVRQ: srvrq = (struct dns_srvrq *)requester; hostname_dn = &srvrq->hostname_dn; hostname_dn_len = srvrq->hostname_dn_len; resolvers = srvrq->resolvers; query_type = DNS_RTYPE_SRV; break; default: goto err; } /* Get a resolution from the resolvers' wait queue or pool */ if ((res = dns_pick_resolution(resolvers, hostname_dn, hostname_dn_len, query_type)) == NULL) goto err; if (srv) { if (!requester_locked) HA_SPIN_LOCK(SERVER_LOCK, &srv->lock); if (srv->dns_requester == NULL) { if ((req = calloc(1, sizeof(*req))) == NULL) { if (!requester_locked) HA_SPIN_UNLOCK(SERVER_LOCK, &srv->lock); goto err; } req->owner = &srv->obj_type; srv->dns_requester = req; } else req = srv->dns_requester; if (!requester_locked) HA_SPIN_UNLOCK(SERVER_LOCK, &srv->lock); } else if (srvrq) { if (srvrq->dns_requester == NULL) { if ((req = calloc(1, sizeof(*req))) == NULL) goto err; req->owner = &srvrq->obj_type; srvrq->dns_requester = req; } else req = srvrq->dns_requester; } else goto err; req->resolution = res; req->requester_cb = snr_resolution_cb; req->requester_error_cb = snr_resolution_error_cb; LIST_ADDQ(&res->requesters, &req->list); return 0; err: if (res && LIST_ISEMPTY(&res->requesters)) dns_free_resolution(res); return -1; }
CWE-125
722
11,351
178777429140660116013529104797130457489
null
null
null
haproxy
efbbdf72992cd20458259962346044cafd9331c0
0
static struct dns_resolution *dns_pick_resolution(struct dns_resolvers *resolvers, char **hostname_dn, int hostname_dn_len, int query_type) { struct dns_resolution *res; if (!*hostname_dn) goto from_pool; /* Search for same hostname and query type in resolutions.curr */ list_for_each_entry(res, &resolvers->resolutions.curr, list) { if (!res->hostname_dn) continue; if ((query_type == res->prefered_query_type) && hostname_dn_len == res->hostname_dn_len && !memcmp(*hostname_dn, res->hostname_dn, hostname_dn_len)) return res; } /* Search for same hostname and query type in resolutions.wait */ list_for_each_entry(res, &resolvers->resolutions.wait, list) { if (!res->hostname_dn) continue; if ((query_type == res->prefered_query_type) && hostname_dn_len == res->hostname_dn_len && !memcmp(*hostname_dn, res->hostname_dn, hostname_dn_len)) return res; } from_pool: /* No resolution could be found, so let's allocate a new one */ res = pool_alloc(dns_resolution_pool); if (res) { memset(res, 0, sizeof(*res)); res->resolvers = resolvers; res->uuid = resolution_uuid; res->status = RSLV_STATUS_NONE; res->step = RSLV_STEP_NONE; res->last_valid = now_ms; LIST_INIT(&res->requesters); LIST_INIT(&res->response.answer_list); res->prefered_query_type = query_type; res->query_type = query_type; res->hostname_dn = *hostname_dn; res->hostname_dn_len = hostname_dn_len; ++resolution_uuid; /* Move the resolution to the resolvers wait queue */ LIST_ADDQ(&resolvers->resolutions.wait, &res->list); } return res; }
CWE-125
723
11,352
253904624247826474765995397439512190302
null
null
null
haproxy
efbbdf72992cd20458259962346044cafd9331c0
0
static struct task *dns_process_resolvers(struct task *t, void *context, unsigned short state) { struct dns_resolvers *resolvers = context; struct dns_resolution *res, *resback; int exp; HA_SPIN_LOCK(DNS_LOCK, &resolvers->lock); /* Handle all expired resolutions from the active list */ list_for_each_entry_safe(res, resback, &resolvers->resolutions.curr, list) { /* When we find the first resolution in the future, then we can * stop here */ exp = tick_add(res->last_query, resolvers->timeout.retry); if (!tick_is_expired(exp, now_ms)) break; /* If current resolution has been tried too many times and * finishes in timeout we update its status and remove it from * the list */ if (!res->try) { struct dns_requester *req; /* Notify the result to the requesters */ if (!res->nb_responses) res->status = RSLV_STATUS_TIMEOUT; list_for_each_entry(req, &res->requesters, list) req->requester_error_cb(req, res->status); /* Clean up resolution info and remove it from the * current list */ dns_reset_resolution(res); LIST_DEL(&res->list); LIST_ADDQ(&resolvers->resolutions.wait, &res->list); } else { /* Otherwise resend the DNS query and requeue the resolution */ if (!res->nb_responses || res->prefered_query_type != res->query_type) { /* No response received (a real timeout) or fallback already done */ res->query_type = res->prefered_query_type; res->try--; } else { /* Fallback from A to AAAA or the opposite and re-send * the resolution immediately. try counter is not * decremented. */ if (res->prefered_query_type == DNS_RTYPE_A) res->query_type = DNS_RTYPE_AAAA; else if (res->prefered_query_type == DNS_RTYPE_AAAA) res->query_type = DNS_RTYPE_A; else res->try--; } dns_send_query(res); } } /* Handle all resolutions in the wait list */ list_for_each_entry_safe(res, resback, &resolvers->resolutions.wait, list) { exp = tick_add(res->last_resolution, dns_resolution_timeout(res)); if (tick_isset(res->last_resolution) && !tick_is_expired(exp, now_ms)) continue; if (dns_run_resolution(res) != 1) { res->last_resolution = now_ms; LIST_DEL(&res->list); LIST_ADDQ(&resolvers->resolutions.wait, &res->list); } } dns_update_resolvers_timeout(resolvers); HA_SPIN_UNLOCK(DNS_LOCK, &resolvers->lock); return t; }
CWE-125
724
11,353
167371127668923317690513459357337362869
null
null
null
haproxy
efbbdf72992cd20458259962346044cafd9331c0
0
int dns_read_name(unsigned char *buffer, unsigned char *bufend, unsigned char *name, char *destination, int dest_len, int *offset, unsigned int depth) { int nb_bytes = 0, n = 0; int label_len; unsigned char *reader = name; char *dest = destination; while (1) { if (reader >= bufend) goto err; /* Name compression is in use */ if ((*reader & 0xc0) == 0xc0) { if (reader + 1 >= bufend) goto err; /* Must point BEFORE current position */ if ((buffer + reader[1]) > reader) goto err; if (depth++ > 100) goto err; n = dns_read_name(buffer, bufend, buffer + reader[1], dest, dest_len - nb_bytes, offset, depth); if (n == 0) goto err; dest += n; nb_bytes += n; goto out; } label_len = *reader; if (label_len == 0) goto out; /* Check if: * - we won't read outside the buffer * - there is enough place in the destination */ if ((reader + label_len >= bufend) || (nb_bytes + label_len >= dest_len)) goto err; /* +1 to take label len + label string */ label_len++; memcpy(dest, reader, label_len); dest += label_len; nb_bytes += label_len; reader += label_len; } out: /* offset computation: * parse from <name> until finding either NULL or a pointer "c0xx" */ reader = name; *offset = 0; while (reader < bufend) { if ((reader[0] & 0xc0) == 0xc0) { *offset += 2; break; } else if (*reader == 0) { *offset += 1; break; } *offset += 1; ++reader; } return nb_bytes; err: return 0; }
CWE-125
725
11,354
265458403725355925449929616221865891347
null
null
null
haproxy
efbbdf72992cd20458259962346044cafd9331c0
0
static void dns_resolve_recv(struct dgram_conn *dgram) { struct dns_nameserver *ns, *tmpns; struct dns_resolvers *resolvers; struct dns_resolution *res; struct dns_query_item *query; unsigned char buf[DNS_MAX_UDP_MESSAGE + 1]; unsigned char *bufend; int fd, buflen, dns_resp; int max_answer_records; unsigned short query_id; struct eb32_node *eb; struct dns_requester *req; fd = dgram->t.sock.fd; /* check if ready for reading */ if (!fd_recv_ready(fd)) return; /* no need to go further if we can't retrieve the nameserver */ if ((ns = dgram->owner) == NULL) return; resolvers = ns->resolvers; HA_SPIN_LOCK(DNS_LOCK, &resolvers->lock); /* process all pending input messages */ while (1) { /* read message received */ memset(buf, '\0', resolvers->accepted_payload_size + 1); if ((buflen = recv(fd, (char*)buf , resolvers->accepted_payload_size + 1, 0)) < 0) { /* FIXME : for now we consider EAGAIN only */ fd_cant_recv(fd); break; } /* message too big */ if (buflen > resolvers->accepted_payload_size) { ns->counters.too_big++; continue; } /* initializing variables */ bufend = buf + buflen; /* pointer to mark the end of the buffer */ /* read the query id from the packet (16 bits) */ if (buf + 2 > bufend) { ns->counters.invalid++; continue; } query_id = dns_response_get_query_id(buf); /* search the query_id in the pending resolution tree */ eb = eb32_lookup(&resolvers->query_ids, query_id); if (eb == NULL) { /* unknown query id means an outdated response and can be safely ignored */ ns->counters.outdated++; continue; } /* known query id means a resolution in prgress */ res = eb32_entry(eb, struct dns_resolution, qid); if (!res) { ns->counters.outdated++; continue; } /* number of responses received */ res->nb_responses++; max_answer_records = (resolvers->accepted_payload_size - DNS_HEADER_SIZE) / DNS_MIN_RECORD_SIZE; dns_resp = dns_validate_dns_response(buf, bufend, res, max_answer_records); switch (dns_resp) { case DNS_RESP_VALID: break; case DNS_RESP_INVALID: case DNS_RESP_QUERY_COUNT_ERROR: case DNS_RESP_WRONG_NAME: res->status = RSLV_STATUS_INVALID; ns->counters.invalid++; break; case DNS_RESP_NX_DOMAIN: res->status = RSLV_STATUS_NX; ns->counters.nx++; break; case DNS_RESP_REFUSED: res->status = RSLV_STATUS_REFUSED; ns->counters.refused++; break; case DNS_RESP_ANCOUNT_ZERO: res->status = RSLV_STATUS_OTHER; ns->counters.any_err++; break; case DNS_RESP_CNAME_ERROR: res->status = RSLV_STATUS_OTHER; ns->counters.cname_error++; break; case DNS_RESP_TRUNCATED: res->status = RSLV_STATUS_OTHER; ns->counters.truncated++; break; case DNS_RESP_NO_EXPECTED_RECORD: case DNS_RESP_ERROR: case DNS_RESP_INTERNAL: res->status = RSLV_STATUS_OTHER; ns->counters.other++; break; } /* Wait all nameservers response to handle errors */ if (dns_resp != DNS_RESP_VALID && res->nb_responses < resolvers->nb_nameservers) continue; /* Process error codes */ if (dns_resp != DNS_RESP_VALID) { if (res->prefered_query_type != res->query_type) { /* The fallback on the query type was already performed, * so check the try counter. If it falls to 0, we can * report an error. Else, wait the next attempt. */ if (!res->try) goto report_res_error; } else { /* Fallback from A to AAAA or the opposite and re-send * the resolution immediately. try counter is not * decremented. */ if (res->prefered_query_type == DNS_RTYPE_A) { res->query_type = DNS_RTYPE_AAAA; dns_send_query(res); } else if (res->prefered_query_type == DNS_RTYPE_AAAA) { res->query_type = DNS_RTYPE_A; dns_send_query(res); } } continue; } /* Now let's check the query's dname corresponds to the one we * sent. We can check only the first query of the list. We send * one query at a time so we get one query in the response */ query = LIST_NEXT(&res->response.query_list, struct dns_query_item *, list); if (query && memcmp(query->name, res->hostname_dn, res->hostname_dn_len) != 0) { dns_resp = DNS_RESP_WRONG_NAME; ns->counters.other++; goto report_res_error; } /* So the resolution succeeded */ res->status = RSLV_STATUS_VALID; res->last_valid = now_ms; ns->counters.valid++; goto report_res_success; report_res_error: list_for_each_entry(req, &res->requesters, list) req->requester_error_cb(req, dns_resp); dns_reset_resolution(res); LIST_DEL(&res->list); LIST_ADDQ(&resolvers->resolutions.wait, &res->list); continue; report_res_success: /* Only the 1rst requester s managed by the server, others are * from the cache */ tmpns = ns; list_for_each_entry(req, &res->requesters, list) { struct server *s = objt_server(req->owner); if (s) HA_SPIN_LOCK(SERVER_LOCK, &s->lock); req->requester_cb(req, tmpns); if (s) HA_SPIN_UNLOCK(SERVER_LOCK, &s->lock); tmpns = NULL; } dns_reset_resolution(res); LIST_DEL(&res->list); LIST_ADDQ(&resolvers->resolutions.wait, &res->list); continue; } dns_update_resolvers_timeout(resolvers); HA_SPIN_UNLOCK(DNS_LOCK, &resolvers->lock); }
CWE-125
726
11,355
332513099847586210728278587684706977348
null
null
null
haproxy
efbbdf72992cd20458259962346044cafd9331c0
0
int dns_str_to_dn_label(const char *str, int str_len, char *dn, int dn_len) { int i, offset; if (dn_len < str_len + 1) return -1; /* First byte of dn will be used to store the length of the first * label */ offset = 0; for (i = 0; i < str_len; ++i) { if (str[i] == '.') { /* 2 or more consecutive dots is invalid */ if (i == offset) return -1; dn[offset] = (i - offset); offset = i+1; continue; } dn[i+1] = str[i]; } dn[offset] = (i - offset - 1); dn[i] = '\0'; return i; }
CWE-125
728
11,356
31956296095874720715866910134663519228
null
null
null
haproxy
efbbdf72992cd20458259962346044cafd9331c0
0
void dns_unlink_resolution(struct dns_requester *requester) { struct dns_resolution *res; struct dns_requester *req; /* Nothing to do */ if (!requester || !requester->resolution) return; res = requester->resolution; /* Clean up the requester */ LIST_DEL(&requester->list); requester->resolution = NULL; /* We need to find another requester linked on this resolution */ if (!LIST_ISEMPTY(&res->requesters)) req = LIST_NEXT(&res->requesters, struct dns_requester *, list); else { dns_free_resolution(res); return; } /* Move hostname_dn related pointers to the next requester */ switch (obj_type(req->owner)) { case OBJ_TYPE_SERVER: res->hostname_dn = __objt_server(req->owner)->hostname_dn; res->hostname_dn_len = __objt_server(req->owner)->hostname_dn_len; break; case OBJ_TYPE_SRVRQ: res->hostname_dn = __objt_dns_srvrq(req->owner)->hostname_dn; res->hostname_dn_len = __objt_dns_srvrq(req->owner)->hostname_dn_len; break; default: res->hostname_dn = NULL; res->hostname_dn_len = 0; break; } }
CWE-125
729
11,357
218606860309032948941365357356572106868
null
null
null
haproxy
efbbdf72992cd20458259962346044cafd9331c0
0
struct dns_srvrq *new_dns_srvrq(struct server *srv, char *fqdn) { struct proxy *px = srv->proxy; struct dns_srvrq *srvrq = NULL; int fqdn_len, hostname_dn_len; fqdn_len = strlen(fqdn); hostname_dn_len = dns_str_to_dn_label(fqdn, fqdn_len + 1, trash.area, trash.size); if (hostname_dn_len == -1) { ha_alert("config : %s '%s', server '%s': failed to parse FQDN '%s'\n", proxy_type_str(px), px->id, srv->id, fqdn); goto err; } if ((srvrq = calloc(1, sizeof(*srvrq))) == NULL) { ha_alert("config : %s '%s', server '%s': out of memory\n", proxy_type_str(px), px->id, srv->id); goto err; } srvrq->obj_type = OBJ_TYPE_SRVRQ; srvrq->proxy = px; srvrq->name = strdup(fqdn); srvrq->hostname_dn = strdup(trash.area); srvrq->hostname_dn_len = hostname_dn_len; if (!srvrq->name || !srvrq->hostname_dn) { ha_alert("config : %s '%s', server '%s': out of memory\n", proxy_type_str(px), px->id, srv->id); goto err; } LIST_ADDQ(&dns_srvrq_list, &srvrq->list); return srvrq; err: if (srvrq) { free(srvrq->name); free(srvrq->hostname_dn); free(srvrq); } return NULL; }
CWE-125
732
11,358
328006933771125948874534218818942423892
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
_poppler_page_new (PopplerDocument *document, Page *page, int index) { PopplerPage *poppler_page; g_return_val_if_fail (POPPLER_IS_DOCUMENT (document), NULL); poppler_page = (PopplerPage *) g_object_new (POPPLER_TYPE_PAGE, NULL, NULL); poppler_page->document = (PopplerDocument *) g_object_ref (document); poppler_page->page = page; poppler_page->index = index; return poppler_page; }
CWE-189
748
11,373
103452768581550381917547369343214630971
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
_poppler_page_render_to_pixbuf (PopplerPage *page, int src_x, int src_y, int src_width, int src_height, double scale, int rotation, GBool printing, GdkPixbuf *pixbuf) { OutputDevData data; poppler_page_prepare_output_dev (page, scale, rotation, FALSE, &data); page->page->displaySlice(page->document->output_dev, 72.0 * scale, 72.0 * scale, rotation, gFalse, /* useMediaBox */ gTrue, /* Crop */ src_x, src_y, src_width, src_height, printing, page->document->doc->getCatalog (), NULL, NULL, printing ? poppler_print_annot_cb : NULL, NULL); poppler_page_copy_to_pixbuf (page, pixbuf, &data); }
CWE-189
749
11,374
239169173080203252192840500348534542437
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
copy_cairo_surface_to_pixbuf (cairo_surface_t *surface, unsigned char *data, GdkPixbuf *pixbuf) { int cairo_width, cairo_height, cairo_rowstride; unsigned char *pixbuf_data, *dst, *cairo_data; int pixbuf_rowstride, pixbuf_n_channels; unsigned int *src; int x, y; cairo_width = cairo_image_surface_get_width (surface); cairo_height = cairo_image_surface_get_height (surface); cairo_rowstride = cairo_width * 4; cairo_data = data; pixbuf_data = gdk_pixbuf_get_pixels (pixbuf); pixbuf_rowstride = gdk_pixbuf_get_rowstride (pixbuf); pixbuf_n_channels = gdk_pixbuf_get_n_channels (pixbuf); if (cairo_width > gdk_pixbuf_get_width (pixbuf)) cairo_width = gdk_pixbuf_get_width (pixbuf); if (cairo_height > gdk_pixbuf_get_height (pixbuf)) cairo_height = gdk_pixbuf_get_height (pixbuf); for (y = 0; y < cairo_height; y++) { src = (unsigned int *) (cairo_data + y * cairo_rowstride); dst = pixbuf_data + y * pixbuf_rowstride; for (x = 0; x < cairo_width; x++) { dst[0] = (*src >> 16) & 0xff; dst[1] = (*src >> 8) & 0xff; dst[2] = (*src >> 0) & 0xff; if (pixbuf_n_channels == 4) dst[3] = (*src >> 24) & 0xff; dst += pixbuf_n_channels; src++; } } }
CWE-189
750
11,375
217756926742718318166524332079865457978
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
image_draw_decide_cb (int image_id, void *data) { return (image_id == GPOINTER_TO_INT (data)); }
CWE-189
751
11,376
161826047759163776001500497038019621528
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_annot_mapping_copy (PopplerAnnotMapping *mapping) { PopplerAnnotMapping *new_mapping; new_mapping = poppler_annot_mapping_new (); *new_mapping = *mapping; if (mapping->annot) new_mapping->annot = (PopplerAnnot *) g_object_ref (mapping->annot); return new_mapping; }
CWE-189
752
11,377
301692906750872906672742401623887962631
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_annot_mapping_free (PopplerAnnotMapping *mapping) { if (!mapping) return; if (mapping->annot) g_object_unref (mapping->annot); g_free (mapping); }
CWE-189
753
11,378
114207947152702405608478376101926835891
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_annot_mapping_new (void) { return (PopplerAnnotMapping *) g_new0 (PopplerAnnotMapping, 1); }
CWE-189
754
11,379
282630087210986230155849356449075218463
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_color_copy (PopplerColor *color) { PopplerColor *new_color; new_color = g_new (PopplerColor, 1); *new_color = *color; return new_color; }
CWE-189
755
11,380
258940643336806039838948754933718303550
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_color_free (PopplerColor *color) { g_free (color); }
CWE-189
756
11,381
321335835554151307275579552469741777239
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_color_new (void) { return (PopplerColor *) g_new0 (PopplerColor, 1); }
CWE-189
757
11,382
28490427181767061050305000585991532816
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_form_field_mapping_free (PopplerFormFieldMapping *mapping) { if (!mapping) return; if (mapping->field) g_object_unref (mapping->field); g_free (mapping); }
CWE-189
758
11,383
119023651473982674124196971107755056300
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_form_field_mapping_new (void) { return (PopplerFormFieldMapping *) g_new0 (PopplerFormFieldMapping, 1); }
CWE-189
759
11,384
86164071927244148793221102620121540873
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_image_mapping_copy (PopplerImageMapping *mapping) { PopplerImageMapping *new_mapping; new_mapping = poppler_image_mapping_new (); *new_mapping = *mapping; return new_mapping; }
CWE-189
760
11,385
4679888462259993148058228605890208234
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_image_mapping_free (PopplerImageMapping *mapping) { g_free (mapping); }
CWE-189
761
11,386
224183035139796350928145703548116177524
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_image_mapping_new (void) { return (PopplerImageMapping *) g_new0 (PopplerImageMapping, 1); }
CWE-189
762
11,387
27350145570051433397793109331365704794
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_link_mapping_copy (PopplerLinkMapping *mapping) { PopplerLinkMapping *new_mapping; new_mapping = poppler_link_mapping_new (); *new_mapping = *mapping; if (new_mapping->action) new_mapping->action = poppler_action_copy (new_mapping->action); return new_mapping; }
CWE-189
763
11,388
78590653903699775796586989402893961900
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_link_mapping_free (PopplerLinkMapping *mapping) { if (mapping->action) poppler_action_free (mapping->action); g_free (mapping); }
CWE-189
764
11,389
29494524629313396233995906358232259774
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_link_mapping_new (void) { return (PopplerLinkMapping *) g_new0 (PopplerLinkMapping, 1); }
CWE-189
765
11,390
40148469825309047787257959765446527140
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_mapping_free (PopplerLinkMapping *mapping) { poppler_action_free (mapping->action); g_free (mapping); }
CWE-189
766
11,391
192856576356607213314495285716549305841
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_class_init (PopplerPageClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GParamSpec *pspec; gobject_class->finalize = poppler_page_finalize; gobject_class->get_property = poppler_page_get_property; pspec = g_param_spec_string ("label", "Page Label", "The label of the page", NULL, G_PARAM_READABLE); g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_LABEL, pspec); }
CWE-189
767
11,392
248701039295976677352475831512530652818
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_copy_to_pixbuf(PopplerPage *page, GdkPixbuf *pixbuf, OutputDevData *data) { SplashOutputDev *output_dev; SplashBitmap *bitmap; SplashColorPtr color_ptr; int splash_width, splash_height, splash_rowstride; int pixbuf_rowstride, pixbuf_n_channels; guchar *pixbuf_data, *dst; int x, y; output_dev = page->document->output_dev; bitmap = output_dev->getBitmap (); color_ptr = bitmap->getDataPtr (); splash_width = bitmap->getWidth (); splash_height = bitmap->getHeight (); splash_rowstride = bitmap->getRowSize (); pixbuf_data = gdk_pixbuf_get_pixels (pixbuf); pixbuf_rowstride = gdk_pixbuf_get_rowstride (pixbuf); pixbuf_n_channels = gdk_pixbuf_get_n_channels (pixbuf); if (splash_width > gdk_pixbuf_get_width (pixbuf)) splash_width = gdk_pixbuf_get_width (pixbuf); if (splash_height > gdk_pixbuf_get_height (pixbuf)) splash_height = gdk_pixbuf_get_height (pixbuf); SplashColorPtr pixel = new Guchar[4]; for (y = 0; y < splash_height; y++) { dst = pixbuf_data + y * pixbuf_rowstride; for (x = 0; x < splash_width; x++) { output_dev->getBitmap()->getPixel(x, y, pixel); dst[0] = pixel[0]; dst[1] = pixel[1]; dst[2] = pixel[2]; if (pixbuf_n_channels == 4) dst[3] = 0xff; dst += pixbuf_n_channels; } } delete [] pixel; }
CWE-189
768
11,393
20322896493496027624490712522548907473
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_finalize (GObject *object) { PopplerPage *page = POPPLER_PAGE (object); g_object_unref (page->document); page->document = NULL; if (page->annots != NULL) delete page->annots; #if defined (HAVE_CAIRO) if (page->text != NULL) page->text->decRefCnt(); #else if (page->gfx != NULL) delete page->gfx; if (page->text_dev != NULL) delete page->text_dev; #endif /* page->page is owned by the document */ }
CWE-189
769
11,394
146326674166001931900162626338498085533
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_find_text (PopplerPage *page, const char *text) { PopplerRectangle *match; GList *matches; double xMin, yMin, xMax, yMax; gunichar *ucs4; glong ucs4_len; double height; #if defined (HAVE_CAIRO) TextPage *text_dev; #else TextOutputDev *text_dev; #endif g_return_val_if_fail (POPPLER_IS_PAGE (page), FALSE); g_return_val_if_fail (text != NULL, FALSE); #if defined (HAVE_CAIRO) text_dev = poppler_page_get_text_page (page); #else text_dev = new TextOutputDev (NULL, gTrue, gFalse, gFalse); page->page->display (text_dev, 72, 72, 0, gFalse, gTrue, gFalse, page->document->doc->getCatalog()); #endif ucs4 = g_utf8_to_ucs4_fast (text, -1, &ucs4_len); poppler_page_get_size (page, NULL, &height); matches = NULL; xMin = 0; yMin = 0; while (text_dev->findText (ucs4, ucs4_len, gFalse, gTrue, // startAtTop, stopAtBottom gTrue, gFalse, // startAtLast, stopAtLast gFalse, gFalse, // caseSensitive, backwards &xMin, &yMin, &xMax, &yMax)) { match = g_new (PopplerRectangle, 1); match->x1 = xMin; match->y1 = height - yMax; match->x2 = xMax; match->y2 = height - yMin; matches = g_list_prepend (matches, match); } #if !defined (HAVE_CAIRO) delete text_dev; #endif g_free (ucs4); return g_list_reverse (matches); }
CWE-189
770
11,395
58373213448697592792253122317851014016
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_free_annot_mapping (GList *list) { if (!list) return; g_list_foreach (list, (GFunc)poppler_annot_mapping_free, NULL); g_list_free (list); }
CWE-189
771
11,396
295873926565590624380610804538219796097
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_free_form_field_mapping (GList *list) { if (list == NULL) return; g_list_foreach (list, (GFunc) poppler_form_field_mapping_free, NULL); g_list_free (list); }
CWE-189
772
11,397
13393342472769493245286337333068203026
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_free_image_mapping (GList *list) { if (list == NULL) return; g_list_foreach (list, (GFunc)g_free, NULL); g_list_free (list); }
CWE-189
773
11,398
252152134513609345940163869014871509970
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_free_image_mapping (GList *list) { }
CWE-189
774
11,399
134607403432497768518864549321048425672
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_free_link_mapping (GList *list) { if (list == NULL) return; g_list_foreach (list, (GFunc) (poppler_mapping_free), NULL); g_list_free (list); }
CWE-189
775
11,400
12368554591861511065762029585322658562
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_get_annot_mapping (PopplerPage *page) { GList *map_list = NULL; double width, height; gint i; g_return_val_if_fail (POPPLER_IS_PAGE (page), NULL); if (!page->annots) page->annots = page->page->getAnnots (page->document->doc->getCatalog ()); if (!page->annots) return NULL; poppler_page_get_size (page, &width, &height); for (i = 0; i < page->annots->getNumAnnots (); i++) { PopplerAnnotMapping *mapping; PopplerRectangle rect; Annot *annot; PDFRectangle *annot_rect; gint rotation = 0; annot = page->annots->getAnnot (i); /* Create the mapping */ mapping = poppler_annot_mapping_new (); switch (annot->getType ()) { case Annot::typeText: mapping->annot = _poppler_annot_text_new (annot); break; case Annot::typeFreeText: mapping->annot = _poppler_annot_free_text_new (annot); break; default: mapping->annot = _poppler_annot_new (annot); break; } annot_rect = annot->getRect (); rect.x1 = annot_rect->x1; rect.y1 = annot_rect->y1; rect.x2 = annot_rect->x2; rect.y2 = annot_rect->y2; if (! (annot->getFlags () & Annot::flagNoRotate)) rotation = page->page->getRotate (); switch (rotation) { case 90: mapping->area.x1 = rect.y1; mapping->area.y1 = height - rect.x2; mapping->area.x2 = mapping->area.x1 + (rect.y2 - rect.y1); mapping->area.y2 = mapping->area.y1 + (rect.x2 - rect.x1); break; case 180: mapping->area.x1 = width - rect.x2; mapping->area.y1 = height - rect.y2; mapping->area.x2 = mapping->area.x1 + (rect.x2 - rect.x1); mapping->area.y2 = mapping->area.y1 + (rect.y2 - rect.y1); break; case 270: mapping->area.x1 = width - rect.y2; mapping->area.y1 = rect.x1; mapping->area.x2 = mapping->area.x1 + (rect.y2 - rect.y1); mapping->area.y2 = mapping->area.y1 + (rect.x2 - rect.x1); break; default: mapping->area.x1 = rect.x1; mapping->area.y1 = rect.y1; mapping->area.x2 = rect.x2; mapping->area.y2 = rect.y2; } mapping->area.x1 -= page->page->getCropBox()->x1; mapping->area.x2 -= page->page->getCropBox()->x1; mapping->area.y1 -= page->page->getCropBox()->y1; mapping->area.y2 -= page->page->getCropBox()->y1; map_list = g_list_prepend (map_list, mapping); } return g_list_reverse (map_list); }
CWE-189
776
11,401
190670642184431713103401483166140042647
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_get_crop_box (PopplerPage *page, PopplerRectangle *rect) { PDFRectangle* cropBox = page->page->getCropBox (); rect->x1 = cropBox->x1; rect->x2 = cropBox->x2; rect->y1 = cropBox->y1; rect->y2 = cropBox->y2; }
CWE-189
777
11,402
151948820432038975520512638684857716350
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_get_duration (PopplerPage *page) { g_return_val_if_fail (POPPLER_IS_PAGE (page), -1); return page->page->getDuration (); }
CWE-189
778
11,403
242733315791125920084665109112870343982
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_get_form_field_mapping (PopplerPage *page) { GList *map_list = NULL; FormPageWidgets *forms; gint i; g_return_val_if_fail (POPPLER_IS_PAGE (page), NULL); forms = page->page->getPageWidgets (); if (forms == NULL) return NULL; for (i = 0; i < forms->getNumWidgets (); i++) { PopplerFormFieldMapping *mapping; FormWidget *field; mapping = poppler_form_field_mapping_new (); field = forms->getWidget (i); mapping->field = _poppler_form_field_new (page->document, field); field->getRect (&(mapping->area.x1), &(mapping->area.y1), &(mapping->area.x2), &(mapping->area.y2)); mapping->area.x1 -= page->page->getCropBox()->x1; mapping->area.x2 -= page->page->getCropBox()->x1; mapping->area.y1 -= page->page->getCropBox()->y1; mapping->area.y2 -= page->page->getCropBox()->y1; map_list = g_list_prepend (map_list, mapping); } return map_list; }
CWE-189
779
11,404
203736447517994838468630148612469165266
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_get_image (PopplerPage *page, gint image_id) { CairoImageOutputDev *out; cairo_surface_t *image; g_return_val_if_fail (POPPLER_IS_PAGE (page), NULL); out = poppler_page_get_image_output_dev (page, image_draw_decide_cb, GINT_TO_POINTER (image_id)); if (image_id >= out->getNumImages ()) { delete out; return NULL; } image = out->getImage (image_id)->getImage (); if (!image) { delete out; return NULL; } cairo_surface_reference (image); delete out; return image; }
CWE-189
780
11,405
121531270889879288299391185308158063205
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_get_image_mapping (PopplerPage *page) { GList *map_list = NULL; CairoImageOutputDev *out; gint i; g_return_val_if_fail (POPPLER_IS_PAGE (page), NULL); out = poppler_page_get_image_output_dev (page, NULL, NULL); for (i = 0; i < out->getNumImages (); i++) { PopplerImageMapping *mapping; CairoImage *image; image = out->getImage (i); /* Create the mapping */ mapping = g_new (PopplerImageMapping, 1); image->getRect (&(mapping->area.x1), &(mapping->area.y1), &(mapping->area.x2), &(mapping->area.y2)); mapping->image_id = i; mapping->area.x1 -= page->page->getCropBox()->x1; mapping->area.x2 -= page->page->getCropBox()->x1; mapping->area.y1 -= page->page->getCropBox()->y1; mapping->area.y2 -= page->page->getCropBox()->y1; map_list = g_list_prepend (map_list, mapping); } delete out; return map_list; }
CWE-189
781
11,406
5000966257629864390081873838544980617
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_get_image_mapping (PopplerPage *page) { return NULL; }
CWE-189
782
11,407
182150302472199018205246694126257281765
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_get_image_output_dev (PopplerPage *page, GBool (*imgDrawDeviceCbk)(int img_id, void *data), void *imgDrawCbkData) { CairoImageOutputDev *image_dev; Gfx *gfx; image_dev = new CairoImageOutputDev (); if (imgDrawDeviceCbk) { image_dev->setImageDrawDecideCbk (imgDrawDeviceCbk, imgDrawCbkData); } gfx = page->page->createGfx(image_dev, 72.0, 72.0, 0, gFalse, /* useMediaBox */ gTrue, /* Crop */ -1, -1, -1, -1, gFalse, /* printing */ page->document->doc->getCatalog (), NULL, NULL, NULL, NULL); page->page->display(gfx); delete gfx; return image_dev; }
CWE-189
783
11,408
76552950781222363123765560526768734410
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_get_link_mapping (PopplerPage *page) { GList *map_list = NULL; gint i; Links *links; Object obj; double width, height; g_return_val_if_fail (POPPLER_IS_PAGE (page), NULL); links = new Links (page->page->getAnnots (&obj), page->document->doc->getCatalog ()->getBaseURI ()); obj.free (); if (links == NULL) return NULL; poppler_page_get_size (page, &width, &height); for (i = 0; i < links->getNumLinks (); i++) { PopplerLinkMapping *mapping; PopplerRectangle rect; LinkAction *link_action; Link *link; link = links->getLink (i); link_action = link->getAction (); /* Create the mapping */ mapping = g_new (PopplerLinkMapping, 1); mapping->action = _poppler_action_new (page->document, link_action, NULL); link->getRect (&rect.x1, &rect.y1, &rect.x2, &rect.y2); switch (page->page->getRotate ()) { case 90: mapping->area.x1 = rect.y1; mapping->area.y1 = height - rect.x2; mapping->area.x2 = mapping->area.x1 + (rect.y2 - rect.y1); mapping->area.y2 = mapping->area.y1 + (rect.x2 - rect.x1); break; case 180: mapping->area.x1 = width - rect.x2; mapping->area.y1 = height - rect.y2; mapping->area.x2 = mapping->area.x1 + (rect.x2 - rect.x1); mapping->area.y2 = mapping->area.y1 + (rect.y2 - rect.y1); break; case 270: mapping->area.x1 = width - rect.y2; mapping->area.y1 = rect.x1; mapping->area.x2 = mapping->area.x1 + (rect.y2 - rect.y1); mapping->area.y2 = mapping->area.y1 + (rect.x2 - rect.x1); break; default: mapping->area.x1 = rect.x1; mapping->area.y1 = rect.y1; mapping->area.x2 = rect.x2; mapping->area.y2 = rect.y2; } mapping->area.x1 -= page->page->getCropBox()->x1; mapping->area.x2 -= page->page->getCropBox()->x1; mapping->area.y1 -= page->page->getCropBox()->y1; mapping->area.y2 -= page->page->getCropBox()->y1; map_list = g_list_prepend (map_list, mapping); } delete links; return map_list; }
CWE-189
785
11,409
85331103155009476114960003079395928443
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { PopplerPage *page = POPPLER_PAGE (object); GooString label; switch (prop_id) { case PROP_LABEL: page->document->doc->getCatalog ()->indexToLabel (page->index, &label); g_value_take_string (value, _poppler_goo_string_to_utf8(&label)); break; } }
CWE-189
786
11,410
26468185100286787476681006236798176068
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_get_selection_region (PopplerPage *page, gdouble scale, PopplerSelectionStyle style, PopplerRectangle *selection) { PDFRectangle poppler_selection; SelectionStyle selection_style = selectionStyleGlyph; GooList *list; GList *region = NULL; int i; poppler_selection.x1 = selection->x1; poppler_selection.y1 = selection->y1; poppler_selection.x2 = selection->x2; poppler_selection.y2 = selection->y2; switch (style) { case POPPLER_SELECTION_GLYPH: selection_style = selectionStyleGlyph; break; case POPPLER_SELECTION_WORD: selection_style = selectionStyleWord; break; case POPPLER_SELECTION_LINE: selection_style = selectionStyleLine; break; } #if defined (HAVE_CAIRO) TextPage *text; text = poppler_page_get_text_page (page); list = text->getSelectionRegion(&poppler_selection, selection_style, scale); #else TextOutputDev *text_dev; text_dev = poppler_page_get_text_output_dev (page); list = text_dev->getSelectionRegion(&poppler_selection, selection_style, scale); #endif for (i = 0; i < list->getLength(); i++) { PDFRectangle *selection_rect = (PDFRectangle *) list->get(i); PopplerRectangle *rect; rect = poppler_rectangle_new (); rect->x1 = selection_rect->x1; rect->y1 = selection_rect->y1; rect->x2 = selection_rect->x2; rect->y2 = selection_rect->y2; region = g_list_prepend (region, rect); delete selection_rect; } delete list; return g_list_reverse (region); }
CWE-189
787
11,411
73262659489876885766104784861635550841
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_get_size (PopplerPage *page, double *width, double *height) { double page_width, page_height; int rotate; g_return_if_fail (POPPLER_IS_PAGE (page)); rotate = page->page->getRotate (); if (rotate == 90 || rotate == 270) { page_height = page->page->getCropWidth (); page_width = page->page->getCropHeight (); } else { page_width = page->page->getCropWidth (); page_height = page->page->getCropHeight (); } if (width != NULL) *width = page_width; if (height != NULL) *height = page_height; }
CWE-189
788
11,412
227706901371355048739607324401049223396
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_get_text (PopplerPage *page, PopplerSelectionStyle style, PopplerRectangle *selection) { GooString *sel_text; double height; char *result; SelectionStyle selection_style = selectionStyleGlyph; PDFRectangle pdf_selection; g_return_val_if_fail (POPPLER_IS_PAGE (page), FALSE); g_return_val_if_fail (selection != NULL, NULL); poppler_page_get_size (page, NULL, &height); pdf_selection.x1 = selection->x1; pdf_selection.y1 = height - selection->y2; pdf_selection.x2 = selection->x2; pdf_selection.y2 = height - selection->y1; switch (style) { case POPPLER_SELECTION_GLYPH: selection_style = selectionStyleGlyph; break; case POPPLER_SELECTION_WORD: selection_style = selectionStyleWord; break; case POPPLER_SELECTION_LINE: selection_style = selectionStyleLine; break; } #if defined (HAVE_CAIRO) TextPage *text; text = poppler_page_get_text_page (page); sel_text = text->getSelectionText (&pdf_selection, selection_style); #else TextOutputDev *text_dev; text_dev = poppler_page_get_text_output_dev (page); sel_text = text_dev->getSelectionText (&pdf_selection, selection_style); #endif result = g_strdup (sel_text->getCString ()); delete sel_text; return result; }
CWE-189
789
11,413
41053920479018917763800548021965540804
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_get_text_output_dev (PopplerPage *page) { if (page->text_dev == NULL) { page->text_dev = new TextOutputDev (NULL, gTrue, gFalse, gFalse); if (page->gfx) delete page->gfx; page->gfx = page->page->createGfx(page->text_dev, 72.0, 72.0, 0, gFalse, /* useMediaBox */ gTrue, /* Crop */ -1, -1, -1, -1, gFalse, /* printing */ page->document->doc->getCatalog (), NULL, NULL, NULL, NULL); page->page->display(page->gfx); page->text_dev->endPage(); } return page->text_dev; }
CWE-189
790
11,414
229629987386990053523916591948619210902
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_get_text_page (PopplerPage *page) { if (page->text == NULL) { cairo_t *cr; cairo_surface_t *surface; surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, 1, 1); cr = cairo_create (surface); poppler_page_render (page, cr); cairo_destroy (cr); cairo_surface_destroy (surface); } return page->text; }
CWE-189
791
11,415
148805590170753664477317877453271853793
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_get_thumbnail (PopplerPage *page) { unsigned char *data; int width, height, rowstride; cairo_surface_t *surface; g_return_val_if_fail (POPPLER_IS_PAGE (page), FALSE); if (!page->page->loadThumb (&data, &width, &height, &rowstride)) return NULL; surface = create_surface_from_thumbnail_data (data, width, height, rowstride); gfree (data); return surface; }
CWE-189
792
11,416
198986583528515259393383765312100882167
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_get_thumbnail_pixbuf (PopplerPage *page) { unsigned char *data; int width, height, rowstride; g_return_val_if_fail (POPPLER_IS_PAGE (page), FALSE); if (!page->page->loadThumb (&data, &width, &height, &rowstride)) return NULL; return gdk_pixbuf_new_from_data (data, GDK_COLORSPACE_RGB, FALSE, 8, width, height, rowstride, (GdkPixbufDestroyNotify)gfree, NULL); }
CWE-189
793
11,417
317026678024211142902397863207436478684
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_get_thumbnail_size (PopplerPage *page, int *width, int *height) { Object thumb; Dict *dict; gboolean retval = FALSE; g_return_val_if_fail (POPPLER_IS_PAGE (page), FALSE); g_return_val_if_fail (width != NULL, FALSE); g_return_val_if_fail (height != NULL, FALSE); page->page->getThumb (&thumb); if (!thumb.isStream ()) { thumb.free (); return FALSE; } dict = thumb.streamGetDict(); /* Theoretically, this could succeed and you would still fail when * loading the thumb */ if (dict->lookupInt ("Width", "W", width) && dict->lookupInt ("Height", "H", height)) retval = TRUE; thumb.free (); return retval; }
CWE-189
794
11,418
212568925501225651180372035519580254576
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_get_transition (PopplerPage *page) { PageTransition *trans; PopplerPageTransition *transition; Object obj; g_return_val_if_fail (POPPLER_IS_PAGE (page), NULL); trans = new PageTransition (page->page->getTrans (&obj)); obj.free (); if (!trans->isOk ()) { delete trans; return NULL; } transition = poppler_page_transition_new (); switch (trans->getType ()) { case transitionReplace: transition->type = POPPLER_PAGE_TRANSITION_REPLACE; break; case transitionSplit: transition->type = POPPLER_PAGE_TRANSITION_SPLIT; break; case transitionBlinds: transition->type = POPPLER_PAGE_TRANSITION_BLINDS; break; case transitionBox: transition->type = POPPLER_PAGE_TRANSITION_BOX; break; case transitionWipe: transition->type = POPPLER_PAGE_TRANSITION_WIPE; break; case transitionDissolve: transition->type = POPPLER_PAGE_TRANSITION_DISSOLVE; break; case transitionGlitter: transition->type = POPPLER_PAGE_TRANSITION_GLITTER; break; case transitionFly: transition->type = POPPLER_PAGE_TRANSITION_FLY; break; case transitionPush: transition->type = POPPLER_PAGE_TRANSITION_PUSH; break; case transitionCover: transition->type = POPPLER_PAGE_TRANSITION_COVER; break; case transitionUncover: transition->type = POPPLER_PAGE_TRANSITION_UNCOVER; break; case transitionFade: transition->type = POPPLER_PAGE_TRANSITION_FADE; break; default: g_assert_not_reached (); } transition->alignment = (trans->getAlignment() == transitionHorizontal) ? POPPLER_PAGE_TRANSITION_HORIZONTAL : POPPLER_PAGE_TRANSITION_VERTICAL; transition->direction = (trans->getDirection() == transitionInward) ? POPPLER_PAGE_TRANSITION_INWARD : POPPLER_PAGE_TRANSITION_OUTWARD; transition->duration = trans->getDuration(); transition->angle = trans->getAngle(); transition->scale = trans->getScale(); transition->rectangular = trans->isRectangular(); delete trans; return transition; }
CWE-189
795
11,419
307442165207418729894300847102088708144
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_init (PopplerPage *page) { }
CWE-189
796
11,420
54892733165717572971794017020965099704
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_prepare_output_dev (PopplerPage *page, double scale, int rotation, gboolean transparent, OutputDevData *output_dev_data) { CairoOutputDev *output_dev; cairo_surface_t *surface; double width, height; int cairo_width, cairo_height, cairo_rowstride, rotate; unsigned char *cairo_data; rotate = rotation + page->page->getRotate (); if (rotate == 90 || rotate == 270) { height = page->page->getCropWidth (); width = page->page->getCropHeight (); } else { width = page->page->getCropWidth (); height = page->page->getCropHeight (); } cairo_width = (int) ceil(width * scale); cairo_height = (int) ceil(height * scale); output_dev = page->document->output_dev; cairo_rowstride = cairo_width * 4; cairo_data = (guchar *) gmallocn (cairo_height, cairo_rowstride); if (transparent) memset (cairo_data, 0x00, cairo_height * cairo_rowstride); else memset (cairo_data, 0xff, cairo_height * cairo_rowstride); surface = cairo_image_surface_create_for_data(cairo_data, CAIRO_FORMAT_ARGB32, cairo_width, cairo_height, cairo_rowstride); output_dev_data->cairo_data = cairo_data; output_dev_data->surface = surface; output_dev_data->cairo = cairo_create (surface); output_dev->setCairo (output_dev_data->cairo); }
CWE-189
797
11,421
330869267907243942093479935882335377215
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_render (PopplerPage *page, cairo_t *cairo) { g_return_if_fail (POPPLER_IS_PAGE (page)); if (!page->text) page->text = new TextPage(gFalse); _poppler_page_render (page, cairo, gFalse); }
CWE-189
799
11,422
96022072506495021213405184717648071128
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_render_for_printing (PopplerPage *page, cairo_t *cairo) { g_return_if_fail (POPPLER_IS_PAGE (page)); _poppler_page_render (page, cairo, gTrue); }
CWE-189
800
11,423
215592190801643023118760570535104564978
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_render_selection (PopplerPage *page, cairo_t *cairo, PopplerRectangle *selection, PopplerRectangle *old_selection, PopplerSelectionStyle style, PopplerColor *glyph_color, PopplerColor *background_color) { CairoOutputDev *output_dev; TextPage *text; SelectionStyle selection_style = selectionStyleGlyph; PDFRectangle pdf_selection(selection->x1, selection->y1, selection->x2, selection->y2); GfxColor gfx_background_color = { { background_color->red, background_color->green, background_color->blue } }; GfxColor gfx_glyph_color = { { glyph_color->red, glyph_color->green, glyph_color->blue } }; switch (style) { case POPPLER_SELECTION_GLYPH: selection_style = selectionStyleGlyph; break; case POPPLER_SELECTION_WORD: selection_style = selectionStyleWord; break; case POPPLER_SELECTION_LINE: selection_style = selectionStyleLine; break; } output_dev = page->document->output_dev; output_dev->setCairo (cairo); text = poppler_page_get_text_page (page); text->drawSelection (output_dev, 1.0, 0, &pdf_selection, selection_style, &gfx_glyph_color, &gfx_background_color); output_dev->setCairo (NULL); }
CWE-189
801
11,424
179813685967082571413775949711604634499
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_render_selection_to_pixbuf (PopplerPage *page, gdouble scale, int rotation, GdkPixbuf *pixbuf, PopplerRectangle *selection, PopplerRectangle *old_selection, PopplerSelectionStyle style, GdkColor *glyph_color, GdkColor *background_color) { OutputDev *output_dev; OutputDevData data; SelectionStyle selection_style = selectionStyleGlyph; PDFRectangle pdf_selection(selection->x1, selection->y1, selection->x2, selection->y2); GfxColor gfx_background_color = { { background_color->red, background_color->green, background_color->blue } }; GfxColor gfx_glyph_color = { { glyph_color->red, glyph_color->green, glyph_color->blue } }; switch (style) { case POPPLER_SELECTION_GLYPH: selection_style = selectionStyleGlyph; break; case POPPLER_SELECTION_WORD: selection_style = selectionStyleWord; break; case POPPLER_SELECTION_LINE: selection_style = selectionStyleLine; break; } output_dev = page->document->output_dev; poppler_page_prepare_output_dev (page, scale, rotation, TRUE, &data); #if defined (HAVE_CAIRO) TextPage *text; text = poppler_page_get_text_page (page); text->drawSelection (output_dev, scale, rotation, &pdf_selection, selection_style, &gfx_glyph_color, &gfx_background_color); #else TextOutputDev *text_dev; text_dev = poppler_page_get_text_output_dev (page); text_dev->drawSelection (output_dev, scale, rotation, &pdf_selection, selection_style, &gfx_glyph_color, &gfx_background_color); /* We'll need a function to destroy page->text_dev and page->gfx * when the application wants to get rid of them. * * Two improvements: 1) make GfxFont refcounted and let TextPage and * friends hold a reference to the GfxFonts they need so we can free * up Gfx early. 2) use a TextPage directly when rendering the page * so we don't have to use TextOutputDev and render a second * time. */ #endif poppler_page_copy_to_pixbuf (page, pixbuf, &data); poppler_page_set_selection_alpha (page, scale, pixbuf, style, selection); }
CWE-189
802
11,425
259553581922897193810533874590057454376
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_render_to_pixbuf (PopplerPage *page, int src_x, int src_y, int src_width, int src_height, double scale, int rotation, GdkPixbuf *pixbuf) { g_return_if_fail (POPPLER_IS_PAGE (page)); g_return_if_fail (scale > 0.0); g_return_if_fail (pixbuf != NULL); _poppler_page_render_to_pixbuf (page, src_x, src_y, src_width, src_height, scale, rotation, gFalse, pixbuf); }
CWE-189
803
11,426
78190675890501512417851766205740087134
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_render_to_ps (PopplerPage *page, PopplerPSFile *ps_file) { g_return_if_fail (POPPLER_IS_PAGE (page)); g_return_if_fail (ps_file != NULL); if (!ps_file->out) ps_file->out = new PSOutputDev (ps_file->filename, ps_file->document->doc->getXRef(), ps_file->document->doc->getCatalog(), NULL, ps_file->first_page, ps_file->last_page, psModePS, (int)ps_file->paper_width, (int)ps_file->paper_height, ps_file->duplex, 0, 0, 0, 0, gFalse, gFalse); ps_file->document->doc->displayPage (ps_file->out, page->index + 1, 72.0, 72.0, 0, gFalse, gTrue, gFalse); }
CWE-189
805
11,427
117990100874064102633523046740136714248
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_selection_region_free (GList *region) { if (!region) return; g_list_foreach (region, (GFunc)poppler_rectangle_free, NULL); g_list_free (region); }
CWE-189
806
11,428
325245833211390924263281768743076407023
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_set_selection_alpha (PopplerPage *page, double scale, GdkPixbuf *pixbuf, PopplerSelectionStyle style, PopplerRectangle *selection) { /* Cairo doesn't need this, since cairo generates an alpha channel. */ }
CWE-189
807
11,429
48734775105510746405522406637203638867
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_set_selection_alpha (PopplerPage *page, double scale, GdkPixbuf *pixbuf, PopplerSelectionStyle style, PopplerRectangle *selection) { GList *region, *l; gint x, y, width, height; int pixbuf_rowstride, pixbuf_n_channels; guchar *pixbuf_data, *dst; pixbuf_data = gdk_pixbuf_get_pixels (pixbuf); pixbuf_rowstride = gdk_pixbuf_get_rowstride (pixbuf); pixbuf_n_channels = gdk_pixbuf_get_n_channels (pixbuf); width = gdk_pixbuf_get_width (pixbuf); height = gdk_pixbuf_get_height (pixbuf); if (pixbuf_n_channels != 4) return; for (y = 0; y < height; y++) { dst = pixbuf_data + y * pixbuf_rowstride; for (x = 0; x < width; x++) { dst[3] = 0x00; dst += pixbuf_n_channels; } } region = poppler_page_get_selection_region (page, scale, style, selection); for (l = region; l; l = g_list_next (l)) { PopplerRectangle *rectangle = (PopplerRectangle *)l->data; GdkRectangle rect; rect.x = (gint)rectangle->x1; rect.y = (gint)rectangle->y1; rect.width = (gint) (rectangle->x2 - rectangle->x1); rect.height = (gint) (rectangle->y2 - rectangle->y1); for (y = 0; y < rect.height; y++) { dst = pixbuf_data + (rect.y + y) * pixbuf_rowstride + rect.x * pixbuf_n_channels; for (x = 0; x < rect.width; x++) { dst[3] = 0xff; dst += pixbuf_n_channels; } } } poppler_page_selection_region_free (region); }
CWE-189
808
11,430
264012997649379358104853524700302900765
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_transition_copy (PopplerPageTransition *transition) { PopplerPageTransition *new_transition; new_transition = poppler_page_transition_new (); *new_transition = *transition; return new_transition; }
CWE-189
809
11,431
299099051566963630277131451556371269592
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_page_transition_free (PopplerPageTransition *transition) { g_free (transition); }
CWE-189
810
11,432
143873816334424813217224493589044225289
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_print_annot_cb (Annot *annot, void *user_data) { if (annot->getFlags () & Annot::flagPrint) return gTrue; return (annot->getType() == Annot::typeWidget); }
CWE-189
812
11,433
295308509253832803778241381449227026512
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_rectangle_copy (PopplerRectangle *rectangle) { PopplerRectangle *new_rectangle; g_return_val_if_fail (rectangle != NULL, NULL); new_rectangle = g_new (PopplerRectangle, 1); *new_rectangle = *rectangle; return new_rectangle; }
CWE-189
813
11,434
329735560898738246333109074007210990491
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_rectangle_free (PopplerRectangle *rectangle) { g_free (rectangle); }
CWE-189
814
11,435
242026125711741790082924691213141919848
null
null
null
poppler
c839b706092583f6b12ed3cc634bf5af34b7a2bb
0
poppler_rectangle_new (void) { return g_new0 (PopplerRectangle, 1); }
CWE-189
815
11,436
297160989146267025799199591172037994226
null
null
null
poppler
284a92899602daa4a7f429e61849e794569310b5
0
SplashOutFontFileID(Ref *rA) { r = *rA; }
CWE-189
816
11,437
287683828521838829313814620270711541188
null
null
null
poppler
284a92899602daa4a7f429e61849e794569310b5
0
SplashOutputDev::SplashOutputDev(SplashColorMode colorModeA, int bitmapRowPadA, GBool reverseVideoA, SplashColorPtr paperColorA, GBool bitmapTopDownA, GBool allowAntialiasA) { colorMode = colorModeA; bitmapRowPad = bitmapRowPadA; bitmapTopDown = bitmapTopDownA; allowAntialias = allowAntialiasA; vectorAntialias = allowAntialias && globalParams->getVectorAntialias() && colorMode != splashModeMono1; setupScreenParams(72.0, 72.0); reverseVideo = reverseVideoA; splashColorCopy(paperColor, paperColorA); xref = NULL; bitmap = new SplashBitmap(1, 1, bitmapRowPad, colorMode, colorMode != splashModeMono1, bitmapTopDown); splash = new Splash(bitmap, vectorAntialias, &screenParams); splash->clear(paperColor, 0); fontEngine = NULL; nT3Fonts = 0; t3GlyphStack = NULL; font = NULL; needFontUpdate = gFalse; textClipPath = NULL; transpGroupStack = NULL; }
CWE-189
817
11,438
80228437156337678480014645674330569040
null
null
null
poppler
284a92899602daa4a7f429e61849e794569310b5
0
T3FontCache::T3FontCache(Ref *fontIDA, double m11A, double m12A, double m21A, double m22A, int glyphXA, int glyphYA, int glyphWA, int glyphHA, GBool validBBoxA, GBool aa) { int i; fontID = *fontIDA; m11 = m11A; m12 = m12A; m21 = m21A; m22 = m22A; glyphX = glyphXA; glyphY = glyphYA; glyphW = glyphWA; glyphH = glyphHA; validBBox = validBBoxA; if (aa) { glyphSize = glyphW * glyphH; } else { glyphSize = ((glyphW + 7) >> 3) * glyphH; } cacheAssoc = 8; if (glyphSize <= 256) { cacheSets = 8; } else if (glyphSize <= 512) { cacheSets = 4; } else if (glyphSize <= 1024) { cacheSets = 2; } else if (glyphSize <= 2048) { cacheSets = 1; cacheAssoc = 4; } else if (glyphSize <= 4096) { cacheSets = 1; cacheAssoc = 2; } else { cacheSets = 1; cacheAssoc = 1; } if (glyphSize < 10485760 / cacheAssoc / cacheSets) { cacheData = (Guchar *)gmallocn_checkoverflow(cacheSets * cacheAssoc, glyphSize); } else { error(-1, "Not creating cacheData for T3FontCache, it asked for too much memory.\n" " This could teoretically result in wrong rendering,\n" " but most probably the document is bogus.\n" " Please report a bug if you think the rendering may be wrong because of this."); cacheData = NULL; } if (cacheData != NULL) { cacheTags = (T3FontCacheTag *)gmallocn(cacheSets * cacheAssoc, sizeof(T3FontCacheTag)); for (i = 0; i < cacheSets * cacheAssoc; ++i) { cacheTags[i].mru = i & (cacheAssoc - 1); } } else { cacheTags = NULL; } }
CWE-189
818
11,439
73556705620886826418594426589714591915
null
null
null
poppler
284a92899602daa4a7f429e61849e794569310b5
0
GBool SplashOutputDev::alphaImageSrc(void *data, SplashColorPtr colorLine, Guchar *alphaLine) { SplashOutImageData *imgData = (SplashOutImageData *)data; Guchar *p, *aq; SplashColorPtr q, col; GfxRGB rgb; GfxGray gray; #if SPLASH_CMYK GfxCMYK cmyk; #endif Guchar alpha; int nComps, x, i; if (imgData->y == imgData->height) { return gFalse; } nComps = imgData->colorMap->getNumPixelComps(); for (x = 0, p = imgData->imgStr->getLine(), q = colorLine, aq = alphaLine; x < imgData->width; ++x, p += nComps) { alpha = 0; for (i = 0; i < nComps; ++i) { if (p[i] < imgData->maskColors[2*i] || p[i] > imgData->maskColors[2*i+1]) { alpha = 0xff; break; } } if (imgData->lookup) { switch (imgData->colorMode) { case splashModeMono1: case splashModeMono8: *q++ = imgData->lookup[*p]; *aq++ = alpha; break; case splashModeRGB8: case splashModeBGR8: col = &imgData->lookup[3 * *p]; *q++ = col[0]; *q++ = col[1]; *q++ = col[2]; *aq++ = alpha; break; case splashModeXBGR8: col = &imgData->lookup[4 * *p]; *q++ = col[0]; *q++ = col[1]; *q++ = col[2]; *q++ = 255; *aq++ = alpha; break; #if SPLASH_CMYK case splashModeCMYK8: col = &imgData->lookup[4 * *p]; *q++ = col[0]; *q++ = col[1]; *q++ = col[2]; *q++ = col[3]; *aq++ = alpha; break; #endif } } else { switch (imgData->colorMode) { case splashModeMono1: case splashModeMono8: imgData->colorMap->getGray(p, &gray); *q++ = colToByte(gray); *aq++ = alpha; break; case splashModeXBGR8: case splashModeRGB8: case splashModeBGR8: imgData->colorMap->getRGB(p, &rgb); *q++ = colToByte(rgb.r); *q++ = colToByte(rgb.g); *q++ = colToByte(rgb.b); if (imgData->colorMode == splashModeXBGR8) *q++ = 255; *aq++ = alpha; break; #if SPLASH_CMYK case splashModeCMYK8: imgData->colorMap->getCMYK(p, &cmyk); *q++ = colToByte(cmyk.c); *q++ = colToByte(cmyk.m); *q++ = colToByte(cmyk.y); *q++ = colToByte(cmyk.k); *aq++ = alpha; break; #endif } } } ++imgData->y; return gTrue; }
CWE-189
819
11,440
237676803937400282908221962287518563949
null
null
null
poppler
284a92899602daa4a7f429e61849e794569310b5
0
void SplashOutputDev::beginTransparencyGroup(GfxState *state, double *bbox, GfxColorSpace *blendingColorSpace, GBool isolated, GBool /*knockout*/, GBool /*forSoftMask*/) { SplashTransparencyGroup *transpGroup; SplashColor color; double xMin, yMin, xMax, yMax, x, y; int tx, ty, w, h; state->transform(bbox[0], bbox[1], &x, &y); xMin = xMax = x; yMin = yMax = y; state->transform(bbox[0], bbox[3], &x, &y); if (x < xMin) { xMin = x; } else if (x > xMax) { xMax = x; } if (y < yMin) { yMin = y; } else if (y > yMax) { yMax = y; } state->transform(bbox[2], bbox[1], &x, &y); if (x < xMin) { xMin = x; } else if (x > xMax) { xMax = x; } if (y < yMin) { yMin = y; } else if (y > yMax) { yMax = y; } state->transform(bbox[2], bbox[3], &x, &y); if (x < xMin) { xMin = x; } else if (x > xMax) { xMax = x; } if (y < yMin) { yMin = y; } else if (y > yMax) { yMax = y; } tx = (int)floor(xMin); if (tx < 0) { tx = 0; } else if (tx > bitmap->getWidth()) { tx = bitmap->getWidth(); } ty = (int)floor(yMin); if (ty < 0) { ty = 0; } else if (ty > bitmap->getHeight()) { ty = bitmap->getHeight(); } w = (int)ceil(xMax) - tx + 1; if (tx + w > bitmap->getWidth()) { w = bitmap->getWidth() - tx; } if (w < 1) { w = 1; } h = (int)ceil(yMax) - ty + 1; if (ty + h > bitmap->getHeight()) { h = bitmap->getHeight() - ty; } if (h < 1) { h = 1; } transpGroup = new SplashTransparencyGroup(); transpGroup->tx = tx; transpGroup->ty = ty; transpGroup->blendingColorSpace = blendingColorSpace; transpGroup->isolated = isolated; transpGroup->next = transpGroupStack; transpGroupStack = transpGroup; transpGroup->origBitmap = bitmap; transpGroup->origSplash = splash; bitmap = new SplashBitmap(w, h, bitmapRowPad, colorMode, gTrue, bitmapTopDown); splash = new Splash(bitmap, vectorAntialias, transpGroup->origSplash->getScreen()); if (isolated) { switch (colorMode) { case splashModeMono1: case splashModeMono8: color[0] = 0; break; case splashModeXBGR8: color[3] = 255; case splashModeRGB8: case splashModeBGR8: color[0] = color[1] = color[2] = 0; break; #if SPLASH_CMYK case splashModeCMYK8: color[0] = color[1] = color[2] = color[3] = 0; break; #endif default: break; } splash->clear(color, 0); } else { splash->blitTransparent(transpGroup->origBitmap, tx, ty, 0, 0, w, h); splash->setInNonIsolatedGroup(transpGroup->origBitmap, tx, ty); } transpGroup->tBitmap = bitmap; state->shiftCTM(-tx, -ty); updateCTM(state, 0, 0, 0, 0, 0, 0); }
CWE-189
820
11,441
323063938721157327742223014217322791201
null
null
null
poppler
284a92899602daa4a7f429e61849e794569310b5
0
GBool SplashOutputDev::beginType3Char(GfxState *state, double x, double y, double dx, double dy, CharCode code, Unicode *u, int uLen) { GfxFont *gfxFont; Ref *fontID; double *ctm, *bbox; T3FontCache *t3Font; T3GlyphStack *t3gs; GBool validBBox; double x1, y1, xMin, yMin, xMax, yMax, xt, yt; int i, j; if (!(gfxFont = state->getFont())) { return gFalse; } fontID = gfxFont->getID(); ctm = state->getCTM(); state->transform(0, 0, &xt, &yt); if (!(nT3Fonts > 0 && t3FontCache[0]->matches(fontID, ctm[0], ctm[1], ctm[2], ctm[3]))) { for (i = 1; i < nT3Fonts; ++i) { if (t3FontCache[i]->matches(fontID, ctm[0], ctm[1], ctm[2], ctm[3])) { t3Font = t3FontCache[i]; for (j = i; j > 0; --j) { t3FontCache[j] = t3FontCache[j - 1]; } t3FontCache[0] = t3Font; break; } } if (i >= nT3Fonts) { if (nT3Fonts == splashOutT3FontCacheSize) { delete t3FontCache[nT3Fonts - 1]; --nT3Fonts; } for (j = nT3Fonts; j > 0; --j) { t3FontCache[j] = t3FontCache[j - 1]; } ++nT3Fonts; bbox = gfxFont->getFontBBox(); if (bbox[0] == 0 && bbox[1] == 0 && bbox[2] == 0 && bbox[3] == 0) { xMin = xt - 5; xMax = xMin + 30; yMax = yt + 15; yMin = yMax - 45; validBBox = gFalse; } else { state->transform(bbox[0], bbox[1], &x1, &y1); xMin = xMax = x1; yMin = yMax = y1; state->transform(bbox[0], bbox[3], &x1, &y1); if (x1 < xMin) { xMin = x1; } else if (x1 > xMax) { xMax = x1; } if (y1 < yMin) { yMin = y1; } else if (y1 > yMax) { yMax = y1; } state->transform(bbox[2], bbox[1], &x1, &y1); if (x1 < xMin) { xMin = x1; } else if (x1 > xMax) { xMax = x1; } if (y1 < yMin) { yMin = y1; } else if (y1 > yMax) { yMax = y1; } state->transform(bbox[2], bbox[3], &x1, &y1); if (x1 < xMin) { xMin = x1; } else if (x1 > xMax) { xMax = x1; } if (y1 < yMin) { yMin = y1; } else if (y1 > yMax) { yMax = y1; } validBBox = gTrue; } t3FontCache[0] = new T3FontCache(fontID, ctm[0], ctm[1], ctm[2], ctm[3], (int)floor(xMin - xt), (int)floor(yMin - yt), (int)ceil(xMax) - (int)floor(xMin) + 3, (int)ceil(yMax) - (int)floor(yMin) + 3, validBBox, colorMode != splashModeMono1); } } t3Font = t3FontCache[0]; i = (code & (t3Font->cacheSets - 1)) * t3Font->cacheAssoc; for (j = 0; j < t3Font->cacheAssoc; ++j) { if (t3Font->cacheTags != NULL) { if ((t3Font->cacheTags[i+j].mru & 0x8000) && t3Font->cacheTags[i+j].code == code) { drawType3Glyph(t3Font, &t3Font->cacheTags[i+j], t3Font->cacheData + (i+j) * t3Font->glyphSize); return gTrue; } } } t3gs = new T3GlyphStack(); t3gs->next = t3GlyphStack; t3GlyphStack = t3gs; t3GlyphStack->code = code; t3GlyphStack->cache = t3Font; t3GlyphStack->cacheTag = NULL; t3GlyphStack->cacheData = NULL; return gFalse; }
CWE-189
821
11,442
334405439552589913315263676023291247288
null
null
null
poppler
284a92899602daa4a7f429e61849e794569310b5
0
void SplashOutputDev::clearModRegion() { splash->clearModRegion(); }
CWE-189
822
11,443
42311685496657995285023865663679460848
null
null
null
poppler
284a92899602daa4a7f429e61849e794569310b5
0
void SplashOutputDev::clearSoftMask(GfxState * /*state*/) { splash->setSoftMask(NULL); }
CWE-189
823
11,444
73198544203263117199412738328126864799
null
null
null
poppler
284a92899602daa4a7f429e61849e794569310b5
0
void SplashOutputDev::clip(GfxState *state) { SplashPath *path; path = convertPath(state, state->getPath()); splash->clipToPath(path, gFalse); delete path; }
CWE-189
824
11,445
340030697527636178313075496957909513314
null
null
null
poppler
284a92899602daa4a7f429e61849e794569310b5
0
void SplashOutputDev::clipToStrokePath(GfxState *state) { SplashPath *path, *path2; path = convertPath(state, state->getPath()); path2 = splash->makeStrokePath(path); delete path; splash->clipToPath(path2, gFalse); delete path2; }
CWE-189
825
11,446
272960097535078362414352510897467612730
null
null
null
poppler
284a92899602daa4a7f429e61849e794569310b5
0
SplashPath *SplashOutputDev::convertPath(GfxState * /*state*/, GfxPath *path) { SplashPath *sPath; GfxSubpath *subpath; int i, j; sPath = new SplashPath(); for (i = 0; i < path->getNumSubpaths(); ++i) { subpath = path->getSubpath(i); if (subpath->getNumPoints() > 0) { sPath->moveTo((SplashCoord)subpath->getX(0), (SplashCoord)subpath->getY(0)); j = 1; while (j < subpath->getNumPoints()) { if (subpath->getCurve(j)) { sPath->curveTo((SplashCoord)subpath->getX(j), (SplashCoord)subpath->getY(j), (SplashCoord)subpath->getX(j+1), (SplashCoord)subpath->getY(j+1), (SplashCoord)subpath->getX(j+2), (SplashCoord)subpath->getY(j+2)); j += 3; } else { sPath->lineTo((SplashCoord)subpath->getX(j), (SplashCoord)subpath->getY(j)); ++j; } } if (subpath->isClosed()) { sPath->close(); } } } return sPath; }
CWE-189
826
11,447
94272420264496202796678397940823592558
null
null
null