prompt
stringclasses 1
value | completions
listlengths 1
1.33k
| labels
listlengths 1
1.33k
| source
stringclasses 1
value | other_info
dict | index
int64 0
151k
|
|---|---|---|---|---|---|
Determine whether the code is vulnerable or not.
|
[
"psf_get_date_str (char *str, int maxlen)\n{\ttime_t\t\tcurrent ;\n\tstruct tm\ttimedata, *tmptr ;",
"\ttime (¤t) ;",
"#if defined (HAVE_GMTIME_R)\n\t/* If the re-entrant version is available, use it. */\n\ttmptr = gmtime_r (¤t, &timedata) ;\n#elif defined (HAVE_GMTIME)\n\t/* Otherwise use the standard one and copy the data to local storage. */\n\ttmptr = gmtime (¤t) ;\n\tmemcpy (&timedata, tmptr, sizeof (timedata)) ;\n#else\n\ttmptr = NULL ;\n#endif",
"\tif (tmptr)\n\t\tsnprintf (str, maxlen, \"%4d-%02d-%02d %02d:%02d:%02d UTC\",\n\t\t\t1900 + timedata.tm_year, timedata.tm_mon, timedata.tm_mday,\n\t\t\ttimedata.tm_hour, timedata.tm_min, timedata.tm_sec) ;\n\telse\n\t\tsnprintf (str, maxlen, \"Unknown date\") ;",
"\treturn ;\n} /* psf_get_date_str */\n"
] |
[
1,
1,
1,
1,
1
] |
BIGVUL
|
{
"CVE ID": "CVE-2017-7586",
"CVE Page": "https://www.cvedetails.com/cve/CVE-2017-7586/",
"CWE ID": "CWE-119",
"codeLink": "https://github.com/erikd/libsndfile/commit/708e996c87c5fae77b104ccfeb8f6db784c32074",
"commit_id": "708e996c87c5fae77b104ccfeb8f6db784c32074",
"commit_message": "src/ : Move to a variable length header buffer\n\nPreviously, the `psf->header` buffer was a fixed length specified by\n`SF_HEADER_LEN` which was set to `12292`. This was problematic for\ntwo reasons; this value was un-necessarily large for the majority\nof files and too small for some others.\n\nNow the size of the header buffer starts at 256 bytes and grows as\nnecessary up to a maximum of 100k.",
"lang": "C",
"project": "libsndfile"
}
| 0
|
Determine whether the code is vulnerable or not.
|
[
"void MultibufferDataSource::CreateResourceLoader(int64_t first_byte_position,\n int64_t last_byte_position) {\n DCHECK(render_task_runner_->BelongsToCurrentThread());",
" SetReader(new MultiBufferReader(\n url_data()->multibuffer(), first_byte_position, last_byte_position,\n base::Bind(&MultibufferDataSource::ProgressCallback, weak_ptr_)));\n reader_->SetIsClientAudioElement(is_client_audio_element_);\n UpdateBufferSizes();\n}\n"
] |
[
1,
1
] |
BIGVUL
|
{
"CVE ID": "CVE-2018-18352",
"CVE Page": "https://www.cvedetails.com/cve/CVE-2018-18352/",
"CWE ID": "CWE-732",
"codeLink": "https://github.com/chromium/chromium/commit/a9cbaa7a40e2b2723cfc2f266c42f4980038a949",
"commit_id": "a9cbaa7a40e2b2723cfc2f266c42f4980038a949",
"commit_message": "Simplify \"WouldTaintOrigin\" concept in media/blink\n\nCurrently WebMediaPlayer has three predicates:\n - DidGetOpaqueResponseFromServiceWorker\n - HasSingleSecurityOrigin\n - DidPassCORSAccessCheck\n. These are used to determine whether the response body is available\nfor scripts. They are known to be confusing, and actually\nMediaElementAudioSourceHandler::WouldTaintOrigin misuses them.\n\nThis CL merges the three predicates to one, WouldTaintOrigin, to remove\nthe confusion. Now the \"response type\" concept is available and we\ndon't need a custom CORS check, so this CL removes\nBaseAudioContext::WouldTaintOrigin. This CL also renames\nURLData::has_opaque_data_ and its (direct and indirect) data accessors\nto match the spec.\n\nBug: 849942, 875153\nChange-Id: I6acf50169d7445c4ff614e80ac606f79ee577d2a\nReviewed-on: https://chromium-review.googlesource.com/c/1238098\nReviewed-by: Fredrik Hubinette <hubbe@chromium.org>\nReviewed-by: Kinuko Yasuda <kinuko@chromium.org>\nReviewed-by: Raymond Toy <rtoy@chromium.org>\nCommit-Queue: Yutaka Hirano <yhirano@chromium.org>\nCr-Commit-Position: refs/heads/master@{#598258}",
"lang": "C",
"project": "Chrome"
}
| 1
|
Determine whether the code is vulnerable or not.
|
[
"fbStore_a2r2g2b2 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed)\n{\n int i;\n CARD8 *pixel = ((CARD8 *) bits) + x;\n for (i = 0; i < width; ++i) {\n Splita(READ(values + i));\n WRITE(pixel++, ((a ) & 0xc0) |\n\t ((r >> 2) & 0x30) |\n\t ((g >> 4) & 0x0c) |\n\t ((b >> 6) ));\n }\n}\n"
] |
[
1
] |
BIGVUL
|
{
"CVE ID": "CVE-2010-1166",
"CVE Page": "https://www.cvedetails.com/cve/CVE-2010-1166/",
"CWE ID": "CWE-189",
"codeLink": "https://cgit.freedesktop.org/xorg/xserver/commit/?id=d2f813f7db",
"commit_id": "d2f813f7db157fc83abc4b3726821c36ee7e40b1",
"commit_message": null,
"lang": "C",
"project": "xserver"
}
| 2
|
Determine whether the code is vulnerable or not.
|
[
"void UsageTracker::DidGetClientGlobalUsage(StorageType type,\n int64 usage,\n int64 unlimited_usage) {\n DCHECK_EQ(type, type_);\n global_usage_.usage += usage;\n global_usage_.unlimited_usage += unlimited_usage;\n if (--global_usage_.pending_clients == 0) {\n if (global_usage_.usage < 0)\n global_usage_.usage = 0;\n if (global_usage_.unlimited_usage > global_usage_.usage)\n global_usage_.unlimited_usage = global_usage_.usage;\n else if (global_usage_.unlimited_usage < 0)\n global_usage_.unlimited_usage = 0;",
" global_usage_callbacks_.Run(type, global_usage_.usage,\n global_usage_.unlimited_usage);\n }\n}\n"
] |
[
1,
1
] |
BIGVUL
|
{
"CVE ID": null,
"CVE Page": null,
"CWE ID": null,
"codeLink": "https://github.com/chromium/chromium/commit/610f904d8215075c4681be4eb413f4348860bf9f",
"commit_id": "610f904d8215075c4681be4eb413f4348860bf9f",
"commit_message": "Retrieve per host storage usage from QuotaManager.\n\nR=kinuko@chromium.org\nBUG=none\nTEST=QuotaManagerTest.GetUsage\n\nReview URL: http://codereview.chromium.org/8079004\n\ngit-svn-id: svn://svn.chromium.org/chrome/trunk/src@103921 0039d316-1c4b-4281-b951-d872f2087c98",
"lang": "C",
"project": "Chrome"
}
| 3
|
Determine whether the code is vulnerable or not.
|
[
"void BlobURLRequestJob::DidRead(int result) {\n if (result < 0) {\n NotifyFailure(net::ERR_FAILED);\n return;\n }\n SetStatus(net::URLRequestStatus()); // Clear the IO_PENDING status",
" AdvanceBytesRead(result);",
" if (!read_buf_remaining_bytes_) {\n int bytes_read = ReadCompleted();\n NotifyReadComplete(bytes_read);\n return;\n }",
" int bytes_read = 0;\n if (ReadLoop(&bytes_read))\n NotifyReadComplete(bytes_read);\n}\n"
] |
[
1,
1,
1,
1
] |
BIGVUL
|
{
"CVE ID": null,
"CVE Page": null,
"CWE ID": null,
"codeLink": "https://github.com/chromium/chromium/commit/957973753ec4159003ff7930d946b7e89c7e09f3",
"commit_id": "957973753ec4159003ff7930d946b7e89c7e09f3",
"commit_message": "Make NotifyHeadersComplete the last call in the function.\n\nBUG=82903\nReview URL: http://codereview.chromium.org/7038017\n\ngit-svn-id: svn://svn.chromium.org/chrome/trunk/src@85719 0039d316-1c4b-4281-b951-d872f2087c98",
"lang": "C",
"project": "Chrome"
}
| 4
|
Determine whether the code is vulnerable or not.
|
[
"gss_get_mic (minor_status,\n\t context_handle,\n\t qop_req,\n\t message_buffer,\n\t msg_token)",
"OM_uint32 *\t\tminor_status;\ngss_ctx_id_t\t\tcontext_handle;\ngss_qop_t\t\tqop_req;\ngss_buffer_t\t\tmessage_buffer;\ngss_buffer_t\t\tmsg_token;",
"{\n OM_uint32\t\tstatus;\n gss_union_ctx_id_t\tctx;\n gss_mechanism\tmech;",
" status = val_get_mic_args(minor_status, context_handle,\n\t\t\t qop_req, message_buffer, msg_token);\n if (status != GSS_S_COMPLETE)\n\treturn (status);",
" /*\n * select the approprate underlying mechanism routine and\n * call it.\n */\n \n ctx = (gss_union_ctx_id_t) context_handle;",
"",
" mech = gssint_get_mechanism (ctx->mech_type);\n \n if (mech) {\n\tif (mech->gss_get_mic) {\n\t status = mech->gss_get_mic(\n\t\t\t\t minor_status,\n\t\t\t\t ctx->internal_ctx_id,\n\t\t\t\t qop_req,\n\t\t\t\t message_buffer,\n\t\t\t\t msg_token);\n\t if (status != GSS_S_COMPLETE)\n\t\tmap_error(minor_status, mech);\n\t} else\n\t status = GSS_S_UNAVAILABLE;",
"\treturn(status);\n }",
" return (GSS_S_BAD_MECH);\n}"
] |
[
1,
1,
1,
1,
1,
0,
1,
1,
1
] |
BIGVUL
|
{
"CVE ID": "CVE-2017-11462",
"CVE Page": "https://www.cvedetails.com/cve/CVE-2017-11462/",
"CWE ID": "CWE-415",
"codeLink": "https://github.com/krb5/krb5/commit/56f7b1bc95a2a3eeb420e069e7655fb181ade5cf",
"commit_id": "56f7b1bc95a2a3eeb420e069e7655fb181ade5cf",
"commit_message": "Preserve GSS context on init/accept failure\n\nAfter gss_init_sec_context() or gss_accept_sec_context() has created a\ncontext, don't delete the mechglue context on failures from subsequent\ncalls, even if the mechanism deletes the mech-specific context (which\nis allowed by RFC 2744 but not preferred). Check for union contexts\nwith no mechanism context in each GSS function which accepts a\ngss_ctx_id_t.\n\nCVE-2017-11462:\n\nRFC 2744 permits a GSS-API implementation to delete an existing\nsecurity context on a second or subsequent call to\ngss_init_sec_context() or gss_accept_sec_context() if the call results\nin an error. This API behavior has been found to be dangerous,\nleading to the possibility of memory errors in some callers. For\nsafety, GSS-API implementations should instead preserve existing\nsecurity contexts on error until the caller deletes them.\n\nAll versions of MIT krb5 prior to this change may delete acceptor\ncontexts on error. Versions 1.13.4 through 1.13.7, 1.14.1 through\n1.14.5, and 1.15 through 1.15.1 may also delete initiator contexts on\nerror.\n\nticket: 8598 (new)\ntarget_version: 1.15-next\ntarget_version: 1.14-next\ntags: pullup",
"lang": "C",
"project": "krb5"
}
| 5
|
Determine whether the code is vulnerable or not.
|
[
"gss_get_mic (minor_status,\n\t context_handle,\n\t qop_req,\n\t message_buffer,\n\t msg_token)",
"OM_uint32 *\t\tminor_status;\ngss_ctx_id_t\t\tcontext_handle;\ngss_qop_t\t\tqop_req;\ngss_buffer_t\t\tmessage_buffer;\ngss_buffer_t\t\tmsg_token;",
"{\n OM_uint32\t\tstatus;\n gss_union_ctx_id_t\tctx;\n gss_mechanism\tmech;",
" status = val_get_mic_args(minor_status, context_handle,\n\t\t\t qop_req, message_buffer, msg_token);\n if (status != GSS_S_COMPLETE)\n\treturn (status);",
" /*\n * select the approprate underlying mechanism routine and\n * call it.\n */\n \n ctx = (gss_union_ctx_id_t) context_handle;",
" if (ctx->internal_ctx_id == GSS_C_NO_CONTEXT)\n\treturn (GSS_S_NO_CONTEXT);",
" mech = gssint_get_mechanism (ctx->mech_type);\n \n if (mech) {\n\tif (mech->gss_get_mic) {\n\t status = mech->gss_get_mic(\n\t\t\t\t minor_status,\n\t\t\t\t ctx->internal_ctx_id,\n\t\t\t\t qop_req,\n\t\t\t\t message_buffer,\n\t\t\t\t msg_token);\n\t if (status != GSS_S_COMPLETE)\n\t\tmap_error(minor_status, mech);\n\t} else\n\t status = GSS_S_UNAVAILABLE;",
"\treturn(status);\n }",
" return (GSS_S_BAD_MECH);\n}"
] |
[
1,
1,
1,
1,
1,
2,
1,
1,
1
] |
BIGVUL
|
{
"CVE ID": "CVE-2017-11462",
"CVE Page": "https://www.cvedetails.com/cve/CVE-2017-11462/",
"CWE ID": "CWE-415",
"codeLink": "https://github.com/krb5/krb5/commit/56f7b1bc95a2a3eeb420e069e7655fb181ade5cf",
"commit_id": "56f7b1bc95a2a3eeb420e069e7655fb181ade5cf",
"commit_message": "Preserve GSS context on init/accept failure\n\nAfter gss_init_sec_context() or gss_accept_sec_context() has created a\ncontext, don't delete the mechglue context on failures from subsequent\ncalls, even if the mechanism deletes the mech-specific context (which\nis allowed by RFC 2744 but not preferred). Check for union contexts\nwith no mechanism context in each GSS function which accepts a\ngss_ctx_id_t.\n\nCVE-2017-11462:\n\nRFC 2744 permits a GSS-API implementation to delete an existing\nsecurity context on a second or subsequent call to\ngss_init_sec_context() or gss_accept_sec_context() if the call results\nin an error. This API behavior has been found to be dangerous,\nleading to the possibility of memory errors in some callers. For\nsafety, GSS-API implementations should instead preserve existing\nsecurity contexts on error until the caller deletes them.\n\nAll versions of MIT krb5 prior to this change may delete acceptor\ncontexts on error. Versions 1.13.4 through 1.13.7, 1.14.1 through\n1.14.5, and 1.15 through 1.15.1 may also delete initiator contexts on\nerror.\n\nticket: 8598 (new)\ntarget_version: 1.15-next\ntarget_version: 1.14-next\ntags: pullup",
"lang": "C",
"project": "krb5"
}
| 5
|
Determine whether the code is vulnerable or not.
|
[
"void PluginServiceImpl::RegisterFilePathWatcher(FilePathWatcher* watcher,\n const FilePath& path) {\n bool result = watcher->Watch(path, false,\n base::Bind(&NotifyPluginDirChanged));\n DCHECK(result);\n}\n"
] |
[
1
] |
BIGVUL
|
{
"CVE ID": "CVE-2013-0910",
"CVE Page": "https://www.cvedetails.com/cve/CVE-2013-0910/",
"CWE ID": "CWE-287",
"codeLink": "https://github.com/chromium/chromium/commit/ac8bd041b81e46e4e4fcd5021aaa5499703952e6",
"commit_id": "ac8bd041b81e46e4e4fcd5021aaa5499703952e6",
"commit_message": "Follow-on fixes and naming changes for https://codereview.chromium.org/12086077/\n\nBUG=172573\nReview URL: https://codereview.chromium.org/12177018\n\ngit-svn-id: svn://svn.chromium.org/chrome/trunk/src@180600 0039d316-1c4b-4281-b951-d872f2087c98",
"lang": "C",
"project": "Chrome"
}
| 6
|
Determine whether the code is vulnerable or not.
|
[
"record_loop_stats(\n\tdouble\toffset,\t\t/* offset */\n\tdouble\tfreq,\t\t/* frequency (PPM) */\n\tdouble\tjitter,\t\t/* jitter */\n\tdouble\twander,\t\t/* wander (PPM) */\n\tint spoll\n\t)\n{\n\tl_fp\tnow;\n\tu_long\tday;",
"\tif (!stats_control)\n\t\treturn;",
"\tget_systime(&now);\n\tfilegen_setup(&loopstats, now.l_ui);\n\tday = now.l_ui / 86400 + MJD_1900;\n\tnow.l_ui %= 86400;\n\tif (loopstats.fp != NULL) {\n\t\tfprintf(loopstats.fp, \"%lu %s %.9f %.3f %.9f %.6f %d\\n\",\n\t\t day, ulfptoa(&now, 3), offset, freq * 1e6, jitter,\n\t\t wander * 1e6, spoll);\n\t\tfflush(loopstats.fp);\n\t}\n}\n"
] |
[
1,
1,
1
] |
BIGVUL
|
{
"CVE ID": "CVE-2015-5195",
"CVE Page": "https://www.cvedetails.com/cve/CVE-2015-5195/",
"CWE ID": "CWE-20",
"codeLink": "https://github.com/ntp-project/ntp/commit/52e977d79a0c4ace997e5c74af429844da2f27be",
"commit_id": "52e977d79a0c4ace997e5c74af429844da2f27be",
"commit_message": "[Bug 1773] openssl not detected during ./configure.\n[Bug 1774] Segfaults if cryptostats enabled and built without OpenSSL.",
"lang": "C",
"project": "ntp"
}
| 7
|
Determine whether the code is vulnerable or not.
|
[
"static void hns_xgmac_exc_irq_en(struct mac_driver *drv, u32 en)\n{\n\tu32 clr_vlue = 0xfffffffful;\n\tu32 msk_vlue = en ? 0xfffffffful : 0; /*1 is en, 0 is dis*/",
"\tdsaf_write_dev(drv, XGMAC_INT_STATUS_REG, clr_vlue);\n\tdsaf_write_dev(drv, XGMAC_INT_ENABLE_REG, msk_vlue);\n}\n"
] |
[
1,
1
] |
BIGVUL
|
{
"CVE ID": "CVE-2017-18222",
"CVE Page": "https://www.cvedetails.com/cve/CVE-2017-18222/",
"CWE ID": "CWE-119",
"codeLink": "https://github.com/torvalds/linux/commit/412b65d15a7f8a93794653968308fc100f2aa87c",
"commit_id": "412b65d15a7f8a93794653968308fc100f2aa87c",
"commit_message": "net: hns: fix ethtool_get_strings overflow in hns driver\n\nhns_get_sset_count() returns HNS_NET_STATS_CNT and the data space allocated\nis not enough for ethtool_get_strings(), which will cause random memory\ncorruption.\n\nWhen SLAB and DEBUG_SLAB are both enabled, memory corruptions like the\nthe following can be observed without this patch:\n[ 43.115200] Slab corruption (Not tainted): Acpi-ParseExt start=ffff801fb0b69030, len=80\n[ 43.115206] Redzone: 0x9f911029d006462/0x5f78745f31657070.\n[ 43.115208] Last user: [<5f7272655f746b70>](0x5f7272655f746b70)\n[ 43.115214] 010: 70 70 65 31 5f 74 78 5f 70 6b 74 00 6b 6b 6b 6b ppe1_tx_pkt.kkkk\n[ 43.115217] 030: 70 70 65 31 5f 74 78 5f 70 6b 74 5f 6f 6b 00 6b ppe1_tx_pkt_ok.k\n[ 43.115218] Next obj: start=ffff801fb0b69098, len=80\n[ 43.115220] Redzone: 0x706d655f6f666966/0x9f911029d74e35b.\n[ 43.115229] Last user: [<ffff0000084b11b0>](acpi_os_release_object+0x28/0x38)\n[ 43.115231] 000: 74 79 00 6b 6b 6b 6b 6b 70 70 65 31 5f 74 78 5f ty.kkkkkppe1_tx_\n[ 43.115232] 010: 70 6b 74 5f 65 72 72 5f 63 73 75 6d 5f 66 61 69 pkt_err_csum_fai\n\nSigned-off-by: Timmy Li <lixiaoping3@huawei.com>\nSigned-off-by: David S. Miller <davem@davemloft.net>",
"lang": "C",
"project": "linux"
}
| 8
|
Determine whether the code is vulnerable or not.
|
[
"void BaseRenderingContext2D::clip(Path2D* dom_path,\n const String& winding_rule_string) {\n ClipInternal(dom_path->GetPath(), winding_rule_string);\n}\n"
] |
[
1
] |
BIGVUL
|
{
"CVE ID": "CVE-2018-6077",
"CVE Page": "https://www.cvedetails.com/cve/CVE-2018-6077/",
"CWE ID": "CWE-200",
"codeLink": "https://github.com/chromium/chromium/commit/6ed26f014f76f10e76e80636027a2db9dcbe1664",
"commit_id": "6ed26f014f76f10e76e80636027a2db9dcbe1664",
"commit_message": "[PE] Distinguish between tainting due to canvas content and filter.\n\nA filter on a canvas can itself lead to origin tainting, for reasons\nother than that the canvas contents are tainted. This CL changes\nto distinguish these two causes, so that we recompute filters\non content-tainting change.\n\nBug: 778506\nChange-Id: I3cec8ef3b2772f2af78cdd4b290520113092cca6\nReviewed-on: https://chromium-review.googlesource.com/811767\nReviewed-by: Fredrik Söderquist <fs@opera.com>\nCommit-Queue: Chris Harrelson <chrishtr@chromium.org>\nCr-Commit-Position: refs/heads/master@{#522274}",
"lang": "C",
"project": "Chrome"
}
| 9
|
Determine whether the code is vulnerable or not.
|
[
"int http_process_request(struct session *s, struct channel *req, int an_bit)\n{\n\tstruct http_txn *txn = &s->txn;\n\tstruct http_msg *msg = &txn->req;\n\tstruct connection *cli_conn = objt_conn(req->prod->end);",
"\tif (unlikely(msg->msg_state < HTTP_MSG_BODY)) {\n\t\t/* we need more data */\n\t\tchannel_dont_connect(req);\n\t\treturn 0;\n\t}",
"\tDPRINTF(stderr,\"[%u] %s: session=%p b=%p, exp(r,w)=%u,%u bf=%08x bh=%d analysers=%02x\\n\",\n\t\tnow_ms, __FUNCTION__,\n\t\ts,\n\t\treq,\n\t\treq->rex, req->wex,\n\t\treq->flags,\n\t\treq->buf->i,\n\t\treq->analysers);",
"\tif (s->fe->comp || s->be->comp)\n\t\tselect_compression_request_header(s, req->buf);",
"\t/*\n\t * Right now, we know that we have processed the entire headers\n\t * and that unwanted requests have been filtered out. We can do\n\t * whatever we want with the remaining request. Also, now we\n\t * may have separate values for ->fe, ->be.\n\t */",
"\t/*\n\t * If HTTP PROXY is set we simply get remote server address parsing\n\t * incoming request. Note that this requires that a connection is\n\t * allocated on the server side.\n\t */\n\tif ((s->be->options & PR_O_HTTP_PROXY) && !(s->flags & SN_ADDR_SET)) {\n\t\tstruct connection *conn;\n\t\tchar *path;",
"\t\t/* Note that for now we don't reuse existing proxy connections */\n\t\tif (unlikely((conn = si_alloc_conn(req->cons, 0)) == NULL)) {\n\t\t\ttxn->req.msg_state = HTTP_MSG_ERROR;\n\t\t\ttxn->status = 500;\n\t\t\treq->analysers = 0;\n\t\t\tstream_int_retnclose(req->prod, http_error_message(s, HTTP_ERR_500));",
"\t\t\tif (!(s->flags & SN_ERR_MASK))\n\t\t\t\ts->flags |= SN_ERR_RESOURCE;\n\t\t\tif (!(s->flags & SN_FINST_MASK))\n\t\t\t\ts->flags |= SN_FINST_R;",
"\t\t\treturn 0;\n\t\t}",
"\t\tpath = http_get_path(txn);\n\t\turl2sa(req->buf->p + msg->sl.rq.u,\n\t\t path ? path - (req->buf->p + msg->sl.rq.u) : msg->sl.rq.u_l,\n\t\t &conn->addr.to, NULL);\n\t\t/* if the path was found, we have to remove everything between\n\t\t * req->buf->p + msg->sl.rq.u and path (excluded). If it was not\n\t\t * found, we need to replace from req->buf->p + msg->sl.rq.u for\n\t\t * u_l characters by a single \"/\".\n\t\t */\n\t\tif (path) {\n\t\t\tchar *cur_ptr = req->buf->p;\n\t\t\tchar *cur_end = cur_ptr + txn->req.sl.rq.l;\n\t\t\tint delta;",
"\t\t\tdelta = buffer_replace2(req->buf, req->buf->p + msg->sl.rq.u, path, NULL, 0);\n\t\t\thttp_msg_move_end(&txn->req, delta);\n\t\t\tcur_end += delta;\n\t\t\tif (http_parse_reqline(&txn->req, HTTP_MSG_RQMETH, cur_ptr, cur_end + 1, NULL, NULL) == NULL)\n\t\t\t\tgoto return_bad_req;\n\t\t}\n\t\telse {\n\t\t\tchar *cur_ptr = req->buf->p;\n\t\t\tchar *cur_end = cur_ptr + txn->req.sl.rq.l;\n\t\t\tint delta;",
"\t\t\tdelta = buffer_replace2(req->buf, req->buf->p + msg->sl.rq.u,\n\t\t\t\t\t\treq->buf->p + msg->sl.rq.u + msg->sl.rq.u_l, \"/\", 1);\n\t\t\thttp_msg_move_end(&txn->req, delta);\n\t\t\tcur_end += delta;\n\t\t\tif (http_parse_reqline(&txn->req, HTTP_MSG_RQMETH, cur_ptr, cur_end + 1, NULL, NULL) == NULL)\n\t\t\t\tgoto return_bad_req;\n\t\t}\n\t}",
"\t/*\n\t * 7: Now we can work with the cookies.\n\t * Note that doing so might move headers in the request, but\n\t * the fields will stay coherent and the URI will not move.\n\t * This should only be performed in the backend.\n\t */\n\tif ((s->be->cookie_name || s->be->appsession_name || s->fe->capture_name)\n\t && !(txn->flags & (TX_CLDENY|TX_CLTARPIT)))\n\t\tmanage_client_side_cookies(s, req);",
"\t/*\n\t * 8: the appsession cookie was looked up very early in 1.2,\n\t * so let's do the same now.\n\t */",
"\t/* It needs to look into the URI unless persistence must be ignored */\n\tif ((txn->sessid == NULL) && s->be->appsession_name && !(s->flags & SN_IGNORE_PRST)) {\n\t\tget_srv_from_appsession(s, req->buf->p + msg->sl.rq.u, msg->sl.rq.u_l);\n\t}",
"\t/* add unique-id if \"header-unique-id\" is specified */",
"\tif (!LIST_ISEMPTY(&s->fe->format_unique_id)) {\n\t\tif ((s->unique_id = pool_alloc2(pool2_uniqueid)) == NULL)\n\t\t\tgoto return_bad_req;\n\t\ts->unique_id[0] = '\\0';\n\t\tbuild_logline(s, s->unique_id, UNIQUEID_LEN, &s->fe->format_unique_id);\n\t}",
"\tif (s->fe->header_unique_id && s->unique_id) {\n\t\tchunk_printf(&trash, \"%s: %s\", s->fe->header_unique_id, s->unique_id);\n\t\tif (trash.len < 0)\n\t\t\tgoto return_bad_req;\n\t\tif (unlikely(http_header_add_tail2(&txn->req, &txn->hdr_idx, trash.str, trash.len) < 0))\n\t\t goto return_bad_req;\n\t}",
"\t/*\n\t * 9: add X-Forwarded-For if either the frontend or the backend\n\t * asks for it.\n\t */\n\tif ((s->fe->options | s->be->options) & PR_O_FWDFOR) {\n\t\tstruct hdr_ctx ctx = { .idx = 0 };\n\t\tif (!((s->fe->options | s->be->options) & PR_O_FF_ALWAYS) &&\n\t\t\thttp_find_header2(s->be->fwdfor_hdr_len ? s->be->fwdfor_hdr_name : s->fe->fwdfor_hdr_name,\n\t\t\t s->be->fwdfor_hdr_len ? s->be->fwdfor_hdr_len : s->fe->fwdfor_hdr_len,\n\t\t\t req->buf->p, &txn->hdr_idx, &ctx)) {\n\t\t\t/* The header is set to be added only if none is present\n\t\t\t * and we found it, so don't do anything.\n\t\t\t */\n\t\t}\n\t\telse if (cli_conn && cli_conn->addr.from.ss_family == AF_INET) {\n\t\t\t/* Add an X-Forwarded-For header unless the source IP is\n\t\t\t * in the 'except' network range.\n\t\t\t */\n\t\t\tif ((!s->fe->except_mask.s_addr ||\n\t\t\t (((struct sockaddr_in *)&cli_conn->addr.from)->sin_addr.s_addr & s->fe->except_mask.s_addr)\n\t\t\t != s->fe->except_net.s_addr) &&\n\t\t\t (!s->be->except_mask.s_addr ||\n\t\t\t (((struct sockaddr_in *)&cli_conn->addr.from)->sin_addr.s_addr & s->be->except_mask.s_addr)\n\t\t\t != s->be->except_net.s_addr)) {\n\t\t\t\tint len;\n\t\t\t\tunsigned char *pn;\n\t\t\t\tpn = (unsigned char *)&((struct sockaddr_in *)&cli_conn->addr.from)->sin_addr;",
"\t\t\t\t/* Note: we rely on the backend to get the header name to be used for\n\t\t\t\t * x-forwarded-for, because the header is really meant for the backends.\n\t\t\t\t * However, if the backend did not specify any option, we have to rely\n\t\t\t\t * on the frontend's header name.\n\t\t\t\t */\n\t\t\t\tif (s->be->fwdfor_hdr_len) {\n\t\t\t\t\tlen = s->be->fwdfor_hdr_len;\n\t\t\t\t\tmemcpy(trash.str, s->be->fwdfor_hdr_name, len);\n\t\t\t\t} else {\n\t\t\t\t\tlen = s->fe->fwdfor_hdr_len;\n\t\t\t\t\tmemcpy(trash.str, s->fe->fwdfor_hdr_name, len);\n\t\t\t\t}\n\t\t\t\tlen += snprintf(trash.str + len, trash.size - len, \": %d.%d.%d.%d\", pn[0], pn[1], pn[2], pn[3]);",
"\t\t\t\tif (unlikely(http_header_add_tail2(&txn->req, &txn->hdr_idx, trash.str, len) < 0))\n\t\t\t\t\tgoto return_bad_req;\n\t\t\t}\n\t\t}\n\t\telse if (cli_conn && cli_conn->addr.from.ss_family == AF_INET6) {\n\t\t\t/* FIXME: for the sake of completeness, we should also support\n\t\t\t * 'except' here, although it is mostly useless in this case.\n\t\t\t */\n\t\t\tint len;\n\t\t\tchar pn[INET6_ADDRSTRLEN];\n\t\t\tinet_ntop(AF_INET6,\n\t\t\t\t (const void *)&((struct sockaddr_in6 *)(&cli_conn->addr.from))->sin6_addr,\n\t\t\t\t pn, sizeof(pn));",
"\t\t\t/* Note: we rely on the backend to get the header name to be used for\n\t\t\t * x-forwarded-for, because the header is really meant for the backends.\n\t\t\t * However, if the backend did not specify any option, we have to rely\n\t\t\t * on the frontend's header name.\n\t\t\t */\n\t\t\tif (s->be->fwdfor_hdr_len) {\n\t\t\t\tlen = s->be->fwdfor_hdr_len;\n\t\t\t\tmemcpy(trash.str, s->be->fwdfor_hdr_name, len);\n\t\t\t} else {\n\t\t\t\tlen = s->fe->fwdfor_hdr_len;\n\t\t\t\tmemcpy(trash.str, s->fe->fwdfor_hdr_name, len);\n\t\t\t}\n\t\t\tlen += snprintf(trash.str + len, trash.size - len, \": %s\", pn);",
"\t\t\tif (unlikely(http_header_add_tail2(&txn->req, &txn->hdr_idx, trash.str, len) < 0))\n\t\t\t\tgoto return_bad_req;\n\t\t}\n\t}",
"\t/*\n\t * 10: add X-Original-To if either the frontend or the backend\n\t * asks for it.\n\t */\n\tif ((s->fe->options | s->be->options) & PR_O_ORGTO) {",
"\t\t/* FIXME: don't know if IPv6 can handle that case too. */\n\t\tif (cli_conn && cli_conn->addr.from.ss_family == AF_INET) {\n\t\t\t/* Add an X-Original-To header unless the destination IP is\n\t\t\t * in the 'except' network range.\n\t\t\t */\n\t\t\tconn_get_to_addr(cli_conn);",
"\t\t\tif (cli_conn->addr.to.ss_family == AF_INET &&\n\t\t\t ((!s->fe->except_mask_to.s_addr ||\n\t\t\t (((struct sockaddr_in *)&cli_conn->addr.to)->sin_addr.s_addr & s->fe->except_mask_to.s_addr)\n\t\t\t != s->fe->except_to.s_addr) &&\n\t\t\t (!s->be->except_mask_to.s_addr ||\n\t\t\t (((struct sockaddr_in *)&cli_conn->addr.to)->sin_addr.s_addr & s->be->except_mask_to.s_addr)\n\t\t\t != s->be->except_to.s_addr))) {\n\t\t\t\tint len;\n\t\t\t\tunsigned char *pn;\n\t\t\t\tpn = (unsigned char *)&((struct sockaddr_in *)&cli_conn->addr.to)->sin_addr;",
"\t\t\t\t/* Note: we rely on the backend to get the header name to be used for\n\t\t\t\t * x-original-to, because the header is really meant for the backends.\n\t\t\t\t * However, if the backend did not specify any option, we have to rely\n\t\t\t\t * on the frontend's header name.\n\t\t\t\t */\n\t\t\t\tif (s->be->orgto_hdr_len) {\n\t\t\t\t\tlen = s->be->orgto_hdr_len;\n\t\t\t\t\tmemcpy(trash.str, s->be->orgto_hdr_name, len);\n\t\t\t\t} else {\n\t\t\t\t\tlen = s->fe->orgto_hdr_len;\n\t\t\t\t\tmemcpy(trash.str, s->fe->orgto_hdr_name, len);\n\t\t\t\t}\n\t\t\t\tlen += snprintf(trash.str + len, trash.size - len, \": %d.%d.%d.%d\", pn[0], pn[1], pn[2], pn[3]);",
"\t\t\t\tif (unlikely(http_header_add_tail2(&txn->req, &txn->hdr_idx, trash.str, len) < 0))\n\t\t\t\t\tgoto return_bad_req;\n\t\t\t}\n\t\t}\n\t}",
"\t/* 11: add \"Connection: close\" or \"Connection: keep-alive\" if needed and not yet set.\n\t * If an \"Upgrade\" token is found, the header is left untouched in order not to have\n\t * to deal with some servers bugs : some of them fail an Upgrade if anything but\n\t * \"Upgrade\" is present in the Connection header.\n\t */\n\tif (!(txn->flags & TX_HDR_CONN_UPG) &&\n\t (((txn->flags & TX_CON_WANT_MSK) != TX_CON_WANT_TUN) ||\n\t ((s->fe->options & PR_O_HTTP_MODE) == PR_O_HTTP_PCL ||\n\t (s->be->options & PR_O_HTTP_MODE) == PR_O_HTTP_PCL))) {\n\t\tunsigned int want_flags = 0;",
"\t\tif (msg->flags & HTTP_MSGF_VER_11) {\n\t\t\tif (((txn->flags & TX_CON_WANT_MSK) >= TX_CON_WANT_SCL ||\n\t\t\t ((s->fe->options & PR_O_HTTP_MODE) == PR_O_HTTP_PCL ||\n\t\t\t (s->be->options & PR_O_HTTP_MODE) == PR_O_HTTP_PCL)) &&\n\t\t\t !((s->fe->options2|s->be->options2) & PR_O2_FAKE_KA))\n\t\t\t\twant_flags |= TX_CON_CLO_SET;\n\t\t} else {\n\t\t\tif (((txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_KAL &&\n\t\t\t ((s->fe->options & PR_O_HTTP_MODE) != PR_O_HTTP_PCL &&\n\t\t\t (s->be->options & PR_O_HTTP_MODE) != PR_O_HTTP_PCL)) ||\n\t\t\t ((s->fe->options2|s->be->options2) & PR_O2_FAKE_KA))\n\t\t\t\twant_flags |= TX_CON_KAL_SET;\n\t\t}",
"\t\tif (want_flags != (txn->flags & (TX_CON_CLO_SET|TX_CON_KAL_SET)))\n\t\t\thttp_change_connection_header(txn, msg, want_flags);\n\t}",
"\n\t/* If we have no server assigned yet and we're balancing on url_param\n\t * with a POST request, we may be interested in checking the body for\n\t * that parameter. This will be done in another analyser.\n\t */\n\tif (!(s->flags & (SN_ASSIGNED|SN_DIRECT)) &&\n\t s->txn.meth == HTTP_METH_POST && s->be->url_param_name != NULL &&\n\t (msg->flags & (HTTP_MSGF_CNT_LEN|HTTP_MSGF_TE_CHNK))) {\n\t\tchannel_dont_connect(req);\n\t\treq->analysers |= AN_REQ_HTTP_BODY;\n\t}",
"\tif (msg->flags & HTTP_MSGF_XFER_LEN) {\n\t\treq->analysers |= AN_REQ_HTTP_XFER_BODY;\n#ifdef TCP_QUICKACK\n\t\t/* We expect some data from the client. Unless we know for sure\n\t\t * we already have a full request, we have to re-enable quick-ack\n\t\t * in case we previously disabled it, otherwise we might cause\n\t\t * the client to delay further data.\n\t\t */\n\t\tif ((s->listener->options & LI_O_NOQUICKACK) &&\n\t\t cli_conn && conn_ctrl_ready(cli_conn) &&\n\t\t ((msg->flags & HTTP_MSGF_TE_CHNK) ||\n\t\t (msg->body_len > req->buf->i - txn->req.eoh - 2)))\n\t\t\tsetsockopt(cli_conn->t.sock.fd, IPPROTO_TCP, TCP_QUICKACK, &one, sizeof(one));\n#endif\n\t}",
"\t/*************************************************************\n\t * OK, that's finished for the headers. We have done what we *\n\t * could. Let's switch to the DATA state. *\n\t ************************************************************/\n\treq->analyse_exp = TICK_ETERNITY;\n\treq->analysers &= ~an_bit;",
"\t/* if the server closes the connection, we want to immediately react\n\t * and close the socket to save packets and syscalls.\n\t */\n\tif (!(req->analysers & AN_REQ_HTTP_XFER_BODY))\n\t\treq->cons->flags |= SI_FL_NOHALF;",
"\ts->logs.tv_request = now;\n\t/* OK let's go on with the BODY now */\n\treturn 1;",
" return_bad_req: /* let's centralize all bad requests */\n\tif (unlikely(msg->msg_state == HTTP_MSG_ERROR) || msg->err_pos >= 0) {\n\t\t/* we detected a parsing error. We want to archive this request\n\t\t * in the dedicated proxy area for later troubleshooting.\n\t\t */\n\t\thttp_capture_bad_message(&s->fe->invalid_req, s, msg, msg->msg_state, s->fe);\n\t}",
"\ttxn->req.msg_state = HTTP_MSG_ERROR;\n\ttxn->status = 400;\n\treq->analysers = 0;\n\tstream_int_retnclose(req->prod, http_error_message(s, HTTP_ERR_400));",
"\ts->fe->fe_counters.failed_req++;\n\tif (s->listener->counters)\n\t\ts->listener->counters->failed_req++;",
"\tif (!(s->flags & SN_ERR_MASK))\n\t\ts->flags |= SN_ERR_PRXCOND;\n\tif (!(s->flags & SN_FINST_MASK))\n\t\ts->flags |= SN_FINST_R;\n\treturn 0;\n}\n"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
BIGVUL
|
{
"CVE ID": "CVE-2014-6269",
"CVE Page": "https://www.cvedetails.com/cve/CVE-2014-6269/",
"CWE ID": "CWE-189",
"codeLink": "https://git.haproxy.org/?p=haproxy-1.5.git;a=commitdiff;h=b4d05093bc89f71377230228007e69a1434c1a0c",
"commit_id": "b4d05093bc89f71377230228007e69a1434c1a0c",
"commit_message": null,
"lang": "C",
"project": "haproxy"
}
| 10
|
Determine whether the code is vulnerable or not.
|
[
"void crypto_aes_encrypt_x86(struct crypto_aes_ctx *ctx, u8 *dst, const u8 *src)\n{\n\taes_enc_blk(ctx, dst, src);\n}\n"
] |
[
1
] |
BIGVUL
|
{
"CVE ID": "CVE-2013-7421",
"CVE Page": "https://www.cvedetails.com/cve/CVE-2013-7421/",
"CWE ID": "CWE-264",
"codeLink": "https://github.com/torvalds/linux/commit/5d26a105b5a73e5635eae0629b42fa0a90e07b7b",
"commit_id": "5d26a105b5a73e5635eae0629b42fa0a90e07b7b",
"commit_message": "crypto: prefix module autoloading with \"crypto-\"\n\nThis prefixes all crypto module loading with \"crypto-\" so we never run\nthe risk of exposing module auto-loading to userspace via a crypto API,\nas demonstrated by Mathias Krause:\n\nhttps://lkml.org/lkml/2013/3/4/70\n\nSigned-off-by: Kees Cook <keescook@chromium.org>\nSigned-off-by: Herbert Xu <herbert@gondor.apana.org.au>",
"lang": "C",
"project": "linux"
}
| 11
|
Determine whether the code is vulnerable or not.
|
[
"error::Error GLES2DecoderPassthroughImpl::DoDeletePathsCHROMIUM(GLuint path,\n GLsizei range) {\n NOTIMPLEMENTED();\n return error::kNoError;\n}\n"
] |
[
1
] |
BIGVUL
|
{
"CVE ID": "CVE-2016-5219",
"CVE Page": "https://www.cvedetails.com/cve/CVE-2016-5219/",
"CWE ID": "CWE-416",
"codeLink": "https://github.com/chromium/chromium/commit/a4150b688a754d3d10d2ca385155b1c95d77d6ae",
"commit_id": "a4150b688a754d3d10d2ca385155b1c95d77d6ae",
"commit_message": "Add GL_PROGRAM_COMPLETION_QUERY_CHROMIUM\n\nThis makes the query of GL_COMPLETION_STATUS_KHR to programs much\ncheaper by minimizing the round-trip to the GPU thread.\n\nBug: 881152, 957001\nChange-Id: Iadfa798af29225e752c710ca5c25f50b3dd3101a\nReviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1586630\nCommit-Queue: Kenneth Russell <kbr@chromium.org>\nReviewed-by: Kentaro Hara <haraken@chromium.org>\nReviewed-by: Geoff Lang <geofflang@chromium.org>\nReviewed-by: Kenneth Russell <kbr@chromium.org>\nCr-Commit-Position: refs/heads/master@{#657568}",
"lang": "C",
"project": "Chrome"
}
| 12
|
Determine whether the code is vulnerable or not.
|
[
"void VideoCaptureImpl::OnBufferCreated(int32_t buffer_id,\n mojo::ScopedSharedBufferHandle handle) {\n DVLOG(1) << __func__ << \" buffer_id: \" << buffer_id;\n DCHECK(io_thread_checker_.CalledOnValidThread());\n DCHECK(handle.is_valid());\n \n base::SharedMemoryHandle memory_handle;\n size_t memory_size = 0;",
" bool read_only_flag = false;",
" \n const MojoResult result = mojo::UnwrapSharedMemoryHandle(",
" std::move(handle), &memory_handle, &memory_size, &read_only_flag);",
" DCHECK_EQ(MOJO_RESULT_OK, result);\n DCHECK_GT(memory_size, 0u);\n ",
"",
" std::unique_ptr<base::SharedMemory> shm(\n new base::SharedMemory(memory_handle, true /* read_only */));\n if (!shm->Map(memory_size)) {\n DLOG(ERROR) << \"OnBufferCreated: Map failed.\";\n return;\n }\n const bool inserted =\n client_buffers_\n .insert(std::make_pair(buffer_id,\n new ClientBuffer(std::move(shm), memory_size)))\n .second;\n DCHECK(inserted);\n}"
] |
[
1,
0,
1,
0,
1,
0,
1
] |
BIGVUL
|
{
"CVE ID": "CVE-2018-6063",
"CVE Page": "https://www.cvedetails.com/cve/CVE-2018-6063/",
"CWE ID": "CWE-787",
"codeLink": "https://github.com/chromium/chromium/commit/673ce95d481ea9368c4d4d43ac756ba1d6d9e608",
"commit_id": "673ce95d481ea9368c4d4d43ac756ba1d6d9e608",
"commit_message": "Correct mojo::WrapSharedMemoryHandle usage\n\nFixes some incorrect uses of mojo::WrapSharedMemoryHandle which\nwere assuming that the call actually has any control over the memory\nprotection applied to a handle when mapped.\n\nWhere fixing usage is infeasible for this CL, TODOs are added to\nannotate follow-up work.\n\nAlso updates the API and documentation to (hopefully) improve clarity\nand avoid similar mistakes from being made in the future.\n\nBUG=792900\n\nCq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel\nChange-Id: I0578aaa9ca3bfcb01aaf2451315d1ede95458477\nReviewed-on: https://chromium-review.googlesource.com/818282\nReviewed-by: Wei Li <weili@chromium.org>\nReviewed-by: Lei Zhang <thestig@chromium.org>\nReviewed-by: John Abd-El-Malek <jam@chromium.org>\nReviewed-by: Daniel Cheng <dcheng@chromium.org>\nReviewed-by: Sadrul Chowdhury <sadrul@chromium.org>\nReviewed-by: Yuzhu Shen <yzshen@chromium.org>\nReviewed-by: Robert Sesek <rsesek@chromium.org>\nCommit-Queue: Ken Rockot <rockot@chromium.org>\nCr-Commit-Position: refs/heads/master@{#530268}",
"lang": "C",
"project": "Chrome"
}
| 13
|
Determine whether the code is vulnerable or not.
|
[
"void VideoCaptureImpl::OnBufferCreated(int32_t buffer_id,\n mojo::ScopedSharedBufferHandle handle) {\n DVLOG(1) << __func__ << \" buffer_id: \" << buffer_id;\n DCHECK(io_thread_checker_.CalledOnValidThread());\n DCHECK(handle.is_valid());\n \n base::SharedMemoryHandle memory_handle;\n size_t memory_size = 0;",
" mojo::UnwrappedSharedMemoryHandleProtection protection;",
" \n const MojoResult result = mojo::UnwrapSharedMemoryHandle(",
" std::move(handle), &memory_handle, &memory_size, &protection);",
" DCHECK_EQ(MOJO_RESULT_OK, result);\n DCHECK_GT(memory_size, 0u);\n ",
" // TODO(https://crbug.com/803136): We should also be able to assert that the\n // unwrapped handle was shared for read-only mapping. That condition is not\n // currently guaranteed to be met.\n",
" std::unique_ptr<base::SharedMemory> shm(\n new base::SharedMemory(memory_handle, true /* read_only */));\n if (!shm->Map(memory_size)) {\n DLOG(ERROR) << \"OnBufferCreated: Map failed.\";\n return;\n }\n const bool inserted =\n client_buffers_\n .insert(std::make_pair(buffer_id,\n new ClientBuffer(std::move(shm), memory_size)))\n .second;\n DCHECK(inserted);\n}"
] |
[
1,
2,
1,
2,
1,
2,
1
] |
BIGVUL
|
{
"CVE ID": "CVE-2018-6063",
"CVE Page": "https://www.cvedetails.com/cve/CVE-2018-6063/",
"CWE ID": "CWE-787",
"codeLink": "https://github.com/chromium/chromium/commit/673ce95d481ea9368c4d4d43ac756ba1d6d9e608",
"commit_id": "673ce95d481ea9368c4d4d43ac756ba1d6d9e608",
"commit_message": "Correct mojo::WrapSharedMemoryHandle usage\n\nFixes some incorrect uses of mojo::WrapSharedMemoryHandle which\nwere assuming that the call actually has any control over the memory\nprotection applied to a handle when mapped.\n\nWhere fixing usage is infeasible for this CL, TODOs are added to\nannotate follow-up work.\n\nAlso updates the API and documentation to (hopefully) improve clarity\nand avoid similar mistakes from being made in the future.\n\nBUG=792900\n\nCq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel\nChange-Id: I0578aaa9ca3bfcb01aaf2451315d1ede95458477\nReviewed-on: https://chromium-review.googlesource.com/818282\nReviewed-by: Wei Li <weili@chromium.org>\nReviewed-by: Lei Zhang <thestig@chromium.org>\nReviewed-by: John Abd-El-Malek <jam@chromium.org>\nReviewed-by: Daniel Cheng <dcheng@chromium.org>\nReviewed-by: Sadrul Chowdhury <sadrul@chromium.org>\nReviewed-by: Yuzhu Shen <yzshen@chromium.org>\nReviewed-by: Robert Sesek <rsesek@chromium.org>\nCommit-Queue: Ken Rockot <rockot@chromium.org>\nCr-Commit-Position: refs/heads/master@{#530268}",
"lang": "C",
"project": "Chrome"
}
| 13
|
Determine whether the code is vulnerable or not.
|
[
"void FFmpegVideoDecodeEngine::DecodeFrame(scoped_refptr<Buffer> buffer) {\n scoped_refptr<VideoFrame> video_frame;",
" AVPacket packet;\n av_init_packet(&packet);\n packet.data = const_cast<uint8*>(buffer->GetData());\n packet.size = buffer->GetDataSize();",
" PipelineStatistics statistics;\n statistics.video_bytes_decoded = buffer->GetDataSize();",
" codec_context_->reordered_opaque = buffer->GetTimestamp().InMicroseconds();",
" av_frame_->reordered_opaque = codec_context_->reordered_opaque;",
" int frame_decoded = 0;\n int result = avcodec_decode_video2(codec_context_,\n av_frame_.get(),\n &frame_decoded,\n &packet);",
" if (result < 0) {\n LOG(ERROR) << \"Error decoding a video frame with timestamp: \"\n << buffer->GetTimestamp().InMicroseconds() << \" us, duration: \"\n << buffer->GetDuration().InMicroseconds() << \" us, packet size: \"\n << buffer->GetDataSize() << \" bytes\";\n event_handler_->OnError();\n return;\n }",
" if (frame_decoded == 0) {\n if (buffer->IsEndOfStream()) { // We had started flushing.\n event_handler_->ConsumeVideoFrame(video_frame, statistics);\n output_eos_reached_ = true;\n } else {\n ReadInput();\n }\n return;\n }",
" if (!av_frame_->data[VideoFrame::kYPlane] ||\n !av_frame_->data[VideoFrame::kUPlane] ||\n !av_frame_->data[VideoFrame::kVPlane]) {\n event_handler_->OnError();\n return;\n }",
" DCHECK_LE(av_frame_->repeat_pict, 2); // Sanity check.\n AVRational doubled_time_base;\n doubled_time_base.num = frame_rate_denominator_;\n doubled_time_base.den = frame_rate_numerator_ * 2;",
" base::TimeDelta timestamp =\n base::TimeDelta::FromMicroseconds(av_frame_->reordered_opaque);\n base::TimeDelta duration =\n ConvertFromTimeBase(doubled_time_base, 2 + av_frame_->repeat_pict);",
" DCHECK(frame_queue_available_.size());\n video_frame = frame_queue_available_.front();\n frame_queue_available_.pop_front();",
" size_t height = codec_context_->height;\n CopyPlane(VideoFrame::kYPlane, video_frame.get(), av_frame_.get(), height);\n CopyPlane(VideoFrame::kUPlane, video_frame.get(), av_frame_.get(), height);\n CopyPlane(VideoFrame::kVPlane, video_frame.get(), av_frame_.get(), height);",
" video_frame->SetTimestamp(timestamp);\n video_frame->SetDuration(duration);",
" pending_output_buffers_--;\n event_handler_->ConsumeVideoFrame(video_frame, statistics);\n}\n"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
BIGVUL
|
{
"CVE ID": "CVE-2011-2843",
"CVE Page": "https://www.cvedetails.com/cve/CVE-2011-2843/",
"CWE ID": "CWE-119",
"codeLink": "https://github.com/chromium/chromium/commit/d304b5ec1b16766ea2cb552a27dc14df848d6a0e",
"commit_id": "d304b5ec1b16766ea2cb552a27dc14df848d6a0e",
"commit_message": "Don't forget the ffmpeg input buffer padding when allocating a codec's\nextradata buffer.\n\nBUG=82438\nReview URL: http://codereview.chromium.org/7137002\n\ngit-svn-id: svn://svn.chromium.org/chrome/trunk/src@88354 0039d316-1c4b-4281-b951-d872f2087c98",
"lang": "C",
"project": "Chrome"
}
| 14
|
Determine whether the code is vulnerable or not.
|
[
"void Performance::BuildJSONValue(V8ObjectBuilder& builder) const {\n builder.AddNumber(\"timeOrigin\", timeOrigin());\n}\n"
] |
[
1
] |
BIGVUL
|
{
"CVE ID": "CVE-2018-6159",
"CVE Page": "https://www.cvedetails.com/cve/CVE-2018-6159/",
"CWE ID": "CWE-200",
"codeLink": "https://github.com/chromium/chromium/commit/01b42e2bc2aac531b17596729ae4e5c223ae7124",
"commit_id": "01b42e2bc2aac531b17596729ae4e5c223ae7124",
"commit_message": "Fix timing allow check algorithm for service workers\n\nThis CL uses the OriginalURLViaServiceWorker() in the timing allow check\nalgorithm if the response WasFetchedViaServiceWorker(). This way, if a\nservice worker changes a same origin request to become cross origin,\nthen the timing allow check algorithm will still fail.\n\nresource-timing-worker.js is changed so it avoids an empty Response,\nwhich is an odd case in terms of same origin checks.\n\nBug: 837275\nChange-Id: I7e497a6fcc2ee14244121b915ca5f5cceded417a\nReviewed-on: https://chromium-review.googlesource.com/1038229\nCommit-Queue: Nicolás Peña Moreno <npm@chromium.org>\nReviewed-by: Yoav Weiss <yoav@yoav.ws>\nReviewed-by: Timothy Dresser <tdresser@chromium.org>\nCr-Commit-Position: refs/heads/master@{#555476}",
"lang": "C",
"project": "Chrome"
}
| 15
|
Determine whether the code is vulnerable or not.
|
[
"void RenderView::OnRedo() {\n if (!webview())\n return;",
" webview()->focusedFrame()->executeCommand(WebString::fromUTF8(\"Redo\"));\n}\n"
] |
[
1,
1
] |
BIGVUL
|
{
"CVE ID": "CVE-2011-2861",
"CVE Page": "https://www.cvedetails.com/cve/CVE-2011-2861/",
"CWE ID": "CWE-20",
"codeLink": "https://github.com/chromium/chromium/commit/8262245d384be025f13e2a5b3a03b7e5c98374ce",
"commit_id": "8262245d384be025f13e2a5b3a03b7e5c98374ce",
"commit_message": "DevTools: move DevToolsAgent/Client into content.\n\nBUG=84078\nTEST=\n\nReview URL: http://codereview.chromium.org/7461019\n\ngit-svn-id: svn://svn.chromium.org/chrome/trunk/src@93596 0039d316-1c4b-4281-b951-d872f2087c98",
"lang": "C",
"project": "Chrome"
}
| 16
|
Determine whether the code is vulnerable or not.
|
[
"void RenderWidgetHostImpl::AddMouseEventCallback(\n const MouseEventCallback& callback) {\n mouse_event_callbacks_.push_back(callback);\n}\n"
] |
[
1
] |
BIGVUL
|
{
"CVE ID": "CVE-2016-1647",
"CVE Page": "https://www.cvedetails.com/cve/CVE-2016-1647/",
"CWE ID": null,
"codeLink": "https://github.com/chromium/chromium/commit/e5787005a9004d7be289cc649c6ae4f3051996cd",
"commit_id": "e5787005a9004d7be289cc649c6ae4f3051996cd",
"commit_message": "Check that RWHI isn't deleted manually while owned by a scoped_ptr in RVHI\n\nBUG=590284\n\nReview URL: https://codereview.chromium.org/1747183002\n\nCr-Commit-Position: refs/heads/master@{#378844}",
"lang": "C",
"project": "Chrome"
}
| 17
|
Determine whether the code is vulnerable or not.
|
[
"void HTMLFormControlElement::didChangeForm() {\n ListedElement::didChangeForm();\n formOwnerSetNeedsValidityCheck();\n if (formOwner() && isConnected() && canBeSuccessfulSubmitButton())\n formOwner()->invalidateDefaultButtonStyle();\n}\n"
] |
[
1
] |
BIGVUL
|
{
"CVE ID": "CVE-2017-5016",
"CVE Page": "https://www.cvedetails.com/cve/CVE-2017-5016/",
"CWE ID": "CWE-1021",
"codeLink": "https://github.com/chromium/chromium/commit/a8e17a3031b6ad69c399e5e04dd0084e577097fc",
"commit_id": "a8e17a3031b6ad69c399e5e04dd0084e577097fc",
"commit_message": "Form validation: Do not show validation bubble if the page is invisible.\n\nBUG=673163\n\nReview-Url: https://codereview.chromium.org/2572813003\nCr-Commit-Position: refs/heads/master@{#438476}",
"lang": "C",
"project": "Chrome"
}
| 18
|
Determine whether the code is vulnerable or not.
|
[
"IMPEG2D_ERROR_CODES_T impeg2d_pre_pic_dec_proc(dec_state_t *ps_dec)\n{\n WORD32 u4_get_disp;\n pic_buf_t *ps_disp_pic;\n IMPEG2D_ERROR_CODES_T e_error = (IMPEG2D_ERROR_CODES_T)IVD_ERROR_NONE;",
" u4_get_disp = 0;\n ps_disp_pic = NULL;",
" /* Field Picture */\n if(ps_dec->u2_picture_structure != FRAME_PICTURE)\n {\n ps_dec->u2_num_vert_mb = (ps_dec->u2_vertical_size + 31) >> 5;",
" if(ps_dec->u2_num_flds_decoded == 0)\n {\n pic_buf_t *ps_pic_buf;\n u4_get_disp = 1;",
" ps_pic_buf = impeg2_buf_mgr_get_next_free(ps_dec->pv_pic_buf_mg, &ps_dec->i4_cur_buf_id);",
" if (NULL == ps_pic_buf)\n {\n return IMPEG2D_NO_FREE_BUF_ERR;\n }",
" impeg2_buf_mgr_set_status((buf_mgr_t *)ps_dec->pv_pic_buf_mg, ps_dec->i4_cur_buf_id, BUF_MGR_DISP);\n impeg2_buf_mgr_set_status((buf_mgr_t *)ps_dec->pv_pic_buf_mg, ps_dec->i4_cur_buf_id, BUF_MGR_REF);",
" ps_pic_buf->u4_ts = ps_dec->u4_inp_ts;\n ps_pic_buf->e_pic_type = ps_dec->e_pic_type;\n ps_dec->ps_cur_pic = ps_pic_buf;\n ps_dec->s_cur_frm_buf.pu1_y = ps_pic_buf->pu1_y;\n ps_dec->s_cur_frm_buf.pu1_u = ps_pic_buf->pu1_u;\n ps_dec->s_cur_frm_buf.pu1_v = ps_pic_buf->pu1_v;\n }",
" if(ps_dec->u2_picture_structure == TOP_FIELD)\n {\n ps_dec->u2_fld_parity = TOP;\n }\n else\n {\n ps_dec->u2_fld_parity = BOTTOM;\n }\n ps_dec->u2_field_dct = 0;\n ps_dec->u2_read_dct_type = 0;\n ps_dec->u2_read_motion_type = 1;\n ps_dec->u2_fld_pic = 1;\n ps_dec->u2_frm_pic = 0;\n ps_dec->ps_func_forw_or_back = gas_impeg2d_func_fld_fw_or_bk;\n ps_dec->ps_func_bi_direct = gas_impeg2d_func_fld_bi_direct;\n }\n /* Frame Picture */\n else\n {\n pic_buf_t *ps_pic_buf;",
"\n ps_dec->u2_num_vert_mb = (ps_dec->u2_vertical_size + 15) >> 4;\n u4_get_disp = 1;\n ps_pic_buf = impeg2_buf_mgr_get_next_free(ps_dec->pv_pic_buf_mg, &ps_dec->i4_cur_buf_id);",
" if (NULL == ps_pic_buf)\n {\n return IMPEG2D_NO_FREE_BUF_ERR;\n }\n impeg2_buf_mgr_set_status((buf_mgr_t *)ps_dec->pv_pic_buf_mg, ps_dec->i4_cur_buf_id, BUF_MGR_DISP);\n impeg2_buf_mgr_set_status((buf_mgr_t *)ps_dec->pv_pic_buf_mg, ps_dec->i4_cur_buf_id, BUF_MGR_REF);",
" ps_pic_buf->u4_ts = ps_dec->u4_inp_ts;\n ps_pic_buf->e_pic_type = ps_dec->e_pic_type;\n ps_dec->ps_cur_pic = ps_pic_buf;\n ps_dec->s_cur_frm_buf.pu1_y = ps_pic_buf->pu1_y;\n ps_dec->s_cur_frm_buf.pu1_u = ps_pic_buf->pu1_u;\n ps_dec->s_cur_frm_buf.pu1_v = ps_pic_buf->pu1_v;",
"\n if(ps_dec->u2_frame_pred_frame_dct == 0)\n {\n ps_dec->u2_read_dct_type = 1;\n ps_dec->u2_read_motion_type = 1;\n }\n else\n {\n ps_dec->u2_read_dct_type = 0;\n ps_dec->u2_read_motion_type = 0;\n ps_dec->u2_motion_type = 2;\n ps_dec->u2_field_dct = 0;\n }",
" ps_dec->u2_fld_parity = TOP;\n ps_dec->u2_fld_pic = 0;\n ps_dec->u2_frm_pic = 1;\n ps_dec->ps_func_forw_or_back = gas_impeg2d_func_frm_fw_or_bk;\n ps_dec->ps_func_bi_direct = gas_impeg2d_func_frm_bi_direct;\n }\n ps_dec->u2_def_dc_pred[Y_LUMA] = 128 << ps_dec->u2_intra_dc_precision;\n ps_dec->u2_def_dc_pred[U_CHROMA] = 128 << ps_dec->u2_intra_dc_precision;\n ps_dec->u2_def_dc_pred[V_CHROMA] = 128 << ps_dec->u2_intra_dc_precision;\n ps_dec->u2_num_mbs_left = ps_dec->u2_num_horiz_mb * ps_dec->u2_num_vert_mb;\n if(u4_get_disp)\n {\n if(ps_dec->u4_num_frames_decoded > 1)\n {\n ps_disp_pic = impeg2_disp_mgr_get(&ps_dec->s_disp_mgr, &ps_dec->i4_disp_buf_id);\n }\n ps_dec->ps_disp_pic = ps_disp_pic;\n if(ps_disp_pic)\n {\n if(1 == ps_dec->u4_share_disp_buf)\n {\n ps_dec->ps_disp_frm_buf->pv_y_buf = ps_disp_pic->pu1_y;\n if(IV_YUV_420P == ps_dec->i4_chromaFormat)\n {\n ps_dec->ps_disp_frm_buf->pv_u_buf = ps_disp_pic->pu1_u;\n ps_dec->ps_disp_frm_buf->pv_v_buf = ps_disp_pic->pu1_v;\n }\n else\n {\n UWORD8 *pu1_buf;",
" pu1_buf = ps_dec->as_disp_buffers[ps_disp_pic->i4_buf_id].pu1_bufs[1];\n ps_dec->ps_disp_frm_buf->pv_u_buf = pu1_buf;",
" pu1_buf = ps_dec->as_disp_buffers[ps_disp_pic->i4_buf_id].pu1_bufs[2];\n ps_dec->ps_disp_frm_buf->pv_v_buf = pu1_buf;\n }\n }\n }\n }",
"\n switch(ps_dec->e_pic_type)\n {\n case I_PIC:\n {\n ps_dec->pf_decode_slice = impeg2d_dec_i_slice;\n break;\n }\n case D_PIC:\n {\n ps_dec->pf_decode_slice = impeg2d_dec_d_slice;\n break;\n }\n case P_PIC:\n {\n ps_dec->pf_decode_slice = impeg2d_dec_p_b_slice;\n ps_dec->pu2_mb_type = gau2_impeg2d_p_mb_type;\n break;\n }\n case B_PIC:\n {\n ps_dec->pf_decode_slice = impeg2d_dec_p_b_slice;\n ps_dec->pu2_mb_type = gau2_impeg2d_b_mb_type;\n break;\n }\n default:\n return IMPEG2D_INVALID_PIC_TYPE;\n }",
" /*************************************************************************/\n /* Set the reference pictures */\n /*************************************************************************/",
" /* Error resilience: If forward and backward pictures are going to be NULL*/\n /* then assign both to the current */\n /* if one of them NULL then we will assign the non null to the NULL one */",
" if(ps_dec->e_pic_type == P_PIC)\n {\n if (NULL == ps_dec->as_recent_fld[1][0].pu1_y)\n {\n ps_dec->as_recent_fld[1][0] = ps_dec->s_cur_frm_buf;\n }\n if (NULL == ps_dec->as_recent_fld[1][1].pu1_y)\n {\n impeg2d_get_bottom_field_buf(&ps_dec->s_cur_frm_buf, &ps_dec->as_recent_fld[1][1],\n ps_dec->u2_frame_width);\n }",
" ps_dec->as_ref_buf[FORW][TOP] = ps_dec->as_recent_fld[1][0];\n ps_dec->as_ref_buf[FORW][BOTTOM] = ps_dec->as_recent_fld[1][1];",
"\n }\n else if(ps_dec->e_pic_type == B_PIC)\n {\n if((NULL == ps_dec->as_recent_fld[1][0].pu1_y) && (NULL == ps_dec->as_recent_fld[0][0].pu1_y))\n {\n ps_dec->as_recent_fld[1][0] = ps_dec->s_cur_frm_buf;\n impeg2d_get_bottom_field_buf(&ps_dec->s_cur_frm_buf, &ps_dec->as_recent_fld[1][1],\n ps_dec->u2_frame_width);\n ps_dec->as_recent_fld[0][0] = ps_dec->s_cur_frm_buf;\n ps_dec->as_recent_fld[0][1] = ps_dec->as_recent_fld[1][1];\n }\n else if ((NULL != ps_dec->as_recent_fld[1][0].pu1_y) && (NULL == ps_dec->as_recent_fld[0][0].pu1_y))\n {\n ps_dec->as_recent_fld[0][0] = ps_dec->as_recent_fld[1][0];\n ps_dec->as_recent_fld[0][1] = ps_dec->as_recent_fld[1][1];\n }\n else if ((NULL == ps_dec->as_recent_fld[1][0].pu1_y) && (NULL != ps_dec->as_recent_fld[0][0].pu1_y))\n {\n ps_dec->as_recent_fld[1][0] = ps_dec->as_recent_fld[0][0];\n ps_dec->as_recent_fld[1][1] = ps_dec->as_recent_fld[0][1];\n }",
" ps_dec->as_ref_buf[FORW][TOP] = ps_dec->as_recent_fld[0][0];\n ps_dec->as_ref_buf[FORW][BOTTOM] = ps_dec->as_recent_fld[0][1];\n ps_dec->as_ref_buf[BACK][TOP] = ps_dec->as_recent_fld[1][0];\n ps_dec->as_ref_buf[BACK][BOTTOM] = ps_dec->as_recent_fld[1][1];",
"\n }",
" return e_error;\n}\n"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
BIGVUL
|
{
"CVE ID": "CVE-2016-0824",
"CVE Page": "https://www.cvedetails.com/cve/CVE-2016-0824/",
"CWE ID": "CWE-254",
"codeLink": "https://android.googlesource.com/platform/external/libmpeg2/+/ffab15eb80630dc799eb410855c93525b75233c3",
"commit_id": "ffab15eb80630dc799eb410855c93525b75233c3",
"commit_message": "Fixed bit stream access to make sure that it is not read beyond the allocated size.\n\nBug: 25765591\n\nChange-Id: I98c23a3c3f84f6710f29bffe5ed73adcf51d47f6\n",
"lang": "C",
"project": "Android"
}
| 19
|
Determine whether the code is vulnerable or not.
|
[
"static void tg3_remove_one(struct pci_dev *pdev)\n{\n\tstruct net_device *dev = pci_get_drvdata(pdev);",
"\tif (dev) {\n\t\tstruct tg3 *tp = netdev_priv(dev);",
"\t\trelease_firmware(tp->fw);",
"\t\ttg3_reset_task_cancel(tp);",
"\t\tif (tg3_flag(tp, USE_PHYLIB)) {\n\t\t\ttg3_phy_fini(tp);\n\t\t\ttg3_mdio_fini(tp);\n\t\t}",
"\t\tunregister_netdev(dev);\n\t\tif (tp->aperegs) {\n\t\t\tiounmap(tp->aperegs);\n\t\t\ttp->aperegs = NULL;\n\t\t}\n\t\tif (tp->regs) {\n\t\t\tiounmap(tp->regs);\n\t\t\ttp->regs = NULL;\n\t\t}\n\t\tfree_netdev(dev);\n\t\tpci_release_regions(pdev);\n\t\tpci_disable_device(pdev);\n\t\tpci_set_drvdata(pdev, NULL);\n\t}\n}\n"
] |
[
1,
1,
1,
1,
1,
1
] |
BIGVUL
|
{
"CVE ID": "CVE-2013-1929",
"CVE Page": "https://www.cvedetails.com/cve/CVE-2013-1929/",
"CWE ID": "CWE-119",
"codeLink": "https://github.com/torvalds/linux/commit/715230a44310a8cf66fbfb5a46f9a62a9b2de424",
"commit_id": "715230a44310a8cf66fbfb5a46f9a62a9b2de424",
"commit_message": "tg3: fix length overflow in VPD firmware parsing\n\nCommit 184b89044fb6e2a74611dafa69b1dce0d98612c6 (\"tg3: Use VPD fw version\nwhen present\") introduced VPD parsing that contained a potential length\noverflow.\n\nLimit the hardware's reported firmware string length (max 255 bytes) to\nstay inside the driver's firmware string length (32 bytes). On overflow,\ntruncate the formatted firmware string instead of potentially overwriting\nportions of the tg3 struct.\n\nhttp://cansecwest.com/slides/2013/PrivateCore%20CSW%202013.pdf\n\nSigned-off-by: Kees Cook <keescook@chromium.org>\nReported-by: Oded Horovitz <oded@privatecore.com>\nReported-by: Brad Spengler <spender@grsecurity.net>\nCc: stable@vger.kernel.org\nCc: Matt Carlson <mcarlson@broadcom.com>\nSigned-off-by: David S. Miller <davem@davemloft.net>",
"lang": "C",
"project": "linux"
}
| 20
|
Determine whether the code is vulnerable or not.
|
[
"void *Type_LUT16_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)\n{\n cmsUInt8Number InputChannels, OutputChannels, CLUTpoints;\n cmsPipeline* NewLUT = NULL;\n cmsUInt32Number nTabSize;\n cmsFloat64Number Matrix[3*3];\n cmsUInt16Number InputEntries, OutputEntries;",
" *nItems = 0;",
" if (!_cmsReadUInt8Number(io, &InputChannels)) return NULL;\n if (!_cmsReadUInt8Number(io, &OutputChannels)) return NULL;\n if (!_cmsReadUInt8Number(io, &CLUTpoints)) return NULL; // 255 maximum",
" if (!_cmsReadUInt8Number(io, NULL)) return NULL;",
" if (InputChannels > cmsMAXCHANNELS) goto Error;\n if (OutputChannels > cmsMAXCHANNELS) goto Error;",
" NewLUT = cmsPipelineAlloc(self ->ContextID, InputChannels, OutputChannels);\n if (NewLUT == NULL) goto Error;",
" if (!_cmsRead15Fixed16Number(io, &Matrix[0])) goto Error;\n if (!_cmsRead15Fixed16Number(io, &Matrix[1])) goto Error;\n if (!_cmsRead15Fixed16Number(io, &Matrix[2])) goto Error;\n if (!_cmsRead15Fixed16Number(io, &Matrix[3])) goto Error;\n if (!_cmsRead15Fixed16Number(io, &Matrix[4])) goto Error;\n if (!_cmsRead15Fixed16Number(io, &Matrix[5])) goto Error;\n if (!_cmsRead15Fixed16Number(io, &Matrix[6])) goto Error;\n if (!_cmsRead15Fixed16Number(io, &Matrix[7])) goto Error;\n if (!_cmsRead15Fixed16Number(io, &Matrix[8])) goto Error;",
"\n if ((InputChannels == 3) && !_cmsMAT3isIdentity((cmsMAT3*) Matrix)) {",
" if (!cmsPipelineInsertStage(NewLUT, cmsAT_END, cmsStageAllocMatrix(self ->ContextID, 3, 3, Matrix, NULL)))\n goto Error;\n }",
" if (!_cmsReadUInt16Number(io, &InputEntries)) goto Error;\n if (!_cmsReadUInt16Number(io, &OutputEntries)) goto Error;",
" if (InputEntries > 0x7FFF || OutputEntries > 0x7FFF) goto Error;\n if (CLUTpoints == 1) goto Error; // Impossible value, 0 for no CLUT and then 2 at least",
" if (!Read16bitTables(self ->ContextID, io, NewLUT, InputChannels, InputEntries)) goto Error;",
" nTabSize = uipow(OutputChannels, CLUTpoints, InputChannels);\n if (nTabSize == (cmsUInt32Number) -1) goto Error;\n if (nTabSize > 0) {",
" cmsUInt16Number *T;",
" T = (cmsUInt16Number*) _cmsCalloc(self ->ContextID, nTabSize, sizeof(cmsUInt16Number));\n if (T == NULL) goto Error;",
" if (!_cmsReadUInt16Array(io, nTabSize, T)) {\n _cmsFree(self ->ContextID, T);\n goto Error;\n }",
" if (!cmsPipelineInsertStage(NewLUT, cmsAT_END, cmsStageAllocCLut16bit(self ->ContextID, CLUTpoints, InputChannels, OutputChannels, T))) {\n _cmsFree(self ->ContextID, T);\n goto Error;\n }\n _cmsFree(self ->ContextID, T);\n }",
"\n if (!Read16bitTables(self ->ContextID, io, NewLUT, OutputChannels, OutputEntries)) goto Error;",
" *nItems = 1;\n return NewLUT;",
"Error:\n if (NewLUT != NULL) cmsPipelineFree(NewLUT);\n return NULL;",
" cmsUNUSED_PARAMETER(SizeOfTag);\n}\n"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
BIGVUL
|
{
"CVE ID": "CVE-2016-10165",
"CVE Page": "https://www.cvedetails.com/cve/CVE-2016-10165/",
"CWE ID": "CWE-125",
"codeLink": "https://github.com/mm2/Little-CMS/commit/5ca71a7bc18b6897ab21d815d15e218e204581e2",
"commit_id": "5ca71a7bc18b6897ab21d815d15e218e204581e2",
"commit_message": "Added an extra check to MLU bounds\n\nThanks to Ibrahim el-sayed for spotting the bug",
"lang": "C",
"project": "Little-CMS"
}
| 21
|
Determine whether the code is vulnerable or not.
|
[
"static int start_audio_datapath(struct a2dp_stream_common *common)\n{\n INFO(\"state %d\", common->state);",
" if (common->ctrl_fd == AUDIO_SKT_DISCONNECTED) {\n INFO(\"%s AUDIO_SKT_DISCONNECTED\", __func__);\n return -1;\n }",
" int oldstate = common->state;\n common->state = AUDIO_A2DP_STATE_STARTING;",
" int a2dp_status = a2dp_command(common, A2DP_CTRL_CMD_START);\n if (a2dp_status < 0)\n {\n ERROR(\"%s Audiopath start failed (status %d)\", __func__, a2dp_status);",
" common->state = oldstate;\n return -1;\n }\n else if (a2dp_status == A2DP_CTRL_ACK_INCALL_FAILURE)\n {\n ERROR(\"%s Audiopath start failed - in call, move to suspended\", __func__);\n common->state = oldstate;\n return -1;\n }",
" /* connect socket if not yet connected */\n if (common->audio_fd == AUDIO_SKT_DISCONNECTED)\n {\n common->audio_fd = skt_connect(A2DP_DATA_PATH, common->buffer_sz);\n if (common->audio_fd < 0)\n {\n common->state = oldstate;\n return -1;\n }",
" common->state = AUDIO_A2DP_STATE_STARTED;\n }",
" return 0;\n}\n"
] |
[
1,
1,
1,
1,
1,
1,
1,
1
] |
BIGVUL
|
{
"CVE ID": "CVE-2016-3839",
"CVE Page": "https://www.cvedetails.com/cve/CVE-2016-3839/",
"CWE ID": "CWE-284",
"codeLink": "https://android.googlesource.com/platform/system/bt/+/472271b153c5dc53c28beac55480a8d8434b2d5c",
"commit_id": "472271b153c5dc53c28beac55480a8d8434b2d5c",
"commit_message": "DO NOT MERGE Fix potential DoS caused by delivering signal to BT process\n\nBug: 28885210\nChange-Id: I63866d894bfca47464d6e42e3fb0357c4f94d360\n\n Conflicts:\n\tbtif/co/bta_hh_co.c\n\tbtif/src/btif_core.c\nMerge conflict resolution of ag/1161415 (referencing ag/1164670)\n- Directly into mnc-mr2-release\n",
"lang": "C",
"project": "Android"
}
| 22
|
Determine whether the code is vulnerable or not.
|
[
"UpdateTouchesForGrab(DeviceIntPtr mouse)\n{\n int i;",
" if (!mouse->touch || mouse->deviceGrab.fromPassiveGrab)\n return;",
" for (i = 0; i < mouse->touch->num_touches; i++) {\n TouchPointInfoPtr ti = mouse->touch->touches + i;\n TouchListener *listener = &ti->listeners[0];\n GrabPtr grab = mouse->deviceGrab.grab;",
" if (ti->active &&\n CLIENT_BITS(listener->listener) == grab->resource) {\n listener->listener = grab->resource;\n listener->level = grab->grabtype;\n listener->state = LISTENER_IS_OWNER;\n listener->window = grab->window;",
" if (grab->grabtype == CORE || grab->grabtype == XI ||\n !xi2mask_isset(grab->xi2mask, mouse, XI_TouchBegin))\n listener->type = LISTENER_POINTER_GRAB;\n else\n listener->type = LISTENER_GRAB;\n if (listener->grab)\n FreeGrab(listener->grab);\n listener->grab = AllocGrab(grab);\n }\n }\n}\n"
] |
[
1,
1,
1,
1,
1
] |
BIGVUL
|
{
"CVE ID": "CVE-2017-10971",
"CVE Page": "https://www.cvedetails.com/cve/CVE-2017-10971/",
"CWE ID": "CWE-119",
"codeLink": "https://cgit.freedesktop.org/xorg/xserver/commit/?id=215f894965df5fb0bb45b107d84524e700d2073c",
"commit_id": "215f894965df5fb0bb45b107d84524e700d2073c",
"commit_message": null,
"lang": "C",
"project": "xserver"
}
| 23
|
Determine whether the code is vulnerable or not.
|
[
" virtual ResourceContext* GetResourceContext() {\n return context_;\n }\n"
] |
[
1
] |
BIGVUL
|
{
"CVE ID": "CVE-2013-0910",
"CVE Page": "https://www.cvedetails.com/cve/CVE-2013-0910/",
"CWE ID": "CWE-287",
"codeLink": "https://github.com/chromium/chromium/commit/ac8bd041b81e46e4e4fcd5021aaa5499703952e6",
"commit_id": "ac8bd041b81e46e4e4fcd5021aaa5499703952e6",
"commit_message": "Follow-on fixes and naming changes for https://codereview.chromium.org/12086077/\n\nBUG=172573\nReview URL: https://codereview.chromium.org/12177018\n\ngit-svn-id: svn://svn.chromium.org/chrome/trunk/src@180600 0039d316-1c4b-4281-b951-d872f2087c98",
"lang": "C",
"project": "Chrome"
}
| 24
|
Determine whether the code is vulnerable or not.
|
[
"static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info,\n const ImageInfo *image_info,Image *image)\n{\n char\n s[2];",
" char\n im_vers[32],\n libpng_runv[32],\n libpng_vers[32],\n zlib_runv[32],\n zlib_vers[32];",
" const char\n *name,\n *property,\n *value;",
" const StringInfo\n *profile;",
" int\n num_passes,\n pass,\n ping_wrote_caNv;",
" png_byte\n ping_trans_alpha[256];",
" png_color\n palette[257];",
" png_color_16\n ping_background,\n ping_trans_color;",
" png_info\n *ping_info;",
" png_struct\n *ping;",
" png_uint_32\n ping_height,\n ping_width;",
" ssize_t\n y;",
" MagickBooleanType\n image_matte,\n logging,\n matte,",
" ping_have_blob,\n ping_have_cheap_transparency,\n ping_have_color,\n ping_have_non_bw,\n ping_have_PLTE,\n ping_have_bKGD,\n ping_have_eXIf,\n ping_have_iCCP,\n ping_have_pHYs,\n ping_have_sRGB,\n ping_have_tRNS,",
" ping_exclude_bKGD,\n ping_exclude_cHRM,\n ping_exclude_date,\n /* ping_exclude_EXIF, */\n ping_exclude_eXIf,\n ping_exclude_gAMA,\n ping_exclude_iCCP,\n /* ping_exclude_iTXt, */\n ping_exclude_oFFs,\n ping_exclude_pHYs,\n ping_exclude_sRGB,\n ping_exclude_tEXt,\n ping_exclude_tIME,\n /* ping_exclude_tRNS, */\n ping_exclude_caNv,\n ping_exclude_zCCP, /* hex-encoded iCCP */\n ping_exclude_zTXt,",
" ping_preserve_colormap,\n ping_preserve_iCCP,\n ping_need_colortype_warning,",
" status,\n tried_332,\n tried_333,\n tried_444;",
" MemoryInfo\n *volatile pixel_info;",
" QuantumInfo\n *quantum_info;",
" register ssize_t\n i,\n x;",
" unsigned char\n *ping_pixels;",
" volatile int\n image_colors,\n ping_bit_depth,\n ping_color_type,\n ping_interlace_method,\n ping_compression_method,\n ping_filter_method,\n ping_num_trans;",
" volatile size_t\n image_depth,\n old_bit_depth;",
" size_t\n quality,\n rowbytes,\n save_image_depth;",
" int\n j,\n number_colors,\n number_opaque,\n number_semitransparent,\n number_transparent,\n ping_pHYs_unit_type;",
" png_uint_32\n ping_pHYs_x_resolution,\n ping_pHYs_y_resolution;",
" logging=LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Enter WriteOnePNGImage()\");",
" /* Define these outside of the following \"if logging()\" block so they will\n * show in debuggers.\n */\n *im_vers='\\0';\n (void) ConcatenateMagickString(im_vers,\n MagickLibVersionText,MaxTextExtent);\n (void) ConcatenateMagickString(im_vers,\n MagickLibAddendum,MaxTextExtent);",
" *libpng_vers='\\0';\n (void) ConcatenateMagickString(libpng_vers,\n PNG_LIBPNG_VER_STRING,32);\n *libpng_runv='\\0';\n (void) ConcatenateMagickString(libpng_runv,\n png_get_libpng_ver(NULL),32);",
" *zlib_vers='\\0';\n (void) ConcatenateMagickString(zlib_vers,\n ZLIB_VERSION,32);\n *zlib_runv='\\0';\n (void) ConcatenateMagickString(zlib_runv,\n zlib_version,32);",
" if (logging != MagickFalse)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" IM version = %s\", im_vers);\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Libpng version = %s\", libpng_vers);\n if (LocaleCompare(libpng_vers,libpng_runv) != 0)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" running with %s\", libpng_runv);\n }\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Zlib version = %s\", zlib_vers);\n if (LocaleCompare(zlib_vers,zlib_runv) != 0)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" running with %s\", zlib_runv);\n }\n }",
" /* Initialize some stuff */\n ping_bit_depth=0,\n ping_color_type=0,\n ping_interlace_method=0,\n ping_compression_method=0,\n ping_filter_method=0,\n ping_num_trans = 0;",
" ping_background.red = 0;\n ping_background.green = 0;\n ping_background.blue = 0;\n ping_background.gray = 0;\n ping_background.index = 0;",
" ping_trans_color.red=0;\n ping_trans_color.green=0;\n ping_trans_color.blue=0;\n ping_trans_color.gray=0;",
" ping_pHYs_unit_type = 0;\n ping_pHYs_x_resolution = 0;\n ping_pHYs_y_resolution = 0;",
" ping_have_blob=MagickFalse;\n ping_have_cheap_transparency=MagickFalse;\n ping_have_color=MagickTrue;\n ping_have_non_bw=MagickTrue;\n ping_have_PLTE=MagickFalse;\n ping_have_bKGD=MagickFalse;\n ping_have_eXIf=MagickTrue;\n ping_have_iCCP=MagickFalse;\n ping_have_pHYs=MagickFalse;\n ping_have_sRGB=MagickFalse;\n ping_have_tRNS=MagickFalse;",
" ping_exclude_bKGD=mng_info->ping_exclude_bKGD;\n ping_exclude_caNv=mng_info->ping_exclude_caNv;\n ping_exclude_cHRM=mng_info->ping_exclude_cHRM;\n ping_exclude_date=mng_info->ping_exclude_date;\n /* ping_exclude_EXIF=mng_info->ping_exclude_EXIF; */\n ping_exclude_eXIf=mng_info->ping_exclude_eXIf;\n ping_exclude_gAMA=mng_info->ping_exclude_gAMA;\n ping_exclude_iCCP=mng_info->ping_exclude_iCCP;\n /* ping_exclude_iTXt=mng_info->ping_exclude_iTXt; */\n ping_exclude_oFFs=mng_info->ping_exclude_oFFs;\n ping_exclude_pHYs=mng_info->ping_exclude_pHYs;\n ping_exclude_sRGB=mng_info->ping_exclude_sRGB;\n ping_exclude_tEXt=mng_info->ping_exclude_tEXt;\n ping_exclude_tIME=mng_info->ping_exclude_tIME;\n /* ping_exclude_tRNS=mng_info->ping_exclude_tRNS; */\n ping_exclude_zCCP=mng_info->ping_exclude_zCCP; /* hex-encoded iCCP in zTXt */\n ping_exclude_zTXt=mng_info->ping_exclude_zTXt;",
" ping_preserve_colormap = mng_info->ping_preserve_colormap;\n ping_preserve_iCCP = mng_info->ping_preserve_iCCP;\n ping_need_colortype_warning = MagickFalse;",
" property=(const char *) NULL;",
" /* Recognize the ICC sRGB profile and convert it to the sRGB chunk,\n * i.e., eliminate the ICC profile and set image->rendering_intent.\n * Note that this will not involve any changes to the actual pixels\n * but merely passes information to applications that read the resulting\n * PNG image.\n *\n * To do: recognize other variants of the sRGB profile, using the CRC to\n * verify all recognized variants including the 7 already known.\n *\n * Work around libpng16+ rejecting some \"known invalid sRGB profiles\".\n *\n * Use something other than image->rendering_intent to record the fact\n * that the sRGB profile was found.\n *\n * Record the ICC version (currently v2 or v4) of the incoming sRGB ICC\n * profile. Record the Blackpoint Compensation, if any.\n */\n if (ping_exclude_sRGB == MagickFalse && ping_preserve_iCCP == MagickFalse)\n {\n char\n *name;",
" const StringInfo\n *profile;",
" ResetImageProfileIterator(image);\n for (name=GetNextImageProfile(image); name != (const char *) NULL; )\n {\n profile=GetImageProfile(image,name);",
" if (profile != (StringInfo *) NULL)\n {\n if ((LocaleCompare(name,\"ICC\") == 0) ||\n (LocaleCompare(name,\"ICM\") == 0))",
" {\n int\n icheck,\n got_crc=0;",
"\n png_uint_32\n length,\n profile_crc=0;",
" unsigned char\n *data;",
" length=(png_uint_32) GetStringInfoLength(profile);",
" for (icheck=0; sRGB_info[icheck].len > 0; icheck++)\n {\n if (length == sRGB_info[icheck].len)\n {\n if (got_crc == 0)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Got a %lu-byte ICC profile (potentially sRGB)\",\n (unsigned long) length);",
" data=GetStringInfoDatum(profile);\n profile_crc=crc32(0,data,length);",
" (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" with crc=%8x\",(unsigned int) profile_crc);\n got_crc++;\n }",
" if (profile_crc == sRGB_info[icheck].crc)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" It is sRGB with rendering intent = %s\",\n Magick_RenderingIntentString_from_PNG_RenderingIntent(\n sRGB_info[icheck].intent));\n if (image->rendering_intent==UndefinedIntent)\n {\n image->rendering_intent=\n Magick_RenderingIntent_from_PNG_RenderingIntent(\n sRGB_info[icheck].intent);\n }\n ping_exclude_iCCP = MagickTrue;\n ping_exclude_zCCP = MagickTrue;\n ping_have_sRGB = MagickTrue;\n break;\n }\n }\n }\n if (sRGB_info[icheck].len == 0)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Got a %lu-byte ICC profile not recognized as sRGB\",\n (unsigned long) length);\n }\n }\n name=GetNextImageProfile(image);\n }\n }",
" number_opaque = 0;\n number_semitransparent = 0;\n number_transparent = 0;",
" if (logging != MagickFalse)\n {\n if (image->storage_class == UndefinedClass)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" image->storage_class=UndefinedClass\");\n if (image->storage_class == DirectClass)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" image->storage_class=DirectClass\");\n if (image->storage_class == PseudoClass)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" image->storage_class=PseudoClass\");\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" image_info->magick= %s\",image_info->magick);\n (void) LogMagickEvent(CoderEvent,GetMagickModule(), image->taint ?\n \" image->taint=MagickTrue\":\n \" image->taint=MagickFalse\");\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" image->gamma=%g\", image->gamma);\n }",
" if (image->storage_class == PseudoClass &&\n (mng_info->write_png8 || mng_info->write_png24 || mng_info->write_png32 ||\n mng_info->write_png48 || mng_info->write_png64 ||\n (mng_info->write_png_colortype != 1 &&\n mng_info->write_png_colortype != 5)))\n {\n (void) SyncImage(image);\n image->storage_class = DirectClass;\n }",
" if (ping_preserve_colormap == MagickFalse)\n {\n if (image->storage_class != PseudoClass && image->colormap != NULL)\n {\n /* Free the bogus colormap; it can cause trouble later */\n if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Freeing bogus colormap\");\n (void) RelinquishMagickMemory(image->colormap);\n image->colormap=NULL;\n }\n }",
" if (IssRGBCompatibleColorspace(image->colorspace) == MagickFalse)\n (void) TransformImageColorspace(image,sRGBColorspace);",
" /*\n Sometimes we get PseudoClass images whose RGB values don't match\n the colors in the colormap. This code syncs the RGB values.\n */\n if (image->depth <= 8 && image->taint && image->storage_class == PseudoClass)\n (void) SyncImage(image);",
"#if (MAGICKCORE_QUANTUM_DEPTH == 8)\n if (image->depth > 8)\n {\n if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Reducing PNG bit depth to 8 since this is a Q8 build.\");",
" image->depth=8;\n }\n#endif",
" /* Respect the -depth option */\n if (image->depth < 4)\n {\n register PixelPacket\n *r;",
" ExceptionInfo\n *exception;",
" exception=(&image->exception);",
" if (image->depth > 2)\n {\n /* Scale to 4-bit */\n LBR04PacketRGBO(image->background_color);",
" for (y=0; y < (ssize_t) image->rows; y++)\n {\n r=GetAuthenticPixels(image,0,y,image->columns,1,\n exception);",
" if (r == (PixelPacket *) NULL)\n break;",
" for (x=0; x < (ssize_t) image->columns; x++)\n {\n LBR04PixelRGBO(r);\n r++;\n }",
" if (SyncAuthenticPixels(image,exception) == MagickFalse)\n break;\n }",
" if (image->storage_class == PseudoClass && image->colormap != NULL)\n {\n for (i=0; i < (ssize_t) image->colors; i++)\n {\n LBR04PacketRGBO(image->colormap[i]);\n }\n }\n }\n else if (image->depth > 1)\n {\n /* Scale to 2-bit */\n LBR02PacketRGBO(image->background_color);",
" for (y=0; y < (ssize_t) image->rows; y++)\n {\n r=GetAuthenticPixels(image,0,y,image->columns,1,\n exception);",
" if (r == (PixelPacket *) NULL)\n break;",
" for (x=0; x < (ssize_t) image->columns; x++)\n {\n LBR02PixelRGBO(r);\n r++;\n }",
" if (SyncAuthenticPixels(image,exception) == MagickFalse)\n break;\n }",
" if (image->storage_class == PseudoClass && image->colormap != NULL)\n {\n for (i=0; i < (ssize_t) image->colors; i++)\n {\n LBR02PacketRGBO(image->colormap[i]);\n }\n }\n }\n else\n {\n /* Scale to 1-bit */\n LBR01PacketRGBO(image->background_color);",
" for (y=0; y < (ssize_t) image->rows; y++)\n {\n r=GetAuthenticPixels(image,0,y,image->columns,1,\n exception);",
" if (r == (PixelPacket *) NULL)\n break;",
" for (x=0; x < (ssize_t) image->columns; x++)\n {\n LBR01PixelRGBO(r);\n r++;\n }",
" if (SyncAuthenticPixels(image,exception) == MagickFalse)\n break;\n }",
" if (image->storage_class == PseudoClass && image->colormap != NULL)\n {\n for (i=0; i < (ssize_t) image->colors; i++)\n {\n LBR01PacketRGBO(image->colormap[i]);\n }\n }\n }\n }",
" /* To do: set to next higher multiple of 8 */\n if (image->depth < 8)\n image->depth=8;",
"#if (MAGICKCORE_QUANTUM_DEPTH > 16)\n /* PNG does not handle depths greater than 16 so reduce it even\n * if lossy\n */\n if (image->depth > 8)\n image->depth=16;\n#endif",
"#if (MAGICKCORE_QUANTUM_DEPTH > 8)\n if (image->depth > 8)\n {\n /* To do: fill low byte properly */\n image->depth=16;\n }",
" if (image->depth == 16 && mng_info->write_png_depth != 16)\n if (mng_info->write_png8 || LosslessReduceDepthOK(image) != MagickFalse)\n image->depth = 8;\n#endif",
" image_colors = (int) image->colors;",
" if (mng_info->write_png_colortype &&\n (mng_info->write_png_colortype > 4 || (mng_info->write_png_depth >= 8 &&\n mng_info->write_png_colortype < 4 && image->matte == MagickFalse)))\n {\n /* Avoid the expensive BUILD_PALETTE operation if we're sure that we\n * are not going to need the result.\n */\n number_opaque = (int) image->colors;\n if (mng_info->write_png_colortype == 1 ||\n mng_info->write_png_colortype == 5)\n ping_have_color=MagickFalse;\n else\n ping_have_color=MagickTrue;\n ping_have_non_bw=MagickFalse;",
" if (image->matte != MagickFalse)\n {\n number_transparent = 2;\n number_semitransparent = 1;\n }",
" else\n {\n number_transparent = 0;\n number_semitransparent = 0;\n }\n }",
" if (mng_info->write_png_colortype < 7)\n {\n /* BUILD_PALETTE\n *\n * Normally we run this just once, but in the case of writing PNG8\n * we reduce the transparency to binary and run again, then if there\n * are still too many colors we reduce to a simple 4-4-4-1, then 3-3-3-1\n * RGBA palette and run again, and then to a simple 3-3-2-1 RGBA\n * palette. Then (To do) we take care of a final reduction that is only\n * needed if there are still 256 colors present and one of them has both\n * transparent and opaque instances.\n */",
" tried_332 = MagickFalse;\n tried_333 = MagickFalse;\n tried_444 = MagickFalse;",
" for (j=0; j<6; j++)\n {\n /*\n * Sometimes we get DirectClass images that have 256 colors or fewer.\n * This code will build a colormap.\n *\n * Also, sometimes we get PseudoClass images with an out-of-date\n * colormap. This code will replace the colormap with a new one.\n * Sometimes we get PseudoClass images that have more than 256 colors.\n * This code will delete the colormap and change the image to\n * DirectClass.\n *\n * If image->matte is MagickFalse, we ignore the opacity channel\n * even though it sometimes contains left-over non-opaque values.\n *\n * Also we gather some information (number of opaque, transparent,\n * and semitransparent pixels, and whether the image has any non-gray\n * pixels or only black-and-white pixels) that we might need later.\n *\n * Even if the user wants to force GrayAlpha or RGBA (colortype 4 or 6)\n * we need to check for bogus non-opaque values, at least.\n */",
" ExceptionInfo\n *exception;",
" int\n n;",
" PixelPacket\n opaque[260],\n semitransparent[260],\n transparent[260];",
" register IndexPacket\n *indexes;",
" register const PixelPacket\n *s,\n *q;",
" register PixelPacket\n *r;",
" if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Enter BUILD_PALETTE:\");",
" if (logging != MagickFalse)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" image->columns=%.20g\",(double) image->columns);\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" image->rows=%.20g\",(double) image->rows);\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" image->matte=%.20g\",(double) image->matte);\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" image->depth=%.20g\",(double) image->depth);",
" if (image->storage_class == PseudoClass && image->colormap != NULL)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Original colormap:\");\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" i (red,green,blue,opacity)\");",
" for (i=0; i < 256; i++)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" %d (%d,%d,%d,%d)\",\n (int) i,\n (int) image->colormap[i].red,\n (int) image->colormap[i].green,\n (int) image->colormap[i].blue,\n (int) image->colormap[i].opacity);\n }",
" for (i=image->colors - 10; i < (ssize_t) image->colors; i++)\n {\n if (i > 255)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" %d (%d,%d,%d,%d)\",\n (int) i,\n (int) image->colormap[i].red,\n (int) image->colormap[i].green,\n (int) image->colormap[i].blue,\n (int) image->colormap[i].opacity);\n }\n }\n }",
" (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" image->colors=%d\",(int) image->colors);",
" if (image->colors == 0)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" (zero means unknown)\");",
" if (ping_preserve_colormap == MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Regenerate the colormap\");\n }",
" exception=(&image->exception);",
" image_colors=0;\n number_opaque = 0;\n number_semitransparent = 0;\n number_transparent = 0;",
" for (y=0; y < (ssize_t) image->rows; y++)\n {\n q=GetAuthenticPixels(image,0,y,image->columns,1,exception);",
" if (q == (PixelPacket *) NULL)\n break;",
" for (x=0; x < (ssize_t) image->columns; x++)\n {\n if (image->matte == MagickFalse ||\n GetPixelOpacity(q) == OpaqueOpacity)\n {\n if (number_opaque < 259)\n {\n if (number_opaque == 0)\n {\n GetPixelRGB(q, opaque);\n opaque[0].opacity=OpaqueOpacity;\n number_opaque=1;\n }",
" for (i=0; i< (ssize_t) number_opaque; i++)\n {\n if (IsColorEqual(q, opaque+i))\n break;\n }",
" if (i == (ssize_t) number_opaque &&\n number_opaque < 259)\n {\n number_opaque++;\n GetPixelRGB(q, opaque+i);\n opaque[i].opacity=OpaqueOpacity;\n }\n }\n }\n else if (q->opacity == TransparentOpacity)\n {\n if (number_transparent < 259)\n {\n if (number_transparent == 0)\n {\n GetPixelRGBO(q, transparent);\n ping_trans_color.red=\n (unsigned short) GetPixelRed(q);\n ping_trans_color.green=\n (unsigned short) GetPixelGreen(q);\n ping_trans_color.blue=\n (unsigned short) GetPixelBlue(q);\n ping_trans_color.gray=\n (unsigned short) GetPixelRed(q);\n number_transparent = 1;\n }",
" for (i=0; i< (ssize_t) number_transparent; i++)\n {\n if (IsColorEqual(q, transparent+i))\n break;\n }",
" if (i == (ssize_t) number_transparent &&\n number_transparent < 259)\n {\n number_transparent++;\n GetPixelRGBO(q, transparent+i);\n }\n }\n }\n else\n {\n if (number_semitransparent < 259)\n {\n if (number_semitransparent == 0)\n {\n GetPixelRGBO(q, semitransparent);\n number_semitransparent = 1;\n }",
" for (i=0; i< (ssize_t) number_semitransparent; i++)\n {\n if (IsColorEqual(q, semitransparent+i)\n && GetPixelOpacity(q) ==\n semitransparent[i].opacity)\n break;\n }",
" if (i == (ssize_t) number_semitransparent &&\n number_semitransparent < 259)\n {\n number_semitransparent++;\n GetPixelRGBO(q, semitransparent+i);\n }\n }\n }\n q++;\n }\n }",
" if (mng_info->write_png8 == MagickFalse &&\n ping_exclude_bKGD == MagickFalse)\n {\n /* Add the background color to the palette, if it\n * isn't already there.\n */\n if (logging != MagickFalse)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Check colormap for background (%d,%d,%d)\",\n (int) image->background_color.red,\n (int) image->background_color.green,\n (int) image->background_color.blue);\n }\n for (i=0; i<number_opaque; i++)\n {\n if (opaque[i].red == image->background_color.red &&\n opaque[i].green == image->background_color.green &&\n opaque[i].blue == image->background_color.blue)\n break;\n }\n if (number_opaque < 259 && i == number_opaque)\n {\n opaque[i] = image->background_color;\n ping_background.index = i;\n number_opaque++;\n if (logging != MagickFalse)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" background_color index is %d\",(int) i);\n }",
" }\n else if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" No room in the colormap to add background color\");\n }",
" image_colors=number_opaque+number_transparent+number_semitransparent;",
" if (logging != MagickFalse)\n {\n if (image_colors > 256)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" image has more than 256 colors\");",
" else\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" image has %d colors\",image_colors);\n }",
" if (ping_preserve_colormap != MagickFalse)\n break;",
" if (mng_info->write_png_colortype != 7) /* We won't need this info */\n {\n ping_have_color=MagickFalse;\n ping_have_non_bw=MagickFalse;",
" if (IssRGBCompatibleColorspace(image->colorspace) == MagickFalse)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \"incompatible colorspace\");\n ping_have_color=MagickTrue;\n ping_have_non_bw=MagickTrue;\n }",
" if(image_colors > 256)\n {\n for (y=0; y < (ssize_t) image->rows; y++)\n {\n q=GetAuthenticPixels(image,0,y,image->columns,1,exception);",
" if (q == (PixelPacket *) NULL)\n break;",
" s=q;\n for (x=0; x < (ssize_t) image->columns; x++)\n {\n if (GetPixelRed(s) != GetPixelGreen(s) ||\n GetPixelRed(s) != GetPixelBlue(s))\n {\n ping_have_color=MagickTrue;\n ping_have_non_bw=MagickTrue;\n break;\n }\n s++;\n }",
" if (ping_have_color != MagickFalse)\n break;",
" /* Worst case is black-and-white; we are looking at every\n * pixel twice.\n */",
" if (ping_have_non_bw == MagickFalse)\n {\n s=q;\n for (x=0; x < (ssize_t) image->columns; x++)\n {\n if (GetPixelRed(s) != 0 &&\n GetPixelRed(s) != QuantumRange)\n {\n ping_have_non_bw=MagickTrue;\n break;\n }\n s++;\n }\n }\n }\n }\n }",
" if (image_colors < 257)\n {\n PixelPacket\n colormap[260];",
" /*\n * Initialize image colormap.\n */",
" if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Sort the new colormap\");",
" /* Sort palette, transparent first */;",
" n = 0;",
" for (i=0; i<number_transparent; i++)\n colormap[n++] = transparent[i];",
" for (i=0; i<number_semitransparent; i++)\n colormap[n++] = semitransparent[i];",
" for (i=0; i<number_opaque; i++)\n colormap[n++] = opaque[i];",
" ping_background.index +=\n (number_transparent + number_semitransparent);",
" /* image_colors < 257; search the colormap instead of the pixels\n * to get ping_have_color and ping_have_non_bw\n */\n for (i=0; i<n; i++)\n {\n if (ping_have_color == MagickFalse)\n {\n if (colormap[i].red != colormap[i].green ||\n colormap[i].red != colormap[i].blue)\n {\n ping_have_color=MagickTrue;\n ping_have_non_bw=MagickTrue;\n break;\n }\n }",
" if (ping_have_non_bw == MagickFalse)\n {\n if (colormap[i].red != 0 && colormap[i].red != QuantumRange)\n ping_have_non_bw=MagickTrue;\n }\n }",
" if ((mng_info->ping_exclude_tRNS == MagickFalse ||\n (number_transparent == 0 && number_semitransparent == 0)) &&\n (((mng_info->write_png_colortype-1) ==\n PNG_COLOR_TYPE_PALETTE) ||\n (mng_info->write_png_colortype == 0)))\n {\n if (logging != MagickFalse)\n {\n if (n != (ssize_t) image_colors)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" image_colors (%d) and n (%d) don't match\",\n image_colors, n);",
" (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" AcquireImageColormap\");\n }",
" image->colors = image_colors;",
" if (AcquireImageColormap(image,image_colors) == MagickFalse)\n {\n (void) ThrowMagickException(exception,GetMagickModule(),\n ResourceLimitError,\"MemoryAllocationFailed\",\"`%s'\",\n image->filename);\n break;\n }",
" for (i=0; i< (ssize_t) image_colors; i++)\n image->colormap[i] = colormap[i];",
" if (logging != MagickFalse)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" image->colors=%d (%d)\",\n (int) image->colors, image_colors);",
" (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Update the pixel indexes\");\n }",
" /* Sync the pixel indices with the new colormap */",
" for (y=0; y < (ssize_t) image->rows; y++)\n {\n q=GetAuthenticPixels(image,0,y,image->columns,1,\n exception);",
" if (q == (PixelPacket *) NULL)\n break;",
" indexes=GetAuthenticIndexQueue(image);",
" for (x=0; x < (ssize_t) image->columns; x++)\n {\n for (i=0; i< (ssize_t) image_colors; i++)\n {\n if ((image->matte == MagickFalse ||\n image->colormap[i].opacity ==\n GetPixelOpacity(q)) &&\n image->colormap[i].red ==\n GetPixelRed(q) &&\n image->colormap[i].green ==\n GetPixelGreen(q) &&\n image->colormap[i].blue ==\n GetPixelBlue(q))\n {\n SetPixelIndex(indexes+x,i);\n break;\n }\n }\n q++;\n }",
" if (SyncAuthenticPixels(image,exception) == MagickFalse)\n break;\n }\n }\n }",
" if (logging != MagickFalse)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" image->colors=%d\", (int) image->colors);",
" if (image->colormap != NULL)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" i (red,green,blue,opacity)\");",
" for (i=0; i < (ssize_t) image->colors; i++)\n {\n if (i < 300 || i >= (ssize_t) image->colors - 10)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" %d (%d,%d,%d,%d)\",\n (int) i,\n (int) image->colormap[i].red,\n (int) image->colormap[i].green,\n (int) image->colormap[i].blue,\n (int) image->colormap[i].opacity);\n }\n }\n }",
" if (number_transparent < 257)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" number_transparent = %d\",\n number_transparent);\n else",
" (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" number_transparent > 256\");",
" if (number_opaque < 257)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" number_opaque = %d\",\n number_opaque);",
" else\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" number_opaque > 256\");",
" if (number_semitransparent < 257)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" number_semitransparent = %d\",\n number_semitransparent);",
" else\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" number_semitransparent > 256\");",
" if (ping_have_non_bw == MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" All pixels and the background are black or white\");",
" else if (ping_have_color == MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" All pixels and the background are gray\");",
" else\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" At least one pixel or the background is non-gray\");",
" (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Exit BUILD_PALETTE:\");\n }",
" if (mng_info->write_png8 == MagickFalse)\n break;",
" /* Make any reductions necessary for the PNG8 format */\n if (image_colors <= 256 &&\n image_colors != 0 && image->colormap != NULL &&\n number_semitransparent == 0 &&\n number_transparent <= 1)\n break;",
" /* PNG8 can't have semitransparent colors so we threshold the\n * opacity to 0 or OpaqueOpacity, and PNG8 can only have one\n * transparent color so if more than one is transparent we merge\n * them into image->background_color.\n */\n if (number_semitransparent != 0 || number_transparent > 1)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Thresholding the alpha channel to binary\");",
" for (y=0; y < (ssize_t) image->rows; y++)\n {\n r=GetAuthenticPixels(image,0,y,image->columns,1,\n exception);",
" if (r == (PixelPacket *) NULL)\n break;",
" for (x=0; x < (ssize_t) image->columns; x++)\n {\n if (GetPixelOpacity(r) > TransparentOpacity/2)\n {\n SetPixelOpacity(r,TransparentOpacity);\n SetPixelRgb(r,&image->background_color);\n }\n else\n SetPixelOpacity(r,OpaqueOpacity);\n r++;\n }",
" if (SyncAuthenticPixels(image,exception) == MagickFalse)\n break;",
" if (image_colors != 0 && image_colors <= 256 &&\n image->colormap != NULL)\n for (i=0; i<image_colors; i++)\n image->colormap[i].opacity =\n (image->colormap[i].opacity > TransparentOpacity/2 ?\n TransparentOpacity : OpaqueOpacity);\n }\n continue;\n }",
" /* PNG8 can't have more than 256 colors so we quantize the pixels and\n * background color to the 4-4-4-1, 3-3-3-1 or 3-3-2-1 palette. If the\n * image is mostly gray, the 4-4-4-1 palette is likely to end up with 256\n * colors or less.\n */\n if (tried_444 == MagickFalse && (image_colors == 0 || image_colors > 256))\n {\n if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Quantizing the background color to 4-4-4\");",
" tried_444 = MagickTrue;",
" LBR04PacketRGB(image->background_color);",
" if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Quantizing the pixel colors to 4-4-4\");",
" if (image->colormap == NULL)\n {\n for (y=0; y < (ssize_t) image->rows; y++)\n {\n r=GetAuthenticPixels(image,0,y,image->columns,1,\n exception);",
" if (r == (PixelPacket *) NULL)\n break;",
" for (x=0; x < (ssize_t) image->columns; x++)\n {\n if (GetPixelOpacity(r) == OpaqueOpacity)\n LBR04PixelRGB(r);\n r++;\n }",
" if (SyncAuthenticPixels(image,exception) == MagickFalse)\n break;\n }\n }",
" else /* Should not reach this; colormap already exists and\n must be <= 256 */\n {\n if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Quantizing the colormap to 4-4-4\");",
" for (i=0; i<image_colors; i++)\n {\n LBR04PacketRGB(image->colormap[i]);\n }\n }\n continue;\n }",
" if (tried_333 == MagickFalse && (image_colors == 0 || image_colors > 256))\n {\n if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Quantizing the background color to 3-3-3\");",
" tried_333 = MagickTrue;",
" LBR03PacketRGB(image->background_color);",
" if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Quantizing the pixel colors to 3-3-3-1\");",
" if (image->colormap == NULL)\n {\n for (y=0; y < (ssize_t) image->rows; y++)\n {\n r=GetAuthenticPixels(image,0,y,image->columns,1,\n exception);",
" if (r == (PixelPacket *) NULL)\n break;",
" for (x=0; x < (ssize_t) image->columns; x++)\n {\n if (GetPixelOpacity(r) == OpaqueOpacity)\n LBR03PixelRGB(r);\n r++;\n }",
" if (SyncAuthenticPixels(image,exception) == MagickFalse)\n break;\n }\n }",
" else /* Should not reach this; colormap already exists and\n must be <= 256 */\n {\n if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Quantizing the colormap to 3-3-3-1\");\n for (i=0; i<image_colors; i++)\n {\n LBR03PacketRGB(image->colormap[i]);\n }\n }\n continue;\n }",
" if (tried_332 == MagickFalse && (image_colors == 0 || image_colors > 256))\n {\n if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Quantizing the background color to 3-3-2\");",
" tried_332 = MagickTrue;",
" /* Red and green were already done so we only quantize the blue\n * channel\n */",
" LBR02PacketBlue(image->background_color);",
" if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Quantizing the pixel colors to 3-3-2-1\");",
" if (image->colormap == NULL)\n {\n for (y=0; y < (ssize_t) image->rows; y++)\n {\n r=GetAuthenticPixels(image,0,y,image->columns,1,\n exception);",
" if (r == (PixelPacket *) NULL)\n break;",
" for (x=0; x < (ssize_t) image->columns; x++)\n {\n if (GetPixelOpacity(r) == OpaqueOpacity)\n LBR02PixelBlue(r);\n r++;\n }",
" if (SyncAuthenticPixels(image,exception) == MagickFalse)\n break;\n }\n }",
" else /* Should not reach this; colormap already exists and\n must be <= 256 */\n {\n if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Quantizing the colormap to 3-3-2-1\");\n for (i=0; i<image_colors; i++)\n {\n LBR02PacketBlue(image->colormap[i]);\n }\n }\n continue;\n }",
" if (image_colors == 0 || image_colors > 256)\n {\n /* Take care of special case with 256 opaque colors + 1 transparent\n * color. We don't need to quantize to 2-3-2-1; we only need to\n * eliminate one color, so we'll merge the two darkest red\n * colors (0x49, 0, 0) -> (0x24, 0, 0).\n */\n if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Merging two dark red background colors to 3-3-2-1\");",
" if (ScaleQuantumToChar(image->background_color.red) == 0x49 &&\n ScaleQuantumToChar(image->background_color.green) == 0x00 &&\n ScaleQuantumToChar(image->background_color.blue) == 0x00)\n {\n image->background_color.red=ScaleCharToQuantum(0x24);\n }",
" if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Merging two dark red pixel colors to 3-3-2-1\");",
" if (image->colormap == NULL)\n {\n for (y=0; y < (ssize_t) image->rows; y++)\n {\n r=GetAuthenticPixels(image,0,y,image->columns,1,\n exception);",
" if (r == (PixelPacket *) NULL)\n break;",
" for (x=0; x < (ssize_t) image->columns; x++)\n {\n if (ScaleQuantumToChar(GetPixelRed(r)) == 0x49 &&\n ScaleQuantumToChar(GetPixelGreen(r)) == 0x00 &&\n ScaleQuantumToChar(GetPixelBlue(r)) == 0x00 &&\n GetPixelOpacity(r) == OpaqueOpacity)\n {\n SetPixelRed(r,ScaleCharToQuantum(0x24));\n }\n r++;\n }",
" if (SyncAuthenticPixels(image,exception) == MagickFalse)\n break;",
" }\n }",
" else\n {\n for (i=0; i<image_colors; i++)\n {\n if (ScaleQuantumToChar(image->colormap[i].red) == 0x49 &&\n ScaleQuantumToChar(image->colormap[i].green) == 0x00 &&\n ScaleQuantumToChar(image->colormap[i].blue) == 0x00)\n {\n image->colormap[i].red=ScaleCharToQuantum(0x24);\n }\n }\n }\n }\n }\n }\n /* END OF BUILD_PALETTE */",
" /* If we are excluding the tRNS chunk and there is transparency,\n * then we must write a Gray-Alpha (color-type 4) or RGBA (color-type 6)\n * PNG.\n */\n if (mng_info->ping_exclude_tRNS != MagickFalse &&\n (number_transparent != 0 || number_semitransparent != 0))\n {\n unsigned int colortype=mng_info->write_png_colortype;",
" if (ping_have_color == MagickFalse)\n mng_info->write_png_colortype = 5;",
" else\n mng_info->write_png_colortype = 7;",
" if (colortype != 0 &&\n mng_info->write_png_colortype != colortype)\n ping_need_colortype_warning=MagickTrue;",
" }",
" /* See if cheap transparency is possible. It is only possible\n * when there is a single transparent color, no semitransparent\n * color, and no opaque color that has the same RGB components\n * as the transparent color. We only need this information if\n * we are writing a PNG with colortype 0 or 2, and we have not\n * excluded the tRNS chunk.\n */\n if (number_transparent == 1 &&\n mng_info->write_png_colortype < 4)\n {\n ping_have_cheap_transparency = MagickTrue;",
" if (number_semitransparent != 0)\n ping_have_cheap_transparency = MagickFalse;",
" else if (image_colors == 0 || image_colors > 256 ||\n image->colormap == NULL)\n {\n ExceptionInfo\n *exception;",
" register const PixelPacket\n *q;",
" exception=(&image->exception);",
" for (y=0; y < (ssize_t) image->rows; y++)\n {\n q=GetVirtualPixels(image,0,y,image->columns,1, exception);",
" if (q == (PixelPacket *) NULL)\n break;",
" for (x=0; x < (ssize_t) image->columns; x++)\n {\n if (q->opacity != TransparentOpacity &&\n (unsigned short) GetPixelRed(q) ==\n ping_trans_color.red &&\n (unsigned short) GetPixelGreen(q) ==\n ping_trans_color.green &&\n (unsigned short) GetPixelBlue(q) ==\n ping_trans_color.blue)\n {\n ping_have_cheap_transparency = MagickFalse;\n break;\n }",
" q++;\n }",
" if (ping_have_cheap_transparency == MagickFalse)\n break;\n }\n }\n else\n {\n /* Assuming that image->colormap[0] is the one transparent color\n * and that all others are opaque.\n */\n if (image_colors > 1)\n for (i=1; i<image_colors; i++)\n if (image->colormap[i].red == image->colormap[0].red &&\n image->colormap[i].green == image->colormap[0].green &&\n image->colormap[i].blue == image->colormap[0].blue)\n {\n ping_have_cheap_transparency = MagickFalse;\n break;\n }\n }",
" if (logging != MagickFalse)\n {\n if (ping_have_cheap_transparency == MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Cheap transparency is not possible.\");",
" else\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Cheap transparency is possible.\");\n }\n }\n else\n ping_have_cheap_transparency = MagickFalse;",
" image_depth=image->depth;",
" quantum_info = (QuantumInfo *) NULL;\n number_colors=0;\n image_colors=(int) image->colors;\n image_matte=image->matte;",
" if (mng_info->write_png_colortype < 5)\n mng_info->IsPalette=image->storage_class == PseudoClass &&\n image_colors <= 256 && image->colormap != NULL;\n else\n mng_info->IsPalette = MagickFalse;",
" if ((mng_info->write_png_colortype == 4 || mng_info->write_png8) &&\n (image->colors == 0 || image->colormap == NULL))\n {\n (void) ThrowMagickException(&image->exception,\n GetMagickModule(),CoderError,\n \"Cannot write PNG8 or color-type 3; colormap is NULL\",\n \"`%s'\",image->filename);",
" return(MagickFalse);\n }",
" /*\n Allocate the PNG structures\n */\n#ifdef PNG_USER_MEM_SUPPORTED\n ping=png_create_write_struct_2(PNG_LIBPNG_VER_STRING,image,\n MagickPNGErrorHandler,MagickPNGWarningHandler,(void *) NULL,\n (png_malloc_ptr) Magick_png_malloc,(png_free_ptr) Magick_png_free);",
"#else\n ping=png_create_write_struct(PNG_LIBPNG_VER_STRING,image,\n MagickPNGErrorHandler,MagickPNGWarningHandler);",
"#endif\n if (ping == (png_struct *) NULL)\n ThrowWriterException(ResourceLimitError,\"MemoryAllocationFailed\");",
" ping_info=png_create_info_struct(ping);",
" if (ping_info == (png_info *) NULL)\n {\n png_destroy_write_struct(&ping,(png_info **) NULL);\n ThrowWriterException(ResourceLimitError,\"MemoryAllocationFailed\");\n }",
" png_set_write_fn(ping,image,png_put_data,png_flush_data);\n pixel_info=(MemoryInfo *) NULL;",
" if (setjmp(png_jmpbuf(ping)))\n {\n /*\n PNG write failed.\n */\n#ifdef PNG_DEBUG\n if (image_info->verbose)\n (void) printf(\"PNG write has failed.\\n\");\n#endif\n png_destroy_write_struct(&ping,&ping_info);",
"#ifdef IMPNG_SETJMP_NOT_THREAD_SAFE\n UnlockSemaphoreInfo(ping_semaphore);\n#endif",
" if (pixel_info != (MemoryInfo *) NULL)\n pixel_info=RelinquishVirtualMemory(pixel_info);",
" if (quantum_info != (QuantumInfo *) NULL)\n quantum_info=DestroyQuantumInfo(quantum_info);",
" return(MagickFalse);\n }",
" /* { For navigation to end of SETJMP-protected block. Within this\n * block, use png_error() instead of Throwing an Exception, to ensure\n * that libpng is able to clean up, and that the semaphore is unlocked.\n */",
"#ifdef IMPNG_SETJMP_NOT_THREAD_SAFE\n LockSemaphoreInfo(ping_semaphore);\n#endif",
"#ifdef PNG_BENIGN_ERRORS_SUPPORTED\n /* Allow benign errors */\n png_set_benign_errors(ping, 1);\n#endif",
"#ifdef PNG_SET_USER_LIMITS_SUPPORTED\n /* Reject images with too many rows or columns */\n png_set_user_limits(ping,\n (png_uint_32) MagickMin(0x7fffffffL,\n GetMagickResourceLimit(WidthResource)),\n (png_uint_32) MagickMin(0x7fffffffL,\n GetMagickResourceLimit(HeightResource)));\n#endif /* PNG_SET_USER_LIMITS_SUPPORTED */",
" /*\n Prepare PNG for writing.\n */",
"#if defined(PNG_MNG_FEATURES_SUPPORTED)\n if (mng_info->write_mng)\n {\n (void) png_permit_mng_features(ping,PNG_ALL_MNG_FEATURES);\n# ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED\n /* Disable new libpng-1.5.10 feature when writing a MNG because\n * zero-length PLTE is OK\n */\n png_set_check_for_invalid_index (ping, 0);\n# endif\n }",
"#else\n# ifdef PNG_WRITE_EMPTY_PLTE_SUPPORTED\n if (mng_info->write_mng)\n png_permit_empty_plte(ping,MagickTrue);",
"# endif\n#endif",
" x=0;",
" ping_width=(png_uint_32) image->columns;\n ping_height=(png_uint_32) image->rows;",
" if (mng_info->write_png8 || mng_info->write_png24 || mng_info->write_png32)\n image_depth=8;",
" if (mng_info->write_png48 || mng_info->write_png64)\n image_depth=16;",
" if (mng_info->write_png_depth != 0)\n image_depth=mng_info->write_png_depth;",
" /* Adjust requested depth to next higher valid depth if necessary */\n if (image_depth > 8)\n image_depth=16;",
" if ((image_depth > 4) && (image_depth < 8))\n image_depth=8;",
" if (image_depth == 3)\n image_depth=4;",
" if (logging != MagickFalse)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" width=%.20g\",(double) ping_width);\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" height=%.20g\",(double) ping_height);\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" image_matte=%.20g\",(double) image->matte);\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" image->depth=%.20g\",(double) image->depth);\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Tentative ping_bit_depth=%.20g\",(double) image_depth);\n }",
" save_image_depth=image_depth;\n ping_bit_depth=(png_byte) save_image_depth;",
"\n#if defined(PNG_pHYs_SUPPORTED)\n if (ping_exclude_pHYs == MagickFalse)\n {\n if ((image->x_resolution != 0) && (image->y_resolution != 0) &&\n (!mng_info->write_mng || !mng_info->equal_physs))\n {\n if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Setting up pHYs chunk\");",
" if (image->units == PixelsPerInchResolution)\n {\n ping_pHYs_unit_type=PNG_RESOLUTION_METER;\n ping_pHYs_x_resolution=\n (png_uint_32) ((100.0*image->x_resolution+0.5)/2.54);\n ping_pHYs_y_resolution=\n (png_uint_32) ((100.0*image->y_resolution+0.5)/2.54);\n }",
" else if (image->units == PixelsPerCentimeterResolution)\n {\n ping_pHYs_unit_type=PNG_RESOLUTION_METER;\n ping_pHYs_x_resolution=(png_uint_32) (100.0*image->x_resolution+0.5);\n ping_pHYs_y_resolution=(png_uint_32) (100.0*image->y_resolution+0.5);\n }",
" else\n {\n ping_pHYs_unit_type=PNG_RESOLUTION_UNKNOWN;\n ping_pHYs_x_resolution=(png_uint_32) image->x_resolution;\n ping_pHYs_y_resolution=(png_uint_32) image->y_resolution;\n }",
" if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Set up PNG pHYs chunk: xres: %.20g, yres: %.20g, units: %d.\",\n (double) ping_pHYs_x_resolution,(double) ping_pHYs_y_resolution,\n (int) ping_pHYs_unit_type);\n ping_have_pHYs = MagickTrue;\n }\n }\n#endif",
" if (ping_exclude_bKGD == MagickFalse)\n {\n if ((!mng_info->adjoin || !mng_info->equal_backgrounds))\n {\n unsigned int\n mask;",
" mask=0xffff;\n if (ping_bit_depth == 8)\n mask=0x00ff;",
" if (ping_bit_depth == 4)\n mask=0x000f;",
" if (ping_bit_depth == 2)\n mask=0x0003;",
" if (ping_bit_depth == 1)\n mask=0x0001;",
" ping_background.red=(png_uint_16)\n (ScaleQuantumToShort(image->background_color.red) & mask);",
" ping_background.green=(png_uint_16)\n (ScaleQuantumToShort(image->background_color.green) & mask);",
" ping_background.blue=(png_uint_16)\n (ScaleQuantumToShort(image->background_color.blue) & mask);",
" ping_background.gray=(png_uint_16) ping_background.green;\n }",
" if (logging != MagickFalse)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Setting up bKGD chunk (1)\");\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" background_color index is %d\",\n (int) ping_background.index);",
" (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" ping_bit_depth=%d\",ping_bit_depth);\n }",
" ping_have_bKGD = MagickTrue;\n }",
" /*\n Select the color type.\n */\n matte=image_matte;\n old_bit_depth=0;",
" if (mng_info->IsPalette && mng_info->write_png8)\n {\n /* To do: make this a function cause it's used twice, except\n for reducing the sample depth from 8. */",
" number_colors=image_colors;",
" ping_have_tRNS=MagickFalse;",
" /*\n Set image palette.\n */\n ping_color_type=(png_byte) PNG_COLOR_TYPE_PALETTE;",
" if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Setting up PLTE chunk with %d colors (%d)\",\n number_colors, image_colors);",
" for (i=0; i < (ssize_t) number_colors; i++)\n {\n palette[i].red=ScaleQuantumToChar(image->colormap[i].red);\n palette[i].green=ScaleQuantumToChar(image->colormap[i].green);\n palette[i].blue=ScaleQuantumToChar(image->colormap[i].blue);\n if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n#if MAGICKCORE_QUANTUM_DEPTH == 8\n \" %3ld (%3d,%3d,%3d)\",\n#else\n \" %5ld (%5d,%5d,%5d)\",\n#endif\n (long) i,palette[i].red,palette[i].green,palette[i].blue);",
" }",
" ping_have_PLTE=MagickTrue;\n image_depth=ping_bit_depth;\n ping_num_trans=0;",
" if (matte != MagickFalse)\n {\n /*\n Identify which colormap entry is transparent.\n */\n assert(number_colors <= 256);\n assert(image->colormap != NULL);",
" for (i=0; i < (ssize_t) number_transparent; i++)\n ping_trans_alpha[i]=0;",
"\n ping_num_trans=(unsigned short) (number_transparent +\n number_semitransparent);",
" if (ping_num_trans == 0)\n ping_have_tRNS=MagickFalse;",
" else\n ping_have_tRNS=MagickTrue;\n }",
" if (ping_exclude_bKGD == MagickFalse)\n {\n /*\n * Identify which colormap entry is the background color.\n */",
" for (i=0; i < (ssize_t) MagickMax(1L*number_colors-1L,1L); i++)\n if (IsPNGColorEqual(ping_background,image->colormap[i]))\n break;",
" ping_background.index=(png_byte) i;",
" if (logging != MagickFalse)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" background_color index is %d\",\n (int) ping_background.index);\n }\n }\n } /* end of write_png8 */",
" else if (mng_info->write_png_colortype == 1)\n {\n image_matte=MagickFalse;\n ping_color_type=(png_byte) PNG_COLOR_TYPE_GRAY;\n }",
" else if (mng_info->write_png24 || mng_info->write_png48 ||\n mng_info->write_png_colortype == 3)\n {\n image_matte=MagickFalse;\n ping_color_type=(png_byte) PNG_COLOR_TYPE_RGB;\n }",
" else if (mng_info->write_png32 || mng_info->write_png64 ||\n mng_info->write_png_colortype == 7)\n {\n image_matte=MagickTrue;\n ping_color_type=(png_byte) PNG_COLOR_TYPE_RGB_ALPHA;\n }",
" else /* mng_info->write_pngNN not specified */\n {\n image_depth=ping_bit_depth;",
" if (mng_info->write_png_colortype != 0)\n {\n ping_color_type=(png_byte) mng_info->write_png_colortype-1;",
" if (ping_color_type == PNG_COLOR_TYPE_GRAY_ALPHA ||\n ping_color_type == PNG_COLOR_TYPE_RGB_ALPHA)\n image_matte=MagickTrue;",
" else\n image_matte=MagickFalse;",
" if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" PNG colortype %d was specified:\",(int) ping_color_type);\n }",
" else /* write_png_colortype not specified */\n {\n if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Selecting PNG colortype:\");",
" ping_color_type=(png_byte) ((matte != MagickFalse)?\n PNG_COLOR_TYPE_RGB_ALPHA:PNG_COLOR_TYPE_RGB);",
" if (image_info->type == TrueColorType)\n {\n ping_color_type=(png_byte) PNG_COLOR_TYPE_RGB;\n image_matte=MagickFalse;\n }",
" if (image_info->type == TrueColorMatteType)\n {\n ping_color_type=(png_byte) PNG_COLOR_TYPE_RGB_ALPHA;\n image_matte=MagickTrue;\n }",
" if (image_info->type == PaletteType ||\n image_info->type == PaletteMatteType)\n ping_color_type=(png_byte) PNG_COLOR_TYPE_PALETTE;",
" if (mng_info->write_png_colortype == 0 &&\n image_info->type == UndefinedType)\n {\n if (ping_have_color == MagickFalse)\n {\n if (image_matte == MagickFalse)\n {\n ping_color_type=(png_byte) PNG_COLOR_TYPE_GRAY;\n image_matte=MagickFalse;\n }",
" else\n {\n ping_color_type=(png_byte) PNG_COLOR_TYPE_GRAY_ALPHA;\n image_matte=MagickTrue;\n }\n }\n else\n {\n if (image_matte == MagickFalse)\n {\n ping_color_type=(png_byte) PNG_COLOR_TYPE_RGB;\n image_matte=MagickFalse;\n }",
" else\n {\n ping_color_type=(png_byte) PNG_COLOR_TYPE_RGBA;\n image_matte=MagickTrue;\n }\n }\n }",
" }",
" if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Selected PNG colortype=%d\",ping_color_type);",
" if (ping_bit_depth < 8)\n {\n if (ping_color_type == PNG_COLOR_TYPE_GRAY_ALPHA ||\n ping_color_type == PNG_COLOR_TYPE_RGB ||\n ping_color_type == PNG_COLOR_TYPE_RGB_ALPHA)\n ping_bit_depth=8;\n }",
" old_bit_depth=ping_bit_depth;",
" if (ping_color_type == PNG_COLOR_TYPE_GRAY)\n {\n if (image->matte == MagickFalse && ping_have_non_bw == MagickFalse)\n ping_bit_depth=1;\n }",
" if (ping_color_type == PNG_COLOR_TYPE_PALETTE)\n {\n size_t one = 1;\n ping_bit_depth=1;",
" if (image->colors == 0)\n {\n /* DO SOMETHING */\n png_error(ping,\"image has 0 colors\");\n }",
" while ((int) (one << ping_bit_depth) < (ssize_t) image_colors)\n ping_bit_depth <<= 1;\n }",
" if (logging != MagickFalse)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Number of colors: %.20g\",(double) image_colors);",
" (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Tentative PNG bit depth: %d\",ping_bit_depth);\n }",
" if (ping_bit_depth < (int) mng_info->write_png_depth)\n ping_bit_depth = mng_info->write_png_depth;\n }",
" image_depth=ping_bit_depth;",
" if (logging != MagickFalse)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Tentative PNG color type: %s (%.20g)\",\n PngColorTypeToString(ping_color_type),\n (double) ping_color_type);",
" (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" image_info->type: %.20g\",(double) image_info->type);",
" (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" image_depth: %.20g\",(double) image_depth);",
" (void) LogMagickEvent(CoderEvent,GetMagickModule(),",
" \" image->depth: %.20g\",(double) image->depth);",
" (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" ping_bit_depth: %.20g\",(double) ping_bit_depth);\n }",
" if (matte != MagickFalse)\n {\n if (mng_info->IsPalette)\n {\n if (mng_info->write_png_colortype == 0)\n {\n ping_color_type=PNG_COLOR_TYPE_GRAY_ALPHA;",
" if (ping_have_color != MagickFalse)\n ping_color_type=PNG_COLOR_TYPE_RGBA;\n }",
" /*\n * Determine if there is any transparent color.\n */\n if (number_transparent + number_semitransparent == 0)\n {\n /*\n No transparent pixels are present. Change 4 or 6 to 0 or 2.\n */",
" image_matte=MagickFalse;",
" if (mng_info->write_png_colortype == 0)\n ping_color_type&=0x03;\n }",
" else\n {\n unsigned int\n mask;",
" mask=0xffff;",
" if (ping_bit_depth == 8)\n mask=0x00ff;",
" if (ping_bit_depth == 4)\n mask=0x000f;",
" if (ping_bit_depth == 2)\n mask=0x0003;",
" if (ping_bit_depth == 1)\n mask=0x0001;",
" ping_trans_color.red=(png_uint_16)\n (ScaleQuantumToShort(image->colormap[0].red) & mask);",
" ping_trans_color.green=(png_uint_16)\n (ScaleQuantumToShort(image->colormap[0].green) & mask);",
" ping_trans_color.blue=(png_uint_16)\n (ScaleQuantumToShort(image->colormap[0].blue) & mask);",
" ping_trans_color.gray=(png_uint_16)\n (ScaleQuantumToShort(ClampToQuantum(GetPixelLuma(image,\n image->colormap))) & mask);",
" ping_trans_color.index=(png_byte) 0;",
" ping_have_tRNS=MagickTrue;\n }",
" if (ping_have_tRNS != MagickFalse)\n {\n /*\n * Determine if there is one and only one transparent color\n * and if so if it is fully transparent.\n */\n if (ping_have_cheap_transparency == MagickFalse)\n ping_have_tRNS=MagickFalse;\n }",
" if (ping_have_tRNS != MagickFalse)\n {\n if (mng_info->write_png_colortype == 0)\n ping_color_type &= 0x03; /* changes 4 or 6 to 0 or 2 */",
" if (image_depth == 8)\n {\n ping_trans_color.red&=0xff;\n ping_trans_color.green&=0xff;\n ping_trans_color.blue&=0xff;\n ping_trans_color.gray&=0xff;\n }\n }\n }\n else\n {\n if (image_depth == 8)\n {\n ping_trans_color.red&=0xff;\n ping_trans_color.green&=0xff;\n ping_trans_color.blue&=0xff;\n ping_trans_color.gray&=0xff;\n }\n }\n }",
" matte=image_matte;",
" if (ping_have_tRNS != MagickFalse)\n image_matte=MagickFalse;",
" if ((mng_info->IsPalette) &&\n mng_info->write_png_colortype-1 != PNG_COLOR_TYPE_PALETTE &&\n ping_have_color == MagickFalse &&\n (image_matte == MagickFalse || image_depth >= 8))\n {\n size_t one=1;",
" if (image_matte != MagickFalse)\n ping_color_type=PNG_COLOR_TYPE_GRAY_ALPHA;",
" else if (mng_info->write_png_colortype-1 != PNG_COLOR_TYPE_GRAY_ALPHA)\n {\n ping_color_type=PNG_COLOR_TYPE_GRAY;",
" if (save_image_depth == 16 && image_depth == 8)\n {\n if (logging != MagickFalse)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Scaling ping_trans_color (0)\");\n }\n ping_trans_color.gray*=0x0101;\n }\n }",
" if (image_depth > MAGICKCORE_QUANTUM_DEPTH)\n image_depth=MAGICKCORE_QUANTUM_DEPTH;",
" if ((image_colors == 0) ||\n ((ssize_t) (image_colors-1) > (ssize_t) MaxColormapSize))\n image_colors=(int) (one << image_depth);",
" if (image_depth > 8)\n ping_bit_depth=16;",
" else\n {\n ping_bit_depth=8;\n if ((int) ping_color_type == PNG_COLOR_TYPE_PALETTE)\n {\n if(!mng_info->write_png_depth)\n {\n ping_bit_depth=1;",
" while ((int) (one << ping_bit_depth)\n < (ssize_t) image_colors)\n ping_bit_depth <<= 1;\n }\n }",
" else if (ping_color_type ==\n PNG_COLOR_TYPE_GRAY && image_colors < 17 &&\n mng_info->IsPalette)\n {\n /* Check if grayscale is reducible */",
" int\n depth_4_ok=MagickTrue,\n depth_2_ok=MagickTrue,\n depth_1_ok=MagickTrue;",
" for (i=0; i < (ssize_t) image_colors; i++)\n {\n unsigned char\n intensity;",
" intensity=ScaleQuantumToChar(image->colormap[i].red);",
" if ((intensity & 0x0f) != ((intensity & 0xf0) >> 4))\n depth_4_ok=depth_2_ok=depth_1_ok=MagickFalse;\n else if ((intensity & 0x03) != ((intensity & 0x0c) >> 2))\n depth_2_ok=depth_1_ok=MagickFalse;\n else if ((intensity & 0x01) != ((intensity & 0x02) >> 1))\n depth_1_ok=MagickFalse;\n }",
" if (depth_1_ok && mng_info->write_png_depth <= 1)\n ping_bit_depth=1;",
" else if (depth_2_ok && mng_info->write_png_depth <= 2)\n ping_bit_depth=2;",
" else if (depth_4_ok && mng_info->write_png_depth <= 4)\n ping_bit_depth=4;\n }\n }",
" image_depth=ping_bit_depth;\n }",
" else",
" if (mng_info->IsPalette)\n {\n number_colors=image_colors;",
" if (image_depth <= 8)\n {\n /*\n Set image palette.\n */\n ping_color_type=(png_byte) PNG_COLOR_TYPE_PALETTE;",
" if (!(mng_info->have_write_global_plte && matte == MagickFalse))\n {\n for (i=0; i < (ssize_t) number_colors; i++)\n {\n palette[i].red=ScaleQuantumToChar(image->colormap[i].red);\n palette[i].green=ScaleQuantumToChar(image->colormap[i].green);\n palette[i].blue=ScaleQuantumToChar(image->colormap[i].blue);\n }",
" if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Setting up PLTE chunk with %d colors\",\n number_colors);",
" ping_have_PLTE=MagickTrue;\n }",
" /* color_type is PNG_COLOR_TYPE_PALETTE */\n if (mng_info->write_png_depth == 0)\n {\n size_t\n one;",
" ping_bit_depth=1;\n one=1;",
" while ((one << ping_bit_depth) < (size_t) number_colors)\n ping_bit_depth <<= 1;\n }",
" ping_num_trans=0;",
" if (matte != MagickFalse)\n {\n /*\n * Set up trans_colors array.\n */\n assert(number_colors <= 256);",
" ping_num_trans=(unsigned short) (number_transparent +\n number_semitransparent);",
" if (ping_num_trans == 0)\n ping_have_tRNS=MagickFalse;",
" else\n {\n if (logging != MagickFalse)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Scaling ping_trans_color (1)\");\n }\n ping_have_tRNS=MagickTrue;",
" for (i=0; i < ping_num_trans; i++)\n {\n ping_trans_alpha[i]= (png_byte) (255-\n ScaleQuantumToChar(image->colormap[i].opacity));\n }\n }\n }\n }\n }",
" else\n {",
" if (image_depth < 8)\n image_depth=8;",
" if ((save_image_depth == 16) && (image_depth == 8))\n {\n if (logging != MagickFalse)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Scaling ping_trans_color from (%d,%d,%d)\",\n (int) ping_trans_color.red,\n (int) ping_trans_color.green,\n (int) ping_trans_color.blue);\n }",
" ping_trans_color.red*=0x0101;\n ping_trans_color.green*=0x0101;\n ping_trans_color.blue*=0x0101;\n ping_trans_color.gray*=0x0101;",
" if (logging != MagickFalse)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" to (%d,%d,%d)\",\n (int) ping_trans_color.red,\n (int) ping_trans_color.green,\n (int) ping_trans_color.blue);\n }\n }\n }",
" if (ping_bit_depth < (ssize_t) mng_info->write_png_depth)\n ping_bit_depth = (ssize_t) mng_info->write_png_depth;",
" /*\n Adjust background and transparency samples in sub-8-bit grayscale files.\n */\n if (ping_bit_depth < 8 && ping_color_type ==\n PNG_COLOR_TYPE_GRAY)\n {\n png_uint_16\n maxval;",
" size_t\n one=1;",
" maxval=(png_uint_16) ((one << ping_bit_depth)-1);",
" if (ping_exclude_bKGD == MagickFalse)\n {",
" ping_background.gray=(png_uint_16)\n ((maxval/65535.)*(ScaleQuantumToShort((Quantum)\n GetPixelLuma(image,&image->background_color)))+.5);\n if (logging != MagickFalse)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Setting up bKGD chunk (2)\");\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" ping_background.index is %d\",\n (int) ping_background.index);\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" ping_background.gray is %d\",\n (int) ping_background.gray);\n }",
" ping_have_bKGD = MagickTrue;\n }",
" if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Scaling ping_trans_color.gray from %d\",\n (int)ping_trans_color.gray);",
" ping_trans_color.gray=(png_uint_16) ((maxval/255.)*(\n ping_trans_color.gray)+.5);",
" if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" to %d\", (int)ping_trans_color.gray);\n }",
" if (ping_exclude_bKGD == MagickFalse)\n {\n if (mng_info->IsPalette && (int) ping_color_type == PNG_COLOR_TYPE_PALETTE)\n {\n /*\n Identify which colormap entry is the background color.\n */",
" number_colors=image_colors;",
" for (i=0; i < (ssize_t) MagickMax(1L*number_colors,1L); i++)\n if (IsPNGColorEqual(image->background_color,image->colormap[i]))\n break;",
" ping_background.index=(png_byte) i;",
" if (logging != MagickFalse)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Setting up bKGD chunk with index=%d\",(int) i);\n }",
" if (i < (ssize_t) number_colors)\n {\n ping_have_bKGD = MagickTrue;",
" if (logging != MagickFalse)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" background =(%d,%d,%d)\",\n (int) ping_background.red,\n (int) ping_background.green,\n (int) ping_background.blue);\n }\n }",
" else /* Can't happen */\n {\n if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" No room in PLTE to add bKGD color\");\n ping_have_bKGD = MagickFalse;\n }\n }\n }",
" if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" PNG color type: %s (%d)\", PngColorTypeToString(ping_color_type),\n ping_color_type);\n /*\n Initialize compression level and filtering.\n */\n if (logging != MagickFalse)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Setting up deflate compression\");",
" (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Compression buffer size: 32768\");\n }",
" png_set_compression_buffer_size(ping,32768L);",
" if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Compression mem level: 9\");",
" png_set_compression_mem_level(ping, 9);",
" /* Untangle the \"-quality\" setting:",
" Undefined is 0; the default is used.\n Default is 75",
" 10's digit:",
" 0 or omitted: Use Z_HUFFMAN_ONLY strategy with the\n zlib default compression level",
" 1-9: the zlib compression level",
" 1's digit:",
" 0-4: the PNG filter method",
" 5: libpng adaptive filtering if compression level > 5\n libpng filter type \"none\" if compression level <= 5\n or if image is grayscale or palette",
" 6: libpng adaptive filtering",
" 7: \"LOCO\" filtering (intrapixel differing) if writing\n a MNG, otherwise \"none\". Did not work in IM-6.7.0-9\n and earlier because of a missing \"else\".",
" 8: Z_RLE strategy (or Z_HUFFMAN_ONLY if quality < 10), adaptive\n filtering. Unused prior to IM-6.7.0-10, was same as 6",
" 9: Z_RLE strategy (or Z_HUFFMAN_ONLY if quality < 10), no PNG filters\n Unused prior to IM-6.7.0-10, was same as 6",
" Note that using the -quality option, not all combinations of\n PNG filter type, zlib compression level, and zlib compression\n strategy are possible. This is addressed by using\n \"-define png:compression-strategy\", etc., which takes precedence\n over -quality.",
" */",
" quality=image_info->quality == UndefinedCompressionQuality ? 75UL :\n image_info->quality;",
" if (quality <= 9)\n {\n if (mng_info->write_png_compression_strategy == 0)\n mng_info->write_png_compression_strategy = Z_HUFFMAN_ONLY+1;\n }",
" else if (mng_info->write_png_compression_level == 0)\n {\n int\n level;",
" level=(int) MagickMin((ssize_t) quality/10,9);",
" mng_info->write_png_compression_level = level+1;\n }",
" if (mng_info->write_png_compression_strategy == 0)\n {\n if ((quality %10) == 8 || (quality %10) == 9)\n#ifdef Z_RLE /* Z_RLE was added to zlib-1.2.0 */\n mng_info->write_png_compression_strategy=Z_RLE+1;\n#else\n mng_info->write_png_compression_strategy = Z_DEFAULT_STRATEGY+1;\n#endif\n }",
" if (mng_info->write_png_compression_filter == 0)\n mng_info->write_png_compression_filter=((int) quality % 10) + 1;",
" if (logging != MagickFalse)\n {\n if (mng_info->write_png_compression_level)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Compression level: %d\",\n (int) mng_info->write_png_compression_level-1);",
" if (mng_info->write_png_compression_strategy)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Compression strategy: %d\",\n (int) mng_info->write_png_compression_strategy-1);",
" (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Setting up filtering\");",
" if (mng_info->write_png_compression_filter == 6)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Base filter method: ADAPTIVE\");\n else if (mng_info->write_png_compression_filter == 0 ||\n mng_info->write_png_compression_filter == 1)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Base filter method: NONE\");\n else\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Base filter method: %d\",\n (int) mng_info->write_png_compression_filter-1);\n }",
" if (mng_info->write_png_compression_level != 0)\n png_set_compression_level(ping,mng_info->write_png_compression_level-1);",
" if (mng_info->write_png_compression_filter == 6)\n {\n if (((int) ping_color_type == PNG_COLOR_TYPE_GRAY) ||\n ((int) ping_color_type == PNG_COLOR_TYPE_PALETTE) ||\n (quality < 50))\n png_set_filter(ping,PNG_FILTER_TYPE_BASE,PNG_NO_FILTERS);\n else\n png_set_filter(ping,PNG_FILTER_TYPE_BASE,PNG_ALL_FILTERS);\n }",
" else if (mng_info->write_png_compression_filter == 7 ||\n mng_info->write_png_compression_filter == 10)\n png_set_filter(ping,PNG_FILTER_TYPE_BASE,PNG_ALL_FILTERS);",
" else if (mng_info->write_png_compression_filter == 8)\n {\n#if defined(PNG_MNG_FEATURES_SUPPORTED) && defined(PNG_INTRAPIXEL_DIFFERENCING)\n if (mng_info->write_mng)\n {\n if (((int) ping_color_type == PNG_COLOR_TYPE_RGB) ||\n ((int) ping_color_type == PNG_COLOR_TYPE_RGBA))\n ping_filter_method=PNG_INTRAPIXEL_DIFFERENCING;\n }\n#endif\n png_set_filter(ping,PNG_FILTER_TYPE_BASE,PNG_NO_FILTERS);\n }",
" else if (mng_info->write_png_compression_filter == 9)\n png_set_filter(ping,PNG_FILTER_TYPE_BASE,PNG_NO_FILTERS);",
" else if (mng_info->write_png_compression_filter != 0)\n png_set_filter(ping,PNG_FILTER_TYPE_BASE,\n mng_info->write_png_compression_filter-1);",
" if (mng_info->write_png_compression_strategy != 0)\n png_set_compression_strategy(ping,\n mng_info->write_png_compression_strategy-1);",
" ping_interlace_method=image_info->interlace != NoInterlace;",
" if (mng_info->write_mng)\n png_set_sig_bytes(ping,8);",
" /* Bail out if cannot meet defined png:bit-depth or png:color-type */",
" if (mng_info->write_png_colortype != 0)\n {\n if (mng_info->write_png_colortype-1 == PNG_COLOR_TYPE_GRAY)\n if (ping_have_color != MagickFalse)\n {\n ping_color_type = PNG_COLOR_TYPE_RGB;",
" if (ping_bit_depth < 8)\n ping_bit_depth=8;\n }",
" if (mng_info->write_png_colortype-1 == PNG_COLOR_TYPE_GRAY_ALPHA)\n if (ping_have_color != MagickFalse)\n ping_color_type = PNG_COLOR_TYPE_RGB_ALPHA;\n }",
" if (ping_need_colortype_warning != MagickFalse ||\n ((mng_info->write_png_depth &&\n (int) mng_info->write_png_depth != ping_bit_depth) ||\n (mng_info->write_png_colortype &&\n ((int) mng_info->write_png_colortype-1 != ping_color_type &&\n mng_info->write_png_colortype != 7 &&\n !(mng_info->write_png_colortype == 5 && ping_color_type == 0)))))\n {\n if (logging != MagickFalse)\n {\n if (ping_need_colortype_warning != MagickFalse)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Image has transparency but tRNS chunk was excluded\");\n }",
" if (mng_info->write_png_depth)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Defined png:bit-depth=%u, Computed depth=%u\",\n mng_info->write_png_depth,\n ping_bit_depth);\n }",
" if (mng_info->write_png_colortype)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Defined png:color-type=%u, Computed color type=%u\",\n mng_info->write_png_colortype-1,\n ping_color_type);\n }\n }",
" png_warning(ping,\n \"Cannot write image with defined png:bit-depth or png:color-type.\");\n }",
" if (image_matte != MagickFalse && image->matte == MagickFalse)\n {\n /* Add an opaque matte channel */\n image->matte = MagickTrue;\n (void) SetImageOpacity(image,0);",
" if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Added an opaque matte channel\");\n }",
" if (number_transparent != 0 || number_semitransparent != 0)\n {\n if (ping_color_type < 4)\n {\n ping_have_tRNS=MagickTrue;\n if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Setting ping_have_tRNS=MagickTrue.\");\n }\n }",
" if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Writing PNG header chunks\");",
" png_set_IHDR(ping,ping_info,ping_width,ping_height,\n ping_bit_depth,ping_color_type,\n ping_interlace_method,ping_compression_method,\n ping_filter_method);",
" if (ping_color_type == 3 && ping_have_PLTE != MagickFalse)\n {\n if (mng_info->have_write_global_plte && matte == MagickFalse)\n {\n png_set_PLTE(ping,ping_info,NULL,0);",
" if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Setting up empty PLTE chunk\");\n }",
" else\n png_set_PLTE(ping,ping_info,palette,number_colors);",
" if (logging != MagickFalse)\n {\n for (i=0; i< (ssize_t) number_colors; i++)\n {\n if (i < ping_num_trans)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" PLTE[%d] = (%d,%d,%d), tRNS[%d] = (%d)\",\n (int) i,\n (int) palette[i].red,\n (int) palette[i].green,\n (int) palette[i].blue,\n (int) i,\n (int) ping_trans_alpha[i]);\n else\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" PLTE[%d] = (%d,%d,%d)\",\n (int) i,\n (int) palette[i].red,\n (int) palette[i].green,\n (int) palette[i].blue);\n }\n }\n }",
" /* Only write the iCCP chunk if we are not writing the sRGB chunk. */\n if (ping_exclude_sRGB != MagickFalse ||\n (!png_get_valid(ping,ping_info,PNG_INFO_sRGB)))\n {\n if ((ping_exclude_tEXt == MagickFalse ||\n ping_exclude_zTXt == MagickFalse) &&\n (ping_exclude_iCCP == MagickFalse || ping_exclude_zCCP == MagickFalse))\n {\n ResetImageProfileIterator(image);\n for (name=GetNextImageProfile(image); name != (const char *) NULL; )\n {\n profile=GetImageProfile(image,name);",
" if (profile != (StringInfo *) NULL)\n {\n#ifdef PNG_WRITE_iCCP_SUPPORTED\n if ((LocaleCompare(name,\"ICC\") == 0) ||\n (LocaleCompare(name,\"ICM\") == 0))\n {",
" if (ping_exclude_iCCP == MagickFalse)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Setting up iCCP chunk\");",
" png_set_iCCP(ping,ping_info,(const png_charp) name,0,\n#if (PNG_LIBPNG_VER < 10500)\n (png_charp) GetStringInfoDatum(profile),\n#else\n (const png_byte *) GetStringInfoDatum(profile),\n#endif\n (png_uint_32) GetStringInfoLength(profile));\n ping_have_iCCP = MagickTrue;\n }\n }",
" else\n#endif\n {\n if (LocaleCompare(name,\"exif\") == 0)\n {\n /* Do not write hex-encoded ICC chunk; we will\n write it later as an eXIf chunk */\n name=GetNextImageProfile(image);\n continue;\n }\n if (ping_exclude_zCCP == MagickFalse)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Setting up zTXT chunk with uuencoded ICC\");\n Magick_png_write_raw_profile(image_info,ping,ping_info,\n (unsigned char *) name,(unsigned char *) name,\n GetStringInfoDatum(profile),\n (png_uint_32) GetStringInfoLength(profile));\n ping_have_iCCP = MagickTrue;\n }\n }\n }",
" if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Setting up text chunk with %s profile\",name);",
" name=GetNextImageProfile(image);\n }\n }\n }",
"#if defined(PNG_WRITE_sRGB_SUPPORTED)\n if ((mng_info->have_write_global_srgb == 0) &&\n ping_have_iCCP != MagickTrue &&\n (ping_have_sRGB != MagickFalse ||\n png_get_valid(ping,ping_info,PNG_INFO_sRGB)))\n {\n if (ping_exclude_sRGB == MagickFalse)\n {\n /*\n Note image rendering intent.\n */\n if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Setting up sRGB chunk\");",
" (void) png_set_sRGB(ping,ping_info,(\n Magick_RenderingIntent_to_PNG_RenderingIntent(\n image->rendering_intent)));",
" ping_have_sRGB = MagickTrue;\n }\n }",
" if ((!mng_info->write_mng) || (!png_get_valid(ping,ping_info,PNG_INFO_sRGB)))\n#endif\n {\n if (ping_exclude_gAMA == MagickFalse &&\n ping_have_iCCP == MagickFalse &&\n ping_have_sRGB == MagickFalse &&\n (ping_exclude_sRGB == MagickFalse ||\n (image->gamma < .45 || image->gamma > .46)))\n {\n if ((mng_info->have_write_global_gama == 0) && (image->gamma != 0.0))\n {\n /*\n Note image gamma.\n To do: check for cHRM+gAMA == sRGB, and write sRGB instead.\n */\n if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Setting up gAMA chunk\");",
" png_set_gAMA(ping,ping_info,image->gamma);\n }\n }",
" if (ping_exclude_cHRM == MagickFalse && ping_have_sRGB == MagickFalse)\n {\n if ((mng_info->have_write_global_chrm == 0) &&\n (image->chromaticity.red_primary.x != 0.0))\n {\n /*\n Note image chromaticity.\n Note: if cHRM+gAMA == sRGB write sRGB instead.\n */\n PrimaryInfo\n bp,\n gp,\n rp,\n wp;",
" wp=image->chromaticity.white_point;\n rp=image->chromaticity.red_primary;\n gp=image->chromaticity.green_primary;\n bp=image->chromaticity.blue_primary;",
" if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Setting up cHRM chunk\");",
" png_set_cHRM(ping,ping_info,wp.x,wp.y,rp.x,rp.y,gp.x,gp.y,\n bp.x,bp.y);\n }\n }\n }",
"\n if (ping_exclude_bKGD == MagickFalse)\n {\n if (ping_have_bKGD != MagickFalse)\n {\n png_set_bKGD(ping,ping_info,&ping_background);\n if (logging != MagickFalse)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Setting up bKGD chunk\");\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" background color = (%d,%d,%d)\",\n (int) ping_background.red,\n (int) ping_background.green,\n (int) ping_background.blue);\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" index = %d, gray=%d\",\n (int) ping_background.index,\n (int) ping_background.gray);\n }\n }\n }",
" if (ping_exclude_pHYs == MagickFalse)\n {\n if (ping_have_pHYs != MagickFalse)\n {\n png_set_pHYs(ping,ping_info,\n ping_pHYs_x_resolution,\n ping_pHYs_y_resolution,\n ping_pHYs_unit_type);",
" if (logging != MagickFalse)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Setting up pHYs chunk\");\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" x_resolution=%lu\",\n (unsigned long) ping_pHYs_x_resolution);\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" y_resolution=%lu\",\n (unsigned long) ping_pHYs_y_resolution);\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" unit_type=%lu\",\n (unsigned long) ping_pHYs_unit_type);\n }\n }\n }",
"#if defined(PNG_tIME_SUPPORTED)\n if (ping_exclude_tIME == MagickFalse)\n {\n const char\n *timestamp;",
" if (image->taint == MagickFalse)\n {\n timestamp=GetImageOption(image_info,\"png:tIME\");",
" if (timestamp == (const char *) NULL)\n timestamp=GetImageProperty(image,\"png:tIME\");\n }",
" else\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Reset tIME in tainted image\");\n timestamp=GetImageProperty(image,\"date:modify\");\n }",
" if (timestamp != (const char *) NULL)\n write_tIME_chunk(image,ping,ping_info,timestamp);\n }\n#endif",
" if (mng_info->need_blob != MagickFalse)\n {\n if (OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception) ==\n MagickFalse)\n png_error(ping,\"WriteBlob Failed\");",
" ping_have_blob=MagickTrue;\n (void) ping_have_blob;\n }",
" png_write_info_before_PLTE(ping, ping_info);",
" if (ping_have_tRNS != MagickFalse && ping_color_type < 4)\n {\n if (logging != MagickFalse)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Calling png_set_tRNS with num_trans=%d\",ping_num_trans);\n }",
" if (ping_color_type == 3)\n (void) png_set_tRNS(ping, ping_info,\n ping_trans_alpha,\n ping_num_trans,\n NULL);",
" else\n {\n (void) png_set_tRNS(ping, ping_info,\n NULL,\n 0,\n &ping_trans_color);",
" if (logging != MagickFalse)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" tRNS color =(%d,%d,%d)\",\n (int) ping_trans_color.red,\n (int) ping_trans_color.green,\n (int) ping_trans_color.blue);\n }\n }\n }",
" png_write_info(ping,ping_info);",
" ping_wrote_caNv = MagickFalse;",
" /* write caNv chunk */\n if (ping_exclude_caNv == MagickFalse)\n {\n if ((image->page.width != 0 && image->page.width != image->columns) ||\n (image->page.height != 0 && image->page.height != image->rows) ||\n image->page.x != 0 || image->page.y != 0)\n {\n unsigned char\n chunk[20];",
" (void) WriteBlobMSBULong(image,16L); /* data length=8 */\n PNGType(chunk,mng_caNv);\n LogPNGChunk(logging,mng_caNv,16L);\n PNGLong(chunk+4,(png_uint_32) image->page.width);\n PNGLong(chunk+8,(png_uint_32) image->page.height);\n PNGsLong(chunk+12,(png_int_32) image->page.x);\n PNGsLong(chunk+16,(png_int_32) image->page.y);\n (void) WriteBlob(image,20,chunk);\n (void) WriteBlobMSBULong(image,crc32(0,chunk,20));\n ping_wrote_caNv = MagickTrue;\n }\n }",
"#if defined(PNG_oFFs_SUPPORTED)\n if (ping_exclude_oFFs == MagickFalse && ping_wrote_caNv == MagickFalse)\n {\n if (image->page.x || image->page.y)\n {\n png_set_oFFs(ping,ping_info,(png_int_32) image->page.x,\n (png_int_32) image->page.y, 0);",
" if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Setting up oFFs chunk with x=%d, y=%d, units=0\",\n (int) image->page.x, (int) image->page.y);\n }\n }\n#endif",
"#if (PNG_LIBPNG_VER == 10206)\n /* avoid libpng-1.2.6 bug by setting PNG_HAVE_IDAT flag */\n#define PNG_HAVE_IDAT 0x04\n ping->mode |= PNG_HAVE_IDAT;\n#undef PNG_HAVE_IDAT\n#endif",
" png_set_packing(ping);\n /*\n Allocate memory.\n */\n rowbytes=image->columns;\n if (image_depth > 8)\n rowbytes*=2;\n switch (ping_color_type)\n {\n case PNG_COLOR_TYPE_RGB:\n rowbytes*=3;\n break;",
" case PNG_COLOR_TYPE_GRAY_ALPHA:\n rowbytes*=2;\n break;",
" case PNG_COLOR_TYPE_RGBA:\n rowbytes*=4;\n break;",
" default:\n break;\n }",
" if (logging != MagickFalse)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Writing PNG image data\");",
" (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Allocating %.20g bytes of memory for pixels\",(double) rowbytes);\n }\n pixel_info=AcquireVirtualMemory(rowbytes,sizeof(*ping_pixels));\n if (pixel_info == (MemoryInfo *) NULL)\n png_error(ping,\"Allocation of memory for pixels failed\");\n ping_pixels=(unsigned char *) GetVirtualMemoryBlob(pixel_info);\n /*\n Initialize image scanlines.\n */\n quantum_info=AcquireQuantumInfo(image_info,image);\n if (quantum_info == (QuantumInfo *) NULL)\n png_error(ping,\"Memory allocation for quantum_info failed\");\n quantum_info->format=UndefinedQuantumFormat;\n SetQuantumDepth(image,quantum_info,image_depth);\n (void) SetQuantumEndian(image,quantum_info,MSBEndian);\n num_passes=png_set_interlace_handling(ping);",
" if ((!mng_info->write_png8 && !mng_info->write_png24 &&\n !mng_info->write_png48 && !mng_info->write_png64 &&\n !mng_info->write_png32) &&\n (mng_info->IsPalette ||\n (image_info->type == BilevelType)) &&\n image_matte == MagickFalse &&\n ping_have_non_bw == MagickFalse)\n {\n /* Palette, Bilevel, or Opaque Monochrome */\n register const PixelPacket\n *p;",
" SetQuantumDepth(image,quantum_info,8);\n for (pass=0; pass < num_passes; pass++)\n {\n /*\n Convert PseudoClass image to a PNG monochrome image.\n */\n for (y=0; y < (ssize_t) image->rows; y++)\n {\n if (logging != MagickFalse && y == 0)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Writing row of pixels (0)\");",
" p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);",
" if (p == (const PixelPacket *) NULL)\n break;",
" if (mng_info->IsPalette)\n {\n (void) ExportQuantumPixels(image,(const CacheView *) NULL,\n quantum_info,GrayQuantum,ping_pixels,&image->exception);\n if (mng_info->write_png_colortype-1 == PNG_COLOR_TYPE_PALETTE &&\n mng_info->write_png_depth &&\n mng_info->write_png_depth != old_bit_depth)\n {\n /* Undo pixel scaling */\n for (i=0; i < (ssize_t) image->columns; i++)\n *(ping_pixels+i)=(unsigned char) (*(ping_pixels+i)\n >> (8-old_bit_depth));\n }\n }",
" else\n {\n (void) ExportQuantumPixels(image,(const CacheView *) NULL,\n quantum_info,RedQuantum,ping_pixels,&image->exception);\n }",
" if (mng_info->write_png_colortype-1 != PNG_COLOR_TYPE_PALETTE)\n for (i=0; i < (ssize_t) image->columns; i++)\n *(ping_pixels+i)=(unsigned char) ((*(ping_pixels+i) > 127) ?\n 255 : 0);",
" if (logging != MagickFalse && y == 0)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Writing row of pixels (1)\");",
" png_write_row(ping,ping_pixels);",
" status=SetImageProgress(image,SaveImageTag,\n (MagickOffsetType) (pass * image->rows + y),\n num_passes * image->rows);\n if (status == MagickFalse)\n break;\n }\n }\n }",
" else /* Not Palette, Bilevel, or Opaque Monochrome */\n {\n if ((!mng_info->write_png8 && !mng_info->write_png24 &&\n !mng_info->write_png48 && !mng_info->write_png64 &&\n !mng_info->write_png32) && (image_matte != MagickFalse ||\n (ping_bit_depth >= MAGICKCORE_QUANTUM_DEPTH)) &&\n (mng_info->IsPalette) && ping_have_color == MagickFalse)\n {\n register const PixelPacket\n *p;",
" for (pass=0; pass < num_passes; pass++)\n {",
" for (y=0; y < (ssize_t) image->rows; y++)\n {\n p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);",
" if (p == (const PixelPacket *) NULL)\n break;",
" if (ping_color_type == PNG_COLOR_TYPE_GRAY)\n {\n if (mng_info->IsPalette)\n (void) ExportQuantumPixels(image,(const CacheView *) NULL,\n quantum_info,GrayQuantum,ping_pixels,&image->exception);",
" else\n (void) ExportQuantumPixels(image,(const CacheView *) NULL,\n quantum_info,RedQuantum,ping_pixels,&image->exception);",
" if (logging != MagickFalse && y == 0)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Writing GRAY PNG pixels (2)\");\n }",
" else /* PNG_COLOR_TYPE_GRAY_ALPHA */\n {\n if (logging != MagickFalse && y == 0)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Writing GRAY_ALPHA PNG pixels (2)\");",
" (void) ExportQuantumPixels(image,(const CacheView *) NULL,\n quantum_info,GrayAlphaQuantum,ping_pixels,&image->exception);\n }",
" if (logging != MagickFalse && y == 0)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Writing row of pixels (2)\");",
" png_write_row(ping,ping_pixels);",
" status=SetImageProgress(image,SaveImageTag,\n (MagickOffsetType) (pass * image->rows + y),\n num_passes * image->rows);\n if (status == MagickFalse)\n break;\n }\n }\n }",
" else\n {\n register const PixelPacket\n *p;",
" for (pass=0; pass < num_passes; pass++)\n {\n if ((image_depth > 8) ||\n mng_info->write_png24 ||\n mng_info->write_png32 ||\n mng_info->write_png48 ||\n mng_info->write_png64 ||\n (!mng_info->write_png8 && !mng_info->IsPalette))\n {\n for (y=0; y < (ssize_t) image->rows; y++)\n {\n p=GetVirtualPixels(image,0,y,image->columns,1,\n &image->exception);",
" if (p == (const PixelPacket *) NULL)\n break;",
" if (ping_color_type == PNG_COLOR_TYPE_GRAY)\n {\n if (image->storage_class == DirectClass)\n (void) ExportQuantumPixels(image,(const CacheView *) NULL,\n quantum_info,RedQuantum,ping_pixels,&image->exception);",
" else\n (void) ExportQuantumPixels(image,(const CacheView *) NULL,\n quantum_info,GrayQuantum,ping_pixels,&image->exception);\n }",
" else if (ping_color_type == PNG_COLOR_TYPE_GRAY_ALPHA)\n {\n (void) ExportQuantumPixels(image,(const CacheView *) NULL,\n quantum_info,GrayAlphaQuantum,ping_pixels,\n &image->exception);",
" if (logging != MagickFalse && y == 0)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Writing GRAY_ALPHA PNG pixels (3)\");\n }",
" else if (image_matte != MagickFalse)\n (void) ExportQuantumPixels(image,(const CacheView *) NULL,\n quantum_info,RGBAQuantum,ping_pixels,&image->exception);",
" else\n (void) ExportQuantumPixels(image,(const CacheView *) NULL,\n quantum_info,RGBQuantum,ping_pixels,&image->exception);",
" if (logging != MagickFalse && y == 0)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Writing row of pixels (3)\");",
" png_write_row(ping,ping_pixels);",
" status=SetImageProgress(image,SaveImageTag,\n (MagickOffsetType) (pass * image->rows + y),\n num_passes * image->rows);\n if (status == MagickFalse)\n break;\n }\n }",
" else\n /* not ((image_depth > 8) ||\n mng_info->write_png24 || mng_info->write_png32 ||\n mng_info->write_png48 || mng_info->write_png64 ||\n (!mng_info->write_png8 && !mng_info->IsPalette))\n */\n {\n if ((ping_color_type != PNG_COLOR_TYPE_GRAY) &&\n (ping_color_type != PNG_COLOR_TYPE_GRAY_ALPHA))\n {\n if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" pass %d, Image Is not GRAY or GRAY_ALPHA\",pass);",
" SetQuantumDepth(image,quantum_info,8);\n image_depth=8;\n }",
" for (y=0; y < (ssize_t) image->rows; y++)\n {\n if (logging != MagickFalse && y == 0)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" pass %d, Image Is RGB, 16-bit GRAY, or GRAY_ALPHA\",pass);",
" p=GetVirtualPixels(image,0,y,image->columns,1,\n &image->exception);",
" if (p == (const PixelPacket *) NULL)\n break;",
" if (ping_color_type == PNG_COLOR_TYPE_GRAY)\n {\n SetQuantumDepth(image,quantum_info,image->depth);",
" (void) ExportQuantumPixels(image,(const CacheView *) NULL,\n quantum_info,GrayQuantum,ping_pixels,&image->exception);\n }",
" else if (ping_color_type == PNG_COLOR_TYPE_GRAY_ALPHA)\n {\n if (logging != MagickFalse && y == 0)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Writing GRAY_ALPHA PNG pixels (4)\");",
" (void) ExportQuantumPixels(image,(const CacheView *) NULL,\n quantum_info,GrayAlphaQuantum,ping_pixels,\n &image->exception);\n }",
" else\n {\n (void) ExportQuantumPixels(image,(const CacheView *) NULL,\n quantum_info,IndexQuantum,ping_pixels,&image->exception);",
" if (logging != MagickFalse && y <= 2)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Writing row of non-gray pixels (4)\");",
" (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" ping_pixels[0]=%d,ping_pixels[1]=%d\",\n (int)ping_pixels[0],(int)ping_pixels[1]);\n }\n }\n png_write_row(ping,ping_pixels);",
" status=SetImageProgress(image,SaveImageTag,\n (MagickOffsetType) (pass * image->rows + y),\n num_passes * image->rows);\n if (status == MagickFalse)\n break;\n }\n }\n }\n }\n }",
" if (quantum_info != (QuantumInfo *) NULL)\n quantum_info=DestroyQuantumInfo(quantum_info);",
" if (logging != MagickFalse)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Wrote PNG image data\");",
" (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Width: %.20g\",(double) ping_width);",
" (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Height: %.20g\",(double) ping_height);",
" if (mng_info->write_png_depth)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Defined png:bit-depth: %d\",mng_info->write_png_depth);\n }",
" (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" PNG bit-depth written: %d\",ping_bit_depth);",
" if (mng_info->write_png_colortype)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Defined png:color-type: %d\",mng_info->write_png_colortype-1);\n }",
" (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" PNG color-type written: %d\",ping_color_type);",
" (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" PNG Interlace method: %d\",ping_interlace_method);\n }\n /*\n Generate text chunks after IDAT.\n */\n if (ping_exclude_tEXt == MagickFalse || ping_exclude_zTXt == MagickFalse)\n {\n ResetImagePropertyIterator(image);\n property=GetNextImageProperty(image);\n while (property != (const char *) NULL)\n {\n png_textp\n text;",
" value=GetImageProperty(image,property);",
" /* Don't write any \"png:\" or \"jpeg:\" properties; those are just for\n * \"identify\" or for passing through to another JPEG\n */\n if ((LocaleNCompare(property,\"png:\",4) != 0 &&\n LocaleNCompare(property,\"jpeg:\",5) != 0) &&",
" /* Suppress density and units if we wrote a pHYs chunk */\n (ping_exclude_pHYs != MagickFalse ||\n LocaleCompare(property,\"density\") != 0 ||\n LocaleCompare(property,\"units\") != 0) &&",
" /* Suppress the IM-generated Date:create and Date:modify */\n (ping_exclude_date == MagickFalse ||\n LocaleNCompare(property, \"Date:\",5) != 0))\n {\n if (value != (const char *) NULL)\n {",
"#if PNG_LIBPNG_VER >= 10400\n text=(png_textp) png_malloc(ping,\n (png_alloc_size_t) sizeof(png_text));\n#else\n text=(png_textp) png_malloc(ping,(png_size_t) sizeof(png_text));\n#endif\n text[0].key=(char *) property;\n text[0].text=(char *) value;\n text[0].text_length=strlen(value);",
" if (ping_exclude_tEXt != MagickFalse)\n text[0].compression=PNG_TEXT_COMPRESSION_zTXt;",
" else if (ping_exclude_zTXt != MagickFalse)\n text[0].compression=PNG_TEXT_COMPRESSION_NONE;",
" else\n {\n text[0].compression=image_info->compression == NoCompression ||\n (image_info->compression == UndefinedCompression &&\n text[0].text_length < 128) ? PNG_TEXT_COMPRESSION_NONE :\n PNG_TEXT_COMPRESSION_zTXt ;\n }",
" if (logging != MagickFalse)\n {\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Setting up text chunk\");",
" (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" keyword: '%s'\",text[0].key);\n }",
" png_set_text(ping,ping_info,text,1);\n png_free(ping,text);\n }\n }\n property=GetNextImageProperty(image);\n }\n }",
" /* write eXIf profile */\n if (ping_have_eXIf != MagickFalse && ping_exclude_eXIf == MagickFalse)\n {\n char\n *name;",
" ResetImageProfileIterator(image);",
" for (name=GetNextImageProfile(image); name != (const char *) NULL; )\n {\n if (LocaleCompare(name,\"exif\") == 0)\n {\n const StringInfo\n *profile;",
" profile=GetImageProfile(image,name);",
" if (profile != (StringInfo *) NULL)\n {\n png_uint_32\n length;\n unsigned char\n chunk[4],\n *data;",
" StringInfo\n *ping_profile;",
" (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Have eXIf profile\");",
" ping_profile=CloneStringInfo(profile);\n data=GetStringInfoDatum(ping_profile),",
" length=(png_uint_32) GetStringInfoLength(ping_profile);",
" PNGType(chunk,mng_eXIf);\n if (length < 7)\n {\n ping_profile=DestroyStringInfo(ping_profile);\n break; /* otherwise crashes */\n }",
" if (*data == 'E' && *(data+1) == 'x' && *(data+2) == 'i' &&\n *(data+3) == 'f' && *(data+4) == '\\0' && *(data+5) == '\\0')\n {\n /* skip the \"Exif\\0\\0\" JFIF Exif Header ID */\n length -= 6;\n data += 6;\n }",
" LogPNGChunk(logging,chunk,length);\n (void) WriteBlobMSBULong(image,length);\n (void) WriteBlob(image,4,chunk);\n (void) WriteBlob(image,length,data);\n (void) WriteBlobMSBULong(image,crc32(crc32(0,chunk,4), data,\n (uInt) length));\n ping_profile=DestroyStringInfo(ping_profile);\n break;\n }\n }\n name=GetNextImageProfile(image);\n }\n }",
" if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" Writing PNG end info\");",
" png_write_end(ping,ping_info);",
" if (mng_info->need_fram && (int) image->dispose == BackgroundDispose)\n {\n if (mng_info->page.x || mng_info->page.y ||\n (ping_width != mng_info->page.width) ||\n (ping_height != mng_info->page.height))\n {\n unsigned char\n chunk[32];",
" /*\n Write FRAM 4 with clipping boundaries followed by FRAM 1.\n */\n (void) WriteBlobMSBULong(image,27L); /* data length=27 */\n PNGType(chunk,mng_FRAM);\n LogPNGChunk(logging,mng_FRAM,27L);\n chunk[4]=4;\n chunk[5]=0; /* frame name separator (no name) */\n chunk[6]=1; /* flag for changing delay, for next frame only */\n chunk[7]=0; /* flag for changing frame timeout */\n chunk[8]=1; /* flag for changing frame clipping for next frame */\n chunk[9]=0; /* flag for changing frame sync_id */\n PNGLong(chunk+10,(png_uint_32) (0L)); /* temporary 0 delay */\n chunk[14]=0; /* clipping boundaries delta type */\n PNGLong(chunk+15,(png_uint_32) (mng_info->page.x)); /* left cb */\n PNGLong(chunk+19,\n (png_uint_32) (mng_info->page.x + ping_width));\n PNGLong(chunk+23,(png_uint_32) (mng_info->page.y)); /* top cb */\n PNGLong(chunk+27,\n (png_uint_32) (mng_info->page.y + ping_height));\n (void) WriteBlob(image,31,chunk);\n (void) WriteBlobMSBULong(image,crc32(0,chunk,31));\n mng_info->old_framing_mode=4;\n mng_info->framing_mode=1;\n }",
" else\n mng_info->framing_mode=3;\n }\n if (mng_info->write_mng && !mng_info->need_fram &&\n ((int) image->dispose == 3))\n png_error(ping, \"Cannot convert GIF with disposal method 3 to MNG-LC\");",
" /*\n Free PNG resources.\n */",
" png_destroy_write_struct(&ping,&ping_info);",
" pixel_info=RelinquishVirtualMemory(pixel_info);",
" /* Store bit depth actually written */\n s[0]=(char) ping_bit_depth;\n s[1]='\\0';",
" (void) SetImageProperty(image,\"png:bit-depth-written\",s);",
" if (logging != MagickFalse)\n (void) LogMagickEvent(CoderEvent,GetMagickModule(),\n \" exit WriteOnePNGImage()\");",
"#ifdef IMPNG_SETJMP_NOT_THREAD_SAFE\n UnlockSemaphoreInfo(ping_semaphore);\n#endif",
" /* } for navigation to beginning of SETJMP-protected block. Revert to\n * Throwing an Exception when an error occurs.\n */",
" return(MagickTrue);\n/* End write one PNG image */",
"}\n"
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
BIGVUL
|
{
"CVE ID": "CVE-2018-16749",
"CVE Page": "https://www.cvedetails.com/cve/CVE-2018-16749/",
"CWE ID": "CWE-617",
"codeLink": "https://github.com/ImageMagick/ImageMagick6/commit/1007b98f8795ad4bea6bc5f68a32d83e982fdae4",
"commit_id": "1007b98f8795ad4bea6bc5f68a32d83e982fdae4",
"commit_message": "https://github.com/ImageMagick/ImageMagick/issues/1119",
"lang": "C",
"project": "ImageMagick6"
}
| 25
|
Determine whether the code is vulnerable or not.
|
[
"v8::Handle<v8::Value> V8WebGLRenderingContext::uniformMatrix2fvCallback(const v8::Arguments& args)\n{\n INC_STATS(\"DOM.WebGLRenderingContext.uniformMatrix2fv()\");\n return uniformMatrixHelper(args, 2);\n}\n"
] |
[
1
] |
BIGVUL
|
{
"CVE ID": "CVE-2011-3055",
"CVE Page": "https://www.cvedetails.com/cve/CVE-2011-3055/",
"CWE ID": null,
"codeLink": "https://github.com/chromium/chromium/commit/e9372a1bfd3588a80fcf49aa07321f0971dd6091",
"commit_id": "e9372a1bfd3588a80fcf49aa07321f0971dd6091",
"commit_message": "[V8] Pass Isolate to throwNotEnoughArgumentsError()\nhttps://bugs.webkit.org/show_bug.cgi?id=86983\n\nReviewed by Adam Barth.\n\nThe objective is to pass Isolate around in V8 bindings.\nThis patch passes Isolate to throwNotEnoughArgumentsError().\n\nNo tests. No change in behavior.\n\n* bindings/scripts/CodeGeneratorV8.pm:\n(GenerateArgumentsCountCheck):\n(GenerateEventConstructorCallback):\n* bindings/scripts/test/V8/V8Float64Array.cpp:\n(WebCore::Float64ArrayV8Internal::fooCallback):\n* bindings/scripts/test/V8/V8TestActiveDOMObject.cpp:\n(WebCore::TestActiveDOMObjectV8Internal::excitingFunctionCallback):\n(WebCore::TestActiveDOMObjectV8Internal::postMessageCallback):\n* bindings/scripts/test/V8/V8TestCustomNamedGetter.cpp:\n(WebCore::TestCustomNamedGetterV8Internal::anotherFunctionCallback):\n* bindings/scripts/test/V8/V8TestEventConstructor.cpp:\n(WebCore::V8TestEventConstructor::constructorCallback):\n* bindings/scripts/test/V8/V8TestEventTarget.cpp:\n(WebCore::TestEventTargetV8Internal::itemCallback):\n(WebCore::TestEventTargetV8Internal::dispatchEventCallback):\n* bindings/scripts/test/V8/V8TestInterface.cpp:\n(WebCore::TestInterfaceV8Internal::supplementalMethod2Callback):\n(WebCore::V8TestInterface::constructorCallback):\n* bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp:\n(WebCore::TestMediaQueryListListenerV8Internal::methodCallback):\n* bindings/scripts/test/V8/V8TestNamedConstructor.cpp:\n(WebCore::V8TestNamedConstructorConstructorCallback):\n* bindings/scripts/test/V8/V8TestObj.cpp:\n(WebCore::TestObjV8Internal::voidMethodWithArgsCallback):\n(WebCore::TestObjV8Internal::intMethodWithArgsCallback):\n(WebCore::TestObjV8Internal::objMethodWithArgsCallback):\n(WebCore::TestObjV8Internal::methodWithSequenceArgCallback):\n(WebCore::TestObjV8Internal::methodReturningSequenceCallback):\n(WebCore::TestObjV8Internal::methodThatRequiresAllArgsAndThrowsCallback):\n(WebCore::TestObjV8Internal::serializedValueCallback):\n(WebCore::TestObjV8Internal::idbKeyCallback):\n(WebCore::TestObjV8Internal::optionsObjectCallback):\n(WebCore::TestObjV8Internal::methodWithNonOptionalArgAndOptionalArgCallback):\n(WebCore::TestObjV8Internal::methodWithNonOptionalArgAndTwoOptionalArgsCallback):\n(WebCore::TestObjV8Internal::methodWithCallbackArgCallback):\n(WebCore::TestObjV8Internal::methodWithNonCallbackArgAndCallbackArgCallback):\n(WebCore::TestObjV8Internal::overloadedMethod1Callback):\n(WebCore::TestObjV8Internal::overloadedMethod2Callback):\n(WebCore::TestObjV8Internal::overloadedMethod3Callback):\n(WebCore::TestObjV8Internal::overloadedMethod4Callback):\n(WebCore::TestObjV8Internal::overloadedMethod5Callback):\n(WebCore::TestObjV8Internal::overloadedMethod6Callback):\n(WebCore::TestObjV8Internal::overloadedMethod7Callback):\n(WebCore::TestObjV8Internal::overloadedMethod11Callback):\n(WebCore::TestObjV8Internal::overloadedMethod12Callback):\n(WebCore::TestObjV8Internal::enabledAtRuntimeMethod1Callback):\n(WebCore::TestObjV8Internal::enabledAtRuntimeMethod2Callback):\n(WebCore::TestObjV8Internal::convert1Callback):\n(WebCore::TestObjV8Internal::convert2Callback):\n(WebCore::TestObjV8Internal::convert3Callback):\n(WebCore::TestObjV8Internal::convert4Callback):\n(WebCore::TestObjV8Internal::convert5Callback):\n(WebCore::TestObjV8Internal::strictFunctionCallback):\n(WebCore::V8TestObj::constructorCallback):\n* bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp:\n(WebCore::TestSerializedScriptValueInterfaceV8Internal::acceptTransferListCallback):\n(WebCore::V8TestSerializedScriptValueInterface::constructorCallback):\n* bindings/v8/ScriptController.cpp:\n(WebCore::setValueAndClosePopupCallback):\n* bindings/v8/V8Proxy.cpp:\n(WebCore::V8Proxy::throwNotEnoughArgumentsError):\n* bindings/v8/V8Proxy.h:\n(V8Proxy):\n* bindings/v8/custom/V8AudioContextCustom.cpp:\n(WebCore::V8AudioContext::constructorCallback):\n* bindings/v8/custom/V8DataViewCustom.cpp:\n(WebCore::V8DataView::getInt8Callback):\n(WebCore::V8DataView::getUint8Callback):\n(WebCore::V8DataView::setInt8Callback):\n(WebCore::V8DataView::setUint8Callback):\n* bindings/v8/custom/V8DirectoryEntryCustom.cpp:\n(WebCore::V8DirectoryEntry::getDirectoryCallback):\n(WebCore::V8DirectoryEntry::getFileCallback):\n* bindings/v8/custom/V8IntentConstructor.cpp:\n(WebCore::V8Intent::constructorCallback):\n* bindings/v8/custom/V8SVGLengthCustom.cpp:\n(WebCore::V8SVGLength::convertToSpecifiedUnitsCallback):\n* bindings/v8/custom/V8WebGLRenderingContextCustom.cpp:\n(WebCore::getObjectParameter):\n(WebCore::V8WebGLRenderingContext::getAttachedShadersCallback):\n(WebCore::V8WebGLRenderingContext::getExtensionCallback):\n(WebCore::V8WebGLRenderingContext::getFramebufferAttachmentParameterCallback):\n(WebCore::V8WebGLRenderingContext::getParameterCallback):\n(WebCore::V8WebGLRenderingContext::getProgramParameterCallback):\n(WebCore::V8WebGLRenderingContext::getShaderParameterCallback):\n(WebCore::V8WebGLRenderingContext::getUniformCallback):\n(WebCore::vertexAttribAndUniformHelperf):\n(WebCore::uniformHelperi):\n(WebCore::uniformMatrixHelper):\n* bindings/v8/custom/V8WebKitMutationObserverCustom.cpp:\n(WebCore::V8WebKitMutationObserver::constructorCallback):\n(WebCore::V8WebKitMutationObserver::observeCallback):\n* bindings/v8/custom/V8WebSocketCustom.cpp:\n(WebCore::V8WebSocket::constructorCallback):\n(WebCore::V8WebSocket::sendCallback):\n* bindings/v8/custom/V8XMLHttpRequestCustom.cpp:\n(WebCore::V8XMLHttpRequest::openCallback):\n\n\ngit-svn-id: svn://svn.chromium.org/blink/trunk@117736 bbb929c8-8fbe-4397-9dbb-9b2b20218538",
"lang": "C",
"project": "Chrome"
}
| 26
|
Determine whether the code is vulnerable or not.
|
[
"static int decode_putfh(struct xdr_stream *xdr)\n{\n\treturn decode_op_hdr(xdr, OP_PUTFH);\n}\n"
] |
[
1
] |
BIGVUL
|
{
"CVE ID": "CVE-2011-4324",
"CVE Page": "https://www.cvedetails.com/cve/CVE-2011-4324/",
"CWE ID": null,
"codeLink": "https://github.com/torvalds/linux/commit/dc0b027dfadfcb8a5504f7d8052754bf8d501ab9",
"commit_id": "dc0b027dfadfcb8a5504f7d8052754bf8d501ab9",
"commit_message": "NFSv4: Convert the open and close ops to use fmode\n\nSigned-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>",
"lang": "C",
"project": "linux"
}
| 27
|
Determine whether the code is vulnerable or not.
|
[
"xsltCheckExtURI(xsltStylesheetPtr style, const xmlChar * URI)\n{\n xsltExtDefPtr cur;",
" if ((style == NULL) || (style->nsDefs == NULL))\n return (0);\n if (URI == NULL)\n return (0);\n cur = (xsltExtDefPtr) style->nsDefs;\n while (cur != NULL) {\n if (xmlStrEqual(URI, cur->URI))\n return (1);\n cur = cur->next;\n }\n return (0);\n}\n"
] |
[
1,
1
] |
BIGVUL
|
{
"CVE ID": "CVE-2016-1683",
"CVE Page": "https://www.cvedetails.com/cve/CVE-2016-1683/",
"CWE ID": "CWE-119",
"codeLink": "https://github.com/chromium/chromium/commit/96dbafe288dbe2f0cc45fa3c39daf6d0c37acbab",
"commit_id": "96dbafe288dbe2f0cc45fa3c39daf6d0c37acbab",
"commit_message": "Roll libxslt to 891681e3e948f31732229f53cb6db7215f740fc7\n\nBUG=583156,583171\n\nReview URL: https://codereview.chromium.org/1853083002\n\nCr-Commit-Position: refs/heads/master@{#385338}",
"lang": "C",
"project": "Chrome"
}
| 28
|
Determine whether the code is vulnerable or not.
|
[
"static int bpf_obj_get(const union bpf_attr *attr)\n{\n\tif (CHECK_ATTR(BPF_OBJ) || attr->bpf_fd != 0)\n\t\treturn -EINVAL;",
"\treturn bpf_obj_get_user(u64_to_ptr(attr->pathname));\n}\n"
] |
[
1,
1
] |
BIGVUL
|
{
"CVE ID": "CVE-2016-4558",
"CVE Page": "https://www.cvedetails.com/cve/CVE-2016-4558/",
"CWE ID": null,
"codeLink": "https://github.com/torvalds/linux/commit/92117d8443bc5afacc8d5ba82e541946310f106e",
"commit_id": "92117d8443bc5afacc8d5ba82e541946310f106e",
"commit_message": "bpf: fix refcnt overflow\n\nOn a system with >32Gbyte of phyiscal memory and infinite RLIMIT_MEMLOCK,\nthe malicious application may overflow 32-bit bpf program refcnt.\nIt's also possible to overflow map refcnt on 1Tb system.\nImpose 32k hard limit which means that the same bpf program or\nmap cannot be shared by more than 32k processes.\n\nFixes: 1be7f75d1668 (\"bpf: enable non-root eBPF programs\")\nReported-by: Jann Horn <jannh@google.com>\nSigned-off-by: Alexei Starovoitov <ast@kernel.org>\nAcked-by: Daniel Borkmann <daniel@iogearbox.net>\nSigned-off-by: David S. Miller <davem@davemloft.net>",
"lang": "C",
"project": "linux"
}
| 29
|
Determine whether the code is vulnerable or not.
|
[
"bool IsLoaderInterceptionEnabled() {\n return base::FeatureList::IsEnabled(network::features::kNetworkService) ||\n blink::ServiceWorkerUtils::IsServicificationEnabled() ||\n signed_exchange_utils::IsSignedExchangeHandlingEnabled();\n}\n"
] |
[
1
] |
BIGVUL
|
{
"CVE ID": "CVE-2018-20068",
"CVE Page": "https://www.cvedetails.com/cve/CVE-2018-20068/",
"CWE ID": "CWE-20",
"codeLink": "https://github.com/chromium/chromium/commit/4f8104c528f0147c7527718d5aa7c9c38c8220d0",
"commit_id": "4f8104c528f0147c7527718d5aa7c9c38c8220d0",
"commit_message": "Abort navigations on 304 responses.\n\nA recent change (https://chromium-review.googlesource.com/1161479)\naccidentally resulted in treating 304 responses as downloads. This CL\ntreats them as ERR_ABORTED instead. This doesn't exactly match old\nbehavior, which passed them on to the renderer, which then aborted them.\n\nThe new code results in correctly restoring the original URL in the\nomnibox, and has a shiny new test to prevent future regressions.\n\nBug: 882270\nChange-Id: Ic73dcce9e9596d43327b13acde03b4ed9bd0c82e\nReviewed-on: https://chromium-review.googlesource.com/1252684\nCommit-Queue: Matt Menke <mmenke@chromium.org>\nReviewed-by: Camille Lamy <clamy@chromium.org>\nCr-Commit-Position: refs/heads/master@{#595641}",
"lang": "C",
"project": "Chrome"
}
| 30
|
Determine whether the code is vulnerable or not.
|
[
"check_switch(int firstcode)\n{\n\treturn (firstcode == SWFACTION_PUSH || firstcode == SWFACTION_JUMP);\n}\n"
] |
[
1
] |
BIGVUL
|
{
"CVE ID": "CVE-2019-12982",
"CVE Page": "https://www.cvedetails.com/cve/CVE-2019-12982/",
"CWE ID": "CWE-119",
"codeLink": "https://github.com/libming/libming/pull/179/commits/2be22fcf56a223dafe8de0e8a20fe20e8bbdb0b9",
"commit_id": "2be22fcf56a223dafe8de0e8a20fe20e8bbdb0b9",
"commit_message": "decompileAction: Prevent heap buffer overflow and underflow with using OpCode",
"lang": "C",
"project": "libming"
}
| 31
|
Determine whether the code is vulnerable or not.
|
[
"xmlParse3986URI(xmlURIPtr uri, const char *str) {\n int ret;",
" ret = xmlParse3986Scheme(uri, &str);\n if (ret != 0) return(ret);\n if (*str != ':') {\n return(1);\n }\n str++;\n ret = xmlParse3986HierPart(uri, &str);\n if (ret != 0) return(ret);\n if (*str == '?') {\n\tstr++;\n\tret = xmlParse3986Query(uri, &str);\n if (ret != 0) return(ret);\n }\n if (*str == '#') {\n\tstr++;\n\tret = xmlParse3986Fragment(uri, &str);\n if (ret != 0) return(ret);\n }\n if (*str != 0) {\n\txmlCleanURI(uri);\n return(1);\n }\n return(0);\n}\n"
] |
[
1,
1
] |
BIGVUL
|
{
"CVE ID": "CVE-2017-7376",
"CVE Page": "https://www.cvedetails.com/cve/CVE-2017-7376/",
"CWE ID": "CWE-119",
"codeLink": "https://android.googlesource.com/platform/external/libxml2/+/51e0cb2e5ec18eaf6fb331bc573ff27b743898f4",
"commit_id": "51e0cb2e5ec18eaf6fb331bc573ff27b743898f4",
"commit_message": "DO NOT MERGE: Use correct limit for port values\n\nno upstream report yet, add it here when we have it\nissue found & patch by nmehta@\n\nBug: 36555370\nChange-Id: Ibf1efea554b95f514e23e939363d608021de4614\n(cherry picked from commit b62884fb49fe92081e414966d9b5fe58250ae53c)\n",
"lang": "C",
"project": "Android"
}
| 32
|
Determine whether the code is vulnerable or not.
|
[
"static inline void assign_proto_idx(struct proto *prot)\n{\n}\n"
] |
[
1
] |
BIGVUL
|
{
"CVE ID": "CVE-2012-2136",
"CVE Page": "https://www.cvedetails.com/cve/CVE-2012-2136/",
"CWE ID": "CWE-20",
"codeLink": "https://github.com/torvalds/linux/commit/cc9b17ad29ecaa20bfe426a8d4dbfb94b13ff1cc",
"commit_id": "cc9b17ad29ecaa20bfe426a8d4dbfb94b13ff1cc",
"commit_message": "net: sock: validate data_len before allocating skb in sock_alloc_send_pskb()\n\nWe need to validate the number of pages consumed by data_len, otherwise frags\narray could be overflowed by userspace. So this patch validate data_len and\nreturn -EMSGSIZE when data_len may occupies more frags than MAX_SKB_FRAGS.\n\nSigned-off-by: Jason Wang <jasowang@redhat.com>\nSigned-off-by: David S. Miller <davem@davemloft.net>",
"lang": "C",
"project": "linux"
}
| 33
|
End of preview. Expand
in Data Studio
README.md exists but content is empty.
- Downloads last month
- 1