idx
int64
func_before
string
Vulnerability Classification
string
vul
int64
func_after
string
patch
string
CWE ID
string
lines_before
string
lines_after
string
200
bgp_attr_unintern (struct attr **attr) { struct attr *ret; struct attr tmp; /* Decrement attribute reference. */ (*attr)->refcnt--; tmp = *(*attr); if ((*attr)->extra) { tmp.extra = bgp_attr_extra_new (); memcpy (tmp.extra, (*attr)->extra, sizeof (struct attr_extra)); } /* If reference becomes zero then free attribute object. */ if ((*attr)->refcnt == 0) { ret = hash_release (attrhash, *attr); assert (ret != NULL); bgp_attr_extra_free (*attr); XFREE (MTYPE_ATTR, *attr); *attr = NULL; } bgp_attr_unintern_sub (&tmp); bgp_attr_extra_free (&tmp); }
DoS
0
bgp_attr_unintern (struct attr **attr) { struct attr *ret; struct attr tmp; /* Decrement attribute reference. */ (*attr)->refcnt--; tmp = *(*attr); if ((*attr)->extra) { tmp.extra = bgp_attr_extra_new (); memcpy (tmp.extra, (*attr)->extra, sizeof (struct attr_extra)); } /* If reference becomes zero then free attribute object. */ if ((*attr)->refcnt == 0) { ret = hash_release (attrhash, *attr); assert (ret != NULL); bgp_attr_extra_free (*attr); XFREE (MTYPE_ATTR, *attr); *attr = NULL; } bgp_attr_unintern_sub (&tmp); bgp_attr_extra_free (&tmp); }
@@ -1646,7 +1646,7 @@ bgp_attr_ext_communities (struct bgp_attr_parser_args *args) static bgp_attr_parse_ret_t bgp_attr_unknown (struct bgp_attr_parser_args *args) { - bgp_size_t total; + bgp_size_t total = args->total; struct transit *transit; struct attr_extra *attre; struct peer *const peer = args->peer;
null
null
null
201
bgp_attr_unintern_sub (struct attr *attr) { /* aspath refcount shoud be decrement. */ if (attr->aspath) aspath_unintern (&attr->aspath); UNSET_FLAG(attr->flag, BGP_ATTR_AS_PATH); if (attr->community) community_unintern (&attr->community); UNSET_FLAG(attr->flag, BGP_ATTR_COMMUNITIES); if (attr->extra) { if (attr->extra->ecommunity) ecommunity_unintern (&attr->extra->ecommunity); UNSET_FLAG(attr->flag, BGP_ATTR_EXT_COMMUNITIES); if (attr->extra->cluster) cluster_unintern (attr->extra->cluster); UNSET_FLAG(attr->flag, BGP_ATTR_CLUSTER_LIST); if (attr->extra->transit) transit_unintern (attr->extra->transit); } }
DoS
0
bgp_attr_unintern_sub (struct attr *attr) { /* aspath refcount shoud be decrement. */ if (attr->aspath) aspath_unintern (&attr->aspath); UNSET_FLAG(attr->flag, BGP_ATTR_AS_PATH); if (attr->community) community_unintern (&attr->community); UNSET_FLAG(attr->flag, BGP_ATTR_COMMUNITIES); if (attr->extra) { if (attr->extra->ecommunity) ecommunity_unintern (&attr->extra->ecommunity); UNSET_FLAG(attr->flag, BGP_ATTR_EXT_COMMUNITIES); if (attr->extra->cluster) cluster_unintern (attr->extra->cluster); UNSET_FLAG(attr->flag, BGP_ATTR_CLUSTER_LIST); if (attr->extra->transit) transit_unintern (attr->extra->transit); } }
@@ -1646,7 +1646,7 @@ bgp_attr_ext_communities (struct bgp_attr_parser_args *args) static bgp_attr_parse_ret_t bgp_attr_unknown (struct bgp_attr_parser_args *args) { - bgp_size_t total; + bgp_size_t total = args->total; struct transit *transit; struct attr_extra *attre; struct peer *const peer = args->peer;
null
null
null
202
bgp_dump_routes_attr (struct stream *s, struct attr *attr, struct prefix *prefix) { unsigned long cp; unsigned long len; size_t aspath_lenp; struct aspath *aspath; /* Remember current pointer. */ cp = stream_get_endp (s); /* Place holder of length. */ stream_putw (s, 0); /* Origin attribute. */ stream_putc (s, BGP_ATTR_FLAG_TRANS); stream_putc (s, BGP_ATTR_ORIGIN); stream_putc (s, 1); stream_putc (s, attr->origin); aspath = attr->aspath; stream_putc (s, BGP_ATTR_FLAG_TRANS|BGP_ATTR_FLAG_EXTLEN); stream_putc (s, BGP_ATTR_AS_PATH); aspath_lenp = stream_get_endp (s); stream_putw (s, 0); stream_putw_at (s, aspath_lenp, aspath_put (s, aspath, 1)); /* Nexthop attribute. */ /* If it's an IPv6 prefix, don't dump the IPv4 nexthop to save space */ if(prefix != NULL #ifdef HAVE_IPV6 && prefix->family != AF_INET6 #endif /* HAVE_IPV6 */ ) { stream_putc (s, BGP_ATTR_FLAG_TRANS); stream_putc (s, BGP_ATTR_NEXT_HOP); stream_putc (s, 4); stream_put_ipv4 (s, attr->nexthop.s_addr); } /* MED attribute. */ if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) { stream_putc (s, BGP_ATTR_FLAG_OPTIONAL); stream_putc (s, BGP_ATTR_MULTI_EXIT_DISC); stream_putc (s, 4); stream_putl (s, attr->med); } /* Local preference. */ if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) { stream_putc (s, BGP_ATTR_FLAG_TRANS); stream_putc (s, BGP_ATTR_LOCAL_PREF); stream_putc (s, 4); stream_putl (s, attr->local_pref); } /* Atomic aggregate. */ if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)) { stream_putc (s, BGP_ATTR_FLAG_TRANS); stream_putc (s, BGP_ATTR_ATOMIC_AGGREGATE); stream_putc (s, 0); } /* Aggregator. */ if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR)) { assert (attr->extra); stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS); stream_putc (s, BGP_ATTR_AGGREGATOR); stream_putc (s, 8); stream_putl (s, attr->extra->aggregator_as); stream_put_ipv4 (s, attr->extra->aggregator_addr.s_addr); } /* Community attribute. */ if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES)) { if (attr->community->size * 4 > 255) { stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS|BGP_ATTR_FLAG_EXTLEN); stream_putc (s, BGP_ATTR_COMMUNITIES); stream_putw (s, attr->community->size * 4); } else { stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS); stream_putc (s, BGP_ATTR_COMMUNITIES); stream_putc (s, attr->community->size * 4); } stream_put (s, attr->community->val, attr->community->size * 4); } #ifdef HAVE_IPV6 /* Add a MP_NLRI attribute to dump the IPv6 next hop */ if (prefix != NULL && prefix->family == AF_INET6 && attr->extra && (attr->extra->mp_nexthop_len == 16 || attr->extra->mp_nexthop_len == 32) ) { int sizep; struct attr_extra *attre = attr->extra; stream_putc(s, BGP_ATTR_FLAG_OPTIONAL); stream_putc(s, BGP_ATTR_MP_REACH_NLRI); sizep = stream_get_endp (s); /* MP header */ stream_putc (s, 0); /* Marker: Attribute length. */ stream_putw(s, AFI_IP6); /* AFI */ stream_putc(s, SAFI_UNICAST); /* SAFI */ /* Next hop */ stream_putc(s, attre->mp_nexthop_len); stream_put(s, &attre->mp_nexthop_global, 16); if (attre->mp_nexthop_len == 32) stream_put(s, &attre->mp_nexthop_local, 16); /* SNPA */ stream_putc(s, 0); /* Prefix */ stream_put_prefix(s, prefix); /* Set MP attribute length. */ stream_putc_at (s, sizep, (stream_get_endp (s) - sizep) - 1); } #endif /* HAVE_IPV6 */ /* Return total size of attribute. */ len = stream_get_endp (s) - cp - 2; stream_putw_at (s, cp, len); }
DoS
0
bgp_dump_routes_attr (struct stream *s, struct attr *attr, struct prefix *prefix) { unsigned long cp; unsigned long len; size_t aspath_lenp; struct aspath *aspath; /* Remember current pointer. */ cp = stream_get_endp (s); /* Place holder of length. */ stream_putw (s, 0); /* Origin attribute. */ stream_putc (s, BGP_ATTR_FLAG_TRANS); stream_putc (s, BGP_ATTR_ORIGIN); stream_putc (s, 1); stream_putc (s, attr->origin); aspath = attr->aspath; stream_putc (s, BGP_ATTR_FLAG_TRANS|BGP_ATTR_FLAG_EXTLEN); stream_putc (s, BGP_ATTR_AS_PATH); aspath_lenp = stream_get_endp (s); stream_putw (s, 0); stream_putw_at (s, aspath_lenp, aspath_put (s, aspath, 1)); /* Nexthop attribute. */ /* If it's an IPv6 prefix, don't dump the IPv4 nexthop to save space */ if(prefix != NULL #ifdef HAVE_IPV6 && prefix->family != AF_INET6 #endif /* HAVE_IPV6 */ ) { stream_putc (s, BGP_ATTR_FLAG_TRANS); stream_putc (s, BGP_ATTR_NEXT_HOP); stream_putc (s, 4); stream_put_ipv4 (s, attr->nexthop.s_addr); } /* MED attribute. */ if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) { stream_putc (s, BGP_ATTR_FLAG_OPTIONAL); stream_putc (s, BGP_ATTR_MULTI_EXIT_DISC); stream_putc (s, 4); stream_putl (s, attr->med); } /* Local preference. */ if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)) { stream_putc (s, BGP_ATTR_FLAG_TRANS); stream_putc (s, BGP_ATTR_LOCAL_PREF); stream_putc (s, 4); stream_putl (s, attr->local_pref); } /* Atomic aggregate. */ if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)) { stream_putc (s, BGP_ATTR_FLAG_TRANS); stream_putc (s, BGP_ATTR_ATOMIC_AGGREGATE); stream_putc (s, 0); } /* Aggregator. */ if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR)) { assert (attr->extra); stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS); stream_putc (s, BGP_ATTR_AGGREGATOR); stream_putc (s, 8); stream_putl (s, attr->extra->aggregator_as); stream_put_ipv4 (s, attr->extra->aggregator_addr.s_addr); } /* Community attribute. */ if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES)) { if (attr->community->size * 4 > 255) { stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS|BGP_ATTR_FLAG_EXTLEN); stream_putc (s, BGP_ATTR_COMMUNITIES); stream_putw (s, attr->community->size * 4); } else { stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS); stream_putc (s, BGP_ATTR_COMMUNITIES); stream_putc (s, attr->community->size * 4); } stream_put (s, attr->community->val, attr->community->size * 4); } #ifdef HAVE_IPV6 /* Add a MP_NLRI attribute to dump the IPv6 next hop */ if (prefix != NULL && prefix->family == AF_INET6 && attr->extra && (attr->extra->mp_nexthop_len == 16 || attr->extra->mp_nexthop_len == 32) ) { int sizep; struct attr_extra *attre = attr->extra; stream_putc(s, BGP_ATTR_FLAG_OPTIONAL); stream_putc(s, BGP_ATTR_MP_REACH_NLRI); sizep = stream_get_endp (s); /* MP header */ stream_putc (s, 0); /* Marker: Attribute length. */ stream_putw(s, AFI_IP6); /* AFI */ stream_putc(s, SAFI_UNICAST); /* SAFI */ /* Next hop */ stream_putc(s, attre->mp_nexthop_len); stream_put(s, &attre->mp_nexthop_global, 16); if (attre->mp_nexthop_len == 32) stream_put(s, &attre->mp_nexthop_local, 16); /* SNPA */ stream_putc(s, 0); /* Prefix */ stream_put_prefix(s, prefix); /* Set MP attribute length. */ stream_putc_at (s, sizep, (stream_get_endp (s) - sizep) - 1); } #endif /* HAVE_IPV6 */ /* Return total size of attribute. */ len = stream_get_endp (s) - cp - 2; stream_putw_at (s, cp, len); }
@@ -1646,7 +1646,7 @@ bgp_attr_ext_communities (struct bgp_attr_parser_args *args) static bgp_attr_parse_ret_t bgp_attr_unknown (struct bgp_attr_parser_args *args) { - bgp_size_t total; + bgp_size_t total = args->total; struct transit *transit; struct attr_extra *attre; struct peer *const peer = args->peer;
null
null
null
203
bgp_mp_reach_parse (struct bgp_attr_parser_args *args, struct bgp_nlri *mp_update) { afi_t afi; safi_t safi; bgp_size_t nlri_len; size_t start; int ret; struct stream *s; struct peer *const peer = args->peer; struct attr *const attr = args->attr; const bgp_size_t length = args->length; struct attr_extra *attre = bgp_attr_extra_get(attr); /* Set end of packet. */ s = BGP_INPUT(peer); start = stream_get_getp(s); /* safe to read statically sized header? */ #define BGP_MP_REACH_MIN_SIZE 5 #define LEN_LEFT (length - (stream_get_getp(s) - start)) if ((length > STREAM_READABLE(s)) || (length < BGP_MP_REACH_MIN_SIZE)) { zlog_info ("%s: %s sent invalid length, %lu", __func__, peer->host, (unsigned long)length); return BGP_ATTR_PARSE_ERROR; } /* Load AFI, SAFI. */ afi = stream_getw (s); safi = stream_getc (s); /* Get nexthop length. */ attre->mp_nexthop_len = stream_getc (s); if (LEN_LEFT < attre->mp_nexthop_len) { zlog_info ("%s: %s, MP nexthop length, %u, goes past end of attribute", __func__, peer->host, attre->mp_nexthop_len); return BGP_ATTR_PARSE_ERROR; } /* Nexthop length check. */ switch (attre->mp_nexthop_len) { case 4: stream_get (&attre->mp_nexthop_global_in, s, 4); /* Probably needed for RFC 2283 */ if (attr->nexthop.s_addr == 0) memcpy(&attr->nexthop.s_addr, &attre->mp_nexthop_global_in, 4); break; case 12: stream_getl (s); /* RD high */ stream_getl (s); /* RD low */ stream_get (&attre->mp_nexthop_global_in, s, 4); break; #ifdef HAVE_IPV6 case 16: stream_get (&attre->mp_nexthop_global, s, 16); break; case 32: stream_get (&attre->mp_nexthop_global, s, 16); stream_get (&attre->mp_nexthop_local, s, 16); if (! IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local)) { char buf1[INET6_ADDRSTRLEN]; char buf2[INET6_ADDRSTRLEN]; if (BGP_DEBUG (update, UPDATE_IN)) zlog_debug ("%s got two nexthop %s %s but second one is not a link-local nexthop", peer->host, inet_ntop (AF_INET6, &attre->mp_nexthop_global, buf1, INET6_ADDRSTRLEN), inet_ntop (AF_INET6, &attre->mp_nexthop_local, buf2, INET6_ADDRSTRLEN)); attre->mp_nexthop_len = 16; } break; #endif /* HAVE_IPV6 */ default: zlog_info ("%s: (%s) Wrong multiprotocol next hop length: %d", __func__, peer->host, attre->mp_nexthop_len); return BGP_ATTR_PARSE_ERROR; } if (!LEN_LEFT) { zlog_info ("%s: (%s) Failed to read SNPA and NLRI(s)", __func__, peer->host); return BGP_ATTR_PARSE_ERROR; } { u_char val; if ((val = stream_getc (s))) zlog_warn ("%s sent non-zero value, %u, for defunct SNPA-length field", peer->host, val); } /* must have nrli_len, what is left of the attribute */ nlri_len = LEN_LEFT; if ((!nlri_len) || (nlri_len > STREAM_READABLE(s))) { zlog_info ("%s: (%s) Failed to read NLRI", __func__, peer->host); return BGP_ATTR_PARSE_ERROR; } if (safi != SAFI_MPLS_LABELED_VPN) { ret = bgp_nlri_sanity_check (peer, afi, stream_pnt (s), nlri_len); if (ret < 0) { zlog_info ("%s: (%s) NLRI doesn't pass sanity check", __func__, peer->host); return BGP_ATTR_PARSE_ERROR; } } mp_update->afi = afi; mp_update->safi = safi; mp_update->nlri = stream_pnt (s); mp_update->length = nlri_len; stream_forward_getp (s, nlri_len); return BGP_ATTR_PARSE_PROCEED; #undef LEN_LEFT }
DoS
0
bgp_mp_reach_parse (struct bgp_attr_parser_args *args, struct bgp_nlri *mp_update) { afi_t afi; safi_t safi; bgp_size_t nlri_len; size_t start; int ret; struct stream *s; struct peer *const peer = args->peer; struct attr *const attr = args->attr; const bgp_size_t length = args->length; struct attr_extra *attre = bgp_attr_extra_get(attr); /* Set end of packet. */ s = BGP_INPUT(peer); start = stream_get_getp(s); /* safe to read statically sized header? */ #define BGP_MP_REACH_MIN_SIZE 5 #define LEN_LEFT (length - (stream_get_getp(s) - start)) if ((length > STREAM_READABLE(s)) || (length < BGP_MP_REACH_MIN_SIZE)) { zlog_info ("%s: %s sent invalid length, %lu", __func__, peer->host, (unsigned long)length); return BGP_ATTR_PARSE_ERROR; } /* Load AFI, SAFI. */ afi = stream_getw (s); safi = stream_getc (s); /* Get nexthop length. */ attre->mp_nexthop_len = stream_getc (s); if (LEN_LEFT < attre->mp_nexthop_len) { zlog_info ("%s: %s, MP nexthop length, %u, goes past end of attribute", __func__, peer->host, attre->mp_nexthop_len); return BGP_ATTR_PARSE_ERROR; } /* Nexthop length check. */ switch (attre->mp_nexthop_len) { case 4: stream_get (&attre->mp_nexthop_global_in, s, 4); /* Probably needed for RFC 2283 */ if (attr->nexthop.s_addr == 0) memcpy(&attr->nexthop.s_addr, &attre->mp_nexthop_global_in, 4); break; case 12: stream_getl (s); /* RD high */ stream_getl (s); /* RD low */ stream_get (&attre->mp_nexthop_global_in, s, 4); break; #ifdef HAVE_IPV6 case 16: stream_get (&attre->mp_nexthop_global, s, 16); break; case 32: stream_get (&attre->mp_nexthop_global, s, 16); stream_get (&attre->mp_nexthop_local, s, 16); if (! IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local)) { char buf1[INET6_ADDRSTRLEN]; char buf2[INET6_ADDRSTRLEN]; if (BGP_DEBUG (update, UPDATE_IN)) zlog_debug ("%s got two nexthop %s %s but second one is not a link-local nexthop", peer->host, inet_ntop (AF_INET6, &attre->mp_nexthop_global, buf1, INET6_ADDRSTRLEN), inet_ntop (AF_INET6, &attre->mp_nexthop_local, buf2, INET6_ADDRSTRLEN)); attre->mp_nexthop_len = 16; } break; #endif /* HAVE_IPV6 */ default: zlog_info ("%s: (%s) Wrong multiprotocol next hop length: %d", __func__, peer->host, attre->mp_nexthop_len); return BGP_ATTR_PARSE_ERROR; } if (!LEN_LEFT) { zlog_info ("%s: (%s) Failed to read SNPA and NLRI(s)", __func__, peer->host); return BGP_ATTR_PARSE_ERROR; } { u_char val; if ((val = stream_getc (s))) zlog_warn ("%s sent non-zero value, %u, for defunct SNPA-length field", peer->host, val); } /* must have nrli_len, what is left of the attribute */ nlri_len = LEN_LEFT; if ((!nlri_len) || (nlri_len > STREAM_READABLE(s))) { zlog_info ("%s: (%s) Failed to read NLRI", __func__, peer->host); return BGP_ATTR_PARSE_ERROR; } if (safi != SAFI_MPLS_LABELED_VPN) { ret = bgp_nlri_sanity_check (peer, afi, stream_pnt (s), nlri_len); if (ret < 0) { zlog_info ("%s: (%s) NLRI doesn't pass sanity check", __func__, peer->host); return BGP_ATTR_PARSE_ERROR; } } mp_update->afi = afi; mp_update->safi = safi; mp_update->nlri = stream_pnt (s); mp_update->length = nlri_len; stream_forward_getp (s, nlri_len); return BGP_ATTR_PARSE_PROCEED; #undef LEN_LEFT }
@@ -1646,7 +1646,7 @@ bgp_attr_ext_communities (struct bgp_attr_parser_args *args) static bgp_attr_parse_ret_t bgp_attr_unknown (struct bgp_attr_parser_args *args) { - bgp_size_t total; + bgp_size_t total = args->total; struct transit *transit; struct attr_extra *attre; struct peer *const peer = args->peer;
null
null
null
204
bgp_packet_attribute (struct bgp *bgp, struct peer *peer, struct stream *s, struct attr *attr, struct prefix *p, afi_t afi, safi_t safi, struct peer *from, struct prefix_rd *prd, u_char *tag) { size_t cp; size_t aspath_sizep; struct aspath *aspath; int send_as4_path = 0; int send_as4_aggregator = 0; int use32bit = (CHECK_FLAG (peer->cap, PEER_CAP_AS4_RCV)) ? 1 : 0; if (! bgp) bgp = bgp_get_default (); /* Remember current pointer. */ cp = stream_get_endp (s); /* Origin attribute. */ stream_putc (s, BGP_ATTR_FLAG_TRANS); stream_putc (s, BGP_ATTR_ORIGIN); stream_putc (s, 1); stream_putc (s, attr->origin); /* AS path attribute. */ /* If remote-peer is EBGP */ if (peer_sort (peer) == BGP_PEER_EBGP && (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED) || attr->aspath->segments == NULL) && (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))) { aspath = aspath_dup (attr->aspath); if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) { /* Strip the confed info, and then stuff our path CONFED_ID on the front */ aspath = aspath_delete_confed_seq (aspath); aspath = aspath_add_seq (aspath, bgp->confed_id); } else { aspath = aspath_add_seq (aspath, peer->local_as); if (peer->change_local_as) aspath = aspath_add_seq (aspath, peer->change_local_as); } } else if (peer_sort (peer) == BGP_PEER_CONFED) { /* A confed member, so we need to do the AS_CONFED_SEQUENCE thing */ aspath = aspath_dup (attr->aspath); aspath = aspath_add_confed_seq (aspath, peer->local_as); } else aspath = attr->aspath; /* If peer is not AS4 capable, then: * - send the created AS_PATH out as AS4_PATH (optional, transitive), * but ensure that no AS_CONFED_SEQUENCE and AS_CONFED_SET path segment * types are in it (i.e. exclude them if they are there) * AND do this only if there is at least one asnum > 65535 in the path! * - send an AS_PATH out, but put 16Bit ASnums in it, not 32bit, and change * all ASnums > 65535 to BGP_AS_TRANS */ stream_putc (s, BGP_ATTR_FLAG_TRANS|BGP_ATTR_FLAG_EXTLEN); stream_putc (s, BGP_ATTR_AS_PATH); aspath_sizep = stream_get_endp (s); stream_putw (s, 0); stream_putw_at (s, aspath_sizep, aspath_put (s, aspath, use32bit)); /* OLD session may need NEW_AS_PATH sent, if there are 4-byte ASNs * in the path */ if (!use32bit && aspath_has_as4 (aspath)) send_as4_path = 1; /* we'll do this later, at the correct place */ /* Nexthop attribute. */ if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP) && afi == AFI_IP) { stream_putc (s, BGP_ATTR_FLAG_TRANS); stream_putc (s, BGP_ATTR_NEXT_HOP); stream_putc (s, 4); if (safi == SAFI_MPLS_VPN) { if (attr->nexthop.s_addr == 0) stream_put_ipv4 (s, peer->nexthop.v4.s_addr); else stream_put_ipv4 (s, attr->nexthop.s_addr); } else stream_put_ipv4 (s, attr->nexthop.s_addr); } /* MED attribute. */ if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) { stream_putc (s, BGP_ATTR_FLAG_OPTIONAL); stream_putc (s, BGP_ATTR_MULTI_EXIT_DISC); stream_putc (s, 4); stream_putl (s, attr->med); } /* Local preference. */ if (peer_sort (peer) == BGP_PEER_IBGP || peer_sort (peer) == BGP_PEER_CONFED) { stream_putc (s, BGP_ATTR_FLAG_TRANS); stream_putc (s, BGP_ATTR_LOCAL_PREF); stream_putc (s, 4); stream_putl (s, attr->local_pref); } /* Atomic aggregate. */ if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)) { stream_putc (s, BGP_ATTR_FLAG_TRANS); stream_putc (s, BGP_ATTR_ATOMIC_AGGREGATE); stream_putc (s, 0); } /* Aggregator. */ if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR)) { assert (attr->extra); /* Common to BGP_ATTR_AGGREGATOR, regardless of ASN size */ stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS); stream_putc (s, BGP_ATTR_AGGREGATOR); if (use32bit) { /* AS4 capable peer */ stream_putc (s, 8); stream_putl (s, attr->extra->aggregator_as); } else { /* 2-byte AS peer */ stream_putc (s, 6); /* Is ASN representable in 2-bytes? Or must AS_TRANS be used? */ if ( attr->extra->aggregator_as > 65535 ) { stream_putw (s, BGP_AS_TRANS); /* we have to send AS4_AGGREGATOR, too. * we'll do that later in order to send attributes in ascending * order. */ send_as4_aggregator = 1; } else stream_putw (s, (u_int16_t) attr->extra->aggregator_as); } stream_put_ipv4 (s, attr->extra->aggregator_addr.s_addr); } /* Community attribute. */ if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) && (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES))) { if (attr->community->size * 4 > 255) { stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS|BGP_ATTR_FLAG_EXTLEN); stream_putc (s, BGP_ATTR_COMMUNITIES); stream_putw (s, attr->community->size * 4); } else { stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS); stream_putc (s, BGP_ATTR_COMMUNITIES); stream_putc (s, attr->community->size * 4); } stream_put (s, attr->community->val, attr->community->size * 4); } /* Route Reflector. */ if (peer_sort (peer) == BGP_PEER_IBGP && from && peer_sort (from) == BGP_PEER_IBGP) { /* Originator ID. */ stream_putc (s, BGP_ATTR_FLAG_OPTIONAL); stream_putc (s, BGP_ATTR_ORIGINATOR_ID); stream_putc (s, 4); if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) stream_put_in_addr (s, &attr->extra->originator_id); else stream_put_in_addr (s, &from->remote_id); /* Cluster list. */ stream_putc (s, BGP_ATTR_FLAG_OPTIONAL); stream_putc (s, BGP_ATTR_CLUSTER_LIST); if (attr->extra && attr->extra->cluster) { stream_putc (s, attr->extra->cluster->length + 4); /* If this peer configuration's parent BGP has cluster_id. */ if (bgp->config & BGP_CONFIG_CLUSTER_ID) stream_put_in_addr (s, &bgp->cluster_id); else stream_put_in_addr (s, &bgp->router_id); stream_put (s, attr->extra->cluster->list, attr->extra->cluster->length); } else { stream_putc (s, 4); /* If this peer configuration's parent BGP has cluster_id. */ if (bgp->config & BGP_CONFIG_CLUSTER_ID) stream_put_in_addr (s, &bgp->cluster_id); else stream_put_in_addr (s, &bgp->router_id); } } #ifdef HAVE_IPV6 /* If p is IPv6 address put it into attribute. */ if (p->family == AF_INET6) { unsigned long sizep; struct attr_extra *attre = attr->extra; assert (attr->extra); stream_putc (s, BGP_ATTR_FLAG_OPTIONAL); stream_putc (s, BGP_ATTR_MP_REACH_NLRI); sizep = stream_get_endp (s); stream_putc (s, 0); /* Marker: Attribute length. */ stream_putw (s, AFI_IP6); /* AFI */ stream_putc (s, safi); /* SAFI */ stream_putc (s, attre->mp_nexthop_len); if (attre->mp_nexthop_len == 16) stream_put (s, &attre->mp_nexthop_global, 16); else if (attre->mp_nexthop_len == 32) { stream_put (s, &attre->mp_nexthop_global, 16); stream_put (s, &attre->mp_nexthop_local, 16); } /* SNPA */ stream_putc (s, 0); /* Prefix write. */ stream_put_prefix (s, p); /* Set MP attribute length. */ stream_putc_at (s, sizep, (stream_get_endp (s) - sizep) - 1); } #endif /* HAVE_IPV6 */ if (p->family == AF_INET && safi == SAFI_MULTICAST) { unsigned long sizep; stream_putc (s, BGP_ATTR_FLAG_OPTIONAL); stream_putc (s, BGP_ATTR_MP_REACH_NLRI); sizep = stream_get_endp (s); stream_putc (s, 0); /* Marker: Attribute Length. */ stream_putw (s, AFI_IP); /* AFI */ stream_putc (s, SAFI_MULTICAST); /* SAFI */ stream_putc (s, 4); stream_put_ipv4 (s, attr->nexthop.s_addr); /* SNPA */ stream_putc (s, 0); /* Prefix write. */ stream_put_prefix (s, p); /* Set MP attribute length. */ stream_putc_at (s, sizep, (stream_get_endp (s) - sizep) - 1); } if (p->family == AF_INET && safi == SAFI_MPLS_VPN) { unsigned long sizep; stream_putc (s, BGP_ATTR_FLAG_OPTIONAL); stream_putc (s, BGP_ATTR_MP_REACH_NLRI); sizep = stream_get_endp (s); stream_putc (s, 0); /* Length of this attribute. */ stream_putw (s, AFI_IP); /* AFI */ stream_putc (s, SAFI_MPLS_LABELED_VPN); /* SAFI */ stream_putc (s, 12); stream_putl (s, 0); stream_putl (s, 0); stream_put (s, &attr->extra->mp_nexthop_global_in, 4); /* SNPA */ stream_putc (s, 0); /* Tag, RD, Prefix write. */ stream_putc (s, p->prefixlen + 88); stream_put (s, tag, 3); stream_put (s, prd->val, 8); stream_put (s, &p->u.prefix, PSIZE (p->prefixlen)); /* Set MP attribute length. */ stream_putc_at (s, sizep, (stream_get_endp (s) - sizep) - 1); } /* Extended Communities attribute. */ if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY) && (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES))) { struct attr_extra *attre = attr->extra; assert (attre); if (peer_sort (peer) == BGP_PEER_IBGP || peer_sort (peer) == BGP_PEER_CONFED) { if (attre->ecommunity->size * 8 > 255) { stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS|BGP_ATTR_FLAG_EXTLEN); stream_putc (s, BGP_ATTR_EXT_COMMUNITIES); stream_putw (s, attre->ecommunity->size * 8); } else { stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS); stream_putc (s, BGP_ATTR_EXT_COMMUNITIES); stream_putc (s, attre->ecommunity->size * 8); } stream_put (s, attre->ecommunity->val, attre->ecommunity->size * 8); } else { u_int8_t *pnt; int tbit; int ecom_tr_size = 0; int i; for (i = 0; i < attre->ecommunity->size; i++) { pnt = attre->ecommunity->val + (i * 8); tbit = *pnt; if (CHECK_FLAG (tbit, ECOMMUNITY_FLAG_NON_TRANSITIVE)) continue; ecom_tr_size++; } if (ecom_tr_size) { if (ecom_tr_size * 8 > 255) { stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS|BGP_ATTR_FLAG_EXTLEN); stream_putc (s, BGP_ATTR_EXT_COMMUNITIES); stream_putw (s, ecom_tr_size * 8); } else { stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS); stream_putc (s, BGP_ATTR_EXT_COMMUNITIES); stream_putc (s, ecom_tr_size * 8); } for (i = 0; i < attre->ecommunity->size; i++) { pnt = attre->ecommunity->val + (i * 8); tbit = *pnt; if (CHECK_FLAG (tbit, ECOMMUNITY_FLAG_NON_TRANSITIVE)) continue; stream_put (s, pnt, 8); } } } } if ( send_as4_path ) { /* If the peer is NOT As4 capable, AND */ /* there are ASnums > 65535 in path THEN * give out AS4_PATH */ /* Get rid of all AS_CONFED_SEQUENCE and AS_CONFED_SET * path segments! * Hm, I wonder... confederation things *should* only be at * the beginning of an aspath, right? Then we should use * aspath_delete_confed_seq for this, because it is already * there! (JK) * Folks, talk to me: what is reasonable here!? */ aspath = aspath_delete_confed_seq (aspath); stream_putc (s, BGP_ATTR_FLAG_TRANS|BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_EXTLEN); stream_putc (s, BGP_ATTR_AS4_PATH); aspath_sizep = stream_get_endp (s); stream_putw (s, 0); stream_putw_at (s, aspath_sizep, aspath_put (s, aspath, 1)); } if (aspath != attr->aspath) aspath_free (aspath); if ( send_as4_aggregator ) { assert (attr->extra); /* send AS4_AGGREGATOR, at this place */ /* this section of code moved here in order to ensure the correct * *ascending* order of attributes */ stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS); stream_putc (s, BGP_ATTR_AS4_AGGREGATOR); stream_putc (s, 8); stream_putl (s, attr->extra->aggregator_as); stream_put_ipv4 (s, attr->extra->aggregator_addr.s_addr); } /* Unknown transit attribute. */ if (attr->extra && attr->extra->transit) stream_put (s, attr->extra->transit->val, attr->extra->transit->length); /* Return total size of attribute. */ return stream_get_endp (s) - cp; }
DoS
0
bgp_packet_attribute (struct bgp *bgp, struct peer *peer, struct stream *s, struct attr *attr, struct prefix *p, afi_t afi, safi_t safi, struct peer *from, struct prefix_rd *prd, u_char *tag) { size_t cp; size_t aspath_sizep; struct aspath *aspath; int send_as4_path = 0; int send_as4_aggregator = 0; int use32bit = (CHECK_FLAG (peer->cap, PEER_CAP_AS4_RCV)) ? 1 : 0; if (! bgp) bgp = bgp_get_default (); /* Remember current pointer. */ cp = stream_get_endp (s); /* Origin attribute. */ stream_putc (s, BGP_ATTR_FLAG_TRANS); stream_putc (s, BGP_ATTR_ORIGIN); stream_putc (s, 1); stream_putc (s, attr->origin); /* AS path attribute. */ /* If remote-peer is EBGP */ if (peer_sort (peer) == BGP_PEER_EBGP && (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED) || attr->aspath->segments == NULL) && (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))) { aspath = aspath_dup (attr->aspath); if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) { /* Strip the confed info, and then stuff our path CONFED_ID on the front */ aspath = aspath_delete_confed_seq (aspath); aspath = aspath_add_seq (aspath, bgp->confed_id); } else { aspath = aspath_add_seq (aspath, peer->local_as); if (peer->change_local_as) aspath = aspath_add_seq (aspath, peer->change_local_as); } } else if (peer_sort (peer) == BGP_PEER_CONFED) { /* A confed member, so we need to do the AS_CONFED_SEQUENCE thing */ aspath = aspath_dup (attr->aspath); aspath = aspath_add_confed_seq (aspath, peer->local_as); } else aspath = attr->aspath; /* If peer is not AS4 capable, then: * - send the created AS_PATH out as AS4_PATH (optional, transitive), * but ensure that no AS_CONFED_SEQUENCE and AS_CONFED_SET path segment * types are in it (i.e. exclude them if they are there) * AND do this only if there is at least one asnum > 65535 in the path! * - send an AS_PATH out, but put 16Bit ASnums in it, not 32bit, and change * all ASnums > 65535 to BGP_AS_TRANS */ stream_putc (s, BGP_ATTR_FLAG_TRANS|BGP_ATTR_FLAG_EXTLEN); stream_putc (s, BGP_ATTR_AS_PATH); aspath_sizep = stream_get_endp (s); stream_putw (s, 0); stream_putw_at (s, aspath_sizep, aspath_put (s, aspath, use32bit)); /* OLD session may need NEW_AS_PATH sent, if there are 4-byte ASNs * in the path */ if (!use32bit && aspath_has_as4 (aspath)) send_as4_path = 1; /* we'll do this later, at the correct place */ /* Nexthop attribute. */ if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP) && afi == AFI_IP) { stream_putc (s, BGP_ATTR_FLAG_TRANS); stream_putc (s, BGP_ATTR_NEXT_HOP); stream_putc (s, 4); if (safi == SAFI_MPLS_VPN) { if (attr->nexthop.s_addr == 0) stream_put_ipv4 (s, peer->nexthop.v4.s_addr); else stream_put_ipv4 (s, attr->nexthop.s_addr); } else stream_put_ipv4 (s, attr->nexthop.s_addr); } /* MED attribute. */ if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) { stream_putc (s, BGP_ATTR_FLAG_OPTIONAL); stream_putc (s, BGP_ATTR_MULTI_EXIT_DISC); stream_putc (s, 4); stream_putl (s, attr->med); } /* Local preference. */ if (peer_sort (peer) == BGP_PEER_IBGP || peer_sort (peer) == BGP_PEER_CONFED) { stream_putc (s, BGP_ATTR_FLAG_TRANS); stream_putc (s, BGP_ATTR_LOCAL_PREF); stream_putc (s, 4); stream_putl (s, attr->local_pref); } /* Atomic aggregate. */ if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)) { stream_putc (s, BGP_ATTR_FLAG_TRANS); stream_putc (s, BGP_ATTR_ATOMIC_AGGREGATE); stream_putc (s, 0); } /* Aggregator. */ if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR)) { assert (attr->extra); /* Common to BGP_ATTR_AGGREGATOR, regardless of ASN size */ stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS); stream_putc (s, BGP_ATTR_AGGREGATOR); if (use32bit) { /* AS4 capable peer */ stream_putc (s, 8); stream_putl (s, attr->extra->aggregator_as); } else { /* 2-byte AS peer */ stream_putc (s, 6); /* Is ASN representable in 2-bytes? Or must AS_TRANS be used? */ if ( attr->extra->aggregator_as > 65535 ) { stream_putw (s, BGP_AS_TRANS); /* we have to send AS4_AGGREGATOR, too. * we'll do that later in order to send attributes in ascending * order. */ send_as4_aggregator = 1; } else stream_putw (s, (u_int16_t) attr->extra->aggregator_as); } stream_put_ipv4 (s, attr->extra->aggregator_addr.s_addr); } /* Community attribute. */ if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) && (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES))) { if (attr->community->size * 4 > 255) { stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS|BGP_ATTR_FLAG_EXTLEN); stream_putc (s, BGP_ATTR_COMMUNITIES); stream_putw (s, attr->community->size * 4); } else { stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS); stream_putc (s, BGP_ATTR_COMMUNITIES); stream_putc (s, attr->community->size * 4); } stream_put (s, attr->community->val, attr->community->size * 4); } /* Route Reflector. */ if (peer_sort (peer) == BGP_PEER_IBGP && from && peer_sort (from) == BGP_PEER_IBGP) { /* Originator ID. */ stream_putc (s, BGP_ATTR_FLAG_OPTIONAL); stream_putc (s, BGP_ATTR_ORIGINATOR_ID); stream_putc (s, 4); if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) stream_put_in_addr (s, &attr->extra->originator_id); else stream_put_in_addr (s, &from->remote_id); /* Cluster list. */ stream_putc (s, BGP_ATTR_FLAG_OPTIONAL); stream_putc (s, BGP_ATTR_CLUSTER_LIST); if (attr->extra && attr->extra->cluster) { stream_putc (s, attr->extra->cluster->length + 4); /* If this peer configuration's parent BGP has cluster_id. */ if (bgp->config & BGP_CONFIG_CLUSTER_ID) stream_put_in_addr (s, &bgp->cluster_id); else stream_put_in_addr (s, &bgp->router_id); stream_put (s, attr->extra->cluster->list, attr->extra->cluster->length); } else { stream_putc (s, 4); /* If this peer configuration's parent BGP has cluster_id. */ if (bgp->config & BGP_CONFIG_CLUSTER_ID) stream_put_in_addr (s, &bgp->cluster_id); else stream_put_in_addr (s, &bgp->router_id); } } #ifdef HAVE_IPV6 /* If p is IPv6 address put it into attribute. */ if (p->family == AF_INET6) { unsigned long sizep; struct attr_extra *attre = attr->extra; assert (attr->extra); stream_putc (s, BGP_ATTR_FLAG_OPTIONAL); stream_putc (s, BGP_ATTR_MP_REACH_NLRI); sizep = stream_get_endp (s); stream_putc (s, 0); /* Marker: Attribute length. */ stream_putw (s, AFI_IP6); /* AFI */ stream_putc (s, safi); /* SAFI */ stream_putc (s, attre->mp_nexthop_len); if (attre->mp_nexthop_len == 16) stream_put (s, &attre->mp_nexthop_global, 16); else if (attre->mp_nexthop_len == 32) { stream_put (s, &attre->mp_nexthop_global, 16); stream_put (s, &attre->mp_nexthop_local, 16); } /* SNPA */ stream_putc (s, 0); /* Prefix write. */ stream_put_prefix (s, p); /* Set MP attribute length. */ stream_putc_at (s, sizep, (stream_get_endp (s) - sizep) - 1); } #endif /* HAVE_IPV6 */ if (p->family == AF_INET && safi == SAFI_MULTICAST) { unsigned long sizep; stream_putc (s, BGP_ATTR_FLAG_OPTIONAL); stream_putc (s, BGP_ATTR_MP_REACH_NLRI); sizep = stream_get_endp (s); stream_putc (s, 0); /* Marker: Attribute Length. */ stream_putw (s, AFI_IP); /* AFI */ stream_putc (s, SAFI_MULTICAST); /* SAFI */ stream_putc (s, 4); stream_put_ipv4 (s, attr->nexthop.s_addr); /* SNPA */ stream_putc (s, 0); /* Prefix write. */ stream_put_prefix (s, p); /* Set MP attribute length. */ stream_putc_at (s, sizep, (stream_get_endp (s) - sizep) - 1); } if (p->family == AF_INET && safi == SAFI_MPLS_VPN) { unsigned long sizep; stream_putc (s, BGP_ATTR_FLAG_OPTIONAL); stream_putc (s, BGP_ATTR_MP_REACH_NLRI); sizep = stream_get_endp (s); stream_putc (s, 0); /* Length of this attribute. */ stream_putw (s, AFI_IP); /* AFI */ stream_putc (s, SAFI_MPLS_LABELED_VPN); /* SAFI */ stream_putc (s, 12); stream_putl (s, 0); stream_putl (s, 0); stream_put (s, &attr->extra->mp_nexthop_global_in, 4); /* SNPA */ stream_putc (s, 0); /* Tag, RD, Prefix write. */ stream_putc (s, p->prefixlen + 88); stream_put (s, tag, 3); stream_put (s, prd->val, 8); stream_put (s, &p->u.prefix, PSIZE (p->prefixlen)); /* Set MP attribute length. */ stream_putc_at (s, sizep, (stream_get_endp (s) - sizep) - 1); } /* Extended Communities attribute. */ if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY) && (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES))) { struct attr_extra *attre = attr->extra; assert (attre); if (peer_sort (peer) == BGP_PEER_IBGP || peer_sort (peer) == BGP_PEER_CONFED) { if (attre->ecommunity->size * 8 > 255) { stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS|BGP_ATTR_FLAG_EXTLEN); stream_putc (s, BGP_ATTR_EXT_COMMUNITIES); stream_putw (s, attre->ecommunity->size * 8); } else { stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS); stream_putc (s, BGP_ATTR_EXT_COMMUNITIES); stream_putc (s, attre->ecommunity->size * 8); } stream_put (s, attre->ecommunity->val, attre->ecommunity->size * 8); } else { u_int8_t *pnt; int tbit; int ecom_tr_size = 0; int i; for (i = 0; i < attre->ecommunity->size; i++) { pnt = attre->ecommunity->val + (i * 8); tbit = *pnt; if (CHECK_FLAG (tbit, ECOMMUNITY_FLAG_NON_TRANSITIVE)) continue; ecom_tr_size++; } if (ecom_tr_size) { if (ecom_tr_size * 8 > 255) { stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS|BGP_ATTR_FLAG_EXTLEN); stream_putc (s, BGP_ATTR_EXT_COMMUNITIES); stream_putw (s, ecom_tr_size * 8); } else { stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS); stream_putc (s, BGP_ATTR_EXT_COMMUNITIES); stream_putc (s, ecom_tr_size * 8); } for (i = 0; i < attre->ecommunity->size; i++) { pnt = attre->ecommunity->val + (i * 8); tbit = *pnt; if (CHECK_FLAG (tbit, ECOMMUNITY_FLAG_NON_TRANSITIVE)) continue; stream_put (s, pnt, 8); } } } } if ( send_as4_path ) { /* If the peer is NOT As4 capable, AND */ /* there are ASnums > 65535 in path THEN * give out AS4_PATH */ /* Get rid of all AS_CONFED_SEQUENCE and AS_CONFED_SET * path segments! * Hm, I wonder... confederation things *should* only be at * the beginning of an aspath, right? Then we should use * aspath_delete_confed_seq for this, because it is already * there! (JK) * Folks, talk to me: what is reasonable here!? */ aspath = aspath_delete_confed_seq (aspath); stream_putc (s, BGP_ATTR_FLAG_TRANS|BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_EXTLEN); stream_putc (s, BGP_ATTR_AS4_PATH); aspath_sizep = stream_get_endp (s); stream_putw (s, 0); stream_putw_at (s, aspath_sizep, aspath_put (s, aspath, 1)); } if (aspath != attr->aspath) aspath_free (aspath); if ( send_as4_aggregator ) { assert (attr->extra); /* send AS4_AGGREGATOR, at this place */ /* this section of code moved here in order to ensure the correct * *ascending* order of attributes */ stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS); stream_putc (s, BGP_ATTR_AS4_AGGREGATOR); stream_putc (s, 8); stream_putl (s, attr->extra->aggregator_as); stream_put_ipv4 (s, attr->extra->aggregator_addr.s_addr); } /* Unknown transit attribute. */ if (attr->extra && attr->extra->transit) stream_put (s, attr->extra->transit->val, attr->extra->transit->length); /* Return total size of attribute. */ return stream_get_endp (s) - cp; }
@@ -1646,7 +1646,7 @@ bgp_attr_ext_communities (struct bgp_attr_parser_args *args) static bgp_attr_parse_ret_t bgp_attr_unknown (struct bgp_attr_parser_args *args) { - bgp_size_t total; + bgp_size_t total = args->total; struct transit *transit; struct attr_extra *attre; struct peer *const peer = args->peer;
null
null
null
205
bgp_packet_withdraw (struct peer *peer, struct stream *s, struct prefix *p, afi_t afi, safi_t safi, struct prefix_rd *prd, u_char *tag) { unsigned long cp; unsigned long attrlen_pnt; bgp_size_t size; cp = stream_get_endp (s); stream_putc (s, BGP_ATTR_FLAG_OPTIONAL); stream_putc (s, BGP_ATTR_MP_UNREACH_NLRI); attrlen_pnt = stream_get_endp (s); stream_putc (s, 0); /* Length of this attribute. */ stream_putw (s, family2afi (p->family)); if (safi == SAFI_MPLS_VPN) { /* SAFI */ stream_putc (s, SAFI_MPLS_LABELED_VPN); /* prefix. */ stream_putc (s, p->prefixlen + 88); stream_put (s, tag, 3); stream_put (s, prd->val, 8); stream_put (s, &p->u.prefix, PSIZE (p->prefixlen)); } else { /* SAFI */ stream_putc (s, safi); /* prefix */ stream_put_prefix (s, p); } /* Set MP attribute length. */ size = stream_get_endp (s) - attrlen_pnt - 1; stream_putc_at (s, attrlen_pnt, size); return stream_get_endp (s) - cp; }
DoS
0
bgp_packet_withdraw (struct peer *peer, struct stream *s, struct prefix *p, afi_t afi, safi_t safi, struct prefix_rd *prd, u_char *tag) { unsigned long cp; unsigned long attrlen_pnt; bgp_size_t size; cp = stream_get_endp (s); stream_putc (s, BGP_ATTR_FLAG_OPTIONAL); stream_putc (s, BGP_ATTR_MP_UNREACH_NLRI); attrlen_pnt = stream_get_endp (s); stream_putc (s, 0); /* Length of this attribute. */ stream_putw (s, family2afi (p->family)); if (safi == SAFI_MPLS_VPN) { /* SAFI */ stream_putc (s, SAFI_MPLS_LABELED_VPN); /* prefix. */ stream_putc (s, p->prefixlen + 88); stream_put (s, tag, 3); stream_put (s, prd->val, 8); stream_put (s, &p->u.prefix, PSIZE (p->prefixlen)); } else { /* SAFI */ stream_putc (s, safi); /* prefix */ stream_put_prefix (s, p); } /* Set MP attribute length. */ size = stream_get_endp (s) - attrlen_pnt - 1; stream_putc_at (s, attrlen_pnt, size); return stream_get_endp (s) - cp; }
@@ -1646,7 +1646,7 @@ bgp_attr_ext_communities (struct bgp_attr_parser_args *args) static bgp_attr_parse_ret_t bgp_attr_unknown (struct bgp_attr_parser_args *args) { - bgp_size_t total; + bgp_size_t total = args->total; struct transit *transit; struct attr_extra *attre; struct peer *const peer = args->peer;
null
null
null
206
cluster_finish (void) { hash_free (cluster_hash); cluster_hash = NULL; }
DoS
0
cluster_finish (void) { hash_free (cluster_hash); cluster_hash = NULL; }
@@ -1646,7 +1646,7 @@ bgp_attr_ext_communities (struct bgp_attr_parser_args *args) static bgp_attr_parse_ret_t bgp_attr_unknown (struct bgp_attr_parser_args *args) { - bgp_size_t total; + bgp_size_t total = args->total; struct transit *transit; struct attr_extra *attre; struct peer *const peer = args->peer;
null
null
null
207
cluster_free (struct cluster_list *cluster) { if (cluster->list) XFREE (MTYPE_CLUSTER_VAL, cluster->list); XFREE (MTYPE_CLUSTER, cluster); }
DoS
0
cluster_free (struct cluster_list *cluster) { if (cluster->list) XFREE (MTYPE_CLUSTER_VAL, cluster->list); XFREE (MTYPE_CLUSTER, cluster); }
@@ -1646,7 +1646,7 @@ bgp_attr_ext_communities (struct bgp_attr_parser_args *args) static bgp_attr_parse_ret_t bgp_attr_unknown (struct bgp_attr_parser_args *args) { - bgp_size_t total; + bgp_size_t total = args->total; struct transit *transit; struct attr_extra *attre; struct peer *const peer = args->peer;
null
null
null
208
cluster_hash_alloc (void *p) { struct cluster_list * val = (struct cluster_list *) p; struct cluster_list *cluster; cluster = XMALLOC (MTYPE_CLUSTER, sizeof (struct cluster_list)); cluster->length = val->length; if (cluster->length) { cluster->list = XMALLOC (MTYPE_CLUSTER_VAL, val->length); memcpy (cluster->list, val->list, val->length); } else cluster->list = NULL; cluster->refcnt = 0; return cluster; }
DoS
0
cluster_hash_alloc (void *p) { struct cluster_list * val = (struct cluster_list *) p; struct cluster_list *cluster; cluster = XMALLOC (MTYPE_CLUSTER, sizeof (struct cluster_list)); cluster->length = val->length; if (cluster->length) { cluster->list = XMALLOC (MTYPE_CLUSTER_VAL, val->length); memcpy (cluster->list, val->list, val->length); } else cluster->list = NULL; cluster->refcnt = 0; return cluster; }
@@ -1646,7 +1646,7 @@ bgp_attr_ext_communities (struct bgp_attr_parser_args *args) static bgp_attr_parse_ret_t bgp_attr_unknown (struct bgp_attr_parser_args *args) { - bgp_size_t total; + bgp_size_t total = args->total; struct transit *transit; struct attr_extra *attre; struct peer *const peer = args->peer;
null
null
null
209
cluster_hash_key_make (void *p) { const struct cluster_list *cluster = p; return jhash(cluster->list, cluster->length, 0); }
DoS
0
cluster_hash_key_make (void *p) { const struct cluster_list *cluster = p; return jhash(cluster->list, cluster->length, 0); }
@@ -1646,7 +1646,7 @@ bgp_attr_ext_communities (struct bgp_attr_parser_args *args) static bgp_attr_parse_ret_t bgp_attr_unknown (struct bgp_attr_parser_args *args) { - bgp_size_t total; + bgp_size_t total = args->total; struct transit *transit; struct attr_extra *attre; struct peer *const peer = args->peer;
null
null
null
210
cluster_init (void) { cluster_hash = hash_create (cluster_hash_key_make, cluster_hash_cmp); }
DoS
0
cluster_init (void) { cluster_hash = hash_create (cluster_hash_key_make, cluster_hash_cmp); }
@@ -1646,7 +1646,7 @@ bgp_attr_ext_communities (struct bgp_attr_parser_args *args) static bgp_attr_parse_ret_t bgp_attr_unknown (struct bgp_attr_parser_args *args) { - bgp_size_t total; + bgp_size_t total = args->total; struct transit *transit; struct attr_extra *attre; struct peer *const peer = args->peer;
null
null
null
211
cluster_intern (struct cluster_list *cluster) { struct cluster_list *find; find = hash_get (cluster_hash, cluster, cluster_hash_alloc); find->refcnt++; return find; }
DoS
0
cluster_intern (struct cluster_list *cluster) { struct cluster_list *find; find = hash_get (cluster_hash, cluster, cluster_hash_alloc); find->refcnt++; return find; }
@@ -1646,7 +1646,7 @@ bgp_attr_ext_communities (struct bgp_attr_parser_args *args) static bgp_attr_parse_ret_t bgp_attr_unknown (struct bgp_attr_parser_args *args) { - bgp_size_t total; + bgp_size_t total = args->total; struct transit *transit; struct attr_extra *attre; struct peer *const peer = args->peer;
null
null
null
212
cluster_loop_check (struct cluster_list *cluster, struct in_addr originator) { int i; for (i = 0; i < cluster->length / 4; i++) if (cluster->list[i].s_addr == originator.s_addr) return 1; return 0; }
DoS
0
cluster_loop_check (struct cluster_list *cluster, struct in_addr originator) { int i; for (i = 0; i < cluster->length / 4; i++) if (cluster->list[i].s_addr == originator.s_addr) return 1; return 0; }
@@ -1646,7 +1646,7 @@ bgp_attr_ext_communities (struct bgp_attr_parser_args *args) static bgp_attr_parse_ret_t bgp_attr_unknown (struct bgp_attr_parser_args *args) { - bgp_size_t total; + bgp_size_t total = args->total; struct transit *transit; struct attr_extra *attre; struct peer *const peer = args->peer;
null
null
null
213
cluster_unintern (struct cluster_list *cluster) { if (cluster->refcnt) cluster->refcnt--; if (cluster->refcnt == 0) { hash_release (cluster_hash, cluster); cluster_free (cluster); } }
DoS
0
cluster_unintern (struct cluster_list *cluster) { if (cluster->refcnt) cluster->refcnt--; if (cluster->refcnt == 0) { hash_release (cluster_hash, cluster); cluster_free (cluster); } }
@@ -1646,7 +1646,7 @@ bgp_attr_ext_communities (struct bgp_attr_parser_args *args) static bgp_attr_parse_ret_t bgp_attr_unknown (struct bgp_attr_parser_args *args) { - bgp_size_t total; + bgp_size_t total = args->total; struct transit *transit; struct attr_extra *attre; struct peer *const peer = args->peer;
null
null
null
214
transit_finish (void) { hash_free (transit_hash); transit_hash = NULL; }
DoS
0
transit_finish (void) { hash_free (transit_hash); transit_hash = NULL; }
@@ -1646,7 +1646,7 @@ bgp_attr_ext_communities (struct bgp_attr_parser_args *args) static bgp_attr_parse_ret_t bgp_attr_unknown (struct bgp_attr_parser_args *args) { - bgp_size_t total; + bgp_size_t total = args->total; struct transit *transit; struct attr_extra *attre; struct peer *const peer = args->peer;
null
null
null
215
transit_free (struct transit *transit) { if (transit->val) XFREE (MTYPE_TRANSIT_VAL, transit->val); XFREE (MTYPE_TRANSIT, transit); }
DoS
0
transit_free (struct transit *transit) { if (transit->val) XFREE (MTYPE_TRANSIT_VAL, transit->val); XFREE (MTYPE_TRANSIT, transit); }
@@ -1646,7 +1646,7 @@ bgp_attr_ext_communities (struct bgp_attr_parser_args *args) static bgp_attr_parse_ret_t bgp_attr_unknown (struct bgp_attr_parser_args *args) { - bgp_size_t total; + bgp_size_t total = args->total; struct transit *transit; struct attr_extra *attre; struct peer *const peer = args->peer;
null
null
null
216
transit_hash_alloc (void *p) { /* Transit structure is already allocated. */ return p; }
DoS
0
transit_hash_alloc (void *p) { /* Transit structure is already allocated. */ return p; }
@@ -1646,7 +1646,7 @@ bgp_attr_ext_communities (struct bgp_attr_parser_args *args) static bgp_attr_parse_ret_t bgp_attr_unknown (struct bgp_attr_parser_args *args) { - bgp_size_t total; + bgp_size_t total = args->total; struct transit *transit; struct attr_extra *attre; struct peer *const peer = args->peer;
null
null
null
217
transit_hash_cmp (const void *p1, const void *p2) { const struct transit * transit1 = p1; const struct transit * transit2 = p2; return (transit1->length == transit2->length && memcmp (transit1->val, transit2->val, transit1->length) == 0); }
DoS
0
transit_hash_cmp (const void *p1, const void *p2) { const struct transit * transit1 = p1; const struct transit * transit2 = p2; return (transit1->length == transit2->length && memcmp (transit1->val, transit2->val, transit1->length) == 0); }
@@ -1646,7 +1646,7 @@ bgp_attr_ext_communities (struct bgp_attr_parser_args *args) static bgp_attr_parse_ret_t bgp_attr_unknown (struct bgp_attr_parser_args *args) { - bgp_size_t total; + bgp_size_t total = args->total; struct transit *transit; struct attr_extra *attre; struct peer *const peer = args->peer;
null
null
null
218
transit_init (void) { transit_hash = hash_create (transit_hash_key_make, transit_hash_cmp); }
DoS
0
transit_init (void) { transit_hash = hash_create (transit_hash_key_make, transit_hash_cmp); }
@@ -1646,7 +1646,7 @@ bgp_attr_ext_communities (struct bgp_attr_parser_args *args) static bgp_attr_parse_ret_t bgp_attr_unknown (struct bgp_attr_parser_args *args) { - bgp_size_t total; + bgp_size_t total = args->total; struct transit *transit; struct attr_extra *attre; struct peer *const peer = args->peer;
null
null
null
219
transit_intern (struct transit *transit) { struct transit *find; find = hash_get (transit_hash, transit, transit_hash_alloc); if (find != transit) transit_free (transit); find->refcnt++; return find; }
DoS
0
transit_intern (struct transit *transit) { struct transit *find; find = hash_get (transit_hash, transit, transit_hash_alloc); if (find != transit) transit_free (transit); find->refcnt++; return find; }
@@ -1646,7 +1646,7 @@ bgp_attr_ext_communities (struct bgp_attr_parser_args *args) static bgp_attr_parse_ret_t bgp_attr_unknown (struct bgp_attr_parser_args *args) { - bgp_size_t total; + bgp_size_t total = args->total; struct transit *transit; struct attr_extra *attre; struct peer *const peer = args->peer;
null
null
null
220
transit_unintern (struct transit *transit) { if (transit->refcnt) transit->refcnt--; if (transit->refcnt == 0) { hash_release (transit_hash, transit); transit_free (transit); } }
DoS
0
transit_unintern (struct transit *transit) { if (transit->refcnt) transit->refcnt--; if (transit->refcnt == 0) { hash_release (transit_hash, transit); transit_free (transit); } }
@@ -1646,7 +1646,7 @@ bgp_attr_ext_communities (struct bgp_attr_parser_args *args) static bgp_attr_parse_ret_t bgp_attr_unknown (struct bgp_attr_parser_args *args) { - bgp_size_t total; + bgp_size_t total = args->total; struct transit *transit; struct attr_extra *attre; struct peer *const peer = args->peer;
null
null
null
221
bgr2cmyk(fz_context *ctx, fz_color_converter *cc, float *dv, const float *sv) { float c = 1 - sv[2]; float m = 1 - sv[1]; float y = 1 - sv[0]; float k = fz_min(c, fz_min(m, y)); dv[0] = c - k; dv[1] = m - k; dv[2] = y - k; dv[3] = k; }
DoS
0
bgr2cmyk(fz_context *ctx, fz_color_converter *cc, float *dv, const float *sv) { float c = 1 - sv[2]; float m = 1 - sv[1]; float y = 1 - sv[0]; float k = fz_min(c, fz_min(m, y)); dv[0] = c - k; dv[1] = m - k; dv[2] = y - k; dv[3] = k; }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
222
bgr2g(fz_context *ctx, fz_color_converter *cc, float *dv, const float *sv) { dv[0] = sv[0] * 0.11f + sv[1] * 0.59f + sv[2] * 0.3f; }
DoS
0
bgr2g(fz_context *ctx, fz_color_converter *cc, float *dv, const float *sv) { dv[0] = sv[0] * 0.11f + sv[1] * 0.59f + sv[2] * 0.3f; }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
223
static void bgr_to_rgb(fz_context *ctx, const fz_colorspace *cs, const float *bgr, float *rgb) { rgb[0] = bgr[2]; rgb[1] = bgr[1]; rgb[2] = bgr[0]; }
DoS
0
static void bgr_to_rgb(fz_context *ctx, const fz_colorspace *cs, const float *bgr, float *rgb) { rgb[0] = bgr[2]; rgb[1] = bgr[1]; rgb[2] = bgr[0]; }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
224
clamp_default(const fz_colorspace *cs, const float *src, float *dst) { int i; for (i = 0; i < cs->n; i++) dst[i] = fz_clamp(src[i], 0, 1); }
DoS
0
clamp_default(const fz_colorspace *cs, const float *src, float *dst) { int i; for (i = 0; i < cs->n; i++) dst[i] = fz_clamp(src[i], 0, 1); }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
225
clamp_indexed(const fz_colorspace *cs, const float *in, float *out) { struct indexed *idx = cs->data; *out = fz_clamp(*in, 0, idx->high) / 255.0f; /* To do, avoid 255 divide */ }
DoS
0
clamp_indexed(const fz_colorspace *cs, const float *in, float *out) { struct indexed *idx = cs->data; *out = fz_clamp(*in, 0, idx->high) / 255.0f; /* To do, avoid 255 divide */ }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
226
clamp_lab(const fz_colorspace *cs, const float *src, float *dst) { int i; for (i = 0; i < 3; i++) dst[i] = fz_clamp(src[i], i ? -128 : 0, i ? 127 : 100); }
DoS
0
clamp_lab(const fz_colorspace *cs, const float *src, float *dst) { int i; for (i = 0; i < 3; i++) dst[i] = fz_clamp(src[i], i ? -128 : 0, i ? 127 : 100); }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
227
clamp_lab_icc(const fz_colorspace *cs, const float *src, float *dst) { dst[0] = (fz_clamp(src[0], 0, 100)) / 100.0f; dst[1] = (fz_clamp(src[1], -128, 127) + 128.0f) / 256; dst[2] = (fz_clamp(src[2], -128, 127) + 128.0f) / 256; }
DoS
0
clamp_lab_icc(const fz_colorspace *cs, const float *src, float *dst) { dst[0] = (fz_clamp(src[0], 0, 100)) / 100.0f; dst[1] = (fz_clamp(src[1], -128, 127) + 128.0f) / 256; dst[2] = (fz_clamp(src[2], -128, 127) + 128.0f) / 256; }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
228
cmyk2bgr(fz_context *ctx, fz_color_converter *cc, float *dv, const float *sv) { #ifdef SLOWCMYK float rgb[3]; cmyk_to_rgb(ctx, NULL, sv, rgb); dv[0] = rgb[2]; dv[1] = rgb[1]; dv[2] = rgb[0]; #else dv[0] = 1 - fz_min(sv[2] + sv[3], 1); dv[1] = 1 - fz_min(sv[1] + sv[3], 1); dv[2] = 1 - fz_min(sv[0] + sv[3], 1); #endif }
DoS
0
cmyk2bgr(fz_context *ctx, fz_color_converter *cc, float *dv, const float *sv) { #ifdef SLOWCMYK float rgb[3]; cmyk_to_rgb(ctx, NULL, sv, rgb); dv[0] = rgb[2]; dv[1] = rgb[1]; dv[2] = rgb[0]; #else dv[0] = 1 - fz_min(sv[2] + sv[3], 1); dv[1] = 1 - fz_min(sv[1] + sv[3], 1); dv[2] = 1 - fz_min(sv[0] + sv[3], 1); #endif }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
229
cmyk2g(fz_context *ctx, fz_color_converter *cc, float *dv, const float *sv) { float c = sv[0] * 0.3f; float m = sv[1] * 0.59f; float y = sv[2] * 0.11f; dv[0] = 1 - fz_min(c + m + y + sv[3], 1); }
DoS
0
cmyk2g(fz_context *ctx, fz_color_converter *cc, float *dv, const float *sv) { float c = sv[0] * 0.3f; float m = sv[1] * 0.59f; float y = sv[2] * 0.11f; dv[0] = 1 - fz_min(c + m + y + sv[3], 1); }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
230
static void cmyk_to_rgb(fz_context *ctx, const fz_colorspace *cs, const float *cmyk, float *rgb) { #ifdef SLOWCMYK /* from poppler */ float c = cmyk[0], m = cmyk[1], y = cmyk[2], k = cmyk[3]; float r, g, b, x; float cm = c * m; float c1m = m - cm; float cm1 = c - cm; float c1m1 = 1 - m - cm1; float c1m1y = c1m1 * y; float c1m1y1 = c1m1 - c1m1y; float c1my = c1m * y; float c1my1 = c1m - c1my; float cm1y = cm1 * y; float cm1y1 = cm1 - cm1y; float cmy = cm * y; float cmy1 = cm - cmy; /* this is a matrix multiplication, unrolled for performance */ x = c1m1y1 * k; /* 0 0 0 1 */ r = g = b = c1m1y1 - x; /* 0 0 0 0 */ r += 0.1373f * x; g += 0.1216f * x; b += 0.1255f * x; x = c1m1y * k; /* 0 0 1 1 */ r += 0.1098f * x; g += 0.1020f * x; x = c1m1y - x; /* 0 0 1 0 */ r += x; g += 0.9490f * x; x = c1my1 * k; /* 0 1 0 1 */ r += 0.1412f * x; x = c1my1 - x; /* 0 1 0 0 */ r += 0.9255f * x; b += 0.5490f * x; x = c1my * k; /* 0 1 1 1 */ r += 0.1333f * x; x = c1my - x; /* 0 1 1 0 */ r += 0.9294f * x; g += 0.1098f * x; b += 0.1412f * x; x = cm1y1 * k; /* 1 0 0 1 */ g += 0.0588f * x; b += 0.1412f * x; x = cm1y1 - x; /* 1 0 0 0 */ g += 0.6784f * x; b += 0.9373f * x; x = cm1y * k; /* 1 0 1 1 */ g += 0.0745f * x; x = cm1y - x; /* 1 0 1 0 */ g += 0.6510f * x; b += 0.3137f * x; x = cmy1 * k; /* 1 1 0 1 */ b += 0.0078f * x; x = cmy1 - x; /* 1 1 0 0 */ r += 0.1804f * x; g += 0.1922f * x; b += 0.5725f * x; x = cmy * (1-k); /* 1 1 1 0 */ r += 0.2118f * x; g += 0.2119f * x; b += 0.2235f * x; rgb[0] = fz_clamp(r, 0, 1); rgb[1] = fz_clamp(g, 0, 1); rgb[2] = fz_clamp(b, 0, 1); #else rgb[0] = 1 - fz_min(1, cmyk[0] + cmyk[3]); rgb[1] = 1 - fz_min(1, cmyk[1] + cmyk[3]); rgb[2] = 1 - fz_min(1, cmyk[2] + cmyk[3]); #endif }
DoS
0
static void cmyk_to_rgb(fz_context *ctx, const fz_colorspace *cs, const float *cmyk, float *rgb) { #ifdef SLOWCMYK /* from poppler */ float c = cmyk[0], m = cmyk[1], y = cmyk[2], k = cmyk[3]; float r, g, b, x; float cm = c * m; float c1m = m - cm; float cm1 = c - cm; float c1m1 = 1 - m - cm1; float c1m1y = c1m1 * y; float c1m1y1 = c1m1 - c1m1y; float c1my = c1m * y; float c1my1 = c1m - c1my; float cm1y = cm1 * y; float cm1y1 = cm1 - cm1y; float cmy = cm * y; float cmy1 = cm - cmy; /* this is a matrix multiplication, unrolled for performance */ x = c1m1y1 * k; /* 0 0 0 1 */ r = g = b = c1m1y1 - x; /* 0 0 0 0 */ r += 0.1373f * x; g += 0.1216f * x; b += 0.1255f * x; x = c1m1y * k; /* 0 0 1 1 */ r += 0.1098f * x; g += 0.1020f * x; x = c1m1y - x; /* 0 0 1 0 */ r += x; g += 0.9490f * x; x = c1my1 * k; /* 0 1 0 1 */ r += 0.1412f * x; x = c1my1 - x; /* 0 1 0 0 */ r += 0.9255f * x; b += 0.5490f * x; x = c1my * k; /* 0 1 1 1 */ r += 0.1333f * x; x = c1my - x; /* 0 1 1 0 */ r += 0.9294f * x; g += 0.1098f * x; b += 0.1412f * x; x = cm1y1 * k; /* 1 0 0 1 */ g += 0.0588f * x; b += 0.1412f * x; x = cm1y1 - x; /* 1 0 0 0 */ g += 0.6784f * x; b += 0.9373f * x; x = cm1y * k; /* 1 0 1 1 */ g += 0.0745f * x; x = cm1y - x; /* 1 0 1 0 */ g += 0.6510f * x; b += 0.3137f * x; x = cmy1 * k; /* 1 1 0 1 */ b += 0.0078f * x; x = cmy1 - x; /* 1 1 0 0 */ r += 0.1804f * x; g += 0.1922f * x; b += 0.5725f * x; x = cmy * (1-k); /* 1 1 1 0 */ r += 0.2118f * x; g += 0.2119f * x; b += 0.2235f * x; rgb[0] = fz_clamp(r, 0, 1); rgb[1] = fz_clamp(g, 0, 1); rgb[2] = fz_clamp(b, 0, 1); #else rgb[0] = 1 - fz_min(1, cmyk[0] + cmyk[3]); rgb[1] = 1 - fz_min(1, cmyk[1] + cmyk[3]); rgb[2] = 1 - fz_min(1, cmyk[2] + cmyk[3]); #endif }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
231
convert_to_icc_base(fz_context *ctx, fz_colorspace *srcs, float *src_f, float *des_f) { float temp_f[FZ_MAX_COLORS]; fz_colorspace *base_cs = srcs->get_base(srcs); if (fz_colorspace_is_icc(ctx, base_cs) || fz_colorspace_is_cal(ctx, base_cs) || fz_colorspace_is_lab(ctx, base_cs)) srcs->to_ccs(ctx, srcs, src_f, des_f); else { srcs->to_ccs(ctx, srcs, src_f, temp_f); convert_to_icc_base(ctx, base_cs, temp_f, des_f); } }
DoS
0
convert_to_icc_base(fz_context *ctx, fz_colorspace *srcs, float *src_f, float *des_f) { float temp_f[FZ_MAX_COLORS]; fz_colorspace *base_cs = srcs->get_base(srcs); if (fz_colorspace_is_icc(ctx, base_cs) || fz_colorspace_is_cal(ctx, base_cs) || fz_colorspace_is_lab(ctx, base_cs)) srcs->to_ccs(ctx, srcs, src_f, des_f); else { srcs->to_ccs(ctx, srcs, src_f, temp_f); convert_to_icc_base(ctx, base_cs, temp_f, des_f); } }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
232
static void fast_any_to_alpha(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src, fz_colorspace *prf, const fz_default_colorspaces *default_cs, const fz_color_params *color_params, int copy_spots) { assert(copy_spots && dst->s == 0 && src->s == 0); if (!src->alpha) fz_clear_pixmap_with_value(ctx, dst, 255); else { unsigned char *s = src->samples; unsigned char *d = dst->samples; size_t w = src->w; int h = src->h; int n = src->n; ptrdiff_t d_line_inc = dst->stride - w * dst->n; ptrdiff_t s_line_inc = src->stride - w * src->n; if ((int)w < 0 || h < 0) return; assert(dst->alpha && src->alpha && dst->n == 1); if (d_line_inc == 0 && s_line_inc == 0) { w *= h; h = 1; } s += n-1; while (h--) { size_t ww = w; while (ww--) { *d++ = *s; s += n; } d += d_line_inc; s += s_line_inc; } } }
DoS
0
static void fast_any_to_alpha(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src, fz_colorspace *prf, const fz_default_colorspaces *default_cs, const fz_color_params *color_params, int copy_spots) { assert(copy_spots && dst->s == 0 && src->s == 0); if (!src->alpha) fz_clear_pixmap_with_value(ctx, dst, 255); else { unsigned char *s = src->samples; unsigned char *d = dst->samples; size_t w = src->w; int h = src->h; int n = src->n; ptrdiff_t d_line_inc = dst->stride - w * dst->n; ptrdiff_t s_line_inc = src->stride - w * src->n; if ((int)w < 0 || h < 0) return; assert(dst->alpha && src->alpha && dst->n == 1); if (d_line_inc == 0 && s_line_inc == 0) { w *= h; h = 1; } s += n-1; while (h--) { size_t ww = w; while (ww--) { *d++ = *s; s += n; } d += d_line_inc; s += s_line_inc; } } }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
233
static void fast_bgr_to_cmyk(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src, fz_colorspace *prf, const fz_default_colorspaces *default_cs, const fz_color_params *color_params, int copy_spots) { unsigned char *s = src->samples; unsigned char *d = dst->samples; size_t w = src->w; int h = src->h; int sn = src->n; int ss = src->s; int sa = src->alpha; int dn = dst->n; int ds = dst->s; int da = dst->alpha; ptrdiff_t d_line_inc = dst->stride - w * dn; ptrdiff_t s_line_inc = src->stride - w * sn; /* Spots must match, and we can never drop alpha (but we can invent it) */ if ((copy_spots && ss != ds) || (!da && sa)) { assert("This should never happen" == NULL); fz_throw(ctx, FZ_ERROR_GENERIC, "Cannot convert between incompatible pixmaps"); } if ((int)w < 0 || h < 0) return; if (d_line_inc == 0 && s_line_inc == 0) { w *= h; h = 1; } if (ss == 0 && ds == 0) { /* Common, no spots case */ if (da) { if (sa) { while (h--) { size_t ww = w; while (ww--) { unsigned char c = s[2]; unsigned char m = s[1]; unsigned char y = s[0]; unsigned char k = (unsigned char)fz_mini(c, fz_mini(m, y)); d[0] = c - k; d[1] = m - k; d[2] = y - k; d[3] = k; d[4] = s[3]; s += 4; d += 5; } d += d_line_inc; s += s_line_inc; } } else { while (h--) { size_t ww = w; while (ww--) { unsigned char c = s[2]; unsigned char m = s[1]; unsigned char y = s[0]; unsigned char k = (unsigned char)fz_mini(c, fz_mini(m, y)); d[0] = c - k; d[1] = m - k; d[2] = y - k; d[3] = k; d[4] = 255; s += 3; d += 5; } d += d_line_inc; s += s_line_inc; } } } else { while (h--) { size_t ww = w; while (ww--) { unsigned char c = s[2]; unsigned char m = s[1]; unsigned char y = s[0]; unsigned char k = (unsigned char)fz_mini(c, fz_mini(m, y)); d[0] = c - k; d[1] = m - k; d[2] = y - k; d[3] = k; s += 3; d += 4; } d += d_line_inc; s += s_line_inc; } } } else if (copy_spots) { /* Slower, spots capable version */ while (h--) { int i; size_t ww = w; while (ww--) { unsigned char c = s[2]; unsigned char m = s[1]; unsigned char y = s[0]; unsigned char k = (unsigned char)fz_mini(c, fz_mini(m, y)); d[0] = c - k; d[1] = m - k; d[2] = y - k; d[3] = k; s += 3; d += 4; for (i=ss; i > 0; i--) *d++ = *s++; if (da) *d++ = sa ? *s++ : 255; } d += d_line_inc; s += s_line_inc; } } else { while (h--) { size_t ww = w; while (ww--) { unsigned char c = s[2]; unsigned char m = s[1]; unsigned char y = s[0]; unsigned char k = (unsigned char)(255 - fz_maxi(c, fz_maxi(m, y))); d[0] = c + k; d[1] = m + k; d[2] = y + k; d[3] = 255 - k; s += sn; d += dn; if (da) d[-1] = sa ? s[-1] : 255; } d += d_line_inc; s += s_line_inc; } } }
DoS
0
static void fast_bgr_to_cmyk(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src, fz_colorspace *prf, const fz_default_colorspaces *default_cs, const fz_color_params *color_params, int copy_spots) { unsigned char *s = src->samples; unsigned char *d = dst->samples; size_t w = src->w; int h = src->h; int sn = src->n; int ss = src->s; int sa = src->alpha; int dn = dst->n; int ds = dst->s; int da = dst->alpha; ptrdiff_t d_line_inc = dst->stride - w * dn; ptrdiff_t s_line_inc = src->stride - w * sn; /* Spots must match, and we can never drop alpha (but we can invent it) */ if ((copy_spots && ss != ds) || (!da && sa)) { assert("This should never happen" == NULL); fz_throw(ctx, FZ_ERROR_GENERIC, "Cannot convert between incompatible pixmaps"); } if ((int)w < 0 || h < 0) return; if (d_line_inc == 0 && s_line_inc == 0) { w *= h; h = 1; } if (ss == 0 && ds == 0) { /* Common, no spots case */ if (da) { if (sa) { while (h--) { size_t ww = w; while (ww--) { unsigned char c = s[2]; unsigned char m = s[1]; unsigned char y = s[0]; unsigned char k = (unsigned char)fz_mini(c, fz_mini(m, y)); d[0] = c - k; d[1] = m - k; d[2] = y - k; d[3] = k; d[4] = s[3]; s += 4; d += 5; } d += d_line_inc; s += s_line_inc; } } else { while (h--) { size_t ww = w; while (ww--) { unsigned char c = s[2]; unsigned char m = s[1]; unsigned char y = s[0]; unsigned char k = (unsigned char)fz_mini(c, fz_mini(m, y)); d[0] = c - k; d[1] = m - k; d[2] = y - k; d[3] = k; d[4] = 255; s += 3; d += 5; } d += d_line_inc; s += s_line_inc; } } } else { while (h--) { size_t ww = w; while (ww--) { unsigned char c = s[2]; unsigned char m = s[1]; unsigned char y = s[0]; unsigned char k = (unsigned char)fz_mini(c, fz_mini(m, y)); d[0] = c - k; d[1] = m - k; d[2] = y - k; d[3] = k; s += 3; d += 4; } d += d_line_inc; s += s_line_inc; } } } else if (copy_spots) { /* Slower, spots capable version */ while (h--) { int i; size_t ww = w; while (ww--) { unsigned char c = s[2]; unsigned char m = s[1]; unsigned char y = s[0]; unsigned char k = (unsigned char)fz_mini(c, fz_mini(m, y)); d[0] = c - k; d[1] = m - k; d[2] = y - k; d[3] = k; s += 3; d += 4; for (i=ss; i > 0; i--) *d++ = *s++; if (da) *d++ = sa ? *s++ : 255; } d += d_line_inc; s += s_line_inc; } } else { while (h--) { size_t ww = w; while (ww--) { unsigned char c = s[2]; unsigned char m = s[1]; unsigned char y = s[0]; unsigned char k = (unsigned char)(255 - fz_maxi(c, fz_maxi(m, y))); d[0] = c + k; d[1] = m + k; d[2] = y + k; d[3] = 255 - k; s += sn; d += dn; if (da) d[-1] = sa ? s[-1] : 255; } d += d_line_inc; s += s_line_inc; } } }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
234
static void fast_bgr_to_gray(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src, fz_colorspace *prf, const fz_default_colorspaces *default_cs, const fz_color_params *color_params, int copy_spots) { unsigned char *s = src->samples; unsigned char *d = dst->samples; size_t w = src->w; int h = src->h; int sn = src->n; int ss = src->s; int sa = src->alpha; int dn = dst->n; int ds = dst->s; int da = dst->alpha; ptrdiff_t d_line_inc = dst->stride - w * dn; ptrdiff_t s_line_inc = src->stride - w * sn; /* If copying spots, they must match, and we can never drop alpha (but we can invent it) */ if ((copy_spots && ss != ds) || (!da && sa)) { assert("This should never happen" == NULL); fz_throw(ctx, FZ_ERROR_GENERIC, "Cannot convert between incompatible pixmaps"); } if ((int)w < 0 || h < 0) return; if (d_line_inc == 0 && s_line_inc == 0) { w *= h; h = 1; } if (ss == 0 && ds == 0) { /* Common, no spots case */ if (da) { if (sa) { while (h--) { size_t ww = w; while (ww--) { d[0] = ((s[0]+1) * 28 + (s[1]+1) * 150 + (s[2]+1) * 77) >> 8; d[1] = s[3]; s += 4; d += 2; } d += d_line_inc; s += s_line_inc; } } else { while (h--) { size_t ww = w; while (ww--) { d[0] = ((s[0]+1) * 28 + (s[1]+1) * 150 + (s[2]+1) * 77) >> 8; d[1] = 255; s += 3; d += 2; } d += d_line_inc; s += s_line_inc; } } } else { int si = 3 + src->alpha; while (h--) { size_t ww = w; while (ww--) { d[0] = ((s[0]+1) * 28 + (s[1]+1) * 150 + (s[2]+1) * 77) >> 8; s += si; d++; } d += d_line_inc; s += s_line_inc; } } } else if (copy_spots) { /* Slower, spots capable version */ while (h--) { int i; size_t ww = w; while (ww--) { d[0] = ((s[0]+1) * 28 + (s[1]+1) * 150 + (s[2]+1) * 77) >> 8; s += 3; d++; for (i=ss; i > 0; i--) *d++ = *s++; if (da) *d++ = sa ? *s++ : 255; } d += d_line_inc; s += s_line_inc; } } else { /* Slower, spots capable version */ while (h--) { size_t ww = w; while (ww--) { d[0] = ((s[0]+1) * 28 + (s[1]+1) * 150 + (s[2]+1) * 77) >> 8; s += sn; d += dn; if (da) d[-1] = sa ? s[-1] : 255; } d += d_line_inc; s += s_line_inc; } } }
DoS
0
static void fast_bgr_to_gray(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src, fz_colorspace *prf, const fz_default_colorspaces *default_cs, const fz_color_params *color_params, int copy_spots) { unsigned char *s = src->samples; unsigned char *d = dst->samples; size_t w = src->w; int h = src->h; int sn = src->n; int ss = src->s; int sa = src->alpha; int dn = dst->n; int ds = dst->s; int da = dst->alpha; ptrdiff_t d_line_inc = dst->stride - w * dn; ptrdiff_t s_line_inc = src->stride - w * sn; /* If copying spots, they must match, and we can never drop alpha (but we can invent it) */ if ((copy_spots && ss != ds) || (!da && sa)) { assert("This should never happen" == NULL); fz_throw(ctx, FZ_ERROR_GENERIC, "Cannot convert between incompatible pixmaps"); } if ((int)w < 0 || h < 0) return; if (d_line_inc == 0 && s_line_inc == 0) { w *= h; h = 1; } if (ss == 0 && ds == 0) { /* Common, no spots case */ if (da) { if (sa) { while (h--) { size_t ww = w; while (ww--) { d[0] = ((s[0]+1) * 28 + (s[1]+1) * 150 + (s[2]+1) * 77) >> 8; d[1] = s[3]; s += 4; d += 2; } d += d_line_inc; s += s_line_inc; } } else { while (h--) { size_t ww = w; while (ww--) { d[0] = ((s[0]+1) * 28 + (s[1]+1) * 150 + (s[2]+1) * 77) >> 8; d[1] = 255; s += 3; d += 2; } d += d_line_inc; s += s_line_inc; } } } else { int si = 3 + src->alpha; while (h--) { size_t ww = w; while (ww--) { d[0] = ((s[0]+1) * 28 + (s[1]+1) * 150 + (s[2]+1) * 77) >> 8; s += si; d++; } d += d_line_inc; s += s_line_inc; } } } else if (copy_spots) { /* Slower, spots capable version */ while (h--) { int i; size_t ww = w; while (ww--) { d[0] = ((s[0]+1) * 28 + (s[1]+1) * 150 + (s[2]+1) * 77) >> 8; s += 3; d++; for (i=ss; i > 0; i--) *d++ = *s++; if (da) *d++ = sa ? *s++ : 255; } d += d_line_inc; s += s_line_inc; } } else { /* Slower, spots capable version */ while (h--) { size_t ww = w; while (ww--) { d[0] = ((s[0]+1) * 28 + (s[1]+1) * 150 + (s[2]+1) * 77) >> 8; s += sn; d += dn; if (da) d[-1] = sa ? s[-1] : 255; } d += d_line_inc; s += s_line_inc; } } }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
235
static void fast_cmyk_to_gray(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src, fz_colorspace *prf, const fz_default_colorspaces *default_cs, const fz_color_params *color_params, int copy_spots) { unsigned char *s = src->samples; unsigned char *d = dst->samples; size_t w = src->w; int h = src->h; int sn = src->n; int ss = src->s; int sa = src->alpha; int dn = dst->n; int ds = dst->s; int da = dst->alpha; ptrdiff_t d_line_inc = dst->stride - w * dn; ptrdiff_t s_line_inc = src->stride - w * sn; /* Spots must match, and we can never drop alpha (but we can invent it) */ if ((copy_spots && ss != ds) || (!da && sa)) { assert("This should never happen" == NULL); fz_throw(ctx, FZ_ERROR_GENERIC, "Cannot convert between incompatible pixmaps"); } if ((int)w < 0 || h < 0) return; if (d_line_inc == 0 && s_line_inc == 0) { w *= h; h = 1; } if (ss == 0 && ds == 0) { /* Common, no spots case */ if (da) { if (sa) { while (h--) { size_t ww = w; while (ww--) { unsigned char c = fz_mul255(s[0], 77); unsigned char m = fz_mul255(s[1], 150); unsigned char y = fz_mul255(s[2], 28); d[0] = 255 - (unsigned char)fz_mini(c + m + y + s[3], 255); d[1] = s[4]; s += 5; d += 2; } d += d_line_inc; s += s_line_inc; } } else { while (h--) { size_t ww = w; while (ww--) { unsigned char c = fz_mul255(s[0], 77); unsigned char m = fz_mul255(s[1], 150); unsigned char y = fz_mul255(s[2], 28); d[0] = 255 - (unsigned char)fz_mini(c + m + y + s[3], 255); d[1] = 255; s += 3; d += 2; } d += d_line_inc; s += s_line_inc; } } } else { while (h--) { size_t ww = w; while (ww--) { unsigned char c = fz_mul255(s[0], 77); unsigned char m = fz_mul255(s[1], 150); unsigned char y = fz_mul255(s[2], 28); d[0] = 255 - (unsigned char)fz_mini(c + m + y + s[3], 255); s += 4; d++; } d += d_line_inc; s += s_line_inc; } } } else if (copy_spots) { /* Slower, spots capable version */ while (h--) { int i; size_t ww = w; while (ww--) { unsigned char c = fz_mul255(s[0], 77); unsigned char m = fz_mul255(s[1], 150); unsigned char y = fz_mul255(s[2], 28); d[0] = 255 - (unsigned char)fz_mini(c + m + y + s[3], 255); s += 4; d++; for (i=ss; i > 0; i--) *d++ = *s++; if (da) *d++ = sa ? *s++ : 255; } d += d_line_inc; s += s_line_inc; } } else { while (h--) { size_t ww = w; while (ww--) { unsigned char c = fz_mul255(255 - s[0], 77); unsigned char m = fz_mul255(255 - s[1], 150); unsigned char y = fz_mul255(255 - s[2], 28); d[0] = (unsigned char)fz_maxi(s[3] - c - m - y, 0); s += sn; d += dn; if (da) d[-1] = sa ? s[-1] : 255; } d += d_line_inc; s += s_line_inc; } } }
DoS
0
static void fast_cmyk_to_gray(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src, fz_colorspace *prf, const fz_default_colorspaces *default_cs, const fz_color_params *color_params, int copy_spots) { unsigned char *s = src->samples; unsigned char *d = dst->samples; size_t w = src->w; int h = src->h; int sn = src->n; int ss = src->s; int sa = src->alpha; int dn = dst->n; int ds = dst->s; int da = dst->alpha; ptrdiff_t d_line_inc = dst->stride - w * dn; ptrdiff_t s_line_inc = src->stride - w * sn; /* Spots must match, and we can never drop alpha (but we can invent it) */ if ((copy_spots && ss != ds) || (!da && sa)) { assert("This should never happen" == NULL); fz_throw(ctx, FZ_ERROR_GENERIC, "Cannot convert between incompatible pixmaps"); } if ((int)w < 0 || h < 0) return; if (d_line_inc == 0 && s_line_inc == 0) { w *= h; h = 1; } if (ss == 0 && ds == 0) { /* Common, no spots case */ if (da) { if (sa) { while (h--) { size_t ww = w; while (ww--) { unsigned char c = fz_mul255(s[0], 77); unsigned char m = fz_mul255(s[1], 150); unsigned char y = fz_mul255(s[2], 28); d[0] = 255 - (unsigned char)fz_mini(c + m + y + s[3], 255); d[1] = s[4]; s += 5; d += 2; } d += d_line_inc; s += s_line_inc; } } else { while (h--) { size_t ww = w; while (ww--) { unsigned char c = fz_mul255(s[0], 77); unsigned char m = fz_mul255(s[1], 150); unsigned char y = fz_mul255(s[2], 28); d[0] = 255 - (unsigned char)fz_mini(c + m + y + s[3], 255); d[1] = 255; s += 3; d += 2; } d += d_line_inc; s += s_line_inc; } } } else { while (h--) { size_t ww = w; while (ww--) { unsigned char c = fz_mul255(s[0], 77); unsigned char m = fz_mul255(s[1], 150); unsigned char y = fz_mul255(s[2], 28); d[0] = 255 - (unsigned char)fz_mini(c + m + y + s[3], 255); s += 4; d++; } d += d_line_inc; s += s_line_inc; } } } else if (copy_spots) { /* Slower, spots capable version */ while (h--) { int i; size_t ww = w; while (ww--) { unsigned char c = fz_mul255(s[0], 77); unsigned char m = fz_mul255(s[1], 150); unsigned char y = fz_mul255(s[2], 28); d[0] = 255 - (unsigned char)fz_mini(c + m + y + s[3], 255); s += 4; d++; for (i=ss; i > 0; i--) *d++ = *s++; if (da) *d++ = sa ? *s++ : 255; } d += d_line_inc; s += s_line_inc; } } else { while (h--) { size_t ww = w; while (ww--) { unsigned char c = fz_mul255(255 - s[0], 77); unsigned char m = fz_mul255(255 - s[1], 150); unsigned char y = fz_mul255(255 - s[2], 28); d[0] = (unsigned char)fz_maxi(s[3] - c - m - y, 0); s += sn; d += dn; if (da) d[-1] = sa ? s[-1] : 255; } d += d_line_inc; s += s_line_inc; } } }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
236
static void fast_cmyk_to_rgb(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src, fz_colorspace *prf, const fz_default_colorspaces *default_cs, const fz_color_params *color_params, int copy_spots) { unsigned char *s = src->samples; unsigned char *d = dst->samples; size_t w = src->w; int h = src->h; int sn = src->n; int ss = src->s; int sa = src->alpha; int dn = dst->n; int ds = dst->s; int da = dst->alpha; ptrdiff_t d_line_inc = dst->stride - w * dn; ptrdiff_t s_line_inc = src->stride - w * sn; unsigned int C,M,Y,K; unsigned char r,g,b; /* Spots must match, and we can never drop alpha (but we can invent it) */ if ((copy_spots && ss != ds) || (!da && sa)) { assert("This should never happen" == NULL); fz_throw(ctx, FZ_ERROR_GENERIC, "Cannot convert between incompatible pixmaps"); } if ((int)w < 0 || h < 0) return; C = 0; M = 0; Y = 0; K = 0; r = 255; g = 255; b = 255; if (d_line_inc == 0 && s_line_inc == 0) { w *= h; h = 1; } if (ss == 0 && ds == 0) { /* Common, no spots case */ if (da) { if (sa) { #ifdef ARCH_ARM if (h == 1) { fast_cmyk_to_rgb_ARM(d, s, w); return; } #endif while (h--) { size_t ww = w; while (ww--) { cached_cmyk_conv(&r, &g, &b, &C, &M, &Y, &K, s[0], s[1], s[2], s[3]); d[0] = r; d[1] = g; d[2] = b; d[3] = s[4]; s += 5; d += 4; } d += d_line_inc; s += s_line_inc; } } else { while (h--) { size_t ww = w; while (ww--) { cached_cmyk_conv(&r, &g, &b, &C, &M, &Y, &K, s[0], s[1], s[2], s[3]); d[0] = r; d[1] = g; d[2] = b; d[3] = 255; s += 4; d += 4; } d += d_line_inc; s += s_line_inc; } } } else { while (h--) { size_t ww = w; while (ww--) { cached_cmyk_conv(&r, &g, &b, &C, &M, &Y, &K, s[0], s[1], s[2], s[3]); d[0] = r; d[1] = g; d[2] = b; s += 4; d += 3; } d += d_line_inc; s += s_line_inc; } } } else if (copy_spots) { /* Slower, spots capable version */ while (h--) { int i; size_t ww = w; while (ww--) { cached_cmyk_conv(&r, &g, &b, &C, &M, &Y, &K, s[0], s[1], s[2], s[3]); d[0] = r; d[1] = g; d[2] = b; s += 4; d += 3; for (i=ss; i > 0; i--) *d++ = *s++; if (da) *d++ = sa ? *s++ : 255; } d += d_line_inc; s += s_line_inc; } } else { /* Slower, spots capable version */ while (h--) { size_t ww = w; while (ww--) { cached_cmyk_conv(&r, &g, &b, &C, &M, &Y, &K, s[0], s[1], s[2], s[3]); d[0] = r; d[1] = g; d[2] = b; s += sn; d += dn; if (da) d[-1] = sa ? s[-1] : 255; } d += d_line_inc; s += s_line_inc; } } }
DoS
0
static void fast_cmyk_to_rgb(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src, fz_colorspace *prf, const fz_default_colorspaces *default_cs, const fz_color_params *color_params, int copy_spots) { unsigned char *s = src->samples; unsigned char *d = dst->samples; size_t w = src->w; int h = src->h; int sn = src->n; int ss = src->s; int sa = src->alpha; int dn = dst->n; int ds = dst->s; int da = dst->alpha; ptrdiff_t d_line_inc = dst->stride - w * dn; ptrdiff_t s_line_inc = src->stride - w * sn; unsigned int C,M,Y,K; unsigned char r,g,b; /* Spots must match, and we can never drop alpha (but we can invent it) */ if ((copy_spots && ss != ds) || (!da && sa)) { assert("This should never happen" == NULL); fz_throw(ctx, FZ_ERROR_GENERIC, "Cannot convert between incompatible pixmaps"); } if ((int)w < 0 || h < 0) return; C = 0; M = 0; Y = 0; K = 0; r = 255; g = 255; b = 255; if (d_line_inc == 0 && s_line_inc == 0) { w *= h; h = 1; } if (ss == 0 && ds == 0) { /* Common, no spots case */ if (da) { if (sa) { #ifdef ARCH_ARM if (h == 1) { fast_cmyk_to_rgb_ARM(d, s, w); return; } #endif while (h--) { size_t ww = w; while (ww--) { cached_cmyk_conv(&r, &g, &b, &C, &M, &Y, &K, s[0], s[1], s[2], s[3]); d[0] = r; d[1] = g; d[2] = b; d[3] = s[4]; s += 5; d += 4; } d += d_line_inc; s += s_line_inc; } } else { while (h--) { size_t ww = w; while (ww--) { cached_cmyk_conv(&r, &g, &b, &C, &M, &Y, &K, s[0], s[1], s[2], s[3]); d[0] = r; d[1] = g; d[2] = b; d[3] = 255; s += 4; d += 4; } d += d_line_inc; s += s_line_inc; } } } else { while (h--) { size_t ww = w; while (ww--) { cached_cmyk_conv(&r, &g, &b, &C, &M, &Y, &K, s[0], s[1], s[2], s[3]); d[0] = r; d[1] = g; d[2] = b; s += 4; d += 3; } d += d_line_inc; s += s_line_inc; } } } else if (copy_spots) { /* Slower, spots capable version */ while (h--) { int i; size_t ww = w; while (ww--) { cached_cmyk_conv(&r, &g, &b, &C, &M, &Y, &K, s[0], s[1], s[2], s[3]); d[0] = r; d[1] = g; d[2] = b; s += 4; d += 3; for (i=ss; i > 0; i--) *d++ = *s++; if (da) *d++ = sa ? *s++ : 255; } d += d_line_inc; s += s_line_inc; } } else { /* Slower, spots capable version */ while (h--) { size_t ww = w; while (ww--) { cached_cmyk_conv(&r, &g, &b, &C, &M, &Y, &K, s[0], s[1], s[2], s[3]); d[0] = r; d[1] = g; d[2] = b; s += sn; d += dn; if (da) d[-1] = sa ? s[-1] : 255; } d += d_line_inc; s += s_line_inc; } } }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
237
fast_cmyk_to_rgb_ARM(unsigned char *dst, unsigned char *src, int n) { asm volatile( ENTER_ARM "stmfd r13!,{r4-r11,r14} \n" "@ r0 = dst \n" "@ r1 = src \n" "@ r2 = n \n" "mov r12, #0 @ r12= CMYK = 0 \n" "b 2f @ enter loop \n" "1: @ White or Black \n" "@ Cunning trick: On entry r11 = 0 if black, r11 = FF if white \n" "eor r12,r11,#0xFF @ r12= FF if black, 0 if white \n" "ldrb r7, [r1],#1 @ r8 = s[4] \n" "strb r11,[r0],#1 @ d[0] = r \n" "strb r11,[r0],#1 @ d[1] = g \n" "strb r11,[r0],#1 @ d[2] = b \n" "strb r7, [r0],#1 @ d[3] = s[4] \n" "mov r12,r12,LSL #24 @ r12 = CMYK \n" "subs r2, r2, #1 @ r2 = n-- \n" "beq 9f \n" "2: @ Main loop starts here \n" "ldrb r3, [r1], #4 @ r3 = c \n" "ldrb r6, [r1, #-1] @ r6 = k \n" "ldrb r5, [r1, #-2] @ r5 = y \n" "ldrb r4, [r1, #-3] @ r4 = m \n" "eors r11,r6, #0xFF @ if (k == 255) \n" "beq 1b @ goto black \n" "orr r7, r3, r4, LSL #8 \n" "orr r14,r5, r6, LSL #8 \n" "orrs r7, r7, r14,LSL #16 @ r7 = cmyk \n" "beq 1b @ if (cmyk == 0) white \n" "@ At this point, we have to decode a new pixel \n" "@ r0 = dst r1 = src r2 = n r7 = cmyk \n" "3: @ unmatched \n" "stmfd r13!,{r0-r1,r7} @ stash regs for space \n" "add r3, r3, r3, LSR #7 @ r3 = c += c>>7 \n" "add r4, r4, r4, LSR #7 @ r4 = m += m>>7 \n" "add r5, r5, r5, LSR #7 @ r5 = y += y>>7 \n" "add r6, r6, r6, LSR #7 @ r6 = k += k>>7 \n" "mov r5, r5, LSR #1 @ sacrifice 1 bit of Y \n" "mul r8, r3, r4 @ r8 = cm = c * m \n" "rsb r9, r8, r4, LSL #8 @ r9 = c1m = (m<<8) - cm \n" "rsb r3, r8, r3, LSL #8 @ r3 = cm1 = (c<<8) - cm \n" "rsb r4, r4, #0x100 @ r4 = 256-m \n" "rsb r4, r3, r4, LSL #8 @ r4 = c1m1 =((256-m)<<8)-cm1 \n" "mul r7, r4, r5 @ r7 = c1m1y = c1m1 * y \n" "rsb r4, r7, r4, LSL #7 @ r4 = c1m1y1 = (c1m1<<7)-c1m1y \n" "mul r10,r9, r5 @ r10= c1my = c1m * y \n" "rsb r9, r10,r9, LSL #7 @ r9 = c1my1 = (c1m<<7) - c1my \n" "mul r11,r3, r5 @ r11= cm1y = cm1 * y \n" "rsb r3, r11,r3, LSL #7 @ r3 = cm1y1 = (cm1<<7) - cm1y \n" "mul r5, r8, r5 @ r5 = cmy = cm * y \n" "rsb r8, r5, r8, LSL #7 @ r8 = cmy1 = (cm<<7) - cmy \n" "@ Register recap: \n" "@ r3 = cm1y1 \n" "@ r4 = c1m1y1 \n" "@ r5 = cmy \n" "@ r6 = k \n" "@ r7 = c1m1y \n" "@ r8 = cmy1 \n" "@ r9 = c1my1 \n" "@ r10= c1my \n" "@ r11= cm1y \n" "@ The actual matrix multiplication \n" "mul r14,r4, r6 @ r14= x1 = c1m1y1 * k \n" "rsb r4, r14,r4, LSL #8 @ r4 = x0 = (c1m1y1<<8) - x1 \n" "add r4, r4, r14,LSR #8-5 @ r4 = b = x0 + 32*(x1>>8) \n" "sub r1, r4, r14,LSR #8 @ r1 = g = x0 + 31*(x1>>8) \n" "add r0, r1, r14,LSR #8-2 @ r0 = r = x0 + 35*(x1>>8) \n" " \n" "mul r14,r7, r6 @ r14= x1 = c1m1y * k \n" "rsb r7, r14,r7, LSL #8 @ r7 = x0 = (c1m1y<<8) - x1 \n" "add r0, r0, r7 @ r0 = r += x0 \n" "add r1, r1, r7 @ r1 = g += (x0>>8 * 256) \n" "sub r1, r1, r7, LSR #8-3 @ 248 \n" "sub r1, r1, r7, LSR #8-2 @ 244 \n" "sub r1, r1, r7, LSR #8 @ 243 \n" "sub r7, r14,r14,LSR #3 @ r7 = 28*(x1>>5) \n" "add r0, r0, r7, LSR #8-5 @ r0 = r += 28 * x1 \n" "sub r7, r7, r14,LSR #4 @ r7 = 26*(x1>>5) \n" "add r1, r1, r7, LSR #8-5 @ r1 = g += 26 * x1 \n" " \n" "mul r14,r9, r6 @ r14= x1 = c1my1 * k \n" "sub r9, r9, r14,LSR #8 @ r9 = x0>>8 = c1my1 - (x1>>8) \n" "add r0, r0, r14,LSR #8-5 @ r0 = r += (x1>>8)*32 \n" "add r0, r0, r14,LSR #8-2 @ r0 = r += (x1>>8)*36 \n" "mov r14,#237 @ r14= 237 \n" "mla r0,r14,r9,r0 @ r14= r += x0*237 \n" "mov r14,#141 @ r14= 141 \n" "mla r4,r14,r9,r4 @ r14= b += x0*141 \n" " \n" "mul r14,r10,r6 @ r14= x1 = c1my * k \n" "sub r10,r10,r14,LSR #8 @ r10= x0>>8 = c1my - (x1>>8) \n" "add r0, r0, r14,LSR #8-5 @ r0 = r += 32 * x1 \n" "add r0, r0, r14,LSR #8-1 @ r0 = r += 34 * x1 \n" "mov r14,#238 @ r14= 238 \n" "mla r0,r14,r10,r0 @ r0 = r += 238 * x0 \n" "mov r14,#28 @ r14= 28 \n" "mla r1,r14,r10,r1 @ r1 = g += 28 * x0 \n" "mov r14,#36 @ r14= 36 \n" "mla r4,r14,r10,r4 @ r4 = b += 36 * x0 \n" " \n" "mul r14,r3, r6 @ r14= x1 = cm1y1 * k \n" "sub r3, r3, r14,LSR #8 @ r3 = x1>>8 = cm1y1 - (x1>>8) \n" "add r1, r1, r14,LSR #8-4 @ r1 = g += 16*x1 \n" "sub r1, r1, r14,LSR #8 @ 15*x1 \n" "add r4, r4, r14,LSR #8-5 @ r4 = b += 32*x1 \n" "add r4, r4, r14,LSR #8-2 @ 36*x1 \n" "mov r14,#174 @ r14= 174 \n" "mla r1, r14,r3, r1 @ r1 = g += 174 * x0 \n" "mov r14,#240 @ r14= 240 \n" "mla r4, r14,r3, r4 @ r4 = b += 240 * x0 \n" " \n" "mul r14,r11,r6 @ r14= x1 = cm1y * k \n" "sub r11,r11,r14,LSR #8 @ r11= x0>>8 = cm1y - (x1>>8) \n" "add r1, r1, r14,LSR #8-4 @ r1 = g += x1 * 16 \n" "add r1, r1, r14,LSR #8 @ x1 * 17 \n" "add r1, r1, r14,LSR #8-1 @ x1 * 19 \n" "mov r14,#167 @ r14 = 167 \n" "mla r1, r14,r11,r1 @ r1 = g += 167 * x0 \n" "mov r14,#80 @ r14 = 80 \n" "mla r4, r14,r11,r4 @ r4 = b += 80 * x0 \n" " \n" "mul r14,r8, r6 @ r14= x1 = cmy1 * k \n" "sub r8, r8, r14,LSR #8 @ r8 = x0>>8 = cmy1 - (x1>>8) \n" "add r4, r4, r14,LSR #8-1 @ r4 = b += x1 * 2 \n" "mov r14,#46 @ r14=46 \n" "mla r0, r14,r8, r0 @ r0 = r += 46 * x0 \n" "mov r14,#49 @ r14=49 \n" "mla r1, r14,r8, r1 @ r1 = g += 49 * x0 \n" "mov r14,#147 @ r14=147 \n" "mla r4, r14,r8, r4 @ r4 = b += 147 * x0 \n" " \n" "rsb r6, r6, #256 @ r6 = k = 256-k \n" "mul r14,r5, r6 @ r14= x0 = cmy * (256-k) \n" "mov r11,#54 @ r11= 54 \n" "mov r14,r14,LSR #8 @ r14= (x0>>8) \n" "mov r8,#57 @ r8 = 57 \n" "mla r0,r14,r11,r0 @ r0 = r += 54*x0 \n" "mla r1,r14,r11,r1 @ r1 = g += 54*x0 \n" "mla r4,r14,r8, r4 @ r4 = b += 57*x0 \n" " \n" "sub r8, r0, r0, LSR #8 @ r8 = r -= (r>>8) \n" "sub r9, r1, r1, LSR #8 @ r9 = g -= (r>>8) \n" "sub r10,r4, r4, LSR #8 @ r10= b -= (r>>8) \n" "ldmfd r13!,{r0-r1,r12} \n" "mov r8, r8, LSR #23 @ r8 = r>>23 \n" "mov r9, r9, LSR #23 @ r9 = g>>23 \n" "mov r10,r10,LSR #23 @ r10= b>>23 \n" "ldrb r14,[r1],#1 @ r8 = s[4] \n" "strb r8, [r0],#1 @ d[0] = r \n" "strb r9, [r0],#1 @ d[1] = g \n" "strb r10,[r0],#1 @ d[2] = b \n" "strb r14,[r0],#1 @ d[3] = s[4] \n" "subs r2, r2, #1 @ r2 = n-- \n" "beq 9f \n" "@ At this point, we've just decoded a pixel \n" "@ r0 = dst r1 = src r2 = n r8 = r r9 = g r10= b r12= CMYK \n" "4: \n" "ldrb r3, [r1], #4 @ r3 = c \n" "ldrb r6, [r1, #-1] @ r6 = k \n" "ldrb r5, [r1, #-2] @ r5 = y \n" "ldrb r4, [r1, #-3] @ r4 = m \n" "eors r11,r6, #0xFF @ if (k == 255) \n" "beq 1b @ goto black \n" "orr r7, r3, r4, LSL #8 \n" "orr r14,r5, r6, LSL #8 \n" "orrs r7, r7, r14,LSL #16 @ r7 = cmyk \n" "beq 1b @ if (cmyk == 0) white \n" "cmp r7, r12 @ if (cmyk != CMYK) \n" "bne 3b @ not the same, loop \n" "@ If we get here, we just matched a pixel we have just decoded \n" "ldrb r3, [r1],#1 @ r8 = s[4] \n" "strb r8, [r0],#1 @ d[0] = r \n" "strb r9, [r0],#1 @ d[1] = g \n" "strb r10,[r0],#1 @ d[2] = b \n" "strb r3, [r0],#1 @ d[3] = s[4] \n" "subs r2, r2, #1 @ r2 = n-- \n" "bne 4b \n" "9: \n" "ldmfd r13!,{r4-r11,PC} @ pop, return to thumb \n" ENTER_THUMB ); }
DoS
0
fast_cmyk_to_rgb_ARM(unsigned char *dst, unsigned char *src, int n) { asm volatile( ENTER_ARM "stmfd r13!,{r4-r11,r14} \n" "@ r0 = dst \n" "@ r1 = src \n" "@ r2 = n \n" "mov r12, #0 @ r12= CMYK = 0 \n" "b 2f @ enter loop \n" "1: @ White or Black \n" "@ Cunning trick: On entry r11 = 0 if black, r11 = FF if white \n" "eor r12,r11,#0xFF @ r12= FF if black, 0 if white \n" "ldrb r7, [r1],#1 @ r8 = s[4] \n" "strb r11,[r0],#1 @ d[0] = r \n" "strb r11,[r0],#1 @ d[1] = g \n" "strb r11,[r0],#1 @ d[2] = b \n" "strb r7, [r0],#1 @ d[3] = s[4] \n" "mov r12,r12,LSL #24 @ r12 = CMYK \n" "subs r2, r2, #1 @ r2 = n-- \n" "beq 9f \n" "2: @ Main loop starts here \n" "ldrb r3, [r1], #4 @ r3 = c \n" "ldrb r6, [r1, #-1] @ r6 = k \n" "ldrb r5, [r1, #-2] @ r5 = y \n" "ldrb r4, [r1, #-3] @ r4 = m \n" "eors r11,r6, #0xFF @ if (k == 255) \n" "beq 1b @ goto black \n" "orr r7, r3, r4, LSL #8 \n" "orr r14,r5, r6, LSL #8 \n" "orrs r7, r7, r14,LSL #16 @ r7 = cmyk \n" "beq 1b @ if (cmyk == 0) white \n" "@ At this point, we have to decode a new pixel \n" "@ r0 = dst r1 = src r2 = n r7 = cmyk \n" "3: @ unmatched \n" "stmfd r13!,{r0-r1,r7} @ stash regs for space \n" "add r3, r3, r3, LSR #7 @ r3 = c += c>>7 \n" "add r4, r4, r4, LSR #7 @ r4 = m += m>>7 \n" "add r5, r5, r5, LSR #7 @ r5 = y += y>>7 \n" "add r6, r6, r6, LSR #7 @ r6 = k += k>>7 \n" "mov r5, r5, LSR #1 @ sacrifice 1 bit of Y \n" "mul r8, r3, r4 @ r8 = cm = c * m \n" "rsb r9, r8, r4, LSL #8 @ r9 = c1m = (m<<8) - cm \n" "rsb r3, r8, r3, LSL #8 @ r3 = cm1 = (c<<8) - cm \n" "rsb r4, r4, #0x100 @ r4 = 256-m \n" "rsb r4, r3, r4, LSL #8 @ r4 = c1m1 =((256-m)<<8)-cm1 \n" "mul r7, r4, r5 @ r7 = c1m1y = c1m1 * y \n" "rsb r4, r7, r4, LSL #7 @ r4 = c1m1y1 = (c1m1<<7)-c1m1y \n" "mul r10,r9, r5 @ r10= c1my = c1m * y \n" "rsb r9, r10,r9, LSL #7 @ r9 = c1my1 = (c1m<<7) - c1my \n" "mul r11,r3, r5 @ r11= cm1y = cm1 * y \n" "rsb r3, r11,r3, LSL #7 @ r3 = cm1y1 = (cm1<<7) - cm1y \n" "mul r5, r8, r5 @ r5 = cmy = cm * y \n" "rsb r8, r5, r8, LSL #7 @ r8 = cmy1 = (cm<<7) - cmy \n" "@ Register recap: \n" "@ r3 = cm1y1 \n" "@ r4 = c1m1y1 \n" "@ r5 = cmy \n" "@ r6 = k \n" "@ r7 = c1m1y \n" "@ r8 = cmy1 \n" "@ r9 = c1my1 \n" "@ r10= c1my \n" "@ r11= cm1y \n" "@ The actual matrix multiplication \n" "mul r14,r4, r6 @ r14= x1 = c1m1y1 * k \n" "rsb r4, r14,r4, LSL #8 @ r4 = x0 = (c1m1y1<<8) - x1 \n" "add r4, r4, r14,LSR #8-5 @ r4 = b = x0 + 32*(x1>>8) \n" "sub r1, r4, r14,LSR #8 @ r1 = g = x0 + 31*(x1>>8) \n" "add r0, r1, r14,LSR #8-2 @ r0 = r = x0 + 35*(x1>>8) \n" " \n" "mul r14,r7, r6 @ r14= x1 = c1m1y * k \n" "rsb r7, r14,r7, LSL #8 @ r7 = x0 = (c1m1y<<8) - x1 \n" "add r0, r0, r7 @ r0 = r += x0 \n" "add r1, r1, r7 @ r1 = g += (x0>>8 * 256) \n" "sub r1, r1, r7, LSR #8-3 @ 248 \n" "sub r1, r1, r7, LSR #8-2 @ 244 \n" "sub r1, r1, r7, LSR #8 @ 243 \n" "sub r7, r14,r14,LSR #3 @ r7 = 28*(x1>>5) \n" "add r0, r0, r7, LSR #8-5 @ r0 = r += 28 * x1 \n" "sub r7, r7, r14,LSR #4 @ r7 = 26*(x1>>5) \n" "add r1, r1, r7, LSR #8-5 @ r1 = g += 26 * x1 \n" " \n" "mul r14,r9, r6 @ r14= x1 = c1my1 * k \n" "sub r9, r9, r14,LSR #8 @ r9 = x0>>8 = c1my1 - (x1>>8) \n" "add r0, r0, r14,LSR #8-5 @ r0 = r += (x1>>8)*32 \n" "add r0, r0, r14,LSR #8-2 @ r0 = r += (x1>>8)*36 \n" "mov r14,#237 @ r14= 237 \n" "mla r0,r14,r9,r0 @ r14= r += x0*237 \n" "mov r14,#141 @ r14= 141 \n" "mla r4,r14,r9,r4 @ r14= b += x0*141 \n" " \n" "mul r14,r10,r6 @ r14= x1 = c1my * k \n" "sub r10,r10,r14,LSR #8 @ r10= x0>>8 = c1my - (x1>>8) \n" "add r0, r0, r14,LSR #8-5 @ r0 = r += 32 * x1 \n" "add r0, r0, r14,LSR #8-1 @ r0 = r += 34 * x1 \n" "mov r14,#238 @ r14= 238 \n" "mla r0,r14,r10,r0 @ r0 = r += 238 * x0 \n" "mov r14,#28 @ r14= 28 \n" "mla r1,r14,r10,r1 @ r1 = g += 28 * x0 \n" "mov r14,#36 @ r14= 36 \n" "mla r4,r14,r10,r4 @ r4 = b += 36 * x0 \n" " \n" "mul r14,r3, r6 @ r14= x1 = cm1y1 * k \n" "sub r3, r3, r14,LSR #8 @ r3 = x1>>8 = cm1y1 - (x1>>8) \n" "add r1, r1, r14,LSR #8-4 @ r1 = g += 16*x1 \n" "sub r1, r1, r14,LSR #8 @ 15*x1 \n" "add r4, r4, r14,LSR #8-5 @ r4 = b += 32*x1 \n" "add r4, r4, r14,LSR #8-2 @ 36*x1 \n" "mov r14,#174 @ r14= 174 \n" "mla r1, r14,r3, r1 @ r1 = g += 174 * x0 \n" "mov r14,#240 @ r14= 240 \n" "mla r4, r14,r3, r4 @ r4 = b += 240 * x0 \n" " \n" "mul r14,r11,r6 @ r14= x1 = cm1y * k \n" "sub r11,r11,r14,LSR #8 @ r11= x0>>8 = cm1y - (x1>>8) \n" "add r1, r1, r14,LSR #8-4 @ r1 = g += x1 * 16 \n" "add r1, r1, r14,LSR #8 @ x1 * 17 \n" "add r1, r1, r14,LSR #8-1 @ x1 * 19 \n" "mov r14,#167 @ r14 = 167 \n" "mla r1, r14,r11,r1 @ r1 = g += 167 * x0 \n" "mov r14,#80 @ r14 = 80 \n" "mla r4, r14,r11,r4 @ r4 = b += 80 * x0 \n" " \n" "mul r14,r8, r6 @ r14= x1 = cmy1 * k \n" "sub r8, r8, r14,LSR #8 @ r8 = x0>>8 = cmy1 - (x1>>8) \n" "add r4, r4, r14,LSR #8-1 @ r4 = b += x1 * 2 \n" "mov r14,#46 @ r14=46 \n" "mla r0, r14,r8, r0 @ r0 = r += 46 * x0 \n" "mov r14,#49 @ r14=49 \n" "mla r1, r14,r8, r1 @ r1 = g += 49 * x0 \n" "mov r14,#147 @ r14=147 \n" "mla r4, r14,r8, r4 @ r4 = b += 147 * x0 \n" " \n" "rsb r6, r6, #256 @ r6 = k = 256-k \n" "mul r14,r5, r6 @ r14= x0 = cmy * (256-k) \n" "mov r11,#54 @ r11= 54 \n" "mov r14,r14,LSR #8 @ r14= (x0>>8) \n" "mov r8,#57 @ r8 = 57 \n" "mla r0,r14,r11,r0 @ r0 = r += 54*x0 \n" "mla r1,r14,r11,r1 @ r1 = g += 54*x0 \n" "mla r4,r14,r8, r4 @ r4 = b += 57*x0 \n" " \n" "sub r8, r0, r0, LSR #8 @ r8 = r -= (r>>8) \n" "sub r9, r1, r1, LSR #8 @ r9 = g -= (r>>8) \n" "sub r10,r4, r4, LSR #8 @ r10= b -= (r>>8) \n" "ldmfd r13!,{r0-r1,r12} \n" "mov r8, r8, LSR #23 @ r8 = r>>23 \n" "mov r9, r9, LSR #23 @ r9 = g>>23 \n" "mov r10,r10,LSR #23 @ r10= b>>23 \n" "ldrb r14,[r1],#1 @ r8 = s[4] \n" "strb r8, [r0],#1 @ d[0] = r \n" "strb r9, [r0],#1 @ d[1] = g \n" "strb r10,[r0],#1 @ d[2] = b \n" "strb r14,[r0],#1 @ d[3] = s[4] \n" "subs r2, r2, #1 @ r2 = n-- \n" "beq 9f \n" "@ At this point, we've just decoded a pixel \n" "@ r0 = dst r1 = src r2 = n r8 = r r9 = g r10= b r12= CMYK \n" "4: \n" "ldrb r3, [r1], #4 @ r3 = c \n" "ldrb r6, [r1, #-1] @ r6 = k \n" "ldrb r5, [r1, #-2] @ r5 = y \n" "ldrb r4, [r1, #-3] @ r4 = m \n" "eors r11,r6, #0xFF @ if (k == 255) \n" "beq 1b @ goto black \n" "orr r7, r3, r4, LSL #8 \n" "orr r14,r5, r6, LSL #8 \n" "orrs r7, r7, r14,LSL #16 @ r7 = cmyk \n" "beq 1b @ if (cmyk == 0) white \n" "cmp r7, r12 @ if (cmyk != CMYK) \n" "bne 3b @ not the same, loop \n" "@ If we get here, we just matched a pixel we have just decoded \n" "ldrb r3, [r1],#1 @ r8 = s[4] \n" "strb r8, [r0],#1 @ d[0] = r \n" "strb r9, [r0],#1 @ d[1] = g \n" "strb r10,[r0],#1 @ d[2] = b \n" "strb r3, [r0],#1 @ d[3] = s[4] \n" "subs r2, r2, #1 @ r2 = n-- \n" "bne 4b \n" "9: \n" "ldmfd r13!,{r4-r11,PC} @ pop, return to thumb \n" ENTER_THUMB ); }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
238
static void fast_gray_to_cmyk(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src, fz_colorspace *prf, const fz_default_colorspaces *default_cs, const fz_color_params *color_params, int copy_spots) { unsigned char *s = src->samples; unsigned char *d = dst->samples; size_t w = src->w; int h = src->h; int sn = src->n; int ss = src->s; int sa = src->alpha; int dn = dst->n; int ds = dst->s; int da = dst->alpha; ptrdiff_t d_line_inc = dst->stride - w * dn; ptrdiff_t s_line_inc = src->stride - w * sn; /* If copying spots, they must match, and we can never drop alpha (but we can invent it) */ if ((copy_spots && ss != ds) || (!da && sa)) { assert("This should never happen" == NULL); fz_throw(ctx, FZ_ERROR_GENERIC, "Cannot convert between incompatible pixmaps"); } if ((int)w < 0 || h < 0) return; if (d_line_inc == 0 && s_line_inc == 0) { w *= h; h = 1; } if (ss == 0 && ds == 0) { /* Common, no spots case */ if (da) { if (sa) { while (h--) { size_t ww = w; while (ww--) { d[0] = 0; d[1] = 0; d[2] = 0; d[3] = 255 - s[0]; d[4] = s[1]; s += 2; d += 5; } d += d_line_inc; s += s_line_inc; } } else { while (h--) { size_t ww = w; while (ww--) { d[0] = 0; d[1] = 0; d[2] = 0; d[3] = 255 - s[0]; d[4] = 255; s++; d += 5; } d += d_line_inc; s += s_line_inc; } } } else { while (h--) { size_t ww = w; while (ww--) { d[0] = 0; d[1] = 0; d[2] = 0; d[3] = 255 - s[0]; s++; d += 4; } d += d_line_inc; s += s_line_inc; } } } else if (copy_spots) { /* Slower, spots capable version */ int i; while (h--) { size_t ww = w; while (ww--) { d[0] = 0; d[1] = 0; d[2] = 0; d[3] = 255 - s[0]; s += 1; d += 4; for (i=ss; i > 0; i--) *d++ = *s++; if (da) *d++ = sa ? *s++ : 255; } d += d_line_inc; s += s_line_inc; } } else { while (h--) { size_t ww = w; while (ww--) { d[0] = 0; d[1] = 0; d[2] = 0; d[3] = 255 - s[0]; s += sn; d += dn; if (da) d[-1] = sa ? s[-1] : 255; } d += d_line_inc; s += s_line_inc; } } }
DoS
0
static void fast_gray_to_cmyk(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src, fz_colorspace *prf, const fz_default_colorspaces *default_cs, const fz_color_params *color_params, int copy_spots) { unsigned char *s = src->samples; unsigned char *d = dst->samples; size_t w = src->w; int h = src->h; int sn = src->n; int ss = src->s; int sa = src->alpha; int dn = dst->n; int ds = dst->s; int da = dst->alpha; ptrdiff_t d_line_inc = dst->stride - w * dn; ptrdiff_t s_line_inc = src->stride - w * sn; /* If copying spots, they must match, and we can never drop alpha (but we can invent it) */ if ((copy_spots && ss != ds) || (!da && sa)) { assert("This should never happen" == NULL); fz_throw(ctx, FZ_ERROR_GENERIC, "Cannot convert between incompatible pixmaps"); } if ((int)w < 0 || h < 0) return; if (d_line_inc == 0 && s_line_inc == 0) { w *= h; h = 1; } if (ss == 0 && ds == 0) { /* Common, no spots case */ if (da) { if (sa) { while (h--) { size_t ww = w; while (ww--) { d[0] = 0; d[1] = 0; d[2] = 0; d[3] = 255 - s[0]; d[4] = s[1]; s += 2; d += 5; } d += d_line_inc; s += s_line_inc; } } else { while (h--) { size_t ww = w; while (ww--) { d[0] = 0; d[1] = 0; d[2] = 0; d[3] = 255 - s[0]; d[4] = 255; s++; d += 5; } d += d_line_inc; s += s_line_inc; } } } else { while (h--) { size_t ww = w; while (ww--) { d[0] = 0; d[1] = 0; d[2] = 0; d[3] = 255 - s[0]; s++; d += 4; } d += d_line_inc; s += s_line_inc; } } } else if (copy_spots) { /* Slower, spots capable version */ int i; while (h--) { size_t ww = w; while (ww--) { d[0] = 0; d[1] = 0; d[2] = 0; d[3] = 255 - s[0]; s += 1; d += 4; for (i=ss; i > 0; i--) *d++ = *s++; if (da) *d++ = sa ? *s++ : 255; } d += d_line_inc; s += s_line_inc; } } else { while (h--) { size_t ww = w; while (ww--) { d[0] = 0; d[1] = 0; d[2] = 0; d[3] = 255 - s[0]; s += sn; d += dn; if (da) d[-1] = sa ? s[-1] : 255; } d += d_line_inc; s += s_line_inc; } } }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
239
static void fast_gray_to_rgb(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src, fz_colorspace *prf, const fz_default_colorspaces *default_cs, const fz_color_params *color_params, int copy_spots) { unsigned char *s = src->samples; unsigned char *d = dst->samples; size_t w = src->w; int h = src->h; int sn = src->n; int ss = src->s; int sa = src->alpha; int dn = dst->n; int ds = dst->s; int da = dst->alpha; ptrdiff_t d_line_inc = dst->stride - w * dn; ptrdiff_t s_line_inc = src->stride - w * sn; /* If copying spots, they must match, and we can never drop alpha (but we can invent it) */ if ((copy_spots && ss != ds) || (!da && sa)) { assert("This should never happen" == NULL); fz_throw(ctx, FZ_ERROR_GENERIC, "Cannot convert between incompatible pixmaps"); } if ((int)w < 0 || h < 0) return; if (d_line_inc == 0 && s_line_inc == 0) { w *= h; h = 1; } if (ss == 0 && ds == 0) { /* Common, no spots case */ if (da) { if (sa) { while (h--) { size_t ww = w; while (ww--) { d[0] = s[0]; d[1] = s[0]; d[2] = s[0]; d[3] = s[1]; s += 2; d += 4; } d += d_line_inc; s += s_line_inc; } } else { while (h--) { size_t ww = w; while (ww--) { d[0] = s[0]; d[1] = s[0]; d[2] = s[0]; d[3] = 255; s++; d += 4; } d += d_line_inc; s += s_line_inc; } } } else { while (h--) { size_t ww = w; while (ww--) { d[0] = s[0]; d[1] = s[0]; d[2] = s[0]; s++; d += 3; } d += d_line_inc; s += s_line_inc; } } } else if (copy_spots) { /* Slower, spots capable version */ int i; while (h--) { size_t ww = w; while (ww--) { d[0] = s[0]; d[1] = s[0]; d[2] = s[0]; s += 1; d += 3; for (i=ss; i > 0; i--) *d++ = *s++; if (da) *d++ = sa ? *s++ : 255; } d += d_line_inc; s += s_line_inc; } } else { while (h--) { size_t ww = w; while (ww--) { d[0] = s[0]; d[1] = s[0]; d[2] = s[0]; s += sn; d += dn; if (da) d[-1] = sa ? s[-1] : 255; } d += d_line_inc; s += s_line_inc; } } }
DoS
0
static void fast_gray_to_rgb(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src, fz_colorspace *prf, const fz_default_colorspaces *default_cs, const fz_color_params *color_params, int copy_spots) { unsigned char *s = src->samples; unsigned char *d = dst->samples; size_t w = src->w; int h = src->h; int sn = src->n; int ss = src->s; int sa = src->alpha; int dn = dst->n; int ds = dst->s; int da = dst->alpha; ptrdiff_t d_line_inc = dst->stride - w * dn; ptrdiff_t s_line_inc = src->stride - w * sn; /* If copying spots, they must match, and we can never drop alpha (but we can invent it) */ if ((copy_spots && ss != ds) || (!da && sa)) { assert("This should never happen" == NULL); fz_throw(ctx, FZ_ERROR_GENERIC, "Cannot convert between incompatible pixmaps"); } if ((int)w < 0 || h < 0) return; if (d_line_inc == 0 && s_line_inc == 0) { w *= h; h = 1; } if (ss == 0 && ds == 0) { /* Common, no spots case */ if (da) { if (sa) { while (h--) { size_t ww = w; while (ww--) { d[0] = s[0]; d[1] = s[0]; d[2] = s[0]; d[3] = s[1]; s += 2; d += 4; } d += d_line_inc; s += s_line_inc; } } else { while (h--) { size_t ww = w; while (ww--) { d[0] = s[0]; d[1] = s[0]; d[2] = s[0]; d[3] = 255; s++; d += 4; } d += d_line_inc; s += s_line_inc; } } } else { while (h--) { size_t ww = w; while (ww--) { d[0] = s[0]; d[1] = s[0]; d[2] = s[0]; s++; d += 3; } d += d_line_inc; s += s_line_inc; } } } else if (copy_spots) { /* Slower, spots capable version */ int i; while (h--) { size_t ww = w; while (ww--) { d[0] = s[0]; d[1] = s[0]; d[2] = s[0]; s += 1; d += 3; for (i=ss; i > 0; i--) *d++ = *s++; if (da) *d++ = sa ? *s++ : 255; } d += d_line_inc; s += s_line_inc; } } else { while (h--) { size_t ww = w; while (ww--) { d[0] = s[0]; d[1] = s[0]; d[2] = s[0]; s += sn; d += dn; if (da) d[-1] = sa ? s[-1] : 255; } d += d_line_inc; s += s_line_inc; } } }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
240
static void fast_rgb_to_bgr(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src, fz_colorspace *prf, const fz_default_colorspaces *default_cs, const fz_color_params *color_params, int copy_spots) { unsigned char *s = src->samples; unsigned char *d = dst->samples; size_t w = src->w; int h = src->h; int sn = src->n; int ss = src->s; int sa = src->alpha; int dn = dst->n; int ds = dst->s; int da = dst->alpha; ptrdiff_t d_line_inc = dst->stride - w * dn; ptrdiff_t s_line_inc = src->stride - w * sn; /* If copying spots, they must match, and we can never drop alpha (but we can invent it) */ if ((copy_spots && ss != ds) || (!da && sa)) { assert("This should never happen" == NULL); fz_throw(ctx, FZ_ERROR_GENERIC, "Cannot convert between incompatible pixmaps"); } if ((int)w < 0 || h < 0) return; if (d_line_inc == 0 && s_line_inc == 0) { w *= h; h = 1; } if (ss == 0 && ds == 0) { /* Common, no spots case */ if (da) { if (sa) { while (h--) { size_t ww = w; while (ww--) { d[0] = s[2]; d[1] = s[1]; d[2] = s[0]; d[3] = s[3]; s += 4; d += 4; } } } else { while (h--) { size_t ww = w; while (ww--) { d[0] = s[2]; d[1] = s[1]; d[2] = s[0]; d[3] = 255; s += 3; d += 4; } } } } else { while (h--) { size_t ww = w; while (ww--) { d[0] = s[2]; d[1] = s[1]; d[2] = s[0]; s += 3; d += 3; } } } } else if (copy_spots) { /* Slower, spots capable version */ while (h--) { int i; size_t ww = w; while (ww--) { d[0] = s[2]; d[1] = s[1]; d[2] = s[0]; s += 3; d += 3; for (i=ss; i > 0; i--) *d++ = *s++; if (da) *d++ = sa ? *s++ : 255; } d += d_line_inc; s += s_line_inc; } } else { while (h--) { size_t ww = w; while (ww--) { d[0] = s[2]; d[1] = s[1]; d[2] = s[0]; s += sn; d += dn; if (da) d[-1] = sa ? s[-1] : 255; } d += d_line_inc; s += s_line_inc; } } }
DoS
0
static void fast_rgb_to_bgr(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src, fz_colorspace *prf, const fz_default_colorspaces *default_cs, const fz_color_params *color_params, int copy_spots) { unsigned char *s = src->samples; unsigned char *d = dst->samples; size_t w = src->w; int h = src->h; int sn = src->n; int ss = src->s; int sa = src->alpha; int dn = dst->n; int ds = dst->s; int da = dst->alpha; ptrdiff_t d_line_inc = dst->stride - w * dn; ptrdiff_t s_line_inc = src->stride - w * sn; /* If copying spots, they must match, and we can never drop alpha (but we can invent it) */ if ((copy_spots && ss != ds) || (!da && sa)) { assert("This should never happen" == NULL); fz_throw(ctx, FZ_ERROR_GENERIC, "Cannot convert between incompatible pixmaps"); } if ((int)w < 0 || h < 0) return; if (d_line_inc == 0 && s_line_inc == 0) { w *= h; h = 1; } if (ss == 0 && ds == 0) { /* Common, no spots case */ if (da) { if (sa) { while (h--) { size_t ww = w; while (ww--) { d[0] = s[2]; d[1] = s[1]; d[2] = s[0]; d[3] = s[3]; s += 4; d += 4; } } } else { while (h--) { size_t ww = w; while (ww--) { d[0] = s[2]; d[1] = s[1]; d[2] = s[0]; d[3] = 255; s += 3; d += 4; } } } } else { while (h--) { size_t ww = w; while (ww--) { d[0] = s[2]; d[1] = s[1]; d[2] = s[0]; s += 3; d += 3; } } } } else if (copy_spots) { /* Slower, spots capable version */ while (h--) { int i; size_t ww = w; while (ww--) { d[0] = s[2]; d[1] = s[1]; d[2] = s[0]; s += 3; d += 3; for (i=ss; i > 0; i--) *d++ = *s++; if (da) *d++ = sa ? *s++ : 255; } d += d_line_inc; s += s_line_inc; } } else { while (h--) { size_t ww = w; while (ww--) { d[0] = s[2]; d[1] = s[1]; d[2] = s[0]; s += sn; d += dn; if (da) d[-1] = sa ? s[-1] : 255; } d += d_line_inc; s += s_line_inc; } } }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
241
static void fast_rgb_to_cmyk(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src, fz_colorspace *prf, const fz_default_colorspaces *default_cs, const fz_color_params *color_params, int copy_spots) { unsigned char *s = src->samples; unsigned char *d = dst->samples; size_t w = src->w; int h = src->h; int sn = src->n; int ss = src->s; int sa = src->alpha; int dn = dst->n; int ds = dst->s; int da = dst->alpha; ptrdiff_t d_line_inc = dst->stride - w * dn; ptrdiff_t s_line_inc = src->stride - w * sn; /* Spots must match, and we can never drop alpha (but we can invent it) */ if ((copy_spots || ss != ds) || (!da && sa)) { assert("This should never happen" == NULL); fz_throw(ctx, FZ_ERROR_GENERIC, "Cannot convert between incompatible pixmaps"); } if ((int)w < 0 || h < 0) return; if (d_line_inc == 0 && s_line_inc == 0) { w *= h; h = 1; } if (ss == 0 && ds == 0) { /* Common, no spots case */ if (da) { if (sa) { while (h--) { size_t ww = w; while (ww--) { unsigned char c = s[0]; unsigned char m = s[1]; unsigned char y = s[2]; unsigned char k = (unsigned char)fz_mini(c, fz_mini(m, y)); d[0] = c - k; d[1] = m - k; d[2] = y - k; d[3] = k; d[4] = s[3]; s += 4; d += 5; } d += d_line_inc; s += s_line_inc; } } else { while (h--) { size_t ww = w; while (ww--) { unsigned char c = s[0]; unsigned char m = s[1]; unsigned char y = s[2]; unsigned char k = (unsigned char)fz_mini(c, fz_mini(m, y)); d[0] = c - k; d[1] = m - k; d[2] = y - k; d[3] = k; d[4] = 255; s += 3; d += 5; } d += d_line_inc; s += s_line_inc; } } } else { while (h--) { size_t ww = w; while (ww--) { unsigned char c = s[0]; unsigned char m = s[1]; unsigned char y = s[2]; unsigned char k = (unsigned char)fz_mini(c, fz_mini(m, y)); d[0] = c - k; d[1] = m - k; d[2] = y - k; d[3] = k; s += 3; d += 4; } d += d_line_inc; s += s_line_inc; } } } else if (copy_spots) { /* Slower, spots capable version */ while (h--) { int i; size_t ww = w; while (ww--) { unsigned char c = s[0]; unsigned char m = s[1]; unsigned char y = s[2]; unsigned char k = (unsigned char)fz_mini(c, fz_mini(m, y)); d[0] = c - k; d[1] = m - k; d[2] = y - k; d[3] = k; s += 3; d += 4; for (i=ss; i > 0; i--) *d++ = *s++; if (da) *d++ = sa ? *s++ : 255; } d += d_line_inc; s += s_line_inc; } } else { while (h--) { size_t ww = w; while (ww--) { unsigned char c = s[0]; unsigned char m = s[1]; unsigned char y = s[2]; unsigned char k = (unsigned char)(255 - fz_maxi(c, fz_maxi(m, y))); d[0] = c + k; d[1] = m + k; d[2] = y + k; d[3] = 255 - k; s += sn; d += dn; if (da) d[-1] = sa ? s[-1] : 255; } d += d_line_inc; s += s_line_inc; } } }
DoS
0
static void fast_rgb_to_cmyk(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src, fz_colorspace *prf, const fz_default_colorspaces *default_cs, const fz_color_params *color_params, int copy_spots) { unsigned char *s = src->samples; unsigned char *d = dst->samples; size_t w = src->w; int h = src->h; int sn = src->n; int ss = src->s; int sa = src->alpha; int dn = dst->n; int ds = dst->s; int da = dst->alpha; ptrdiff_t d_line_inc = dst->stride - w * dn; ptrdiff_t s_line_inc = src->stride - w * sn; /* Spots must match, and we can never drop alpha (but we can invent it) */ if ((copy_spots || ss != ds) || (!da && sa)) { assert("This should never happen" == NULL); fz_throw(ctx, FZ_ERROR_GENERIC, "Cannot convert between incompatible pixmaps"); } if ((int)w < 0 || h < 0) return; if (d_line_inc == 0 && s_line_inc == 0) { w *= h; h = 1; } if (ss == 0 && ds == 0) { /* Common, no spots case */ if (da) { if (sa) { while (h--) { size_t ww = w; while (ww--) { unsigned char c = s[0]; unsigned char m = s[1]; unsigned char y = s[2]; unsigned char k = (unsigned char)fz_mini(c, fz_mini(m, y)); d[0] = c - k; d[1] = m - k; d[2] = y - k; d[3] = k; d[4] = s[3]; s += 4; d += 5; } d += d_line_inc; s += s_line_inc; } } else { while (h--) { size_t ww = w; while (ww--) { unsigned char c = s[0]; unsigned char m = s[1]; unsigned char y = s[2]; unsigned char k = (unsigned char)fz_mini(c, fz_mini(m, y)); d[0] = c - k; d[1] = m - k; d[2] = y - k; d[3] = k; d[4] = 255; s += 3; d += 5; } d += d_line_inc; s += s_line_inc; } } } else { while (h--) { size_t ww = w; while (ww--) { unsigned char c = s[0]; unsigned char m = s[1]; unsigned char y = s[2]; unsigned char k = (unsigned char)fz_mini(c, fz_mini(m, y)); d[0] = c - k; d[1] = m - k; d[2] = y - k; d[3] = k; s += 3; d += 4; } d += d_line_inc; s += s_line_inc; } } } else if (copy_spots) { /* Slower, spots capable version */ while (h--) { int i; size_t ww = w; while (ww--) { unsigned char c = s[0]; unsigned char m = s[1]; unsigned char y = s[2]; unsigned char k = (unsigned char)fz_mini(c, fz_mini(m, y)); d[0] = c - k; d[1] = m - k; d[2] = y - k; d[3] = k; s += 3; d += 4; for (i=ss; i > 0; i--) *d++ = *s++; if (da) *d++ = sa ? *s++ : 255; } d += d_line_inc; s += s_line_inc; } } else { while (h--) { size_t ww = w; while (ww--) { unsigned char c = s[0]; unsigned char m = s[1]; unsigned char y = s[2]; unsigned char k = (unsigned char)(255 - fz_maxi(c, fz_maxi(m, y))); d[0] = c + k; d[1] = m + k; d[2] = y + k; d[3] = 255 - k; s += sn; d += dn; if (da) d[-1] = sa ? s[-1] : 255; } d += d_line_inc; s += s_line_inc; } } }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
242
static void fast_rgb_to_gray(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src, fz_colorspace *prf, const fz_default_colorspaces *default_cs, const fz_color_params *color_params, int copy_spots) { unsigned char *s = src->samples; unsigned char *d = dst->samples; size_t w = src->w; int h = src->h; int sn = src->n; int ss = src->s; int sa = src->alpha; int dn = dst->n; int ds = dst->s; int da = dst->alpha; ptrdiff_t d_line_inc = dst->stride - w * dn; ptrdiff_t s_line_inc = src->stride - w * sn; /* If copying spots, they must match, and we can never drop alpha (but we can invent it) */ if ((copy_spots && ss != ds) || (!da && sa)) { assert("This should never happen" == NULL); fz_throw(ctx, FZ_ERROR_GENERIC, "Cannot convert between incompatible pixmaps"); } if ((int)w < 0 || h < 0) return; if (d_line_inc == 0 && s_line_inc == 0) { w *= h; h = 1; } if (ss == 0 && ds == 0) { /* Common, no spots case */ if (da) { if (sa) { while (h--) { size_t ww = w; while (ww--) { d[0] = ((s[0]+1) * 77 + (s[1]+1) * 150 + (s[2]+1) * 28) >> 8; d[1] = s[3]; s += 4; d += 2; } d += d_line_inc; s += s_line_inc; } } else { while (h--) { size_t ww = w; while (ww--) { d[0] = ((s[0]+1) * 77 + (s[1]+1) * 150 + (s[2]+1) * 28) >> 8; d[1] = 255; s += 3; d += 2; } d += d_line_inc; s += s_line_inc; } } } else { while (h--) { size_t ww = w; while (ww--) { d[0] = ((s[0]+1) * 77 + (s[1]+1) * 150 + (s[2]+1) * 28) >> 8; s += 3; d++; } d += d_line_inc; s += s_line_inc; } } } else if (copy_spots) { /* Slower, spots capable version */ int i; while (h--) { size_t ww = w; while (ww--) { d[0] = ((s[0]+1) * 77 + (s[1]+1) * 150 + (s[2]+1) * 28) >> 8; s += 3; d++; for (i=ss; i > 0; i--) *d++ = *s++; if (da) *d++ = sa ? *s++ : 255; } d += d_line_inc; s += s_line_inc; } } else { while (h--) { size_t ww = w; while (ww--) { d[0] = ((s[0]+1) * 77 + (s[1]+1) * 150 + (s[2]+1) * 28) >> 8; s += sn; d += dn; if (da) d[-1] = sa ? s[-1] : 255; } d += d_line_inc; s += s_line_inc; } } }
DoS
0
static void fast_rgb_to_gray(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src, fz_colorspace *prf, const fz_default_colorspaces *default_cs, const fz_color_params *color_params, int copy_spots) { unsigned char *s = src->samples; unsigned char *d = dst->samples; size_t w = src->w; int h = src->h; int sn = src->n; int ss = src->s; int sa = src->alpha; int dn = dst->n; int ds = dst->s; int da = dst->alpha; ptrdiff_t d_line_inc = dst->stride - w * dn; ptrdiff_t s_line_inc = src->stride - w * sn; /* If copying spots, they must match, and we can never drop alpha (but we can invent it) */ if ((copy_spots && ss != ds) || (!da && sa)) { assert("This should never happen" == NULL); fz_throw(ctx, FZ_ERROR_GENERIC, "Cannot convert between incompatible pixmaps"); } if ((int)w < 0 || h < 0) return; if (d_line_inc == 0 && s_line_inc == 0) { w *= h; h = 1; } if (ss == 0 && ds == 0) { /* Common, no spots case */ if (da) { if (sa) { while (h--) { size_t ww = w; while (ww--) { d[0] = ((s[0]+1) * 77 + (s[1]+1) * 150 + (s[2]+1) * 28) >> 8; d[1] = s[3]; s += 4; d += 2; } d += d_line_inc; s += s_line_inc; } } else { while (h--) { size_t ww = w; while (ww--) { d[0] = ((s[0]+1) * 77 + (s[1]+1) * 150 + (s[2]+1) * 28) >> 8; d[1] = 255; s += 3; d += 2; } d += d_line_inc; s += s_line_inc; } } } else { while (h--) { size_t ww = w; while (ww--) { d[0] = ((s[0]+1) * 77 + (s[1]+1) * 150 + (s[2]+1) * 28) >> 8; s += 3; d++; } d += d_line_inc; s += s_line_inc; } } } else if (copy_spots) { /* Slower, spots capable version */ int i; while (h--) { size_t ww = w; while (ww--) { d[0] = ((s[0]+1) * 77 + (s[1]+1) * 150 + (s[2]+1) * 28) >> 8; s += 3; d++; for (i=ss; i > 0; i--) *d++ = *s++; if (da) *d++ = sa ? *s++ : 255; } d += d_line_inc; s += s_line_inc; } } else { while (h--) { size_t ww = w; while (ww--) { d[0] = ((s[0]+1) * 77 + (s[1]+1) * 150 + (s[2]+1) * 28) >> 8; s += sn; d += dn; if (da) d[-1] = sa ? s[-1] : 255; } d += d_line_inc; s += s_line_inc; } } }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
243
free_cal(fz_context *ctx, fz_colorspace *cs) { fz_cal_colorspace *cal_data = cs->data; if (cal_data->profile != NULL) { fz_drop_buffer(ctx, cal_data->profile->buffer); fz_cmm_fin_profile(ctx, cal_data->profile); fz_free(ctx, cal_data->profile); } fz_free(ctx, cal_data); }
DoS
0
free_cal(fz_context *ctx, fz_colorspace *cs) { fz_cal_colorspace *cal_data = cs->data; if (cal_data->profile != NULL) { fz_drop_buffer(ctx, cal_data->profile->buffer); fz_cmm_fin_profile(ctx, cal_data->profile); fz_free(ctx, cal_data->profile); } fz_free(ctx, cal_data); }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
244
free_icc(fz_context *ctx, fz_colorspace *cs) { fz_iccprofile *profile = cs->data; fz_drop_buffer(ctx, profile->buffer); fz_cmm_fin_profile(ctx, profile); fz_free(ctx, profile); }
DoS
0
free_icc(fz_context *ctx, fz_colorspace *cs) { fz_iccprofile *profile = cs->data; fz_drop_buffer(ctx, profile->buffer); fz_cmm_fin_profile(ctx, profile); fz_free(ctx, profile); }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
245
fz_clamp_color(fz_context *ctx, const fz_colorspace *cs, const float *in, float *out) { cs->clamp(cs, in, out); }
DoS
0
fz_clamp_color(fz_context *ctx, const fz_colorspace *cs, const float *in, float *out) { cs->clamp(cs, in, out); }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
246
fz_clone_default_colorspaces(fz_context *ctx, fz_default_colorspaces *base) { fz_default_colorspaces *default_cs = fz_malloc_struct(ctx, fz_default_colorspaces); default_cs->refs = 1; default_cs->gray = fz_keep_colorspace(ctx, base->gray); default_cs->rgb = fz_keep_colorspace(ctx, base->rgb); default_cs->cmyk = fz_keep_colorspace(ctx, base->cmyk); default_cs->oi = fz_keep_colorspace(ctx, base->oi); return default_cs; }
DoS
0
fz_clone_default_colorspaces(fz_context *ctx, fz_default_colorspaces *base) { fz_default_colorspaces *default_cs = fz_malloc_struct(ctx, fz_default_colorspaces); default_cs->refs = 1; default_cs->gray = fz_keep_colorspace(ctx, base->gray); default_cs->rgb = fz_keep_colorspace(ctx, base->rgb); default_cs->cmyk = fz_keep_colorspace(ctx, base->cmyk); default_cs->oi = fz_keep_colorspace(ctx, base->oi); return default_cs; }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
247
void fz_cmm_drop_instance(fz_context *ctx) { if (ctx && ctx->colorspace && ctx->colorspace->cmm && ctx->cmm_instance) ctx->colorspace->cmm->drop_instance(ctx->cmm_instance); }
DoS
0
void fz_cmm_drop_instance(fz_context *ctx) { if (ctx && ctx->colorspace && ctx->colorspace->cmm && ctx->cmm_instance) ctx->colorspace->cmm->drop_instance(ctx->cmm_instance); }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
248
fz_cmm_fin_link(fz_context *ctx, fz_icclink *link) { if (ctx && ctx->colorspace && ctx->colorspace->cmm && ctx->cmm_instance) ctx->colorspace->cmm->fin_link(ctx->cmm_instance, link); }
DoS
0
fz_cmm_fin_link(fz_context *ctx, fz_icclink *link) { if (ctx && ctx->colorspace && ctx->colorspace->cmm && ctx->cmm_instance) ctx->colorspace->cmm->fin_link(ctx->cmm_instance, link); }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
249
void fz_cmm_fin_profile(fz_context *ctx, fz_iccprofile *profile) { if (ctx && ctx->colorspace && ctx->colorspace->cmm && ctx->cmm_instance) if (profile && profile->cmm_handle != NULL) ctx->colorspace->cmm->fin_profile(ctx->cmm_instance, profile); }
DoS
0
void fz_cmm_fin_profile(fz_context *ctx, fz_iccprofile *profile) { if (ctx && ctx->colorspace && ctx->colorspace->cmm && ctx->cmm_instance) if (profile && profile->cmm_handle != NULL) ctx->colorspace->cmm->fin_profile(ctx->cmm_instance, profile); }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
250
fz_cmm_init_link(fz_context *ctx, fz_icclink *link, const fz_iccprofile *dst, int dst_extras, const fz_iccprofile *src, int src_extras, const fz_iccprofile *prf, const fz_color_params *rend, int cmm_flags, int num_bytes, int copy_spots) { if (ctx && ctx->colorspace && ctx->colorspace->cmm && ctx->cmm_instance) ctx->colorspace->cmm->init_link(ctx->cmm_instance, link, dst, dst_extras, src, src_extras, prf, rend, cmm_flags, num_bytes, copy_spots); }
DoS
0
fz_cmm_init_link(fz_context *ctx, fz_icclink *link, const fz_iccprofile *dst, int dst_extras, const fz_iccprofile *src, int src_extras, const fz_iccprofile *prf, const fz_color_params *rend, int cmm_flags, int num_bytes, int copy_spots) { if (ctx && ctx->colorspace && ctx->colorspace->cmm && ctx->cmm_instance) ctx->colorspace->cmm->init_link(ctx->cmm_instance, link, dst, dst_extras, src, src_extras, prf, rend, cmm_flags, num_bytes, copy_spots); }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
251
void fz_cmm_init_profile(fz_context *ctx, fz_iccprofile *profile) { if (ctx && ctx->colorspace && ctx->colorspace->cmm && ctx->cmm_instance) ctx->colorspace->cmm->init_profile(ctx->cmm_instance, profile); }
DoS
0
void fz_cmm_init_profile(fz_context *ctx, fz_iccprofile *profile) { if (ctx && ctx->colorspace && ctx->colorspace->cmm && ctx->cmm_instance) ctx->colorspace->cmm->init_profile(ctx->cmm_instance, profile); }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
252
fz_cmm_transform_color(fz_context *ctx, fz_icclink *link, unsigned short *dst, const unsigned short *src) { if (ctx && ctx->colorspace && ctx->colorspace->cmm && ctx->cmm_instance) ctx->colorspace->cmm->transform_color(ctx->cmm_instance, link, dst, src); }
DoS
0
fz_cmm_transform_color(fz_context *ctx, fz_icclink *link, unsigned short *dst, const unsigned short *src) { if (ctx && ctx->colorspace && ctx->colorspace->cmm && ctx->cmm_instance) ctx->colorspace->cmm->transform_color(ctx->cmm_instance, link, dst, src); }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
253
fz_cmm_transform_pixmap(fz_context *ctx, fz_icclink *link, fz_pixmap *dst, fz_pixmap *src) { if (ctx && ctx->colorspace && ctx->colorspace->cmm && ctx->cmm_instance) ctx->colorspace->cmm->transform_pixmap(ctx->cmm_instance, link, dst, src); }
DoS
0
fz_cmm_transform_pixmap(fz_context *ctx, fz_icclink *link, fz_pixmap *dst, fz_pixmap *src) { if (ctx && ctx->colorspace && ctx->colorspace->cmm && ctx->cmm_instance) ctx->colorspace->cmm->transform_pixmap(ctx->cmm_instance, link, dst, src); }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
254
fz_cmp_link_key(fz_context *ctx, void *k0_, void *k1_) { fz_link_key *k0 = (fz_link_key *)k0_; fz_link_key *k1 = (fz_link_key *)k1_; return k0->proof == k1->proof && k0->src_extras == k1->src_extras && k0->dst_extras == k1->dst_extras && k0->copy_spots == k1->copy_spots && k0->depth == k1->depth && k0->rend.bp == k1->rend.bp && k0->rend.ri == k1->rend.ri && memcmp(k0->dst_md5, k1->dst_md5, 16) == 0 && memcmp(k0->src_md5, k1->src_md5, 16); }
DoS
0
fz_cmp_link_key(fz_context *ctx, void *k0_, void *k1_) { fz_link_key *k0 = (fz_link_key *)k0_; fz_link_key *k1 = (fz_link_key *)k1_; return k0->proof == k1->proof && k0->src_extras == k1->src_extras && k0->dst_extras == k1->dst_extras && k0->copy_spots == k1->copy_spots && k0->depth == k1->depth && k0->rend.bp == k1->rend.bp && k0->rend.ri == k1->rend.ri && memcmp(k0->dst_md5, k1->dst_md5, 16) == 0 && memcmp(k0->src_md5, k1->src_md5, 16); }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
255
fz_colorspace *fz_colorspace_base(fz_context *ctx, const fz_colorspace *cs) { return cs && cs->get_base ? cs->get_base(cs) : NULL; }
DoS
0
fz_colorspace *fz_colorspace_base(fz_context *ctx, const fz_colorspace *cs) { return cs && cs->get_base ? cs->get_base(cs) : NULL; }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
256
const char *fz_colorspace_colorant(fz_context *ctx, const fz_colorspace *cs, int i) { if (!cs || i < 0 || i >= cs->n) fz_throw(ctx, FZ_ERROR_GENERIC, "Colorant out of range"); return cs->colorant[i]; }
DoS
0
const char *fz_colorspace_colorant(fz_context *ctx, const fz_colorspace *cs, int i) { if (!cs || i < 0 || i >= cs->n) fz_throw(ctx, FZ_ERROR_GENERIC, "Colorant out of range"); return cs->colorant[i]; }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
257
int fz_colorspace_device_n_has_cmyk(fz_context *ctx, const fz_colorspace *cs) { return cs && (cs->flags & FZ_CS_HAS_CMYK); }
DoS
0
int fz_colorspace_device_n_has_cmyk(fz_context *ctx, const fz_colorspace *cs) { return cs && (cs->flags & FZ_CS_HAS_CMYK); }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
258
int fz_colorspace_is_bgr(fz_context *ctx, const fz_colorspace *cs) { return cs && cs->type == FZ_COLORSPACE_BGR; }
DoS
0
int fz_colorspace_is_bgr(fz_context *ctx, const fz_colorspace *cs) { return cs && cs->type == FZ_COLORSPACE_BGR; }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
259
int fz_colorspace_is_cal(fz_context *ctx, const fz_colorspace *cs) { return cs && (cs->flags & FZ_COLORSPACE_IS_CAL); }
DoS
0
int fz_colorspace_is_cal(fz_context *ctx, const fz_colorspace *cs) { return cs && (cs->flags & FZ_COLORSPACE_IS_CAL); }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
260
int fz_colorspace_is_cmyk(fz_context *ctx, const fz_colorspace *cs) { return cs && cs->type == FZ_COLORSPACE_CMYK; }
DoS
0
int fz_colorspace_is_cmyk(fz_context *ctx, const fz_colorspace *cs) { return cs && cs->type == FZ_COLORSPACE_CMYK; }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
261
int fz_colorspace_is_device_gray(fz_context *ctx, const fz_colorspace *cs) { return fz_colorspace_is_device(ctx, cs) && fz_colorspace_is_gray(ctx, cs); }
DoS
0
int fz_colorspace_is_device_gray(fz_context *ctx, const fz_colorspace *cs) { return fz_colorspace_is_device(ctx, cs) && fz_colorspace_is_gray(ctx, cs); }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
262
int fz_colorspace_is_device_n(fz_context *ctx, const fz_colorspace *cs) { return cs && (cs->type == FZ_COLORSPACE_SEPARATION); }
DoS
0
int fz_colorspace_is_device_n(fz_context *ctx, const fz_colorspace *cs) { return cs && (cs->type == FZ_COLORSPACE_SEPARATION); }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
263
int fz_colorspace_is_gray(fz_context *ctx, const fz_colorspace *cs) { return cs && cs->type == FZ_COLORSPACE_GRAY; }
DoS
0
int fz_colorspace_is_gray(fz_context *ctx, const fz_colorspace *cs) { return cs && cs->type == FZ_COLORSPACE_GRAY; }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
264
int fz_colorspace_is_icc(fz_context *ctx, const fz_colorspace *cs) { return cs && (cs->flags & FZ_COLORSPACE_IS_ICC); }
DoS
0
int fz_colorspace_is_icc(fz_context *ctx, const fz_colorspace *cs) { return cs && (cs->flags & FZ_COLORSPACE_IS_ICC); }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
265
int fz_colorspace_is_lab(fz_context *ctx, const fz_colorspace *cs) { return cs && cs->type == FZ_COLORSPACE_LAB; }
DoS
0
int fz_colorspace_is_lab(fz_context *ctx, const fz_colorspace *cs) { return cs && cs->type == FZ_COLORSPACE_LAB; }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
266
int fz_colorspace_is_lab_icc(fz_context *ctx, const fz_colorspace *cs) { return fz_colorspace_is_lab(ctx, cs) && fz_colorspace_is_icc(ctx, cs); }
DoS
0
int fz_colorspace_is_lab_icc(fz_context *ctx, const fz_colorspace *cs) { return fz_colorspace_is_lab(ctx, cs) && fz_colorspace_is_icc(ctx, cs); }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
267
int fz_colorspace_is_rgb(fz_context *ctx, const fz_colorspace *cs) { return cs && cs->type == FZ_COLORSPACE_RGB; }
DoS
0
int fz_colorspace_is_rgb(fz_context *ctx, const fz_colorspace *cs) { return cs && cs->type == FZ_COLORSPACE_RGB; }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
268
int fz_colorspace_n(fz_context *ctx, const fz_colorspace *cs) { return cs ? cs->n : 0; }
DoS
0
int fz_colorspace_n(fz_context *ctx, const fz_colorspace *cs) { return cs ? cs->n : 0; }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
269
const char *fz_colorspace_name(fz_context *ctx, const fz_colorspace *cs) { return cs ? cs->name : ""; }
DoS
0
const char *fz_colorspace_name(fz_context *ctx, const fz_colorspace *cs) { return cs ? cs->name : ""; }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
270
void fz_colorspace_name_colorant(fz_context *ctx, fz_colorspace *cs, int i, const char *name) { if (!cs) return; if (i < 0 || i >= cs->n) fz_throw(ctx, FZ_ERROR_GENERIC, "Attempt to name out of range colorant"); fz_free(ctx, cs->colorant[i]); cs->colorant[i] = NULL; if (name) { cs->colorant[i] = fz_strdup(ctx, name); if (cs->type == FZ_COLORSPACE_SEPARATION) { if (i == 0) { if (strcmp(name, "Cyan") == 0 || strcmp(name, "Magenta") == 0 || strcmp(name, "Yellow") == 0 || strcmp(name, "Black") == 0) { cs->flags |= FZ_CS_HAS_CMYK; } } else { if ((cs->flags & FZ_CS_HAS_CMYK_AND_SPOTS) != FZ_CS_HAS_CMYK_AND_SPOTS) { if (strcmp(name, "Cyan") == 0 || strcmp(name, "Magenta") == 0 || strcmp(name, "Yellow") == 0 || strcmp(name, "Black") == 0) cs->flags |= FZ_CS_HAS_CMYK; else cs->flags |= FZ_CS_HAS_SPOTS; } } } } }
DoS
0
void fz_colorspace_name_colorant(fz_context *ctx, fz_colorspace *cs, int i, const char *name) { if (!cs) return; if (i < 0 || i >= cs->n) fz_throw(ctx, FZ_ERROR_GENERIC, "Attempt to name out of range colorant"); fz_free(ctx, cs->colorant[i]); cs->colorant[i] = NULL; if (name) { cs->colorant[i] = fz_strdup(ctx, name); if (cs->type == FZ_COLORSPACE_SEPARATION) { if (i == 0) { if (strcmp(name, "Cyan") == 0 || strcmp(name, "Magenta") == 0 || strcmp(name, "Yellow") == 0 || strcmp(name, "Black") == 0) { cs->flags |= FZ_CS_HAS_CMYK; } } else { if ((cs->flags & FZ_CS_HAS_CMYK_AND_SPOTS) != FZ_CS_HAS_CMYK_AND_SPOTS) { if (strcmp(name, "Cyan") == 0 || strcmp(name, "Magenta") == 0 || strcmp(name, "Yellow") == 0 || strcmp(name, "Black") == 0) cs->flags |= FZ_CS_HAS_CMYK; else cs->flags |= FZ_CS_HAS_SPOTS; } } } } }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
271
fz_colorspace_type(fz_context *ctx, fz_colorspace *cs) { return cs ? cs->type : FZ_COLORSPACE_NONE; }
DoS
0
fz_colorspace_type(fz_context *ctx, fz_colorspace *cs) { return cs ? cs->type : FZ_COLORSPACE_NONE; }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
272
fz_default_cmyk(fz_context *ctx, const fz_default_colorspaces *default_cs) { if (default_cs) return default_cs->cmyk; else return fz_device_cmyk(ctx); }
DoS
0
fz_default_cmyk(fz_context *ctx, const fz_default_colorspaces *default_cs) { if (default_cs) return default_cs->cmyk; else return fz_device_cmyk(ctx); }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
273
fz_default_color_params(fz_context *ctx) { return default_color_params; }
DoS
0
fz_default_color_params(fz_context *ctx) { return default_color_params; }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
274
fz_default_gray(fz_context *ctx, const fz_default_colorspaces *default_cs) { if (default_cs) return default_cs->gray; else return fz_device_gray(ctx); }
DoS
0
fz_default_gray(fz_context *ctx, const fz_default_colorspaces *default_cs) { if (default_cs) return default_cs->gray; else return fz_device_gray(ctx); }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
275
fz_default_rgb(fz_context *ctx, const fz_default_colorspaces *default_cs) { if (default_cs) return default_cs->rgb; else return fz_device_rgb(ctx); }
DoS
0
fz_default_rgb(fz_context *ctx, const fz_default_colorspaces *default_cs) { if (default_cs) return default_cs->rgb; else return fz_device_rgb(ctx); }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
276
fz_device_bgr(fz_context *ctx) { return ctx->colorspace->bgr; }
DoS
0
fz_device_bgr(fz_context *ctx) { return ctx->colorspace->bgr; }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
277
fz_device_cmyk(fz_context *ctx) { return ctx->colorspace->cmyk; }
DoS
0
fz_device_cmyk(fz_context *ctx) { return ctx->colorspace->cmyk; }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
278
fz_drop_cmm_context(fz_context *ctx) { fz_cmm_drop_instance(ctx); ctx->cmm_instance = NULL; }
DoS
0
fz_drop_cmm_context(fz_context *ctx) { fz_cmm_drop_instance(ctx); ctx->cmm_instance = NULL; }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
279
fz_drop_color_converter(fz_context *ctx, fz_color_converter *cc) { fz_icclink *link = (fz_icclink *)cc->link; if (link) fz_drop_icclink(ctx, link); cc->link = NULL; }
DoS
0
fz_drop_color_converter(fz_context *ctx, fz_color_converter *cc) { fz_icclink *link = (fz_icclink *)cc->link; if (link) fz_drop_icclink(ctx, link); cc->link = NULL; }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
280
fz_drop_colorspace(fz_context *ctx, fz_colorspace *cs) { fz_drop_key_storable(ctx, &cs->key_storable); }
DoS
0
fz_drop_colorspace(fz_context *ctx, fz_colorspace *cs) { fz_drop_key_storable(ctx, &cs->key_storable); }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
281
fz_drop_colorspace_imp(fz_context *ctx, fz_storable *cs_) { fz_colorspace *cs = (fz_colorspace *)cs_; int i; if (cs->free_data && cs->data) cs->free_data(ctx, cs); for (i = 0; i < FZ_MAX_COLORS; i++) fz_free(ctx, cs->colorant[i]); fz_free(ctx, cs); }
DoS
0
fz_drop_colorspace_imp(fz_context *ctx, fz_storable *cs_) { fz_colorspace *cs = (fz_colorspace *)cs_; int i; if (cs->free_data && cs->data) cs->free_data(ctx, cs); for (i = 0; i < FZ_MAX_COLORS; i++) fz_free(ctx, cs->colorant[i]); fz_free(ctx, cs); }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
282
fz_drop_default_colorspaces(fz_context *ctx, fz_default_colorspaces *default_cs) { if (fz_drop_imp(ctx, default_cs, &default_cs->refs)) { fz_drop_colorspace(ctx, default_cs->gray); fz_drop_colorspace(ctx, default_cs->rgb); fz_drop_colorspace(ctx, default_cs->cmyk); fz_drop_colorspace(ctx, default_cs->oi); fz_free(ctx, default_cs); } }
DoS
0
fz_drop_default_colorspaces(fz_context *ctx, fz_default_colorspaces *default_cs) { if (fz_drop_imp(ctx, default_cs, &default_cs->refs)) { fz_drop_colorspace(ctx, default_cs->gray); fz_drop_colorspace(ctx, default_cs->rgb); fz_drop_colorspace(ctx, default_cs->cmyk); fz_drop_colorspace(ctx, default_cs->oi); fz_free(ctx, default_cs); } }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
283
fz_drop_icclink(fz_context *ctx, fz_icclink *link) { fz_drop_storable(ctx, &link->storable); }
DoS
0
fz_drop_icclink(fz_context *ctx, fz_icclink *link) { fz_drop_storable(ctx, &link->storable); }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
284
fz_drop_link_imp(fz_context *ctx, fz_storable *storable) { fz_icclink *link = (fz_icclink *)storable; fz_cmm_fin_link(ctx, link); fz_free(ctx, link); }
DoS
0
fz_drop_link_imp(fz_context *ctx, fz_storable *storable) { fz_icclink *link = (fz_icclink *)storable; fz_cmm_fin_link(ctx, link); fz_free(ctx, link); }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
285
fz_expand_indexed_pixmap(fz_context *ctx, const fz_pixmap *src, int alpha) { struct indexed *idx; fz_pixmap *dst; const unsigned char *s; unsigned char *d; int y, x, k, n, high; unsigned char *lookup; fz_irect bbox; int s_line_inc, d_line_inc; assert(src->colorspace->to_ccs == indexed_to_rgb || src->colorspace->to_ccs == indexed_to_alt); assert(src->n == 1 + alpha); idx = src->colorspace->data; high = idx->high; lookup = idx->lookup; n = idx->base->n; dst = fz_new_pixmap_with_bbox(ctx, idx->base, fz_pixmap_bbox(ctx, src, &bbox), src->seps, alpha); s = src->samples; d = dst->samples; s_line_inc = src->stride - src->w * src->n; d_line_inc = dst->stride - dst->w * dst->n; if (alpha) { for (y = 0; y < src->h; y++) { for (x = 0; x < src->w; x++) { int v = *s++; int a = *s++; int aa = a + (a>>7); v = fz_mini(v, high); for (k = 0; k < n; k++) *d++ = (aa * lookup[v * n + k] + 128)>>8; *d++ = a; } s += s_line_inc; d += d_line_inc; } } else { for (y = 0; y < src->h; y++) { for (x = 0; x < src->w; x++) { int v = *s++; v = fz_mini(v, high); for (k = 0; k < n; k++) *d++ = lookup[v * n + k]; } s += s_line_inc; d += d_line_inc; } } if (src->flags & FZ_PIXMAP_FLAG_INTERPOLATE) dst->flags |= FZ_PIXMAP_FLAG_INTERPOLATE; else dst->flags &= ~FZ_PIXMAP_FLAG_INTERPOLATE; return dst; }
DoS
0
fz_expand_indexed_pixmap(fz_context *ctx, const fz_pixmap *src, int alpha) { struct indexed *idx; fz_pixmap *dst; const unsigned char *s; unsigned char *d; int y, x, k, n, high; unsigned char *lookup; fz_irect bbox; int s_line_inc, d_line_inc; assert(src->colorspace->to_ccs == indexed_to_rgb || src->colorspace->to_ccs == indexed_to_alt); assert(src->n == 1 + alpha); idx = src->colorspace->data; high = idx->high; lookup = idx->lookup; n = idx->base->n; dst = fz_new_pixmap_with_bbox(ctx, idx->base, fz_pixmap_bbox(ctx, src, &bbox), src->seps, alpha); s = src->samples; d = dst->samples; s_line_inc = src->stride - src->w * src->n; d_line_inc = dst->stride - dst->w * dst->n; if (alpha) { for (y = 0; y < src->h; y++) { for (x = 0; x < src->w; x++) { int v = *s++; int a = *s++; int aa = a + (a>>7); v = fz_mini(v, high); for (k = 0; k < n; k++) *d++ = (aa * lookup[v * n + k] + 128)>>8; *d++ = a; } s += s_line_inc; d += d_line_inc; } } else { for (y = 0; y < src->h; y++) { for (x = 0; x < src->w; x++) { int v = *s++; v = fz_mini(v, high); for (k = 0; k < n; k++) *d++ = lookup[v * n + k]; } s += s_line_inc; d += d_line_inc; } } if (src->flags & FZ_PIXMAP_FLAG_INTERPOLATE) dst->flags |= FZ_PIXMAP_FLAG_INTERPOLATE; else dst->flags &= ~FZ_PIXMAP_FLAG_INTERPOLATE; return dst; }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
286
void fz_find_color_converter(fz_context *ctx, fz_color_converter *cc, const fz_colorspace *is, const fz_colorspace *ds, const fz_colorspace *ss, const fz_color_params *params) { if (ds == NULL) ds = fz_device_gray(ctx); if (ss == NULL) ss = fz_device_gray(ctx); cc->ds = ds; cc->ss = ss; cc->is = is; cc->link = NULL; if (ss == default_gray) { if ((ds == default_rgb) || (ds == default_bgr)) cc->convert = g2rgb; else if (ds == default_cmyk) cc->convert = g2cmyk; else cc->convert = std_conv_color; } else if (ss == default_rgb) { if (ds == default_gray) cc->convert = rgb2g; else if (ds == default_bgr) cc->convert = rgb2bgr; else if (ds == default_cmyk) cc->convert = rgb2cmyk; else cc->convert = std_conv_color; } else if (ss == default_bgr) { if (ds == default_gray) cc->convert = bgr2g; else if (ds == default_rgb) cc->convert = rgb2bgr; else if (ds == default_cmyk) cc->convert = bgr2cmyk; else cc->convert = std_conv_color; } else if (ss == default_cmyk) { if (ds == default_gray) cc->convert = cmyk2g; else if (ds == default_rgb) cc->convert = cmyk2rgb; else if (ds == default_bgr) cc->convert = cmyk2bgr; else cc->convert = std_conv_color; } else if ((ss == fz_device_rgb(ctx) && ds == fz_device_bgr(ctx)) || (ss == fz_device_bgr(ctx) && ds == fz_device_rgb(ctx))) { cc->convert = rgb2bgr; } else { const fz_colorspace *ss_base = fz_source_colorspace_cm(ctx, ss); if (ss_base != NULL && fz_colorspace_is_icc(ctx, ds)) { if (ss_base == ss) cc->convert = icc_conv_color; else cc->convert = icc_base_conv_color; /* Special case: Do not set link if we are doing DeviceGray to CMYK. */ /* Handle DeviceGray to CMYK as K only. See note in Section 6.3 of PDF spec 1.7. */ if (!(fz_colorspace_is_device_gray(ctx, ss_base) && fz_colorspace_is_cmyk(ctx, ds))) cc->link = fz_get_icc_link(ctx, ds, 0, ss_base, 0, is, params, 2, 0, &cc->n); } else cc->convert = std_conv_color; } }
DoS
0
void fz_find_color_converter(fz_context *ctx, fz_color_converter *cc, const fz_colorspace *is, const fz_colorspace *ds, const fz_colorspace *ss, const fz_color_params *params) { if (ds == NULL) ds = fz_device_gray(ctx); if (ss == NULL) ss = fz_device_gray(ctx); cc->ds = ds; cc->ss = ss; cc->is = is; cc->link = NULL; if (ss == default_gray) { if ((ds == default_rgb) || (ds == default_bgr)) cc->convert = g2rgb; else if (ds == default_cmyk) cc->convert = g2cmyk; else cc->convert = std_conv_color; } else if (ss == default_rgb) { if (ds == default_gray) cc->convert = rgb2g; else if (ds == default_bgr) cc->convert = rgb2bgr; else if (ds == default_cmyk) cc->convert = rgb2cmyk; else cc->convert = std_conv_color; } else if (ss == default_bgr) { if (ds == default_gray) cc->convert = bgr2g; else if (ds == default_rgb) cc->convert = rgb2bgr; else if (ds == default_cmyk) cc->convert = bgr2cmyk; else cc->convert = std_conv_color; } else if (ss == default_cmyk) { if (ds == default_gray) cc->convert = cmyk2g; else if (ds == default_rgb) cc->convert = cmyk2rgb; else if (ds == default_bgr) cc->convert = cmyk2bgr; else cc->convert = std_conv_color; } else if ((ss == fz_device_rgb(ctx) && ds == fz_device_bgr(ctx)) || (ss == fz_device_bgr(ctx) && ds == fz_device_rgb(ctx))) { cc->convert = rgb2bgr; } else { const fz_colorspace *ss_base = fz_source_colorspace_cm(ctx, ss); if (ss_base != NULL && fz_colorspace_is_icc(ctx, ds)) { if (ss_base == ss) cc->convert = icc_conv_color; else cc->convert = icc_base_conv_color; /* Special case: Do not set link if we are doing DeviceGray to CMYK. */ /* Handle DeviceGray to CMYK as K only. See note in Section 6.3 of PDF spec 1.7. */ if (!(fz_colorspace_is_device_gray(ctx, ss_base) && fz_colorspace_is_cmyk(ctx, ds))) cc->link = fz_get_icc_link(ctx, ds, 0, ss_base, 0, is, params, 2, 0, &cc->n); } else cc->convert = std_conv_color; } }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
287
const fz_cmm_engine *fz_get_cmm_engine(fz_context *ctx) { return ctx->colorspace ? ctx->colorspace->cmm : NULL; }
DoS
0
const fz_cmm_engine *fz_get_cmm_engine(fz_context *ctx) { return ctx->colorspace ? ctx->colorspace->cmm : NULL; }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
288
fz_get_icc_link(fz_context *ctx, const fz_colorspace *dst, int dst_extras, const fz_colorspace *src, int src_extras, const fz_colorspace *prf, const fz_color_params *rend, int num_bytes, int copy_spots, int *src_n) { fz_icclink *link = NULL; fz_iccprofile *src_icc = NULL; fz_iccprofile *dst_icc = dst->data; fz_iccprofile *prf_icc = NULL; fz_link_key *key = NULL; fz_icclink *new_link; assert(!copy_spots || src_extras == dst_extras); if (prf != NULL) prf_icc = prf->data; if (fz_colorspace_is_icc(ctx, src)) src_icc = src->data; else if (fz_colorspace_is_cal(ctx, src)) { fz_cal_colorspace *cal; cal = src->data; src_icc = cal->profile; /* Check if we have any work to do. */ if (src_icc == NULL) src_icc = fz_icc_from_cal(ctx, src); if (src_icc->cmm_handle == NULL) { fz_cmm_init_profile(ctx, src_icc); /* The CMM failed to make a profile. Use the default. */ if (src_icc->cmm_handle == NULL) { switch (src->n) { case 1: src_icc = fz_device_gray(ctx)->data; break; case 3: src_icc = fz_device_rgb(ctx)->data; break; case 4: src_icc = fz_device_cmyk(ctx)->data; break; default: fz_throw(ctx, FZ_ERROR_GENERIC, "Poorly formed Cal color space"); } /* To avoid repeated failures building the pdf-cal color space, * assign the default profile. */ fz_cmm_fin_profile(ctx, src_icc); cal->profile = src_icc; } } } else src_icc = get_base_icc_profile(ctx, src); if (src_icc == NULL) fz_throw(ctx, FZ_ERROR_GENERIC, "Profile missing during link creation"); *src_n = src_icc->num_devcomp; fz_var(link); fz_var(key); if (rend == NULL) rend = fz_default_color_params(ctx); fz_try(ctx) { /* Check the storable to see if we have a copy. */ key = fz_malloc_struct(ctx, fz_link_key); key->refs = 1; memcpy(&key->dst_md5, dst_icc->md5, 16); memcpy(&key->src_md5, src_icc->md5, 16); key->rend.ri = rend->ri; key->rend.bp = rend->bp; key->src_extras = src_extras; key->dst_extras = dst_extras; key->depth = num_bytes; key->proof = (prf_icc != NULL); key->copy_spots = copy_spots; link = fz_find_item(ctx, fz_drop_link_imp, key, &fz_link_store_type); /* Not found. Make new one add to store. */ if (link == NULL) { link = fz_new_icc_link(ctx, dst_icc, dst_extras, src_icc, src_extras, prf_icc, rend, num_bytes, copy_spots); new_link = fz_store_item(ctx, key, link, sizeof(fz_icclink), &fz_link_store_type); if (new_link != NULL) { /* Found one while adding! Perhaps from another thread? */ fz_drop_icclink(ctx, link); link = new_link; } } } fz_always(ctx) { fz_drop_link_key(ctx, key); } fz_catch(ctx) { /* Ignore any error that came just from the enstoring. */ if (link == NULL) fz_rethrow(ctx); } return link; }
DoS
0
fz_get_icc_link(fz_context *ctx, const fz_colorspace *dst, int dst_extras, const fz_colorspace *src, int src_extras, const fz_colorspace *prf, const fz_color_params *rend, int num_bytes, int copy_spots, int *src_n) { fz_icclink *link = NULL; fz_iccprofile *src_icc = NULL; fz_iccprofile *dst_icc = dst->data; fz_iccprofile *prf_icc = NULL; fz_link_key *key = NULL; fz_icclink *new_link; assert(!copy_spots || src_extras == dst_extras); if (prf != NULL) prf_icc = prf->data; if (fz_colorspace_is_icc(ctx, src)) src_icc = src->data; else if (fz_colorspace_is_cal(ctx, src)) { fz_cal_colorspace *cal; cal = src->data; src_icc = cal->profile; /* Check if we have any work to do. */ if (src_icc == NULL) src_icc = fz_icc_from_cal(ctx, src); if (src_icc->cmm_handle == NULL) { fz_cmm_init_profile(ctx, src_icc); /* The CMM failed to make a profile. Use the default. */ if (src_icc->cmm_handle == NULL) { switch (src->n) { case 1: src_icc = fz_device_gray(ctx)->data; break; case 3: src_icc = fz_device_rgb(ctx)->data; break; case 4: src_icc = fz_device_cmyk(ctx)->data; break; default: fz_throw(ctx, FZ_ERROR_GENERIC, "Poorly formed Cal color space"); } /* To avoid repeated failures building the pdf-cal color space, * assign the default profile. */ fz_cmm_fin_profile(ctx, src_icc); cal->profile = src_icc; } } } else src_icc = get_base_icc_profile(ctx, src); if (src_icc == NULL) fz_throw(ctx, FZ_ERROR_GENERIC, "Profile missing during link creation"); *src_n = src_icc->num_devcomp; fz_var(link); fz_var(key); if (rend == NULL) rend = fz_default_color_params(ctx); fz_try(ctx) { /* Check the storable to see if we have a copy. */ key = fz_malloc_struct(ctx, fz_link_key); key->refs = 1; memcpy(&key->dst_md5, dst_icc->md5, 16); memcpy(&key->src_md5, src_icc->md5, 16); key->rend.ri = rend->ri; key->rend.bp = rend->bp; key->src_extras = src_extras; key->dst_extras = dst_extras; key->depth = num_bytes; key->proof = (prf_icc != NULL); key->copy_spots = copy_spots; link = fz_find_item(ctx, fz_drop_link_imp, key, &fz_link_store_type); /* Not found. Make new one add to store. */ if (link == NULL) { link = fz_new_icc_link(ctx, dst_icc, dst_extras, src_icc, src_extras, prf_icc, rend, num_bytes, copy_spots); new_link = fz_store_item(ctx, key, link, sizeof(fz_icclink), &fz_link_store_type); if (new_link != NULL) { /* Found one while adding! Perhaps from another thread? */ fz_drop_icclink(ctx, link); link = new_link; } } } fz_always(ctx) { fz_drop_link_key(ctx, key); } fz_catch(ctx) { /* Ignore any error that came just from the enstoring. */ if (link == NULL) fz_rethrow(ctx); } return link; }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
289
fz_icc_data_from_icc_colorspace(fz_context *ctx, const fz_colorspace *cs) { fz_iccprofile *profile; if (cs == NULL || !fz_colorspace_is_icc(ctx, cs)) return NULL; profile = cs->data; if (!profile) return NULL; return profile->buffer; }
DoS
0
fz_icc_data_from_icc_colorspace(fz_context *ctx, const fz_colorspace *cs) { fz_iccprofile *profile; if (cs == NULL || !fz_colorspace_is_icc(ctx, cs)) return NULL; profile = cs->data; if (!profile) return NULL; return profile->buffer; }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
290
fz_icc_from_cal(fz_context *ctx, const fz_colorspace *cs) { fz_cal_colorspace *cal_data = cs->data; fz_iccprofile *profile; if (cal_data->profile != NULL) return cal_data->profile; profile = fz_malloc_struct(ctx, fz_iccprofile); fz_try(ctx) { profile->buffer = fz_new_icc_data_from_cal_colorspace(ctx, cal_data); fz_md5_icc(ctx, profile); cal_data->profile = profile; } fz_catch(ctx) { fz_free(ctx, profile); fz_rethrow(ctx); } return profile; }
DoS
0
fz_icc_from_cal(fz_context *ctx, const fz_colorspace *cs) { fz_cal_colorspace *cal_data = cs->data; fz_iccprofile *profile; if (cal_data->profile != NULL) return cal_data->profile; profile = fz_malloc_struct(ctx, fz_iccprofile); fz_try(ctx) { profile->buffer = fz_new_icc_data_from_cal_colorspace(ctx, cal_data); fz_md5_icc(ctx, profile); cal_data->profile = profile; } fz_catch(ctx) { fz_free(ctx, profile); fz_rethrow(ctx); } return profile; }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
291
fz_indexed_colorspace_palette(fz_context *ctx, fz_colorspace *cs, int *high) { struct indexed *idx = cs->data; if (!fz_colorspace_is_indexed(ctx, cs)) fz_throw(ctx, FZ_ERROR_GENERIC, "colorspace not indexed"); *high = idx->high; return idx->lookup; }
DoS
0
fz_indexed_colorspace_palette(fz_context *ctx, fz_colorspace *cs, int *high) { struct indexed *idx = cs->data; if (!fz_colorspace_is_indexed(ctx, cs)) fz_throw(ctx, FZ_ERROR_GENERIC, "colorspace not indexed"); *high = idx->high; return idx->lookup; }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
292
fz_keep_colorspace(fz_context *ctx, fz_colorspace *cs) { return fz_keep_key_storable(ctx, &cs->key_storable); }
DoS
0
fz_keep_colorspace(fz_context *ctx, fz_colorspace *cs) { return fz_keep_key_storable(ctx, &cs->key_storable); }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
293
fz_keep_colorspace_context(fz_context *ctx) { if (!ctx) return NULL; return fz_keep_imp(ctx, ctx->colorspace, &ctx->colorspace->ctx_refs); }
DoS
0
fz_keep_colorspace_context(fz_context *ctx) { if (!ctx) return NULL; return fz_keep_imp(ctx, ctx->colorspace, &ctx->colorspace->ctx_refs); }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
294
fz_keep_colorspace_store_key(fz_context *ctx, fz_colorspace *cs) { return fz_keep_key_storable_key(ctx, &cs->key_storable); }
DoS
0
fz_keep_colorspace_store_key(fz_context *ctx, fz_colorspace *cs) { return fz_keep_key_storable_key(ctx, &cs->key_storable); }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
295
fz_keep_link_key(fz_context *ctx, void *key_) { fz_link_key *key = (fz_link_key *)key_; return fz_keep_imp(ctx, key, &key->refs); }
DoS
0
fz_keep_link_key(fz_context *ctx, void *key_) { fz_link_key *key = (fz_link_key *)key_; return fz_keep_imp(ctx, key, &key->refs); }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
296
fz_pixmap_converter *fz_lookup_pixmap_converter(fz_context *ctx, fz_colorspace *ds, fz_colorspace *ss) { if (ds == NULL) return fast_any_to_alpha; if (ss == default_gray) { if (ds == default_rgb) return fast_gray_to_rgb; else if (ds == default_bgr) return fast_gray_to_rgb; /* bgr == rgb here */ else if (ds == default_cmyk) return fast_gray_to_cmyk; else return std_conv_pixmap; } else if (ss == default_rgb) { if (ds == default_gray) return fast_rgb_to_gray; else if (ds == default_bgr) return fast_rgb_to_bgr; else if (ds == default_cmyk) return fast_rgb_to_cmyk; else return std_conv_pixmap; } else if (ss == default_bgr) { if (ds == default_gray) return fast_bgr_to_gray; else if (ds == default_rgb) return fast_rgb_to_bgr; /* bgr = rgb here */ else if (ds == default_cmyk) return fast_bgr_to_cmyk; else return std_conv_pixmap; } else if (ss == default_cmyk) { if (ds == default_gray) return fast_cmyk_to_gray; else if (ds == default_bgr) return fast_cmyk_to_bgr; else if (ds == default_rgb) return fast_cmyk_to_rgb; else return std_conv_pixmap; } else if ((ss == fz_device_rgb(ctx) && ds == fz_device_bgr(ctx)) || (ds == fz_device_rgb(ctx) && ss == fz_device_bgr(ctx))) { return fast_rgb_to_bgr; } else { const fz_colorspace *ss_base = fz_source_colorspace_cm(ctx, ss); if (ss_base != NULL && fz_colorspace_is_icc(ctx, ds)) { if (ss_base == ss) return icc_conv_pixmap; else return icc_base_conv_pixmap; } else return std_conv_pixmap; } }
DoS
0
fz_pixmap_converter *fz_lookup_pixmap_converter(fz_context *ctx, fz_colorspace *ds, fz_colorspace *ss) { if (ds == NULL) return fast_any_to_alpha; if (ss == default_gray) { if (ds == default_rgb) return fast_gray_to_rgb; else if (ds == default_bgr) return fast_gray_to_rgb; /* bgr == rgb here */ else if (ds == default_cmyk) return fast_gray_to_cmyk; else return std_conv_pixmap; } else if (ss == default_rgb) { if (ds == default_gray) return fast_rgb_to_gray; else if (ds == default_bgr) return fast_rgb_to_bgr; else if (ds == default_cmyk) return fast_rgb_to_cmyk; else return std_conv_pixmap; } else if (ss == default_bgr) { if (ds == default_gray) return fast_bgr_to_gray; else if (ds == default_rgb) return fast_rgb_to_bgr; /* bgr = rgb here */ else if (ds == default_cmyk) return fast_bgr_to_cmyk; else return std_conv_pixmap; } else if (ss == default_cmyk) { if (ds == default_gray) return fast_cmyk_to_gray; else if (ds == default_bgr) return fast_cmyk_to_bgr; else if (ds == default_rgb) return fast_cmyk_to_rgb; else return std_conv_pixmap; } else if ((ss == fz_device_rgb(ctx) && ds == fz_device_bgr(ctx)) || (ds == fz_device_rgb(ctx) && ss == fz_device_bgr(ctx))) { return fast_rgb_to_bgr; } else { const fz_colorspace *ss_base = fz_source_colorspace_cm(ctx, ss); if (ss_base != NULL && fz_colorspace_is_icc(ctx, ds)) { if (ss_base == ss) return icc_conv_pixmap; else return icc_base_conv_pixmap; } else return std_conv_pixmap; } }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
297
fz_make_hash_link_key(fz_context *ctx, fz_store_hash *hash, void *key_) { fz_link_key *key = (fz_link_key *)key_; memcpy(hash->u.link.dst_md5, key->dst_md5, 16); memcpy(hash->u.link.src_md5, key->src_md5, 16); hash->u.link.ri = key->rend.ri; hash->u.link.bp = key->rend.bp; hash->u.link.src_extras = key->src_extras; hash->u.link.dst_extras = key->dst_extras; hash->u.link.bpp16 = key->depth == 2; hash->u.link.proof = key->proof; hash->u.link.copy_spots = key->copy_spots; return 1; }
DoS
0
fz_make_hash_link_key(fz_context *ctx, fz_store_hash *hash, void *key_) { fz_link_key *key = (fz_link_key *)key_; memcpy(hash->u.link.dst_md5, key->dst_md5, 16); memcpy(hash->u.link.src_md5, key->src_md5, 16); hash->u.link.ri = key->rend.ri; hash->u.link.bp = key->rend.bp; hash->u.link.src_extras = key->src_extras; hash->u.link.dst_extras = key->dst_extras; hash->u.link.bpp16 = key->depth == 2; hash->u.link.proof = key->proof; hash->u.link.copy_spots = key->copy_spots; return 1; }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
298
fz_md5_icc(fz_context *ctx, fz_iccprofile *profile) { if (profile) fz_md5_buffer(ctx, profile->buffer, profile->md5); }
DoS
0
fz_md5_icc(fz_context *ctx, fz_iccprofile *profile) { if (profile) fz_md5_buffer(ctx, profile->buffer, profile->md5); }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null
299
fz_new_cmm_context(fz_context *ctx) { ctx->cmm_instance = fz_cmm_new_instance(ctx); }
DoS
0
fz_new_cmm_context(fz_context *ctx) { ctx->cmm_instance = fz_cmm_new_instance(ctx); }
@@ -3663,6 +3663,7 @@ void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_ fz_drop_color_converter(ctx, &cached->base); fz_drop_hash_table(ctx, cached->hash); fz_free(ctx, cached); + cc->opaque = NULL; fz_rethrow(ctx); } }
CWE-20
null
null