instruction
stringclasses
1 value
input
stringlengths
306
235k
output
stringclasses
3 values
__index_level_0__
int64
165k
175k
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: void perf_bp_event(struct perf_event *bp, void *data) { struct perf_sample_data sample; struct pt_regs *regs = data; perf_sample_data_init(&sample, bp->attr.bp_addr); if (!bp->hw.state && !perf_exclude_event(bp, regs)) perf_swevent_event(bp, 1, 1, &sample, regs); } Vulnerability Type: DoS Overflow CWE ID: CWE-399 Summary: The Performance Events subsystem in the Linux kernel before 3.1 does not properly handle event overflows associated with PERF_COUNT_SW_CPU_CLOCK events, which allows local users to cause a denial of service (system hang) via a crafted application. Commit Message: perf: Remove the nmi parameter from the swevent and overflow interface The nmi parameter indicated if we could do wakeups from the current context, if not, we would set some state and self-IPI and let the resulting interrupt do the wakeup. For the various event classes: - hardware: nmi=0; PMI is in fact an NMI or we run irq_work_run from the PMI-tail (ARM etc.) - tracepoint: nmi=0; since tracepoint could be from NMI context. - software: nmi=[0,1]; some, like the schedule thing cannot perform wakeups, and hence need 0. As one can see, there is very little nmi=1 usage, and the down-side of not using it is that on some platforms some software events can have a jiffy delay in wakeup (when arch_irq_work_raise isn't implemented). The up-side however is that we can remove the nmi parameter and save a bunch of conditionals in fast paths. Signed-off-by: Peter Zijlstra <[email protected]> Cc: Michael Cree <[email protected]> Cc: Will Deacon <[email protected]> Cc: Deng-Cheng Zhu <[email protected]> Cc: Anton Blanchard <[email protected]> Cc: Eric B Munson <[email protected]> Cc: Heiko Carstens <[email protected]> Cc: Paul Mundt <[email protected]> Cc: David S. Miller <[email protected]> Cc: Frederic Weisbecker <[email protected]> Cc: Jason Wessel <[email protected]> Cc: Don Zickus <[email protected]> Link: http://lkml.kernel.org/n/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
Medium
165,829
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: vtp_print (netdissect_options *ndo, const u_char *pptr, u_int length) { int type, len, tlv_len, tlv_value, mgmtd_len; const u_char *tptr; const struct vtp_vlan_ *vtp_vlan; if (length < VTP_HEADER_LEN) goto trunc; tptr = pptr; ND_TCHECK2(*tptr, VTP_HEADER_LEN); type = *(tptr+1); ND_PRINT((ndo, "VTPv%u, Message %s (0x%02x), length %u", *tptr, tok2str(vtp_message_type_values,"Unknown message type", type), type, length)); /* In non-verbose mode, just print version and message type */ if (ndo->ndo_vflag < 1) { return; } /* verbose mode print all fields */ ND_PRINT((ndo, "\n\tDomain name: ")); mgmtd_len = *(tptr + 3); if (mgmtd_len < 1 || mgmtd_len > 32) { ND_PRINT((ndo, " [invalid MgmtD Len %d]", mgmtd_len)); return; } fn_printzp(ndo, tptr + 4, mgmtd_len, NULL); ND_PRINT((ndo, ", %s: %u", tok2str(vtp_header_values, "Unknown", type), *(tptr+2))); tptr += VTP_HEADER_LEN; switch (type) { case VTP_SUMMARY_ADV: /* * SUMMARY ADVERTISEMENT * * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Version | Code | Followers | MgmtD Len | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Management Domain Name (zero-padded to 32 bytes) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Configuration revision number | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Updater Identity IP address | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Update Timestamp (12 bytes) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | MD5 digest (16 bytes) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * */ ND_TCHECK2(*tptr, 8); ND_PRINT((ndo, "\n\t Config Rev %x, Updater %s", EXTRACT_32BITS(tptr), ipaddr_string(ndo, tptr+4))); tptr += 8; ND_TCHECK2(*tptr, VTP_UPDATE_TIMESTAMP_LEN); ND_PRINT((ndo, ", Timestamp 0x%08x 0x%08x 0x%08x", EXTRACT_32BITS(tptr), EXTRACT_32BITS(tptr + 4), EXTRACT_32BITS(tptr + 8))); tptr += VTP_UPDATE_TIMESTAMP_LEN; ND_TCHECK2(*tptr, VTP_MD5_DIGEST_LEN); ND_PRINT((ndo, ", MD5 digest: %08x%08x%08x%08x", EXTRACT_32BITS(tptr), EXTRACT_32BITS(tptr + 4), EXTRACT_32BITS(tptr + 8), EXTRACT_32BITS(tptr + 12))); tptr += VTP_MD5_DIGEST_LEN; break; case VTP_SUBSET_ADV: /* * SUBSET ADVERTISEMENT * * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Version | Code | Seq number | MgmtD Len | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Management Domain Name (zero-padded to 32 bytes) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Configuration revision number | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | VLAN info field 1 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | ................ | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | VLAN info field N | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * */ ND_TCHECK_32BITS(tptr); ND_PRINT((ndo, ", Config Rev %x", EXTRACT_32BITS(tptr))); /* * VLAN INFORMATION * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | V info len | Status | VLAN type | VLAN name len | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | ISL vlan id | MTU size | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | 802.10 index (SAID) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | VLAN name | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * */ tptr += 4; while (tptr < (pptr+length)) { ND_TCHECK_8BITS(tptr); len = *tptr; if (len == 0) break; ND_TCHECK2(*tptr, len); vtp_vlan = (const struct vtp_vlan_*)tptr; ND_TCHECK(*vtp_vlan); ND_PRINT((ndo, "\n\tVLAN info status %s, type %s, VLAN-id %u, MTU %u, SAID 0x%08x, Name ", tok2str(vtp_vlan_status,"Unknown",vtp_vlan->status), tok2str(vtp_vlan_type_values,"Unknown",vtp_vlan->type), EXTRACT_16BITS(&vtp_vlan->vlanid), EXTRACT_16BITS(&vtp_vlan->mtu), EXTRACT_32BITS(&vtp_vlan->index))); fn_printzp(ndo, tptr + VTP_VLAN_INFO_OFFSET, vtp_vlan->name_len, NULL); /* * Vlan names are aligned to 32-bit boundaries. */ len -= VTP_VLAN_INFO_OFFSET + 4*((vtp_vlan->name_len + 3)/4); tptr += VTP_VLAN_INFO_OFFSET + 4*((vtp_vlan->name_len + 3)/4); /* TLV information follows */ while (len > 0) { /* * Cisco specs says 2 bytes for type + 2 bytes for length, take only 1 * See: http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/frames.htm */ type = *tptr; tlv_len = *(tptr+1); ND_PRINT((ndo, "\n\t\t%s (0x%04x) TLV", tok2str(vtp_vlan_tlv_values, "Unknown", type), type)); /* * infinite loop check */ if (type == 0 || tlv_len == 0) { return; } ND_TCHECK2(*tptr, tlv_len * 2 +2); tlv_value = EXTRACT_16BITS(tptr+2); switch (type) { case VTP_VLAN_STE_HOP_COUNT: ND_PRINT((ndo, ", %u", tlv_value)); break; case VTP_VLAN_PRUNING: ND_PRINT((ndo, ", %s (%u)", tlv_value == 1 ? "Enabled" : "Disabled", tlv_value)); break; case VTP_VLAN_STP_TYPE: ND_PRINT((ndo, ", %s (%u)", tok2str(vtp_stp_type_values, "Unknown", tlv_value), tlv_value)); break; case VTP_VLAN_BRIDGE_TYPE: ND_PRINT((ndo, ", %s (%u)", tlv_value == 1 ? "SRB" : "SRT", tlv_value)); break; case VTP_VLAN_BACKUP_CRF_MODE: ND_PRINT((ndo, ", %s (%u)", tlv_value == 1 ? "Backup" : "Not backup", tlv_value)); break; /* * FIXME those are the defined TLVs that lack a decoder * you are welcome to contribute code ;-) */ case VTP_VLAN_SOURCE_ROUTING_RING_NUMBER: case VTP_VLAN_SOURCE_ROUTING_BRIDGE_NUMBER: case VTP_VLAN_PARENT_VLAN: case VTP_VLAN_TRANS_BRIDGED_VLAN: case VTP_VLAN_ARP_HOP_COUNT: default: print_unknown_data(ndo, tptr, "\n\t\t ", 2 + tlv_len*2); break; } len -= 2 + tlv_len*2; tptr += 2 + tlv_len*2; } } break; case VTP_ADV_REQUEST: /* * ADVERTISEMENT REQUEST * * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Version | Code | Reserved | MgmtD Len | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Management Domain Name (zero-padded to 32 bytes) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Start value | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * */ ND_TCHECK2(*tptr, 4); ND_PRINT((ndo, "\n\tStart value: %u", EXTRACT_32BITS(tptr))); break; case VTP_JOIN_MESSAGE: /* FIXME - Could not find message format */ break; default: break; } return; trunc: ND_PRINT((ndo, "[|vtp]")); } Vulnerability Type: CWE ID: CWE-125 Summary: The VTP parser in tcpdump before 4.9.2 has a buffer over-read in print-vtp.c:vtp_print(). Commit Message: CVE-2017-13033/VTP: Add more bound and length checks. This fixes a buffer over-read discovered by Bhargava Shastry. Add a test using the capture file supplied by the reporter(s), modified so the capture file won't be rejected as an invalid capture. Update another VTP test's .out file for this change. Don't treate a TLV type or length of 0 as invalid; a type of 0 should just be reported as illegal if that type isn't used, and the length is the length of the *value*, not the length of the entire TLV, so if it's zero there won't be an infinite loop. (It's still not *legal*, as the values of all the TLVs we handle are 1 16-bit word long; we added a check for that.) Update some comments while we're at it, to give a new URL for one Cisco page and a non-Cisco URL for another former Cisco page (Cisco's UniverCD pages don't seem to be available any more, and Cisco's robots.txt file didn't allow the Wayback Machine to archive it).
High
167,850
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: void AppCacheDispatcherHost::OnChannelConnected(int32 peer_pid) { if (appcache_service_.get()) { backend_impl_.Initialize( appcache_service_.get(), &frontend_proxy_, process_id_); get_status_callback_ = base::Bind(&AppCacheDispatcherHost::GetStatusCallback, base::Unretained(this)); start_update_callback_ = base::Bind(&AppCacheDispatcherHost::StartUpdateCallback, base::Unretained(this)); swap_cache_callback_ = base::Bind(&AppCacheDispatcherHost::SwapCacheCallback, base::Unretained(this)); } } Vulnerability Type: DoS CWE ID: Summary: Use-after-free vulnerability in content/browser/appcache/appcache_dispatcher_host.cc in the AppCache implementation in Google Chrome before 47.0.2526.73 allows remote attackers to cause a denial of service or possibly have unspecified other impact by leveraging incorrect pointer maintenance associated with certain callbacks. Commit Message: AppCache: Use WeakPtr<> to fix a potential uaf bug. BUG=554908 Review URL: https://codereview.chromium.org/1441683004 Cr-Commit-Position: refs/heads/master@{#359930}
High
171,745
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: juniper_services_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p) { struct juniper_l2info_t l2info; struct juniper_services_header { uint8_t svc_id; uint8_t flags_len; uint8_t svc_set_id[2]; uint8_t dir_iif[4]; }; const struct juniper_services_header *sh; l2info.pictype = DLT_JUNIPER_SERVICES; if (juniper_parse_header(ndo, p, h, &l2info) == 0) return l2info.header_len; p+=l2info.header_len; sh = (const struct juniper_services_header *)p; if (ndo->ndo_eflag) ND_PRINT((ndo, "service-id %u flags 0x%02x service-set-id 0x%04x iif %u: ", sh->svc_id, sh->flags_len, EXTRACT_16BITS(&sh->svc_set_id), EXTRACT_24BITS(&sh->dir_iif[1]))); /* no proto field - lets guess by first byte of IP header*/ ip_heuristic_guess (ndo, p, l2info.length); return l2info.header_len; } Vulnerability Type: CWE ID: CWE-125 Summary: The Juniper protocols parser in tcpdump before 4.9.2 has a buffer over-read in print-juniper.c, several functions. Commit Message: CVE-2017-12993/Juniper: Add more bounds checks. This fixes a buffer over-read discovered by Kamil Frankowicz. Add tests using the capture files supplied by the reporter(s).
High
167,921
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: std::string SanitizeEndpoint(const std::string& value) { if (value.find('&') != std::string::npos || value.find('?') != std::string::npos) return std::string(); return value; } Vulnerability Type: +Info CWE ID: CWE-200 Summary: Google Chrome prior to 56.0.2924.76 for Windows insufficiently sanitized DevTools URLs, which allowed a remote attacker who convinced a user to install a malicious extension to read filesystem contents via a crafted HTML page. Commit Message: DevTools: move front-end URL handling to DevToolsUIBindingds BUG=662859 Review-Url: https://codereview.chromium.org/2607833002 Cr-Commit-Position: refs/heads/master@{#440926}
Medium
172,457
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: static int fsck_gitmodules_fn(const char *var, const char *value, void *vdata) { struct fsck_gitmodules_data *data = vdata; const char *subsection, *key; int subsection_len; char *name; if (parse_config_key(var, "submodule", &subsection, &subsection_len, &key) < 0 || !subsection) return 0; name = xmemdupz(subsection, subsection_len); if (check_submodule_name(name) < 0) data->ret |= report(data->options, data->obj, FSCK_MSG_GITMODULES_NAME, "disallowed submodule name: %s", name); free(name); return 0; } Vulnerability Type: Exec Code CWE ID: CWE-20 Summary: Git before 2.14.5, 2.15.x before 2.15.3, 2.16.x before 2.16.5, 2.17.x before 2.17.2, 2.18.x before 2.18.1, and 2.19.x before 2.19.1 allows remote code execution during processing of a recursive *git clone* of a superproject if a .gitmodules file has a URL field beginning with a '-' character. Commit Message: fsck: detect submodule urls starting with dash Urls with leading dashes can cause mischief on older versions of Git. We should detect them so that they can be rejected by receive.fsckObjects, preventing modern versions of git from being a vector by which attacks can spread. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
High
169,019
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: bool LayoutSVGViewportContainer::calculateLocalTransform() { if (!m_needsTransformUpdate) return false; m_localToParentTransform = AffineTransform::translation(m_viewport.x(), m_viewport.y()) * viewportTransform(); m_needsTransformUpdate = false; return true; } Vulnerability Type: DoS CWE ID: Summary: Multiple unspecified vulnerabilities in Google Chrome before 36.0.1985.143 allow attackers to cause a denial of service or possibly have other impact via unknown vectors. Commit Message: Avoid using forced layout to trigger paint invalidation for SVG containers Currently, SVG containers in the LayoutObject hierarchy force layout of their children if the transform changes. The main reason for this is to trigger paint invalidation of the subtree. In some cases - changes to the scale factor - there are other reasons to trigger layout, like computing a new scale factor for <text> or re-layout nodes with non-scaling stroke. Compute a "scale-factor change" in addition to the "transform change" already computed, then use this new signal to determine if layout should be forced for the subtree. Trigger paint invalidation using the LayoutObject flags instead. The downside to this is that paint invalidation will walk into "hidden" containers which rarely require repaint (since they are not technically visible). This will hopefully be rectified in a follow-up CL. For the testcase from 603850, this essentially eliminates the cost of layout (from ~350ms to ~0ms on authors machine; layout cost is related to text metrics recalculation), bumping frame rate significantly. BUG=603956,603850 Review-Url: https://codereview.chromium.org/1996543002 Cr-Commit-Position: refs/heads/master@{#400950}
High
171,667
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: static Image *ReadSCTImage(const ImageInfo *image_info,ExceptionInfo *exception) { char magick[2]; Image *image; MagickBooleanType status; MagickRealType height, width; Quantum pixel; register IndexPacket *indexes; register ssize_t i, x; register PixelPacket *q; ssize_t count, y; unsigned char buffer[768]; size_t separations, separations_mask, units; /* Open image file. */ assert(image_info != (const ImageInfo *) NULL); assert(image_info->signature == MagickSignature); if (image_info->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", image_info->filename); assert(exception != (ExceptionInfo *) NULL); assert(exception->signature == MagickSignature); image=AcquireImage(image_info); status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); if (status == MagickFalse) { image=DestroyImageList(image); return((Image *) NULL); } /* Read control block. */ count=ReadBlob(image,80,buffer); (void) count; count=ReadBlob(image,2,(unsigned char *) magick); if ((LocaleNCompare((char *) magick,"CT",2) != 0) && (LocaleNCompare((char *) magick,"LW",2) != 0) && (LocaleNCompare((char *) magick,"BM",2) != 0) && (LocaleNCompare((char *) magick,"PG",2) != 0) && (LocaleNCompare((char *) magick,"TX",2) != 0)) ThrowReaderException(CorruptImageError,"ImproperImageHeader"); if ((LocaleNCompare((char *) magick,"LW",2) == 0) || (LocaleNCompare((char *) magick,"BM",2) == 0) || (LocaleNCompare((char *) magick,"PG",2) == 0) || (LocaleNCompare((char *) magick,"TX",2) == 0)) ThrowReaderException(CoderError,"OnlyContinuousTonePictureSupported"); count=ReadBlob(image,174,buffer); count=ReadBlob(image,768,buffer); /* Read paramter block. */ units=1UL*ReadBlobByte(image); if (units == 0) image->units=PixelsPerCentimeterResolution; separations=1UL*ReadBlobByte(image); separations_mask=ReadBlobMSBShort(image); count=ReadBlob(image,14,buffer); buffer[14]='\0'; height=StringToDouble((char *) buffer,(char **) NULL); count=ReadBlob(image,14,buffer); width=StringToDouble((char *) buffer,(char **) NULL); count=ReadBlob(image,12,buffer); buffer[12]='\0'; image->rows=StringToUnsignedLong((char *) buffer); count=ReadBlob(image,12,buffer); image->columns=StringToUnsignedLong((char *) buffer); count=ReadBlob(image,200,buffer); count=ReadBlob(image,768,buffer); if (separations_mask == 0x0f) SetImageColorspace(image,CMYKColorspace); image->x_resolution=1.0*image->columns/width; image->y_resolution=1.0*image->rows/height; if (image_info->ping != MagickFalse) { (void) CloseBlob(image); return(GetFirstImageInList(image)); } /* Convert SCT raster image to pixel packets. */ for (y=0; y < (ssize_t) image->rows; y++) { for (i=0; i < (ssize_t) separations; i++) { q=GetAuthenticPixels(image,0,y,image->columns,1,exception); if (q == (PixelPacket *) NULL) break; indexes=GetAuthenticIndexQueue(image); for (x=0; x < (ssize_t) image->columns; x++) { pixel=(Quantum) ScaleCharToQuantum((unsigned char) ReadBlobByte(image)); if (image->colorspace == CMYKColorspace) pixel=(Quantum) (QuantumRange-pixel); switch (i) { case 0: { SetPixelRed(q,pixel); SetPixelGreen(q,pixel); SetPixelBlue(q,pixel); break; } case 1: { SetPixelGreen(q,pixel); break; } case 2: { SetPixelBlue(q,pixel); break; } case 3: { if (image->colorspace == CMYKColorspace) SetPixelBlack(indexes+x,pixel); break; } } q++; } if (SyncAuthenticPixels(image,exception) == MagickFalse) break; if ((image->columns % 2) != 0) (void) ReadBlobByte(image); /* pad */ } status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, image->rows); if (status == MagickFalse) break; } if (EOFBlob(image) != MagickFalse) ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile", image->filename); (void) CloseBlob(image); return(GetFirstImageInList(image)); } Vulnerability Type: DoS Overflow CWE ID: CWE-119 Summary: Buffer overflow in the ReadVIFFImage function in coders/viff.c in ImageMagick before 6.9.4-5 allows remote attackers to cause a denial of service (application crash) via a crafted file. Commit Message:
Medium
168,603
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: static int start_decoder(vorb *f) { uint8 header[6], x,y; int len,i,j,k, max_submaps = 0; int longest_floorlist=0; if (!start_page(f)) return FALSE; if (!(f->page_flag & PAGEFLAG_first_page)) return error(f, VORBIS_invalid_first_page); if (f->page_flag & PAGEFLAG_last_page) return error(f, VORBIS_invalid_first_page); if (f->page_flag & PAGEFLAG_continued_packet) return error(f, VORBIS_invalid_first_page); if (f->segment_count != 1) return error(f, VORBIS_invalid_first_page); if (f->segments[0] != 30) { if (f->segments[0] == 64 && getn(f, header, 6) && header[0] == 'f' && header[1] == 'i' && header[2] == 's' && header[3] == 'h' && header[4] == 'e' && header[5] == 'a' && get8(f) == 'd' && get8(f) == '\0') return error(f, VORBIS_ogg_skeleton_not_supported); else return error(f, VORBIS_invalid_first_page); } if (get8(f) != VORBIS_packet_id) return error(f, VORBIS_invalid_first_page); if (!getn(f, header, 6)) return error(f, VORBIS_unexpected_eof); if (!vorbis_validate(header)) return error(f, VORBIS_invalid_first_page); if (get32(f) != 0) return error(f, VORBIS_invalid_first_page); f->channels = get8(f); if (!f->channels) return error(f, VORBIS_invalid_first_page); if (f->channels > STB_VORBIS_MAX_CHANNELS) return error(f, VORBIS_too_many_channels); f->sample_rate = get32(f); if (!f->sample_rate) return error(f, VORBIS_invalid_first_page); get32(f); // bitrate_maximum get32(f); // bitrate_nominal get32(f); // bitrate_minimum x = get8(f); { int log0,log1; log0 = x & 15; log1 = x >> 4; f->blocksize_0 = 1 << log0; f->blocksize_1 = 1 << log1; if (log0 < 6 || log0 > 13) return error(f, VORBIS_invalid_setup); if (log1 < 6 || log1 > 13) return error(f, VORBIS_invalid_setup); if (log0 > log1) return error(f, VORBIS_invalid_setup); } x = get8(f); if (!(x & 1)) return error(f, VORBIS_invalid_first_page); if (!start_page(f)) return FALSE; if (!start_packet(f)) return FALSE; do { len = next_segment(f); skip(f, len); f->bytes_in_seg = 0; } while (len); if (!start_packet(f)) return FALSE; #ifndef STB_VORBIS_NO_PUSHDATA_API if (IS_PUSH_MODE(f)) { if (!is_whole_packet_present(f, TRUE)) { if (f->error == VORBIS_invalid_stream) f->error = VORBIS_invalid_setup; return FALSE; } } #endif crc32_init(); // always init it, to avoid multithread race conditions if (get8_packet(f) != VORBIS_packet_setup) return error(f, VORBIS_invalid_setup); for (i=0; i < 6; ++i) header[i] = get8_packet(f); if (!vorbis_validate(header)) return error(f, VORBIS_invalid_setup); f->codebook_count = get_bits(f,8) + 1; f->codebooks = (Codebook *) setup_malloc(f, sizeof(*f->codebooks) * f->codebook_count); if (f->codebooks == NULL) return error(f, VORBIS_outofmem); memset(f->codebooks, 0, sizeof(*f->codebooks) * f->codebook_count); for (i=0; i < f->codebook_count; ++i) { uint32 *values; int ordered, sorted_count; int total=0; uint8 *lengths; Codebook *c = f->codebooks+i; CHECK(f); x = get_bits(f, 8); if (x != 0x42) return error(f, VORBIS_invalid_setup); x = get_bits(f, 8); if (x != 0x43) return error(f, VORBIS_invalid_setup); x = get_bits(f, 8); if (x != 0x56) return error(f, VORBIS_invalid_setup); x = get_bits(f, 8); c->dimensions = (get_bits(f, 8)<<8) + x; x = get_bits(f, 8); y = get_bits(f, 8); c->entries = (get_bits(f, 8)<<16) + (y<<8) + x; ordered = get_bits(f,1); c->sparse = ordered ? 0 : get_bits(f,1); if (c->dimensions == 0 && c->entries != 0) return error(f, VORBIS_invalid_setup); if (c->sparse) lengths = (uint8 *) setup_temp_malloc(f, c->entries); else lengths = c->codeword_lengths = (uint8 *) setup_malloc(f, c->entries); if (!lengths) return error(f, VORBIS_outofmem); if (ordered) { int current_entry = 0; int current_length = get_bits(f,5) + 1; while (current_entry < c->entries) { int limit = c->entries - current_entry; int n = get_bits(f, ilog(limit)); if (current_entry + n > (int) c->entries) { return error(f, VORBIS_invalid_setup); } memset(lengths + current_entry, current_length, n); current_entry += n; ++current_length; } } else { for (j=0; j < c->entries; ++j) { int present = c->sparse ? get_bits(f,1) : 1; if (present) { lengths[j] = get_bits(f, 5) + 1; ++total; if (lengths[j] == 32) return error(f, VORBIS_invalid_setup); } else { lengths[j] = NO_CODE; } } } if (c->sparse && total >= c->entries >> 2) { if (c->entries > (int) f->setup_temp_memory_required) f->setup_temp_memory_required = c->entries; c->codeword_lengths = (uint8 *) setup_malloc(f, c->entries); if (c->codeword_lengths == NULL) return error(f, VORBIS_outofmem); memcpy(c->codeword_lengths, lengths, c->entries); setup_temp_free(f, lengths, c->entries); // note this is only safe if there have been no intervening temp mallocs! lengths = c->codeword_lengths; c->sparse = 0; } if (c->sparse) { sorted_count = total; } else { sorted_count = 0; #ifndef STB_VORBIS_NO_HUFFMAN_BINARY_SEARCH for (j=0; j < c->entries; ++j) if (lengths[j] > STB_VORBIS_FAST_HUFFMAN_LENGTH && lengths[j] != NO_CODE) ++sorted_count; #endif } c->sorted_entries = sorted_count; values = NULL; CHECK(f); if (!c->sparse) { c->codewords = (uint32 *) setup_malloc(f, sizeof(c->codewords[0]) * c->entries); if (!c->codewords) return error(f, VORBIS_outofmem); } else { unsigned int size; if (c->sorted_entries) { c->codeword_lengths = (uint8 *) setup_malloc(f, c->sorted_entries); if (!c->codeword_lengths) return error(f, VORBIS_outofmem); c->codewords = (uint32 *) setup_temp_malloc(f, sizeof(*c->codewords) * c->sorted_entries); if (!c->codewords) return error(f, VORBIS_outofmem); values = (uint32 *) setup_temp_malloc(f, sizeof(*values) * c->sorted_entries); if (!values) return error(f, VORBIS_outofmem); } size = c->entries + (sizeof(*c->codewords) + sizeof(*values)) * c->sorted_entries; if (size > f->setup_temp_memory_required) f->setup_temp_memory_required = size; } if (!compute_codewords(c, lengths, c->entries, values)) { if (c->sparse) setup_temp_free(f, values, 0); return error(f, VORBIS_invalid_setup); } if (c->sorted_entries) { c->sorted_codewords = (uint32 *) setup_malloc(f, sizeof(*c->sorted_codewords) * (c->sorted_entries+1)); if (c->sorted_codewords == NULL) return error(f, VORBIS_outofmem); c->sorted_values = ( int *) setup_malloc(f, sizeof(*c->sorted_values ) * (c->sorted_entries+1)); if (c->sorted_values == NULL) return error(f, VORBIS_outofmem); ++c->sorted_values; c->sorted_values[-1] = -1; compute_sorted_huffman(c, lengths, values); } if (c->sparse) { setup_temp_free(f, values, sizeof(*values)*c->sorted_entries); setup_temp_free(f, c->codewords, sizeof(*c->codewords)*c->sorted_entries); setup_temp_free(f, lengths, c->entries); c->codewords = NULL; } compute_accelerated_huffman(c); CHECK(f); c->lookup_type = get_bits(f, 4); if (c->lookup_type > 2) return error(f, VORBIS_invalid_setup); if (c->lookup_type > 0) { uint16 *mults; c->minimum_value = float32_unpack(get_bits(f, 32)); c->delta_value = float32_unpack(get_bits(f, 32)); c->value_bits = get_bits(f, 4)+1; c->sequence_p = get_bits(f,1); if (c->lookup_type == 1) { c->lookup_values = lookup1_values(c->entries, c->dimensions); } else { c->lookup_values = c->entries * c->dimensions; } if (c->lookup_values == 0) return error(f, VORBIS_invalid_setup); mults = (uint16 *) setup_temp_malloc(f, sizeof(mults[0]) * c->lookup_values); if (mults == NULL) return error(f, VORBIS_outofmem); for (j=0; j < (int) c->lookup_values; ++j) { int q = get_bits(f, c->value_bits); if (q == EOP) { setup_temp_free(f,mults,sizeof(mults[0])*c->lookup_values); return error(f, VORBIS_invalid_setup); } mults[j] = q; } #ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK if (c->lookup_type == 1) { int len, sparse = c->sparse; float last=0; if (sparse) { if (c->sorted_entries == 0) goto skip; c->multiplicands = (codetype *) setup_malloc(f, sizeof(c->multiplicands[0]) * c->sorted_entries * c->dimensions); } else c->multiplicands = (codetype *) setup_malloc(f, sizeof(c->multiplicands[0]) * c->entries * c->dimensions); if (c->multiplicands == NULL) { setup_temp_free(f,mults,sizeof(mults[0])*c->lookup_values); return error(f, VORBIS_outofmem); } len = sparse ? c->sorted_entries : c->entries; for (j=0; j < len; ++j) { unsigned int z = sparse ? c->sorted_values[j] : j; unsigned int div=1; for (k=0; k < c->dimensions; ++k) { int off = (z / div) % c->lookup_values; float val = mults[off]; val = mults[off]*c->delta_value + c->minimum_value + last; c->multiplicands[j*c->dimensions + k] = val; if (c->sequence_p) last = val; if (k+1 < c->dimensions) { if (div > UINT_MAX / (unsigned int) c->lookup_values) { setup_temp_free(f, mults,sizeof(mults[0])*c->lookup_values); return error(f, VORBIS_invalid_setup); } div *= c->lookup_values; } } } c->lookup_type = 2; } else #endif { float last=0; CHECK(f); c->multiplicands = (codetype *) setup_malloc(f, sizeof(c->multiplicands[0]) * c->lookup_values); if (c->multiplicands == NULL) { setup_temp_free(f, mults,sizeof(mults[0])*c->lookup_values); return error(f, VORBIS_outofmem); } for (j=0; j < (int) c->lookup_values; ++j) { float val = mults[j] * c->delta_value + c->minimum_value + last; c->multiplicands[j] = val; if (c->sequence_p) last = val; } } #ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK skip:; #endif setup_temp_free(f, mults, sizeof(mults[0])*c->lookup_values); CHECK(f); } CHECK(f); } x = get_bits(f, 6) + 1; for (i=0; i < x; ++i) { uint32 z = get_bits(f, 16); if (z != 0) return error(f, VORBIS_invalid_setup); } f->floor_count = get_bits(f, 6)+1; f->floor_config = (Floor *) setup_malloc(f, f->floor_count * sizeof(*f->floor_config)); if (f->floor_config == NULL) return error(f, VORBIS_outofmem); for (i=0; i < f->floor_count; ++i) { f->floor_types[i] = get_bits(f, 16); if (f->floor_types[i] > 1) return error(f, VORBIS_invalid_setup); if (f->floor_types[i] == 0) { Floor0 *g = &f->floor_config[i].floor0; g->order = get_bits(f,8); g->rate = get_bits(f,16); g->bark_map_size = get_bits(f,16); g->amplitude_bits = get_bits(f,6); g->amplitude_offset = get_bits(f,8); g->number_of_books = get_bits(f,4) + 1; for (j=0; j < g->number_of_books; ++j) g->book_list[j] = get_bits(f,8); return error(f, VORBIS_feature_not_supported); } else { stbv__floor_ordering p[31*8+2]; Floor1 *g = &f->floor_config[i].floor1; int max_class = -1; g->partitions = get_bits(f, 5); for (j=0; j < g->partitions; ++j) { g->partition_class_list[j] = get_bits(f, 4); if (g->partition_class_list[j] > max_class) max_class = g->partition_class_list[j]; } for (j=0; j <= max_class; ++j) { g->class_dimensions[j] = get_bits(f, 3)+1; g->class_subclasses[j] = get_bits(f, 2); if (g->class_subclasses[j]) { g->class_masterbooks[j] = get_bits(f, 8); if (g->class_masterbooks[j] >= f->codebook_count) return error(f, VORBIS_invalid_setup); } for (k=0; k < 1 << g->class_subclasses[j]; ++k) { g->subclass_books[j][k] = get_bits(f,8)-1; if (g->subclass_books[j][k] >= f->codebook_count) return error(f, VORBIS_invalid_setup); } } g->floor1_multiplier = get_bits(f,2)+1; g->rangebits = get_bits(f,4); g->Xlist[0] = 0; g->Xlist[1] = 1 << g->rangebits; g->values = 2; for (j=0; j < g->partitions; ++j) { int c = g->partition_class_list[j]; for (k=0; k < g->class_dimensions[c]; ++k) { g->Xlist[g->values] = get_bits(f, g->rangebits); ++g->values; } } for (j=0; j < g->values; ++j) { p[j].x = g->Xlist[j]; p[j].id = j; } qsort(p, g->values, sizeof(p[0]), point_compare); for (j=0; j < g->values; ++j) g->sorted_order[j] = (uint8) p[j].id; for (j=2; j < g->values; ++j) { int low,hi; neighbors(g->Xlist, j, &low,&hi); g->neighbors[j][0] = low; g->neighbors[j][1] = hi; } if (g->values > longest_floorlist) longest_floorlist = g->values; } } f->residue_count = get_bits(f, 6)+1; f->residue_config = (Residue *) setup_malloc(f, f->residue_count * sizeof(f->residue_config[0])); if (f->residue_config == NULL) return error(f, VORBIS_outofmem); memset(f->residue_config, 0, f->residue_count * sizeof(f->residue_config[0])); for (i=0; i < f->residue_count; ++i) { uint8 residue_cascade[64]; Residue *r = f->residue_config+i; f->residue_types[i] = get_bits(f, 16); if (f->residue_types[i] > 2) return error(f, VORBIS_invalid_setup); r->begin = get_bits(f, 24); r->end = get_bits(f, 24); if (r->end < r->begin) return error(f, VORBIS_invalid_setup); r->part_size = get_bits(f,24)+1; r->classifications = get_bits(f,6)+1; r->classbook = get_bits(f,8); if (r->classbook >= f->codebook_count) return error(f, VORBIS_invalid_setup); for (j=0; j < r->classifications; ++j) { uint8 high_bits=0; uint8 low_bits=get_bits(f,3); if (get_bits(f,1)) high_bits = get_bits(f,5); residue_cascade[j] = high_bits*8 + low_bits; } r->residue_books = (short (*)[8]) setup_malloc(f, sizeof(r->residue_books[0]) * r->classifications); if (r->residue_books == NULL) return error(f, VORBIS_outofmem); for (j=0; j < r->classifications; ++j) { for (k=0; k < 8; ++k) { if (residue_cascade[j] & (1 << k)) { r->residue_books[j][k] = get_bits(f, 8); if (r->residue_books[j][k] >= f->codebook_count) return error(f, VORBIS_invalid_setup); } else { r->residue_books[j][k] = -1; } } } r->classdata = (uint8 **) setup_malloc(f, sizeof(*r->classdata) * f->codebooks[r->classbook].entries); if (!r->classdata) return error(f, VORBIS_outofmem); memset(r->classdata, 0, sizeof(*r->classdata) * f->codebooks[r->classbook].entries); for (j=0; j < f->codebooks[r->classbook].entries; ++j) { int classwords = f->codebooks[r->classbook].dimensions; int temp = j; r->classdata[j] = (uint8 *) setup_malloc(f, sizeof(r->classdata[j][0]) * classwords); if (r->classdata[j] == NULL) return error(f, VORBIS_outofmem); for (k=classwords-1; k >= 0; --k) { r->classdata[j][k] = temp % r->classifications; temp /= r->classifications; } } } f->mapping_count = get_bits(f,6)+1; f->mapping = (Mapping *) setup_malloc(f, f->mapping_count * sizeof(*f->mapping)); if (f->mapping == NULL) return error(f, VORBIS_outofmem); memset(f->mapping, 0, f->mapping_count * sizeof(*f->mapping)); for (i=0; i < f->mapping_count; ++i) { Mapping *m = f->mapping + i; int mapping_type = get_bits(f,16); if (mapping_type != 0) return error(f, VORBIS_invalid_setup); m->chan = (MappingChannel *) setup_malloc(f, f->channels * sizeof(*m->chan)); if (m->chan == NULL) return error(f, VORBIS_outofmem); if (get_bits(f,1)) m->submaps = get_bits(f,4)+1; else m->submaps = 1; if (m->submaps > max_submaps) max_submaps = m->submaps; if (get_bits(f,1)) { m->coupling_steps = get_bits(f,8)+1; for (k=0; k < m->coupling_steps; ++k) { m->chan[k].magnitude = get_bits(f, ilog(f->channels-1)); m->chan[k].angle = get_bits(f, ilog(f->channels-1)); if (m->chan[k].magnitude >= f->channels) return error(f, VORBIS_invalid_setup); if (m->chan[k].angle >= f->channels) return error(f, VORBIS_invalid_setup); if (m->chan[k].magnitude == m->chan[k].angle) return error(f, VORBIS_invalid_setup); } } else m->coupling_steps = 0; if (get_bits(f,2)) return error(f, VORBIS_invalid_setup); if (m->submaps > 1) { for (j=0; j < f->channels; ++j) { m->chan[j].mux = get_bits(f, 4); if (m->chan[j].mux >= m->submaps) return error(f, VORBIS_invalid_setup); } } else for (j=0; j < f->channels; ++j) m->chan[j].mux = 0; for (j=0; j < m->submaps; ++j) { get_bits(f,8); // discard m->submap_floor[j] = get_bits(f,8); m->submap_residue[j] = get_bits(f,8); if (m->submap_floor[j] >= f->floor_count) return error(f, VORBIS_invalid_setup); if (m->submap_residue[j] >= f->residue_count) return error(f, VORBIS_invalid_setup); } } f->mode_count = get_bits(f, 6)+1; for (i=0; i < f->mode_count; ++i) { Mode *m = f->mode_config+i; m->blockflag = get_bits(f,1); m->windowtype = get_bits(f,16); m->transformtype = get_bits(f,16); m->mapping = get_bits(f,8); if (m->windowtype != 0) return error(f, VORBIS_invalid_setup); if (m->transformtype != 0) return error(f, VORBIS_invalid_setup); if (m->mapping >= f->mapping_count) return error(f, VORBIS_invalid_setup); } flush_packet(f); f->previous_length = 0; for (i=0; i < f->channels; ++i) { f->channel_buffers[i] = (float *) setup_malloc(f, sizeof(float) * f->blocksize_1); f->previous_window[i] = (float *) setup_malloc(f, sizeof(float) * f->blocksize_1/2); f->finalY[i] = (int16 *) setup_malloc(f, sizeof(int16) * longest_floorlist); if (f->channel_buffers[i] == NULL || f->previous_window[i] == NULL || f->finalY[i] == NULL) return error(f, VORBIS_outofmem); memset(f->channel_buffers[i], 0, sizeof(float) * f->blocksize_1); #ifdef STB_VORBIS_NO_DEFER_FLOOR f->floor_buffers[i] = (float *) setup_malloc(f, sizeof(float) * f->blocksize_1/2); if (f->floor_buffers[i] == NULL) return error(f, VORBIS_outofmem); #endif } if (!init_blocksize(f, 0, f->blocksize_0)) return FALSE; if (!init_blocksize(f, 1, f->blocksize_1)) return FALSE; f->blocksize[0] = f->blocksize_0; f->blocksize[1] = f->blocksize_1; #ifdef STB_VORBIS_DIVIDE_TABLE if (integer_divide_table[1][1]==0) for (i=0; i < DIVTAB_NUMER; ++i) for (j=1; j < DIVTAB_DENOM; ++j) integer_divide_table[i][j] = i / j; #endif { uint32 imdct_mem = (f->blocksize_1 * sizeof(float) >> 1); uint32 classify_mem; int i,max_part_read=0; for (i=0; i < f->residue_count; ++i) { Residue *r = f->residue_config + i; unsigned int actual_size = f->blocksize_1 / 2; unsigned int limit_r_begin = r->begin < actual_size ? r->begin : actual_size; unsigned int limit_r_end = r->end < actual_size ? r->end : actual_size; int n_read = limit_r_end - limit_r_begin; int part_read = n_read / r->part_size; if (part_read > max_part_read) max_part_read = part_read; } #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE classify_mem = f->channels * (sizeof(void*) + max_part_read * sizeof(uint8 *)); #else classify_mem = f->channels * (sizeof(void*) + max_part_read * sizeof(int *)); #endif f->temp_memory_required = classify_mem; if (imdct_mem > f->temp_memory_required) f->temp_memory_required = imdct_mem; } f->first_decode = TRUE; if (f->alloc.alloc_buffer) { assert(f->temp_offset == f->alloc.alloc_buffer_length_in_bytes); if (f->setup_offset + sizeof(*f) + f->temp_memory_required > (unsigned) f->temp_offset) return error(f, VORBIS_outofmem); } f->first_audio_page_offset = stb_vorbis_get_file_offset(f); return TRUE; } Vulnerability Type: DoS CWE ID: CWE-20 Summary: A reachable assertion in the lookup1_values function in stb_vorbis through 2019-03-04 allows an attacker to cause a denial of service by opening a crafted Ogg Vorbis file. Commit Message: Fix seven bugs discovered and fixed by ForAllSecure: CVE-2019-13217: heap buffer overflow in start_decoder() CVE-2019-13218: stack buffer overflow in compute_codewords() CVE-2019-13219: uninitialized memory in vorbis_decode_packet_rest() CVE-2019-13220: out-of-range read in draw_line() CVE-2019-13221: issue with large 1D codebooks in lookup1_values() CVE-2019-13222: unchecked NULL returned by get_window() CVE-2019-13223: division by zero in predict_point()
Medium
169,617
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: OMX_ERRORTYPE SoftMPEG4Encoder::initEncParams() { CHECK(mHandle != NULL); memset(mHandle, 0, sizeof(tagvideoEncControls)); CHECK(mEncParams != NULL); memset(mEncParams, 0, sizeof(tagvideoEncOptions)); if (!PVGetDefaultEncOption(mEncParams, 0)) { ALOGE("Failed to get default encoding parameters"); return OMX_ErrorUndefined; } mEncParams->encMode = mEncodeMode; mEncParams->encWidth[0] = mWidth; mEncParams->encHeight[0] = mHeight; mEncParams->encFrameRate[0] = mFramerate >> 16; // mFramerate is in Q16 format mEncParams->rcType = VBR_1; mEncParams->vbvDelay = 5.0f; mEncParams->profile_level = CORE_PROFILE_LEVEL2; mEncParams->packetSize = 32; mEncParams->rvlcEnable = PV_OFF; mEncParams->numLayers = 1; mEncParams->timeIncRes = 1000; mEncParams->tickPerSrc = ((int64_t)mEncParams->timeIncRes << 16) / mFramerate; mEncParams->bitRate[0] = mBitrate; mEncParams->iQuant[0] = 15; mEncParams->pQuant[0] = 12; mEncParams->quantType[0] = 0; mEncParams->noFrameSkipped = PV_OFF; if (mColorFormat != OMX_COLOR_FormatYUV420Planar || mInputDataIsMeta) { free(mInputFrameData); mInputFrameData = (uint8_t *) malloc((mWidth * mHeight * 3 ) >> 1); CHECK(mInputFrameData != NULL); } if (mWidth % 16 != 0 || mHeight % 16 != 0) { ALOGE("Video frame size %dx%d must be a multiple of 16", mWidth, mHeight); return OMX_ErrorBadParameter; } if (mIDRFrameRefreshIntervalInSec < 0) { mEncParams->intraPeriod = -1; } else if (mIDRFrameRefreshIntervalInSec == 0) { mEncParams->intraPeriod = 1; // All I frames } else { mEncParams->intraPeriod = (mIDRFrameRefreshIntervalInSec * mFramerate) >> 16; } mEncParams->numIntraMB = 0; mEncParams->sceneDetect = PV_ON; mEncParams->searchRange = 16; mEncParams->mv8x8Enable = PV_OFF; mEncParams->gobHeaderInterval = 0; mEncParams->useACPred = PV_ON; mEncParams->intraDCVlcTh = 0; return OMX_ErrorNone; } Vulnerability Type: DoS Exec Code Overflow Mem. Corr. CWE ID: CWE-119 Summary: libstagefright in mediaserver in Android 4.x before 4.4.4, 5.x before 5.1.1 LMY49G, and 6.x before 2016-02-01 allows remote attackers to execute arbitrary code or cause a denial of service (memory corruption) via a crafted media file that triggers a large memory allocation in the (1) SoftMPEG4Encoder or (2) SoftVPXEncoder component, aka internal bug 25812794. Commit Message: DO NOT MERGE - libstagefright: check requested memory size before allocation for SoftMPEG4Encoder and SoftVPXEncoder. Bug: 25812794 Change-Id: I96dc74734380d462583f6efa33d09946f9532809 (cherry picked from commit 87f8cbb223ee516803dbb99699320c2484cbf3ba) (cherry picked from commit 0462975291796e414891e04bcec9da993914e458)
High
173,970
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: static void *btif_hl_select_thread(void *arg){ fd_set org_set, curr_set; int r, max_curr_s, max_org_s; UNUSED(arg); BTIF_TRACE_DEBUG("entered btif_hl_select_thread"); FD_ZERO(&org_set); max_org_s = btif_hl_select_wakeup_init(&org_set); BTIF_TRACE_DEBUG("max_s=%d ", max_org_s); for (;;) { r = 0; BTIF_TRACE_DEBUG("set curr_set = org_set "); curr_set = org_set; max_curr_s = max_org_s; int ret = select((max_curr_s + 1), &curr_set, NULL, NULL, NULL); BTIF_TRACE_DEBUG("select unblocked ret=%d", ret); if (ret == -1) { BTIF_TRACE_DEBUG("select() ret -1, exit the thread"); btif_hl_thread_cleanup(); select_thread_id = -1; return 0; } else if (ret) { BTIF_TRACE_DEBUG("btif_hl_select_wake_signaled, signal ret=%d", ret); if (btif_hl_select_wake_signaled(&curr_set)) { r = btif_hl_select_wake_reset(); BTIF_TRACE_DEBUG("btif_hl_select_wake_signaled, signal:%d", r); if (r == btif_hl_signal_select_wakeup || r == btif_hl_signal_select_close_connected ) { btif_hl_select_wakeup_callback(&org_set, r); } else if( r == btif_hl_signal_select_exit) { btif_hl_thread_cleanup(); BTIF_TRACE_DEBUG("Exit hl_select_thread for btif_hl_signal_select_exit"); return 0; } } btif_hl_select_monitor_callback(&curr_set, &org_set); max_org_s = btif_hl_update_maxfd(max_org_s); } else BTIF_TRACE_DEBUG("no data, select ret: %d\n", ret); } BTIF_TRACE_DEBUG("leaving hl_select_thread"); return 0; } Vulnerability Type: DoS CWE ID: CWE-284 Summary: Bluetooth in Android 4.x before 4.4.4, 5.0.x before 5.0.2, 5.1.x before 5.1.1, and 6.x before 2016-08-01 allows attackers to cause a denial of service (loss of Bluetooth 911 functionality) via a crafted application that sends a signal to a Bluetooth process, aka internal bug 28885210. Commit Message: DO NOT MERGE Fix potential DoS caused by delivering signal to BT process Bug: 28885210 Change-Id: I63866d894bfca47464d6e42e3fb0357c4f94d360 Conflicts: btif/co/bta_hh_co.c btif/src/btif_core.c Merge conflict resolution of ag/1161415 (referencing ag/1164670) - Directly into mnc-mr2-release
Medium
173,442
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: void MojoAudioOutputIPC::StreamCreated( mojo::ScopedSharedBufferHandle shared_memory, mojo::ScopedHandle socket) { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK(delegate_); DCHECK(socket.is_valid()); DCHECK(shared_memory.is_valid()); base::PlatformFile socket_handle; auto result = mojo::UnwrapPlatformFile(std::move(socket), &socket_handle); DCHECK_EQ(result, MOJO_RESULT_OK); base::SharedMemoryHandle memory_handle; bool read_only = false; size_t memory_length = 0; result = mojo::UnwrapSharedMemoryHandle( std::move(shared_memory), &memory_handle, &memory_length, &read_only); DCHECK_EQ(result, MOJO_RESULT_OK); DCHECK(!read_only); delegate_->OnStreamCreated(memory_handle, socket_handle); } Vulnerability Type: CWE ID: CWE-787 Summary: Incorrect use of mojo::WrapSharedMemoryHandle in Mojo in Google Chrome prior to 65.0.3325.146 allowed a remote attacker who had compromised the renderer process to perform an out of bounds memory write via a crafted HTML page. Commit Message: Correct mojo::WrapSharedMemoryHandle usage Fixes some incorrect uses of mojo::WrapSharedMemoryHandle which were assuming that the call actually has any control over the memory protection applied to a handle when mapped. Where fixing usage is infeasible for this CL, TODOs are added to annotate follow-up work. Also updates the API and documentation to (hopefully) improve clarity and avoid similar mistakes from being made in the future. BUG=792900 Cq-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 Change-Id: I0578aaa9ca3bfcb01aaf2451315d1ede95458477 Reviewed-on: https://chromium-review.googlesource.com/818282 Reviewed-by: Wei Li <[email protected]> Reviewed-by: Lei Zhang <[email protected]> Reviewed-by: John Abd-El-Malek <[email protected]> Reviewed-by: Daniel Cheng <[email protected]> Reviewed-by: Sadrul Chowdhury <[email protected]> Reviewed-by: Yuzhu Shen <[email protected]> Reviewed-by: Robert Sesek <[email protected]> Commit-Queue: Ken Rockot <[email protected]> Cr-Commit-Position: refs/heads/master@{#530268}
Medium
172,864
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: DECLAREcpFunc(cpSeparate2ContigByRow) { tsize_t scanlinesizein = TIFFScanlineSize(in); tsize_t scanlinesizeout = TIFFScanlineSize(out); tdata_t inbuf; tdata_t outbuf; register uint8 *inp, *outp; register uint32 n; uint32 row; tsample_t s; inbuf = _TIFFmalloc(scanlinesizein); outbuf = _TIFFmalloc(scanlinesizeout); if (!inbuf || !outbuf) goto bad; _TIFFmemset(inbuf, 0, scanlinesizein); _TIFFmemset(outbuf, 0, scanlinesizeout); for (row = 0; row < imagelength; row++) { /* merge channels */ for (s = 0; s < spp; s++) { if (TIFFReadScanline(in, inbuf, row, s) < 0 && !ignore) { TIFFError(TIFFFileName(in), "Error, can't read scanline %lu", (unsigned long) row); goto bad; } inp = (uint8*)inbuf; outp = ((uint8*)outbuf) + s; for (n = imagewidth; n-- > 0;) { *outp = *inp++; outp += spp; } } if (TIFFWriteScanline(out, outbuf, row, 0) < 0) { TIFFError(TIFFFileName(out), "Error, can't write scanline %lu", (unsigned long) row); goto bad; } } if (inbuf) _TIFFfree(inbuf); if (outbuf) _TIFFfree(outbuf); return 1; bad: if (inbuf) _TIFFfree(inbuf); if (outbuf) _TIFFfree(outbuf); return 0; } Vulnerability Type: Exec Code Overflow CWE ID: CWE-119 Summary: LibTIFF version 4.0.7 is vulnerable to a heap buffer overflow in the tools/tiffcp resulting in DoS or code execution via a crafted BitsPerSample value. Commit Message: * tools/tiffcp.c: error out cleanly in cpContig2SeparateByRow and cpSeparate2ContigByRow if BitsPerSample != 8 to avoid heap based overflow. Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2656 and http://bugzilla.maptools.org/show_bug.cgi?id=2657
High
168,413
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: static int dnxhd_find_frame_end(DNXHDParserContext *dctx, const uint8_t *buf, int buf_size) { ParseContext *pc = &dctx->pc; uint64_t state = pc->state64; int pic_found = pc->frame_start_found; int i = 0; if (!pic_found) { for (i = 0; i < buf_size; i++) { state = (state << 8) | buf[i]; if (ff_dnxhd_check_header_prefix(state & 0xffffffffff00LL) != 0) { i++; pic_found = 1; dctx->cur_byte = 0; dctx->remaining = 0; break; } } } if (pic_found && !dctx->remaining) { if (!buf_size) /* EOF considered as end of frame */ return 0; for (; i < buf_size; i++) { dctx->cur_byte++; state = (state << 8) | buf[i]; if (dctx->cur_byte == 24) { dctx->h = (state >> 32) & 0xFFFF; } else if (dctx->cur_byte == 26) { dctx->w = (state >> 32) & 0xFFFF; } else if (dctx->cur_byte == 42) { int cid = (state >> 32) & 0xFFFFFFFF; if (cid <= 0) continue; dctx->remaining = avpriv_dnxhd_get_frame_size(cid); if (dctx->remaining <= 0) { dctx->remaining = dnxhd_get_hr_frame_size(cid, dctx->w, dctx->h); if (dctx->remaining <= 0) return dctx->remaining; } if (buf_size - i + 47 >= dctx->remaining) { int remaining = dctx->remaining; pc->frame_start_found = 0; pc->state64 = -1; dctx->cur_byte = 0; dctx->remaining = 0; return remaining; } else { dctx->remaining -= buf_size; } } } } else if (pic_found) { if (dctx->remaining > buf_size) { dctx->remaining -= buf_size; } else { int remaining = dctx->remaining; pc->frame_start_found = 0; pc->state64 = -1; dctx->cur_byte = 0; dctx->remaining = 0; return remaining; } } pc->frame_start_found = pic_found; pc->state64 = state; return END_NOT_FOUND; } Vulnerability Type: DoS CWE ID: CWE-476 Summary: The dnxhd decoder in FFmpeg before 3.2.6, and 3.3.x before 3.3.3 allows remote attackers to cause a denial of service (NULL pointer dereference) via a crafted mov file. Commit Message: avcodec/dnxhd_parser: Do not return invalid value from dnxhd_find_frame_end() on error Fixes: Null pointer dereference Fixes: CVE-2017-9608 Found-by: Yihan Lian Signed-off-by: Michael Niedermayer <[email protected]> (cherry picked from commit 611b35627488a8d0763e75c25ee0875c5b7987dd) Signed-off-by: Michael Niedermayer <[email protected]>
Medium
170,046
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: CompositedLayerRasterInvalidator::ChunkPropertiesChanged( const RefCountedPropertyTreeState& new_chunk_state, const PaintChunkInfo& new_chunk, const PaintChunkInfo& old_chunk, const PropertyTreeState& layer_state) const { if (!ApproximatelyEqual(new_chunk.chunk_to_layer_transform, old_chunk.chunk_to_layer_transform)) return PaintInvalidationReason::kPaintProperty; if (new_chunk_state.Effect() != old_chunk.effect_state || new_chunk_state.Effect()->Changed(*layer_state.Effect())) return PaintInvalidationReason::kPaintProperty; if (new_chunk.chunk_to_layer_clip.IsTight() && old_chunk.chunk_to_layer_clip.IsTight()) { if (new_chunk.chunk_to_layer_clip == old_chunk.chunk_to_layer_clip) return PaintInvalidationReason::kNone; if (ClipByLayerBounds(new_chunk.chunk_to_layer_clip.Rect()) == ClipByLayerBounds(old_chunk.chunk_to_layer_clip.Rect())) return PaintInvalidationReason::kNone; return PaintInvalidationReason::kIncremental; } if (new_chunk_state.Clip() != old_chunk.clip_state || new_chunk_state.Clip()->Changed(*layer_state.Clip())) return PaintInvalidationReason::kPaintProperty; return PaintInvalidationReason::kNone; } Vulnerability Type: DoS CWE ID: Summary: Multiple unspecified vulnerabilities in Google Chrome before 47.0.2526.73 allow attackers to cause a denial of service or possibly have other impact via unknown vectors. Commit Message: Reland "[CI] Make paint property nodes non-ref-counted" This reverts commit 887383b30842d9d9006e11bb6932660a3cb5b1b7. Reason for revert: Retry in M69. Original change's description: > Revert "[CI] Make paint property nodes non-ref-counted" > > This reverts commit 70fc0b018c9517558b7aa2be00edf2debb449123. > > Reason for revert: Caused bugs found by clusterfuzz > > Original change's description: > > [CI] Make paint property nodes non-ref-counted > > > > Now all paint property nodes are owned by ObjectPaintProperties > > (and LocalFrameView temporarily before removing non-RLS mode). > > Others just use raw pointers or references. > > > > Bug: 833496 > > Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2 > > Change-Id: I2d544fe153bb94698623248748df63c8aa2081ae > > Reviewed-on: https://chromium-review.googlesource.com/1031101 > > Reviewed-by: Tien-Ren Chen <[email protected]> > > Commit-Queue: Xianzhu Wang <[email protected]> > > Cr-Commit-Position: refs/heads/master@{#554626} > > [email protected],[email protected],[email protected] > > Change-Id: I02bb50d6744cb81a797246a0116b677e80a3c69f > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: 833496,837932,837943 > Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2 > Reviewed-on: https://chromium-review.googlesource.com/1034292 > Reviewed-by: Xianzhu Wang <[email protected]> > Commit-Queue: Xianzhu Wang <[email protected]> > Cr-Commit-Position: refs/heads/master@{#554653} [email protected],[email protected],[email protected] # Not skipping CQ checks because original CL landed > 1 day ago. Bug: 833496, 837932, 837943 Change-Id: I0b4ef70db1f1f211ba97c30d617225355c750992 Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2 Reviewed-on: https://chromium-review.googlesource.com/1083491 Commit-Queue: Xianzhu Wang <[email protected]> Reviewed-by: Xianzhu Wang <[email protected]> Cr-Commit-Position: refs/heads/master@{#563930}
High
171,810
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: P2PQuicStreamImpl* P2PQuicTransportImpl::CreateStreamInternal( quic::QuicStreamId id) { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK(crypto_stream_); DCHECK(IsEncryptionEstablished()); DCHECK(!IsClosed()); return new P2PQuicStreamImpl(id, this); } Vulnerability Type: Bypass CWE ID: CWE-284 Summary: The TreeScope::adoptIfNeeded function in WebKit/Source/core/dom/TreeScope.cpp in the DOM implementation in Blink, as used in Google Chrome before 50.0.2661.102, does not prevent script execution during node-adoption operations, which allows remote attackers to bypass the Same Origin Policy via a crafted web site. Commit Message: P2PQuicStream write functionality. This adds the P2PQuicStream::WriteData function and adds tests. It also adds the concept of a write buffered amount, enforcing this at the P2PQuicStreamImpl. Bug: 874296 Change-Id: Id02c8aa8d5368a87bb24a2e50dab5ef94bcae131 Reviewed-on: https://chromium-review.googlesource.com/c/1315534 Commit-Queue: Seth Hampson <[email protected]> Reviewed-by: Henrik Boström <[email protected]> Cr-Commit-Position: refs/heads/master@{#605766}
Medium
172,265
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: static void btsnoop_write(const void *data, size_t length) { if (logfile_fd != INVALID_FD) write(logfile_fd, data, length); btsnoop_net_write(data, length); } Vulnerability Type: DoS CWE ID: CWE-284 Summary: Bluetooth in Android 4.x before 4.4.4, 5.0.x before 5.0.2, 5.1.x before 5.1.1, and 6.x before 2016-08-01 allows attackers to cause a denial of service (loss of Bluetooth 911 functionality) via a crafted application that sends a signal to a Bluetooth process, aka internal bug 28885210. Commit Message: DO NOT MERGE Fix potential DoS caused by delivering signal to BT process Bug: 28885210 Change-Id: I63866d894bfca47464d6e42e3fb0357c4f94d360 Conflicts: btif/co/bta_hh_co.c btif/src/btif_core.c Merge conflict resolution of ag/1161415 (referencing ag/1164670) - Directly into mnc-mr2-release
Medium
173,472
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: static struct sem_undo *find_alloc_undo(struct ipc_namespace *ns, int semid) { struct sem_array *sma; struct sem_undo_list *ulp; struct sem_undo *un, *new; int nsems; int error; error = get_undo_list(&ulp); if (error) return ERR_PTR(error); rcu_read_lock(); spin_lock(&ulp->lock); un = lookup_undo(ulp, semid); spin_unlock(&ulp->lock); if (likely(un!=NULL)) goto out; /* no undo structure around - allocate one. */ /* step 1: figure out the size of the semaphore array */ sma = sem_obtain_object_check(ns, semid); if (IS_ERR(sma)) { rcu_read_unlock(); return ERR_CAST(sma); } nsems = sma->sem_nsems; ipc_rcu_getref(sma); rcu_read_unlock(); /* step 2: allocate new undo structure */ new = kzalloc(sizeof(struct sem_undo) + sizeof(short)*nsems, GFP_KERNEL); if (!new) { sem_putref(sma); return ERR_PTR(-ENOMEM); } /* step 3: Acquire the lock on semaphore array */ sem_lock_and_putref(sma); if (sma->sem_perm.deleted) { sem_unlock(sma); kfree(new); un = ERR_PTR(-EIDRM); goto out; } spin_lock(&ulp->lock); /* * step 4: check for races: did someone else allocate the undo struct? */ un = lookup_undo(ulp, semid); if (un) { kfree(new); goto success; } /* step 5: initialize & link new undo structure */ new->semadj = (short *) &new[1]; new->ulp = ulp; new->semid = semid; assert_spin_locked(&ulp->lock); list_add_rcu(&new->list_proc, &ulp->list_proc); assert_spin_locked(&sma->sem_perm.lock); list_add(&new->list_id, &sma->list_id); un = new; success: spin_unlock(&ulp->lock); rcu_read_lock(); sem_unlock(sma); out: return un; } Vulnerability Type: DoS CWE ID: CWE-189 Summary: The ipc_rcu_putref function in ipc/util.c in the Linux kernel before 3.10 does not properly manage a reference count, which allows local users to cause a denial of service (memory consumption or system crash) via a crafted application. Commit Message: ipc,sem: fine grained locking for semtimedop Introduce finer grained locking for semtimedop, to handle the common case of a program wanting to manipulate one semaphore from an array with multiple semaphores. If the call is a semop manipulating just one semaphore in an array with multiple semaphores, only take the lock for that semaphore itself. If the call needs to manipulate multiple semaphores, or another caller is in a transaction that manipulates multiple semaphores, the sem_array lock is taken, as well as all the locks for the individual semaphores. On a 24 CPU system, performance numbers with the semop-multi test with N threads and N semaphores, look like this: vanilla Davidlohr's Davidlohr's + Davidlohr's + threads patches rwlock patches v3 patches 10 610652 726325 1783589 2142206 20 341570 365699 1520453 1977878 30 288102 307037 1498167 2037995 40 290714 305955 1612665 2256484 50 288620 312890 1733453 2650292 60 289987 306043 1649360 2388008 70 291298 306347 1723167 2717486 80 290948 305662 1729545 2763582 90 290996 306680 1736021 2757524 100 292243 306700 1773700 3059159 [[email protected]: do not call sem_lock when bogus sma] [[email protected]: make refcounter atomic] Signed-off-by: Rik van Riel <[email protected]> Suggested-by: Linus Torvalds <[email protected]> Acked-by: Davidlohr Bueso <[email protected]> Cc: Chegu Vinod <[email protected]> Cc: Jason Low <[email protected]> Reviewed-by: Michel Lespinasse <[email protected]> Cc: Peter Hurley <[email protected]> Cc: Stanislav Kinsbursky <[email protected]> Tested-by: Emmanuel Benisty <[email protected]> Tested-by: Sedat Dilek <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
Medium
165,970
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: static int parse_index(git_index *index, const char *buffer, size_t buffer_size) { int error = 0; unsigned int i; struct index_header header = { 0 }; git_oid checksum_calculated, checksum_expected; const char *last = NULL; const char *empty = ""; #define seek_forward(_increase) { \ if (_increase >= buffer_size) { \ error = index_error_invalid("ran out of data while parsing"); \ goto done; } \ buffer += _increase; \ buffer_size -= _increase;\ } if (buffer_size < INDEX_HEADER_SIZE + INDEX_FOOTER_SIZE) return index_error_invalid("insufficient buffer space"); /* Precalculate the SHA1 of the files's contents -- we'll match it to * the provided SHA1 in the footer */ git_hash_buf(&checksum_calculated, buffer, buffer_size - INDEX_FOOTER_SIZE); /* Parse header */ if ((error = read_header(&header, buffer)) < 0) return error; index->version = header.version; if (index->version >= INDEX_VERSION_NUMBER_COMP) last = empty; seek_forward(INDEX_HEADER_SIZE); assert(!index->entries.length); if (index->ignore_case) git_idxmap_icase_resize((khash_t(idxicase) *) index->entries_map, header.entry_count); else git_idxmap_resize(index->entries_map, header.entry_count); /* Parse all the entries */ for (i = 0; i < header.entry_count && buffer_size > INDEX_FOOTER_SIZE; ++i) { git_index_entry *entry = NULL; size_t entry_size = read_entry(&entry, index, buffer, buffer_size, last); /* 0 bytes read means an object corruption */ if (entry_size == 0) { error = index_error_invalid("invalid entry"); goto done; } if ((error = git_vector_insert(&index->entries, entry)) < 0) { index_entry_free(entry); goto done; } INSERT_IN_MAP(index, entry, &error); if (error < 0) { index_entry_free(entry); goto done; } error = 0; if (index->version >= INDEX_VERSION_NUMBER_COMP) last = entry->path; seek_forward(entry_size); } if (i != header.entry_count) { error = index_error_invalid("header entries changed while parsing"); goto done; } /* There's still space for some extensions! */ while (buffer_size > INDEX_FOOTER_SIZE) { size_t extension_size; extension_size = read_extension(index, buffer, buffer_size); /* see if we have read any bytes from the extension */ if (extension_size == 0) { error = index_error_invalid("extension is truncated"); goto done; } seek_forward(extension_size); } if (buffer_size != INDEX_FOOTER_SIZE) { error = index_error_invalid( "buffer size does not match index footer size"); goto done; } /* 160-bit SHA-1 over the content of the index file before this checksum. */ git_oid_fromraw(&checksum_expected, (const unsigned char *)buffer); if (git_oid__cmp(&checksum_calculated, &checksum_expected) != 0) { error = index_error_invalid( "calculated checksum does not match expected"); goto done; } git_oid_cpy(&index->checksum, &checksum_calculated); #undef seek_forward /* Entries are stored case-sensitively on disk, so re-sort now if * in-memory index is supposed to be case-insensitive */ git_vector_set_sorted(&index->entries, !index->ignore_case); git_vector_sort(&index->entries); done: return error; } Vulnerability Type: DoS CWE ID: CWE-415 Summary: Incorrect returning of an error code in the index.c:read_entry() function leads to a double free in libgit2 before v0.26.2, which allows an attacker to cause a denial of service via a crafted repository index file. Commit Message: index: convert `read_entry` to return entry size via an out-param The function `read_entry` does not conform to our usual coding style of returning stuff via the out parameter and to use the return value for reporting errors. Due to most of our code conforming to that pattern, it has become quite natural for us to actually return `-1` in case there is any error, which has also slipped in with commit 5625d86b9 (index: support index v4, 2016-05-17). As the function returns an `size_t` only, though, the return value is wrapped around, causing the caller of `read_tree` to continue with an invalid index entry. Ultimately, this can lead to a double-free. Improve code and fix the bug by converting the function to return the index entry size via an out parameter and only using the return value to indicate errors. Reported-by: Krishna Ram Prakash R <[email protected]> Reported-by: Vivek Parikh <[email protected]>
Medium
169,299
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: gamma_display_init(gamma_display *dp, png_modifier *pm, png_uint_32 id, double file_gamma, double screen_gamma, png_byte sbit, int threshold_test, int use_input_precision, int scale16, int expand16, int do_background, PNG_CONST png_color_16 *pointer_to_the_background_color, double background_gamma) { /* Standard fields */ standard_display_init(&dp->this, &pm->this, id, 0/*do_interlace*/, pm->use_update_info); /* Parameter fields */ dp->pm = pm; dp->file_gamma = file_gamma; dp->screen_gamma = screen_gamma; dp->background_gamma = background_gamma; dp->sbit = sbit; dp->threshold_test = threshold_test; dp->use_input_precision = use_input_precision; dp->scale16 = scale16; dp->expand16 = expand16; dp->do_background = do_background; if (do_background && pointer_to_the_background_color != 0) dp->background_color = *pointer_to_the_background_color; else memset(&dp->background_color, 0, sizeof dp->background_color); /* Local variable fields */ dp->maxerrout = dp->maxerrpc = dp->maxerrabs = 0; } Vulnerability Type: +Priv CWE ID: Summary: Unspecified vulnerability in libpng before 1.6.20, as used in Android 4.x before 4.4.4, 5.0.x before 5.0.2, 5.1.x before 5.1.1, and 6.x before 2016-07-01, allows attackers to gain privileges via a crafted application, as demonstrated by obtaining Signature or SignatureOrSystem access, aka internal bug 23265085. Commit Message: DO NOT MERGE Update libpng to 1.6.20 BUG:23265085 Change-Id: I85199805636d771f3597b691b63bc0bf46084833 (cherry picked from commit bbe98b40cda082024b669fa508931042eed18f82)
High
173,611
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: void RenderWidgetHostViewAura::CopyFromCompositingSurfaceFinished( base::WeakPtr<RenderWidgetHostViewAura> render_widget_host_view, const base::Callback<void(bool)>& callback, bool result) { callback.Run(result); if (!render_widget_host_view.get()) return; --render_widget_host_view->pending_thumbnail_tasks_; render_widget_host_view->AdjustSurfaceProtection(); } Vulnerability Type: CWE ID: Summary: Google Chrome before 25.0.1364.99 on Mac OS X does not properly implement signal handling for Native Client (aka NaCl) code, which has unspecified impact and attack vectors. Commit Message: Implement TextureImageTransportSurface using texture mailbox This has a couple of advantages: - allow tearing down and recreating the UI parent context without losing the renderer contexts - do not require a context to be able to generate textures when creating the GLSurfaceHandle - clearer ownership semantics that potentially allows for more robust and easier lost context handling/thumbnailing/etc., since a texture is at any given time owned by either: UI parent, mailbox, or TextureImageTransportSurface - simplify frontbuffer protection logic; the frontbuffer textures are now owned by RWHV where they are refcounted The TextureImageTransportSurface informs RenderWidgetHostView of the mailbox names for the front- and backbuffer textures by associating them with a surface_handle (1 or 2) in the AcceleratedSurfaceNew message. During SwapBuffers() or PostSubBuffer() cycles, it then uses produceTextureCHROMIUM() and consumeTextureCHROMIUM() to transfer ownership between renderer and browser compositor. RWHV sends back the surface_handle of the buffer being returned with the Swap ACK (or 0 if no buffer is being returned in which case TextureImageTransportSurface will allocate a new texture - note that this could be used to simply keep textures for thumbnailing). BUG=154815,139616 [email protected] Review URL: https://chromiumcodereview.appspot.com/11194042 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171569 0039d316-1c4b-4281-b951-d872f2087c98
High
171,378
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { ALOGV("entering parseChunk %lld/%d", *offset, depth); uint32_t hdr[2]; if (mDataSource->readAt(*offset, hdr, 8) < 8) { return ERROR_IO; } uint64_t chunk_size = ntohl(hdr[0]); uint32_t chunk_type = ntohl(hdr[1]); off64_t data_offset = *offset + 8; if (chunk_size == 1) { if (mDataSource->readAt(*offset + 8, &chunk_size, 8) < 8) { return ERROR_IO; } chunk_size = ntoh64(chunk_size); data_offset += 8; if (chunk_size < 16) { return ERROR_MALFORMED; } } else if (chunk_size == 0) { if (depth == 0) { off64_t sourceSize; if (mDataSource->getSize(&sourceSize) == OK) { chunk_size = (sourceSize - *offset); } else { ALOGE("atom size is 0, and data source has no size"); return ERROR_MALFORMED; } } else { *offset += 4; return OK; } } else if (chunk_size < 8) { ALOGE("invalid chunk size: %" PRIu64, chunk_size); return ERROR_MALFORMED; } char chunk[5]; MakeFourCCString(chunk_type, chunk); ALOGV("chunk: %s @ %lld, %d", chunk, *offset, depth); #if 0 static const char kWhitespace[] = " "; const char *indent = &kWhitespace[sizeof(kWhitespace) - 1 - 2 * depth]; printf("%sfound chunk '%s' of size %" PRIu64 "\n", indent, chunk, chunk_size); char buffer[256]; size_t n = chunk_size; if (n > sizeof(buffer)) { n = sizeof(buffer); } if (mDataSource->readAt(*offset, buffer, n) < (ssize_t)n) { return ERROR_IO; } hexdump(buffer, n); #endif PathAdder autoAdder(&mPath, chunk_type); off64_t chunk_data_size = *offset + chunk_size - data_offset; if (chunk_type != FOURCC('c', 'p', 'r', 't') && chunk_type != FOURCC('c', 'o', 'v', 'r') && mPath.size() == 5 && underMetaDataPath(mPath)) { off64_t stop_offset = *offset + chunk_size; *offset = data_offset; while (*offset < stop_offset) { status_t err = parseChunk(offset, depth + 1); if (err != OK) { return err; } } if (*offset != stop_offset) { return ERROR_MALFORMED; } return OK; } switch(chunk_type) { case FOURCC('m', 'o', 'o', 'v'): case FOURCC('t', 'r', 'a', 'k'): case FOURCC('m', 'd', 'i', 'a'): case FOURCC('m', 'i', 'n', 'f'): case FOURCC('d', 'i', 'n', 'f'): case FOURCC('s', 't', 'b', 'l'): case FOURCC('m', 'v', 'e', 'x'): case FOURCC('m', 'o', 'o', 'f'): case FOURCC('t', 'r', 'a', 'f'): case FOURCC('m', 'f', 'r', 'a'): case FOURCC('u', 'd', 't', 'a'): case FOURCC('i', 'l', 's', 't'): case FOURCC('s', 'i', 'n', 'f'): case FOURCC('s', 'c', 'h', 'i'): case FOURCC('e', 'd', 't', 's'): { if (chunk_type == FOURCC('s', 't', 'b', 'l')) { ALOGV("sampleTable chunk is %" PRIu64 " bytes long.", chunk_size); if (mDataSource->flags() & (DataSource::kWantsPrefetching | DataSource::kIsCachingDataSource)) { sp<MPEG4DataSource> cachedSource = new MPEG4DataSource(mDataSource); if (cachedSource->setCachedRange(*offset, chunk_size) == OK) { mDataSource = cachedSource; } } mLastTrack->sampleTable = new SampleTable(mDataSource); } bool isTrack = false; if (chunk_type == FOURCC('t', 'r', 'a', 'k')) { isTrack = true; Track *track = new Track; track->next = NULL; if (mLastTrack) { mLastTrack->next = track; } else { mFirstTrack = track; } mLastTrack = track; track->meta = new MetaData; track->includes_expensive_metadata = false; track->skipTrack = false; track->timescale = 0; track->meta->setCString(kKeyMIMEType, "application/octet-stream"); } off64_t stop_offset = *offset + chunk_size; *offset = data_offset; while (*offset < stop_offset) { status_t err = parseChunk(offset, depth + 1); if (err != OK) { return err; } } if (*offset != stop_offset) { return ERROR_MALFORMED; } if (isTrack) { if (mLastTrack->skipTrack) { Track *cur = mFirstTrack; if (cur == mLastTrack) { delete cur; mFirstTrack = mLastTrack = NULL; } else { while (cur && cur->next != mLastTrack) { cur = cur->next; } cur->next = NULL; delete mLastTrack; mLastTrack = cur; } return OK; } status_t err = verifyTrack(mLastTrack); if (err != OK) { return err; } } else if (chunk_type == FOURCC('m', 'o', 'o', 'v')) { mInitCheck = OK; if (!mIsDrm) { return UNKNOWN_ERROR; // Return a dummy error. } else { return OK; } } break; } case FOURCC('e', 'l', 's', 't'): { *offset += chunk_size; uint8_t version; if (mDataSource->readAt(data_offset, &version, 1) < 1) { return ERROR_IO; } uint32_t entry_count; if (!mDataSource->getUInt32(data_offset + 4, &entry_count)) { return ERROR_IO; } if (entry_count != 1) { ALOGW("ignoring edit list with %d entries", entry_count); } else if (mHeaderTimescale == 0) { ALOGW("ignoring edit list because timescale is 0"); } else { off64_t entriesoffset = data_offset + 8; uint64_t segment_duration; int64_t media_time; if (version == 1) { if (!mDataSource->getUInt64(entriesoffset, &segment_duration) || !mDataSource->getUInt64(entriesoffset + 8, (uint64_t*)&media_time)) { return ERROR_IO; } } else if (version == 0) { uint32_t sd; int32_t mt; if (!mDataSource->getUInt32(entriesoffset, &sd) || !mDataSource->getUInt32(entriesoffset + 4, (uint32_t*)&mt)) { return ERROR_IO; } segment_duration = sd; media_time = mt; } else { return ERROR_IO; } uint64_t halfscale = mHeaderTimescale / 2; segment_duration = (segment_duration * 1000000 + halfscale)/ mHeaderTimescale; media_time = (media_time * 1000000 + halfscale) / mHeaderTimescale; int64_t duration; int32_t samplerate; if (!mLastTrack) { return ERROR_MALFORMED; } if (mLastTrack->meta->findInt64(kKeyDuration, &duration) && mLastTrack->meta->findInt32(kKeySampleRate, &samplerate)) { int64_t delay = (media_time * samplerate + 500000) / 1000000; mLastTrack->meta->setInt32(kKeyEncoderDelay, delay); int64_t paddingus = duration - (segment_duration + media_time); if (paddingus < 0) { paddingus = 0; } int64_t paddingsamples = (paddingus * samplerate + 500000) / 1000000; mLastTrack->meta->setInt32(kKeyEncoderPadding, paddingsamples); } } break; } case FOURCC('f', 'r', 'm', 'a'): { *offset += chunk_size; uint32_t original_fourcc; if (mDataSource->readAt(data_offset, &original_fourcc, 4) < 4) { return ERROR_IO; } original_fourcc = ntohl(original_fourcc); ALOGV("read original format: %d", original_fourcc); mLastTrack->meta->setCString(kKeyMIMEType, FourCC2MIME(original_fourcc)); uint32_t num_channels = 0; uint32_t sample_rate = 0; if (AdjustChannelsAndRate(original_fourcc, &num_channels, &sample_rate)) { mLastTrack->meta->setInt32(kKeyChannelCount, num_channels); mLastTrack->meta->setInt32(kKeySampleRate, sample_rate); } break; } case FOURCC('t', 'e', 'n', 'c'): { *offset += chunk_size; if (chunk_size < 32) { return ERROR_MALFORMED; } char buf[4]; memset(buf, 0, 4); if (mDataSource->readAt(data_offset + 4, buf + 1, 3) < 3) { return ERROR_IO; } uint32_t defaultAlgorithmId = ntohl(*((int32_t*)buf)); if (defaultAlgorithmId > 1) { return ERROR_MALFORMED; } memset(buf, 0, 4); if (mDataSource->readAt(data_offset + 7, buf + 3, 1) < 1) { return ERROR_IO; } uint32_t defaultIVSize = ntohl(*((int32_t*)buf)); if ((defaultAlgorithmId == 0 && defaultIVSize != 0) || (defaultAlgorithmId != 0 && defaultIVSize == 0)) { return ERROR_MALFORMED; } else if (defaultIVSize != 0 && defaultIVSize != 8 && defaultIVSize != 16) { return ERROR_MALFORMED; } uint8_t defaultKeyId[16]; if (mDataSource->readAt(data_offset + 8, &defaultKeyId, 16) < 16) { return ERROR_IO; } mLastTrack->meta->setInt32(kKeyCryptoMode, defaultAlgorithmId); mLastTrack->meta->setInt32(kKeyCryptoDefaultIVSize, defaultIVSize); mLastTrack->meta->setData(kKeyCryptoKey, 'tenc', defaultKeyId, 16); break; } case FOURCC('t', 'k', 'h', 'd'): { *offset += chunk_size; status_t err; if ((err = parseTrackHeader(data_offset, chunk_data_size)) != OK) { return err; } break; } case FOURCC('p', 's', 's', 'h'): { *offset += chunk_size; PsshInfo pssh; if (mDataSource->readAt(data_offset + 4, &pssh.uuid, 16) < 16) { return ERROR_IO; } uint32_t psshdatalen = 0; if (mDataSource->readAt(data_offset + 20, &psshdatalen, 4) < 4) { return ERROR_IO; } pssh.datalen = ntohl(psshdatalen); ALOGV("pssh data size: %d", pssh.datalen); if (pssh.datalen + 20 > chunk_size) { return ERROR_MALFORMED; } pssh.data = new (std::nothrow) uint8_t[pssh.datalen]; if (pssh.data == NULL) { return ERROR_MALFORMED; } ALOGV("allocated pssh @ %p", pssh.data); ssize_t requested = (ssize_t) pssh.datalen; if (mDataSource->readAt(data_offset + 24, pssh.data, requested) < requested) { return ERROR_IO; } mPssh.push_back(pssh); break; } case FOURCC('m', 'd', 'h', 'd'): { *offset += chunk_size; if (chunk_data_size < 4 || mLastTrack == NULL) { return ERROR_MALFORMED; } uint8_t version; if (mDataSource->readAt( data_offset, &version, sizeof(version)) < (ssize_t)sizeof(version)) { return ERROR_IO; } off64_t timescale_offset; if (version == 1) { timescale_offset = data_offset + 4 + 16; } else if (version == 0) { timescale_offset = data_offset + 4 + 8; } else { return ERROR_IO; } uint32_t timescale; if (mDataSource->readAt( timescale_offset, &timescale, sizeof(timescale)) < (ssize_t)sizeof(timescale)) { return ERROR_IO; } mLastTrack->timescale = ntohl(timescale); int64_t duration = 0; if (version == 1) { if (mDataSource->readAt( timescale_offset + 4, &duration, sizeof(duration)) < (ssize_t)sizeof(duration)) { return ERROR_IO; } if (duration != -1) { duration = ntoh64(duration); } } else { uint32_t duration32; if (mDataSource->readAt( timescale_offset + 4, &duration32, sizeof(duration32)) < (ssize_t)sizeof(duration32)) { return ERROR_IO; } if (duration32 != 0xffffffff) { duration = ntohl(duration32); } } if (duration != 0) { mLastTrack->meta->setInt64( kKeyDuration, (duration * 1000000) / mLastTrack->timescale); } uint8_t lang[2]; off64_t lang_offset; if (version == 1) { lang_offset = timescale_offset + 4 + 8; } else if (version == 0) { lang_offset = timescale_offset + 4 + 4; } else { return ERROR_IO; } if (mDataSource->readAt(lang_offset, &lang, sizeof(lang)) < (ssize_t)sizeof(lang)) { return ERROR_IO; } char lang_code[4]; lang_code[0] = ((lang[0] >> 2) & 0x1f) + 0x60; lang_code[1] = ((lang[0] & 0x3) << 3 | (lang[1] >> 5)) + 0x60; lang_code[2] = (lang[1] & 0x1f) + 0x60; lang_code[3] = '\0'; mLastTrack->meta->setCString( kKeyMediaLanguage, lang_code); break; } case FOURCC('s', 't', 's', 'd'): { if (chunk_data_size < 8) { return ERROR_MALFORMED; } uint8_t buffer[8]; if (chunk_data_size < (off64_t)sizeof(buffer)) { return ERROR_MALFORMED; } if (mDataSource->readAt( data_offset, buffer, 8) < 8) { return ERROR_IO; } if (U32_AT(buffer) != 0) { return ERROR_MALFORMED; } uint32_t entry_count = U32_AT(&buffer[4]); if (entry_count > 1) { const char *mime; CHECK(mLastTrack->meta->findCString(kKeyMIMEType, &mime)); if (strcasecmp(mime, MEDIA_MIMETYPE_TEXT_3GPP) && strcasecmp(mime, "application/octet-stream")) { mLastTrack->skipTrack = true; *offset += chunk_size; break; } } off64_t stop_offset = *offset + chunk_size; *offset = data_offset + 8; for (uint32_t i = 0; i < entry_count; ++i) { status_t err = parseChunk(offset, depth + 1); if (err != OK) { return err; } } if (*offset != stop_offset) { return ERROR_MALFORMED; } break; } case FOURCC('m', 'p', '4', 'a'): case FOURCC('e', 'n', 'c', 'a'): case FOURCC('s', 'a', 'm', 'r'): case FOURCC('s', 'a', 'w', 'b'): { uint8_t buffer[8 + 20]; if (chunk_data_size < (ssize_t)sizeof(buffer)) { return ERROR_MALFORMED; } if (mDataSource->readAt( data_offset, buffer, sizeof(buffer)) < (ssize_t)sizeof(buffer)) { return ERROR_IO; } uint16_t data_ref_index = U16_AT(&buffer[6]); uint32_t num_channels = U16_AT(&buffer[16]); uint16_t sample_size = U16_AT(&buffer[18]); uint32_t sample_rate = U32_AT(&buffer[24]) >> 16; if (chunk_type != FOURCC('e', 'n', 'c', 'a')) { mLastTrack->meta->setCString(kKeyMIMEType, FourCC2MIME(chunk_type)); AdjustChannelsAndRate(chunk_type, &num_channels, &sample_rate); } ALOGV("*** coding='%s' %d channels, size %d, rate %d\n", chunk, num_channels, sample_size, sample_rate); mLastTrack->meta->setInt32(kKeyChannelCount, num_channels); mLastTrack->meta->setInt32(kKeySampleRate, sample_rate); off64_t stop_offset = *offset + chunk_size; *offset = data_offset + sizeof(buffer); while (*offset < stop_offset) { status_t err = parseChunk(offset, depth + 1); if (err != OK) { return err; } } if (*offset != stop_offset) { return ERROR_MALFORMED; } break; } case FOURCC('m', 'p', '4', 'v'): case FOURCC('e', 'n', 'c', 'v'): case FOURCC('s', '2', '6', '3'): case FOURCC('H', '2', '6', '3'): case FOURCC('h', '2', '6', '3'): case FOURCC('a', 'v', 'c', '1'): case FOURCC('h', 'v', 'c', '1'): case FOURCC('h', 'e', 'v', '1'): { mHasVideo = true; uint8_t buffer[78]; if (chunk_data_size < (ssize_t)sizeof(buffer)) { return ERROR_MALFORMED; } if (mDataSource->readAt( data_offset, buffer, sizeof(buffer)) < (ssize_t)sizeof(buffer)) { return ERROR_IO; } uint16_t data_ref_index = U16_AT(&buffer[6]); uint16_t width = U16_AT(&buffer[6 + 18]); uint16_t height = U16_AT(&buffer[6 + 20]); if (width == 0) width = 352; if (height == 0) height = 288; if (chunk_type != FOURCC('e', 'n', 'c', 'v')) { mLastTrack->meta->setCString(kKeyMIMEType, FourCC2MIME(chunk_type)); } mLastTrack->meta->setInt32(kKeyWidth, width); mLastTrack->meta->setInt32(kKeyHeight, height); off64_t stop_offset = *offset + chunk_size; *offset = data_offset + sizeof(buffer); while (*offset < stop_offset) { status_t err = parseChunk(offset, depth + 1); if (err != OK) { return err; } } if (*offset != stop_offset) { return ERROR_MALFORMED; } break; } case FOURCC('s', 't', 'c', 'o'): case FOURCC('c', 'o', '6', '4'): { status_t err = mLastTrack->sampleTable->setChunkOffsetParams( chunk_type, data_offset, chunk_data_size); *offset += chunk_size; if (err != OK) { return err; } break; } case FOURCC('s', 't', 's', 'c'): { status_t err = mLastTrack->sampleTable->setSampleToChunkParams( data_offset, chunk_data_size); *offset += chunk_size; if (err != OK) { return err; } break; } case FOURCC('s', 't', 's', 'z'): case FOURCC('s', 't', 'z', '2'): { status_t err = mLastTrack->sampleTable->setSampleSizeParams( chunk_type, data_offset, chunk_data_size); *offset += chunk_size; if (err != OK) { return err; } size_t max_size; err = mLastTrack->sampleTable->getMaxSampleSize(&max_size); if (err != OK) { return err; } if (max_size != 0) { mLastTrack->meta->setInt32(kKeyMaxInputSize, max_size + 10 * 2); } else { int32_t width, height; if (!mLastTrack->meta->findInt32(kKeyWidth, &width) || !mLastTrack->meta->findInt32(kKeyHeight, &height)) { ALOGE("No width or height, assuming worst case 1080p"); width = 1920; height = 1080; } const char *mime; CHECK(mLastTrack->meta->findCString(kKeyMIMEType, &mime)); if (!strcmp(mime, MEDIA_MIMETYPE_VIDEO_AVC)) { max_size = ((width + 15) / 16) * ((height + 15) / 16) * 192; } else { max_size = width * height * 3 / 2; } mLastTrack->meta->setInt32(kKeyMaxInputSize, max_size); } const char *mime; CHECK(mLastTrack->meta->findCString(kKeyMIMEType, &mime)); if (!strncasecmp("video/", mime, 6)) { size_t nSamples = mLastTrack->sampleTable->countSamples(); int64_t durationUs; if (mLastTrack->meta->findInt64(kKeyDuration, &durationUs)) { if (durationUs > 0) { int32_t frameRate = (nSamples * 1000000LL + (durationUs >> 1)) / durationUs; mLastTrack->meta->setInt32(kKeyFrameRate, frameRate); } } } break; } case FOURCC('s', 't', 't', 's'): { *offset += chunk_size; status_t err = mLastTrack->sampleTable->setTimeToSampleParams( data_offset, chunk_data_size); if (err != OK) { return err; } break; } case FOURCC('c', 't', 't', 's'): { *offset += chunk_size; status_t err = mLastTrack->sampleTable->setCompositionTimeToSampleParams( data_offset, chunk_data_size); if (err != OK) { return err; } break; } case FOURCC('s', 't', 's', 's'): { *offset += chunk_size; status_t err = mLastTrack->sampleTable->setSyncSampleParams( data_offset, chunk_data_size); if (err != OK) { return err; } break; } case FOURCC('\xA9', 'x', 'y', 'z'): { *offset += chunk_size; if (chunk_data_size < 8) { return ERROR_MALFORMED; } char buffer[18]; off64_t location_length = chunk_data_size - 5; if (location_length >= (off64_t) sizeof(buffer)) { return ERROR_MALFORMED; } if (mDataSource->readAt( data_offset + 4, buffer, location_length) < location_length) { return ERROR_IO; } buffer[location_length] = '\0'; mFileMetaData->setCString(kKeyLocation, buffer); break; } case FOURCC('e', 's', 'd', 's'): { *offset += chunk_size; if (chunk_data_size < 4) { return ERROR_MALFORMED; } uint8_t buffer[256]; if (chunk_data_size > (off64_t)sizeof(buffer)) { return ERROR_BUFFER_TOO_SMALL; } if (mDataSource->readAt( data_offset, buffer, chunk_data_size) < chunk_data_size) { return ERROR_IO; } if (U32_AT(buffer) != 0) { return ERROR_MALFORMED; } mLastTrack->meta->setData( kKeyESDS, kTypeESDS, &buffer[4], chunk_data_size - 4); if (mPath.size() >= 2 && mPath[mPath.size() - 2] == FOURCC('m', 'p', '4', 'a')) { status_t err = updateAudioTrackInfoFromESDS_MPEG4Audio( &buffer[4], chunk_data_size - 4); if (err != OK) { return err; } } break; } case FOURCC('a', 'v', 'c', 'C'): { *offset += chunk_size; sp<ABuffer> buffer = new ABuffer(chunk_data_size); if (mDataSource->readAt( data_offset, buffer->data(), chunk_data_size) < chunk_data_size) { return ERROR_IO; } mLastTrack->meta->setData( kKeyAVCC, kTypeAVCC, buffer->data(), chunk_data_size); break; } case FOURCC('h', 'v', 'c', 'C'): { sp<ABuffer> buffer = new ABuffer(chunk_data_size); if (mDataSource->readAt( data_offset, buffer->data(), chunk_data_size) < chunk_data_size) { return ERROR_IO; } mLastTrack->meta->setData( kKeyHVCC, kTypeHVCC, buffer->data(), chunk_data_size); *offset += chunk_size; break; } case FOURCC('d', '2', '6', '3'): { *offset += chunk_size; /* * d263 contains a fixed 7 bytes part: * vendor - 4 bytes * version - 1 byte * level - 1 byte * profile - 1 byte * optionally, "d263" box itself may contain a 16-byte * bit rate box (bitr) * average bit rate - 4 bytes * max bit rate - 4 bytes */ char buffer[23]; if (chunk_data_size != 7 && chunk_data_size != 23) { ALOGE("Incorrect D263 box size %lld", chunk_data_size); return ERROR_MALFORMED; } if (mDataSource->readAt( data_offset, buffer, chunk_data_size) < chunk_data_size) { return ERROR_IO; } mLastTrack->meta->setData(kKeyD263, kTypeD263, buffer, chunk_data_size); break; } case FOURCC('m', 'e', 't', 'a'): { uint8_t buffer[4]; if (chunk_data_size < (off64_t)sizeof(buffer)) { *offset += chunk_size; return ERROR_MALFORMED; } if (mDataSource->readAt( data_offset, buffer, 4) < 4) { *offset += chunk_size; return ERROR_IO; } if (U32_AT(buffer) != 0) { *offset += chunk_size; return OK; } off64_t stop_offset = *offset + chunk_size; *offset = data_offset + sizeof(buffer); while (*offset < stop_offset) { status_t err = parseChunk(offset, depth + 1); if (err != OK) { return err; } } if (*offset != stop_offset) { return ERROR_MALFORMED; } break; } case FOURCC('m', 'e', 'a', 'n'): case FOURCC('n', 'a', 'm', 'e'): case FOURCC('d', 'a', 't', 'a'): { *offset += chunk_size; if (mPath.size() == 6 && underMetaDataPath(mPath)) { status_t err = parseITunesMetaData(data_offset, chunk_data_size); if (err != OK) { return err; } } break; } case FOURCC('m', 'v', 'h', 'd'): { *offset += chunk_size; if (chunk_data_size < 32) { return ERROR_MALFORMED; } uint8_t header[32]; if (mDataSource->readAt( data_offset, header, sizeof(header)) < (ssize_t)sizeof(header)) { return ERROR_IO; } uint64_t creationTime; uint64_t duration = 0; if (header[0] == 1) { creationTime = U64_AT(&header[4]); mHeaderTimescale = U32_AT(&header[20]); duration = U64_AT(&header[24]); if (duration == 0xffffffffffffffff) { duration = 0; } } else if (header[0] != 0) { return ERROR_MALFORMED; } else { creationTime = U32_AT(&header[4]); mHeaderTimescale = U32_AT(&header[12]); uint32_t d32 = U32_AT(&header[16]); if (d32 == 0xffffffff) { d32 = 0; } duration = d32; } if (duration != 0) { mFileMetaData->setInt64(kKeyDuration, duration * 1000000 / mHeaderTimescale); } String8 s; convertTimeToDate(creationTime, &s); mFileMetaData->setCString(kKeyDate, s.string()); break; } case FOURCC('m', 'e', 'h', 'd'): { *offset += chunk_size; if (chunk_data_size < 8) { return ERROR_MALFORMED; } uint8_t flags[4]; if (mDataSource->readAt( data_offset, flags, sizeof(flags)) < (ssize_t)sizeof(flags)) { return ERROR_IO; } uint64_t duration = 0; if (flags[0] == 1) { if (chunk_data_size < 12) { return ERROR_MALFORMED; } mDataSource->getUInt64(data_offset + 4, &duration); if (duration == 0xffffffffffffffff) { duration = 0; } } else if (flags[0] == 0) { uint32_t d32; mDataSource->getUInt32(data_offset + 4, &d32); if (d32 == 0xffffffff) { d32 = 0; } duration = d32; } else { return ERROR_MALFORMED; } if (duration != 0) { mFileMetaData->setInt64(kKeyDuration, duration * 1000000 / mHeaderTimescale); } break; } case FOURCC('m', 'd', 'a', 't'): { ALOGV("mdat chunk, drm: %d", mIsDrm); if (!mIsDrm) { *offset += chunk_size; break; } if (chunk_size < 8) { return ERROR_MALFORMED; } return parseDrmSINF(offset, data_offset); } case FOURCC('h', 'd', 'l', 'r'): { *offset += chunk_size; uint32_t buffer; if (mDataSource->readAt( data_offset + 8, &buffer, 4) < 4) { return ERROR_IO; } uint32_t type = ntohl(buffer); if (type == FOURCC('t', 'e', 'x', 't') || type == FOURCC('s', 'b', 't', 'l')) { mLastTrack->meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_TEXT_3GPP); } break; } case FOURCC('t', 'r', 'e', 'x'): { *offset += chunk_size; if (chunk_data_size < 24) { return ERROR_IO; } uint32_t duration; Trex trex; if (!mDataSource->getUInt32(data_offset + 4, &trex.track_ID) || !mDataSource->getUInt32(data_offset + 8, &trex.default_sample_description_index) || !mDataSource->getUInt32(data_offset + 12, &trex.default_sample_duration) || !mDataSource->getUInt32(data_offset + 16, &trex.default_sample_size) || !mDataSource->getUInt32(data_offset + 20, &trex.default_sample_flags)) { return ERROR_IO; } mTrex.add(trex); break; } case FOURCC('t', 'x', '3', 'g'): { uint32_t type; const void *data; size_t size = 0; if (!mLastTrack->meta->findData( kKeyTextFormatData, &type, &data, &size)) { size = 0; } uint8_t *buffer = new (std::nothrow) uint8_t[size + chunk_size]; if (buffer == NULL) { return ERROR_MALFORMED; } if (size > 0) { memcpy(buffer, data, size); } if ((size_t)(mDataSource->readAt(*offset, buffer + size, chunk_size)) < chunk_size) { delete[] buffer; buffer = NULL; *offset += chunk_size; return ERROR_IO; } mLastTrack->meta->setData( kKeyTextFormatData, 0, buffer, size + chunk_size); delete[] buffer; *offset += chunk_size; break; } case FOURCC('c', 'o', 'v', 'r'): { *offset += chunk_size; if (mFileMetaData != NULL) { ALOGV("chunk_data_size = %lld and data_offset = %lld", chunk_data_size, data_offset); sp<ABuffer> buffer = new ABuffer(chunk_data_size + 1); if (mDataSource->readAt( data_offset, buffer->data(), chunk_data_size) != (ssize_t)chunk_data_size) { return ERROR_IO; } const int kSkipBytesOfDataBox = 16; mFileMetaData->setData( kKeyAlbumArt, MetaData::TYPE_NONE, buffer->data() + kSkipBytesOfDataBox, chunk_data_size - kSkipBytesOfDataBox); } break; } case FOURCC('t', 'i', 't', 'l'): case FOURCC('p', 'e', 'r', 'f'): case FOURCC('a', 'u', 't', 'h'): case FOURCC('g', 'n', 'r', 'e'): case FOURCC('a', 'l', 'b', 'm'): case FOURCC('y', 'r', 'r', 'c'): { *offset += chunk_size; status_t err = parse3GPPMetaData(data_offset, chunk_data_size, depth); if (err != OK) { return err; } break; } case FOURCC('I', 'D', '3', '2'): { *offset += chunk_size; if (chunk_data_size < 6) { return ERROR_MALFORMED; } parseID3v2MetaData(data_offset + 6); break; } case FOURCC('-', '-', '-', '-'): { mLastCommentMean.clear(); mLastCommentName.clear(); mLastCommentData.clear(); *offset += chunk_size; break; } case FOURCC('s', 'i', 'd', 'x'): { parseSegmentIndex(data_offset, chunk_data_size); *offset += chunk_size; return UNKNOWN_ERROR; // stop parsing after sidx } default: { *offset += chunk_size; break; } } return OK; } Vulnerability Type: DoS Exec Code Overflow Mem. Corr. CWE ID: CWE-119 Summary: The MPEG4Extractor::parseChunk function in MPEG4Extractor.cpp in libstagefright in Android before 5.1.1 LMY48I does not validate the relationship between chunk sizes and skip sizes, which allows remote attackers to execute arbitrary code or cause a denial of service (integer underflow and memory corruption) via crafted MPEG-4 covr atoms, aka internal bug 20923261. Commit Message: Fix integer underflow in covr MPEG4 processing When the 'chunk_data_size' variable is less than 'kSkipBytesOfDataBox', an integer underflow can occur. This causes an extraordinarily large value to be passed to MetaData::setData, leading to a buffer overflow. Bug: 20923261 Change-Id: Icd28f63594ad941eabb3a12c750a4a2d5d2bf94b
High
173,368
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: SYSCALL_DEFINE2(osf_getdomainname, char __user *, name, int, namelen) { unsigned len; int i; if (!access_ok(VERIFY_WRITE, name, namelen)) return -EFAULT; len = namelen; if (namelen > 32) len = 32; down_read(&uts_sem); for (i = 0; i < len; ++i) { __put_user(utsname()->domainname[i], name + i); if (utsname()->domainname[i] == '\0') break; } up_read(&uts_sem); return 0; } Vulnerability Type: +Priv CWE ID: CWE-264 Summary: The osf_wait4 function in arch/alpha/kernel/osf_sys.c in the Linux kernel before 2.6.39.4 on the Alpha platform uses an incorrect pointer, which allows local users to gain privileges by writing a certain integer value to kernel memory. Commit Message: alpha: fix several security issues Fix several security issues in Alpha-specific syscalls. Untested, but mostly trivial. 1. Signedness issue in osf_getdomainname allows copying out-of-bounds kernel memory to userland. 2. Signedness issue in osf_sysinfo allows copying large amounts of kernel memory to userland. 3. Typo (?) in osf_getsysinfo bounds minimum instead of maximum copy size, allowing copying large amounts of kernel memory to userland. 4. Usage of user pointer in osf_wait4 while under KERNEL_DS allows privilege escalation via writing return value of sys_wait4 to kernel memory. Signed-off-by: Dan Rosenberg <[email protected]> Cc: Richard Henderson <[email protected]> Cc: Ivan Kokshaysky <[email protected]> Cc: Matt Turner <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
High
165,867
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: void CloudPolicySubsystem::StopAutoRetry() { cloud_policy_controller_->StopAutoRetry(); device_token_fetcher_->StopAutoRetry(); data_store_->Reset(); } Vulnerability Type: DoS CWE ID: CWE-399 Summary: Use-after-free vulnerability in Google Chrome before 14.0.835.202 allows remote attackers to cause a denial of service or possibly have unspecified other impact via vectors related to the Google V8 bindings. Commit Message: Reset the device policy machinery upon retrying enrollment. BUG=chromium-os:18208 TEST=See bug description Review URL: http://codereview.chromium.org/7676005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97615 0039d316-1c4b-4281-b951-d872f2087c98
Medium
170,283
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: IV_API_CALL_STATUS_T impeg2d_api_entity(iv_obj_t *ps_dechdl, void *pv_api_ip, void *pv_api_op) { iv_obj_t *ps_dec_handle; dec_state_t *ps_dec_state; dec_state_multi_core_t *ps_dec_state_multi_core; impeg2d_video_decode_ip_t *ps_dec_ip; impeg2d_video_decode_op_t *ps_dec_op; WORD32 bytes_remaining; pic_buf_t *ps_disp_pic; ps_dec_ip = (impeg2d_video_decode_ip_t *)pv_api_ip; ps_dec_op = (impeg2d_video_decode_op_t *)pv_api_op; memset(ps_dec_op,0,sizeof(impeg2d_video_decode_op_t)); ps_dec_op->s_ivd_video_decode_op_t.u4_size = sizeof(impeg2d_video_decode_op_t); ps_dec_op->s_ivd_video_decode_op_t.u4_output_present = 0; bytes_remaining = ps_dec_ip->s_ivd_video_decode_ip_t.u4_num_Bytes; ps_dec_handle = (iv_obj_t *)ps_dechdl; if(ps_dechdl == NULL) { return(IV_FAIL); } ps_dec_state_multi_core = ps_dec_handle->pv_codec_handle; ps_dec_state = ps_dec_state_multi_core->ps_dec_state[0]; ps_dec_state->ps_disp_frm_buf = &(ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf); if(0 == ps_dec_state->u4_share_disp_buf) { ps_dec_state->ps_disp_frm_buf->pv_y_buf = ps_dec_ip->s_ivd_video_decode_ip_t.s_out_buffer.pu1_bufs[0]; ps_dec_state->ps_disp_frm_buf->pv_u_buf = ps_dec_ip->s_ivd_video_decode_ip_t.s_out_buffer.pu1_bufs[1]; ps_dec_state->ps_disp_frm_buf->pv_v_buf = ps_dec_ip->s_ivd_video_decode_ip_t.s_out_buffer.pu1_bufs[2]; } ps_dec_state->ps_disp_pic = NULL; ps_dec_state->i4_frame_decoded = 0; /*rest bytes consumed */ ps_dec_op->s_ivd_video_decode_op_t.u4_num_bytes_consumed = 0; ps_dec_op->s_ivd_video_decode_op_t.u4_error_code = IV_SUCCESS; if((ps_dec_ip->s_ivd_video_decode_ip_t.pv_stream_buffer == NULL)&&(ps_dec_state->u1_flushfrm==0)) { ps_dec_op->s_ivd_video_decode_op_t.u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM; ps_dec_op->s_ivd_video_decode_op_t.u4_error_code |= IVD_DEC_FRM_BS_BUF_NULL; return IV_FAIL; } if (ps_dec_state->u4_num_frames_decoded > NUM_FRAMES_LIMIT) { ps_dec_op->s_ivd_video_decode_op_t.u4_error_code = IMPEG2D_SAMPLE_VERSION_LIMIT_ERR; return(IV_FAIL); } if(((0 == ps_dec_state->u2_header_done) || (ps_dec_state->u2_decode_header == 1)) && (ps_dec_state->u1_flushfrm == 0)) { impeg2d_dec_hdr(ps_dec_state,ps_dec_ip ,ps_dec_op); bytes_remaining -= ps_dec_op->s_ivd_video_decode_op_t.u4_num_bytes_consumed; } if((1 != ps_dec_state->u2_decode_header) && ((bytes_remaining > 0) || ps_dec_state->u1_flushfrm)) { if(ps_dec_state->u1_flushfrm) { if(ps_dec_state->aps_ref_pics[1] != NULL) { impeg2_disp_mgr_add(&ps_dec_state->s_disp_mgr, ps_dec_state->aps_ref_pics[1], ps_dec_state->aps_ref_pics[1]->i4_buf_id); impeg2_buf_mgr_release(ps_dec_state->pv_pic_buf_mg, ps_dec_state->aps_ref_pics[1]->i4_buf_id, BUF_MGR_REF); impeg2_buf_mgr_release(ps_dec_state->pv_pic_buf_mg, ps_dec_state->aps_ref_pics[0]->i4_buf_id, BUF_MGR_REF); ps_dec_state->aps_ref_pics[1] = NULL; ps_dec_state->aps_ref_pics[0] = NULL; } else if(ps_dec_state->aps_ref_pics[0] != NULL) { impeg2_disp_mgr_add(&ps_dec_state->s_disp_mgr, ps_dec_state->aps_ref_pics[0], ps_dec_state->aps_ref_pics[0]->i4_buf_id); impeg2_buf_mgr_release(ps_dec_state->pv_pic_buf_mg, ps_dec_state->aps_ref_pics[0]->i4_buf_id, BUF_MGR_REF); ps_dec_state->aps_ref_pics[0] = NULL; } ps_dec_ip->s_ivd_video_decode_ip_t.u4_size = sizeof(impeg2d_video_decode_ip_t); ps_dec_op->s_ivd_video_decode_op_t.u4_size = sizeof(impeg2d_video_decode_op_t); ps_disp_pic = impeg2_disp_mgr_get(&ps_dec_state->s_disp_mgr, &ps_dec_state->i4_disp_buf_id); ps_dec_state->ps_disp_pic = ps_disp_pic; if(ps_disp_pic == NULL) { ps_dec_op->s_ivd_video_decode_op_t.u4_output_present = 0; } else { WORD32 fmt_conv; if(0 == ps_dec_state->u4_share_disp_buf) { ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf.pv_y_buf = ps_dec_ip->s_ivd_video_decode_ip_t.s_out_buffer.pu1_bufs[0]; ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf.pv_u_buf = ps_dec_ip->s_ivd_video_decode_ip_t.s_out_buffer.pu1_bufs[1]; ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf.pv_v_buf = ps_dec_ip->s_ivd_video_decode_ip_t.s_out_buffer.pu1_bufs[2]; fmt_conv = 1; } else { ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf.pv_y_buf = ps_disp_pic->pu1_y; if(IV_YUV_420P == ps_dec_state->i4_chromaFormat) { ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf.pv_u_buf = ps_disp_pic->pu1_u; ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf.pv_v_buf = ps_disp_pic->pu1_v; fmt_conv = 0; } else { UWORD8 *pu1_buf; pu1_buf = ps_dec_state->as_disp_buffers[ps_disp_pic->i4_buf_id].pu1_bufs[1]; ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf.pv_u_buf = pu1_buf; pu1_buf = ps_dec_state->as_disp_buffers[ps_disp_pic->i4_buf_id].pu1_bufs[2]; ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf.pv_v_buf = pu1_buf; fmt_conv = 1; } } if(fmt_conv == 1) { iv_yuv_buf_t *ps_dst; ps_dst = &(ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf); if(ps_dec_state->u4_deinterlace && (0 == ps_dec_state->u2_progressive_frame)) { impeg2d_deinterlace(ps_dec_state, ps_disp_pic, ps_dst, 0, ps_dec_state->u2_vertical_size); } else { impeg2d_format_convert(ps_dec_state, ps_disp_pic, ps_dst, 0, ps_dec_state->u2_vertical_size); } } if(ps_dec_state->u4_deinterlace) { if(ps_dec_state->ps_deint_pic) { impeg2_buf_mgr_release(ps_dec_state->pv_pic_buf_mg, ps_dec_state->ps_deint_pic->i4_buf_id, MPEG2_BUF_MGR_DEINT); } ps_dec_state->ps_deint_pic = ps_disp_pic; } if(0 == ps_dec_state->u4_share_disp_buf) impeg2_buf_mgr_release(ps_dec_state->pv_pic_buf_mg, ps_disp_pic->i4_buf_id, BUF_MGR_DISP); ps_dec_op->s_ivd_video_decode_op_t.u4_pic_ht = ps_dec_state->u2_vertical_size; ps_dec_op->s_ivd_video_decode_op_t.u4_pic_wd = ps_dec_state->u2_horizontal_size; ps_dec_op->s_ivd_video_decode_op_t.u4_output_present = 1; ps_dec_op->s_ivd_video_decode_op_t.u4_disp_buf_id = ps_disp_pic->i4_buf_id; ps_dec_op->s_ivd_video_decode_op_t.u4_ts = ps_disp_pic->u4_ts; ps_dec_op->s_ivd_video_decode_op_t.e_output_format = (IV_COLOR_FORMAT_T)ps_dec_state->i4_chromaFormat; ps_dec_op->s_ivd_video_decode_op_t.u4_is_ref_flag = (B_PIC != ps_dec_state->e_pic_type); ps_dec_op->s_ivd_video_decode_op_t.u4_progressive_frame_flag = IV_PROGRESSIVE; ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf.u4_y_wd = ps_dec_state->u2_horizontal_size; ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf.u4_y_strd = ps_dec_state->u4_frm_buf_stride; ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf.u4_y_ht = ps_dec_state->u2_vertical_size; ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf.u4_u_wd = ps_dec_state->u2_horizontal_size >> 1; ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf.u4_u_strd = ps_dec_state->u4_frm_buf_stride >> 1; ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf.u4_u_ht = ps_dec_state->u2_vertical_size >> 1; ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf.u4_v_wd = ps_dec_state->u2_horizontal_size >> 1; ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf.u4_v_strd = ps_dec_state->u4_frm_buf_stride >> 1; ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf.u4_v_ht = ps_dec_state->u2_vertical_size >> 1; ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf.u4_size = sizeof(ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf); switch(ps_dec_state->i4_chromaFormat) { case IV_YUV_420SP_UV: case IV_YUV_420SP_VU: ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf.u4_u_wd = ps_dec_state->u2_horizontal_size; ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf.u4_u_strd = ps_dec_state->u4_frm_buf_stride; break; case IV_YUV_422ILE: ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf.u4_u_wd = 0; ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf.u4_u_ht = 0; ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf.u4_v_wd = 0; ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf.u4_v_ht = 0; break; default: break; } } if(ps_dec_op->s_ivd_video_decode_op_t.u4_output_present) { if(1 == ps_dec_op->s_ivd_video_decode_op_t.u4_output_present) { INSERT_LOGO(ps_dec_ip->s_ivd_video_decode_ip_t.s_out_buffer.pu1_bufs[0], ps_dec_ip->s_ivd_video_decode_ip_t.s_out_buffer.pu1_bufs[1], ps_dec_ip->s_ivd_video_decode_ip_t.s_out_buffer.pu1_bufs[2], ps_dec_state->u4_frm_buf_stride, ps_dec_state->u2_horizontal_size, ps_dec_state->u2_vertical_size, ps_dec_state->i4_chromaFormat, ps_dec_state->u2_horizontal_size, ps_dec_state->u2_vertical_size); } return(IV_SUCCESS); } else { ps_dec_state->u1_flushfrm = 0; return(IV_FAIL); } } else if(ps_dec_state->u1_flushfrm==0) { ps_dec_ip->s_ivd_video_decode_ip_t.u4_size = sizeof(impeg2d_video_decode_ip_t); ps_dec_op->s_ivd_video_decode_op_t.u4_size = sizeof(impeg2d_video_decode_op_t); if(ps_dec_ip->s_ivd_video_decode_ip_t.u4_num_Bytes < 4) { ps_dec_op->s_ivd_video_decode_op_t.u4_num_bytes_consumed = ps_dec_ip->s_ivd_video_decode_ip_t.u4_num_Bytes; return(IV_FAIL); } if(1 == ps_dec_state->u4_share_disp_buf) { if(0 == impeg2_buf_mgr_check_free(ps_dec_state->pv_pic_buf_mg)) { ps_dec_op->s_ivd_video_decode_op_t.u4_error_code = (IMPEG2D_ERROR_CODES_T)IVD_DEC_REF_BUF_NULL; return IV_FAIL; } } ps_dec_op->s_ivd_video_decode_op_t.e_output_format = (IV_COLOR_FORMAT_T)ps_dec_state->i4_chromaFormat; ps_dec_op->s_ivd_video_decode_op_t.u4_is_ref_flag = (B_PIC != ps_dec_state->e_pic_type); ps_dec_op->s_ivd_video_decode_op_t.u4_progressive_frame_flag = IV_PROGRESSIVE; if (0 == ps_dec_state->u4_frm_buf_stride) { ps_dec_state->u4_frm_buf_stride = (ps_dec_state->u2_horizontal_size); } ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf.u4_y_wd = ps_dec_state->u2_horizontal_size; ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf.u4_y_strd = ps_dec_state->u4_frm_buf_stride; ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf.u4_y_ht = ps_dec_state->u2_vertical_size; ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf.u4_u_wd = ps_dec_state->u2_horizontal_size >> 1; ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf.u4_u_strd = ps_dec_state->u4_frm_buf_stride >> 1; ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf.u4_u_ht = ps_dec_state->u2_vertical_size >> 1; ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf.u4_v_wd = ps_dec_state->u2_horizontal_size >> 1; ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf.u4_v_strd = ps_dec_state->u4_frm_buf_stride >> 1; ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf.u4_v_ht = ps_dec_state->u2_vertical_size >> 1; ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf.u4_size = sizeof(ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf); switch(ps_dec_state->i4_chromaFormat) { case IV_YUV_420SP_UV: case IV_YUV_420SP_VU: ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf.u4_u_wd = ps_dec_state->u2_horizontal_size; ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf.u4_u_strd = ps_dec_state->u4_frm_buf_stride; break; case IV_YUV_422ILE: ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf.u4_u_wd = 0; ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf.u4_u_ht = 0; ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf.u4_v_wd = 0; ps_dec_op->s_ivd_video_decode_op_t.s_disp_frm_buf.u4_v_ht = 0; break; default: break; } if( ps_dec_state->u1_flushfrm == 0) { ps_dec_state->u1_flushcnt = 0; /*************************************************************************/ /* Frame Decode */ /*************************************************************************/ impeg2d_dec_frm(ps_dec_state,ps_dec_ip,ps_dec_op); if (IVD_ERROR_NONE == ps_dec_op->s_ivd_video_decode_op_t.u4_error_code) { if(ps_dec_state->u1_first_frame_done == 0) { ps_dec_state->u1_first_frame_done = 1; } if(ps_dec_state->ps_disp_pic) { ps_dec_op->s_ivd_video_decode_op_t.u4_output_present = 1; switch(ps_dec_state->ps_disp_pic->e_pic_type) { case I_PIC : ps_dec_op->s_ivd_video_decode_op_t.e_pic_type = IV_I_FRAME; break; case P_PIC: ps_dec_op->s_ivd_video_decode_op_t.e_pic_type = IV_P_FRAME; break; case B_PIC: ps_dec_op->s_ivd_video_decode_op_t.e_pic_type = IV_B_FRAME; break; case D_PIC: ps_dec_op->s_ivd_video_decode_op_t.e_pic_type = IV_I_FRAME; break; default : ps_dec_op->s_ivd_video_decode_op_t.e_pic_type = IV_FRAMETYPE_DEFAULT; break; } } else { ps_dec_op->s_ivd_video_decode_op_t.u4_output_present = 0; ps_dec_op->s_ivd_video_decode_op_t.e_pic_type = IV_NA_FRAME; } ps_dec_state->u4_num_frames_decoded++; } } else { ps_dec_state->u1_flushcnt++; } } if(ps_dec_state->ps_disp_pic) { ps_dec_op->s_ivd_video_decode_op_t.u4_disp_buf_id = ps_dec_state->ps_disp_pic->i4_buf_id; ps_dec_op->s_ivd_video_decode_op_t.u4_ts = ps_dec_state->ps_disp_pic->u4_ts; if(0 == ps_dec_state->u4_share_disp_buf) { impeg2_buf_mgr_release(ps_dec_state->pv_pic_buf_mg, ps_dec_state->ps_disp_pic->i4_buf_id, BUF_MGR_DISP); } } if(ps_dec_state->u4_deinterlace) { if(ps_dec_state->ps_deint_pic) { impeg2_buf_mgr_release(ps_dec_state->pv_pic_buf_mg, ps_dec_state->ps_deint_pic->i4_buf_id, MPEG2_BUF_MGR_DEINT); } ps_dec_state->ps_deint_pic = ps_dec_state->ps_disp_pic; } if(1 == ps_dec_op->s_ivd_video_decode_op_t.u4_output_present) { INSERT_LOGO(ps_dec_ip->s_ivd_video_decode_ip_t.s_out_buffer.pu1_bufs[0], ps_dec_ip->s_ivd_video_decode_ip_t.s_out_buffer.pu1_bufs[1], ps_dec_ip->s_ivd_video_decode_ip_t.s_out_buffer.pu1_bufs[2], ps_dec_state->u4_frm_buf_stride, ps_dec_state->u2_horizontal_size, ps_dec_state->u2_vertical_size, ps_dec_state->i4_chromaFormat, ps_dec_state->u2_horizontal_size, ps_dec_state->u2_vertical_size); } } ps_dec_op->s_ivd_video_decode_op_t.u4_progressive_frame_flag = 1; ps_dec_op->s_ivd_video_decode_op_t.e4_fld_type = ps_dec_state->s_disp_op.e4_fld_type; if(ps_dec_op->s_ivd_video_decode_op_t.u4_error_code) return IV_FAIL; else return IV_SUCCESS; } Vulnerability Type: Exec Code Overflow Mem. Corr. CWE ID: CWE-119 Summary: A remote code execution vulnerability in libmpeg2 in Mediaserver could enable an attacker using a specially crafted file to cause memory corruption during media file and data processing. This issue is rated as Critical due to the possibility of remote code execution within the context of the Mediaserver process. Product: Android. Versions: 6.0, 6.0.1, 7.0, 7.1.1, 7.1.2. Android ID: A-35219737. Commit Message: Fix in handling header decode errors If header decode was unsuccessful, do not try decoding a frame Also, initialize pic_wd, pic_ht for reinitialization when decoder is created with smaller dimensions Bug: 28886651 Bug: 35219737 Change-Id: I8c06d9052910e47fce2e6fe25ad318d4c83d2c50 (cherry picked from commit 2b9fa9ace2dbedfbac026fc9b6ab6cdac7f68c27) (cherry picked from commit c2395cd7cc0c286a66de674032dd2ed26500aef4)
High
174,032
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: ScriptPromise BluetoothRemoteGATTCharacteristic::getDescriptorsImpl( ScriptState* scriptState, mojom::blink::WebBluetoothGATTQueryQuantity quantity, const String& descriptor) { if (!getGatt()->connected()) { return ScriptPromise::rejectWithDOMException( scriptState, BluetoothRemoteGATTUtils::CreateDOMException( BluetoothRemoteGATTUtils::ExceptionType::kGATTServerNotConnected)); } if (!getGatt()->device()->isValidCharacteristic( m_characteristic->instance_id)) { return ScriptPromise::rejectWithDOMException( scriptState, BluetoothRemoteGATTUtils::CreateDOMException( BluetoothRemoteGATTUtils::ExceptionType::kInvalidCharacteristic)); } ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); ScriptPromise promise = resolver->promise(); getGatt()->AddToActiveAlgorithms(resolver); mojom::blink::WebBluetoothService* service = m_device->bluetooth()->service(); WTF::Optional<String> uuid = WTF::nullopt; if (!descriptor.isEmpty()) uuid = descriptor; service->RemoteCharacteristicGetDescriptors( m_characteristic->instance_id, quantity, uuid, convertToBaseCallback( WTF::bind(&BluetoothRemoteGATTCharacteristic::GetDescriptorsCallback, wrapPersistent(this), m_characteristic->instance_id, quantity, wrapPersistent(resolver)))); return promise; } Vulnerability Type: DoS Overflow CWE ID: CWE-119 Summary: The filters implementation in Skia, as used in Google Chrome before 41.0.2272.76, allows remote attackers to cause a denial of service or possibly have unspecified other impact via vectors that trigger an out-of-bounds write operation. Commit Message: Allow serialization of empty bluetooth uuids. This change allows the passing WTF::Optional<String> types as bluetooth.mojom.UUID optional parameter without needing to ensure the passed object isn't empty. BUG=None R=juncai, dcheng Review-Url: https://codereview.chromium.org/2646613003 Cr-Commit-Position: refs/heads/master@{#445809}
High
172,021
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: check_acl(pam_handle_t *pamh, const char *sense, const char *this_user, const char *other_user, int noent_code, int debug) { char path[PATH_MAX]; struct passwd *pwd; { char path[PATH_MAX]; struct passwd *pwd; FILE *fp; int i, save_errno; uid_t fsuid; /* Check this user's <sense> file. */ pwd = pam_modutil_getpwnam(pamh, this_user); if (pwd == NULL) { } /* Figure out what that file is really named. */ i = snprintf(path, sizeof(path), "%s/.xauth/%s", pwd->pw_dir, sense); if ((i >= (int)sizeof(path)) || (i < 0)) { pam_syslog(pamh, LOG_ERR, "name of user's home directory is too long"); return PAM_SESSION_ERR; } fsuid = setfsuid(pwd->pw_uid); fp = fopen(path, "r"); return PAM_SESSION_ERR; } fsuid = setfsuid(pwd->pw_uid); fp = fopen(path, "r"); save_errno = errno; setfsuid(fsuid); if (fp != NULL) { char buf[LINE_MAX], *tmp; /* Scan the file for a list of specs of users to "trust". */ while (fgets(buf, sizeof(buf), fp) != NULL) { other_user, path); } fclose(fp); return PAM_PERM_DENIED; } else { /* Default to okay if the file doesn't exist. */ errno = save_errno; switch (errno) { case ENOENT: if (noent_code == PAM_SUCCESS) { if (debug) { pam_syslog(pamh, LOG_DEBUG, "%s does not exist, ignoring", path); } } else { if (debug) { pam_syslog(pamh, LOG_DEBUG, "%s does not exist, failing", path); } } return noent_code; default: if (debug) { pam_syslog(pamh, LOG_DEBUG, "error opening %s: %m", path); } return PAM_PERM_DENIED; } } } Vulnerability Type: DoS CWE ID: CWE-399 Summary: The check_acl function in pam_xauth.c in the pam_xauth module in Linux-PAM (aka pam) 1.1.2 and earlier does not verify that a certain ACL file is a regular file, which might allow local users to cause a denial of service (resource consumption) via a special file. Commit Message:
Medium
164,788
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: bool DataReductionProxySettings::IsDataReductionProxyManaged() { return spdy_proxy_auth_enabled_.IsManaged(); } Vulnerability Type: Overflow CWE ID: CWE-119 Summary: An off by one error resulting in an allocation of zero size in FFmpeg in Google Chrome prior to 54.0.2840.98 for Mac, and 54.0.2840.99 for Windows, and 54.0.2840.100 for Linux, and 55.0.2883.84 for Android allowed a remote attacker to potentially exploit heap corruption via a crafted video file. Commit Message: Move IsDataSaverEnabledByUser to be a static method and use it This method now officially becomes the source of truth that everything in the code base eventually calls into to determine whether or not DataSaver is enabled. Bug: 934399 Change-Id: Iae837b710ace8cc3101188f79d02cbc2d4f0fd93 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1537242 Reviewed-by: Joshua Pawlicki <[email protected]> Reviewed-by: Tarun Bansal <[email protected]> Commit-Queue: Robert Ogden <[email protected]> Cr-Commit-Position: refs/heads/master@{#643948}
Medium
172,555
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: void SoftGSM::onQueueFilled(OMX_U32 /* portIndex */) { if (mSignalledError) { return; } List<BufferInfo *> &inQueue = getPortQueue(0); List<BufferInfo *> &outQueue = getPortQueue(1); while (!inQueue.empty() && !outQueue.empty()) { BufferInfo *inInfo = *inQueue.begin(); OMX_BUFFERHEADERTYPE *inHeader = inInfo->mHeader; BufferInfo *outInfo = *outQueue.begin(); OMX_BUFFERHEADERTYPE *outHeader = outInfo->mHeader; if (inHeader->nFlags & OMX_BUFFERFLAG_EOS) { inQueue.erase(inQueue.begin()); inInfo->mOwnedByUs = false; notifyEmptyBufferDone(inHeader); outHeader->nFilledLen = 0; outHeader->nFlags = OMX_BUFFERFLAG_EOS; outQueue.erase(outQueue.begin()); outInfo->mOwnedByUs = false; notifyFillBufferDone(outHeader); return; } if (inHeader->nFilledLen > kMaxNumSamplesPerFrame) { ALOGE("input buffer too large (%d).", inHeader->nFilledLen); notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL); mSignalledError = true; } if(((inHeader->nFilledLen / kMSGSMFrameSize) * kMSGSMFrameSize) != inHeader->nFilledLen) { ALOGE("input buffer not multiple of %d (%d).", kMSGSMFrameSize, inHeader->nFilledLen); notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL); mSignalledError = true; } uint8_t *inputptr = inHeader->pBuffer + inHeader->nOffset; int n = mSignalledError ? 0 : DecodeGSM(mGsm, reinterpret_cast<int16_t *>(outHeader->pBuffer), inputptr, inHeader->nFilledLen); outHeader->nTimeStamp = inHeader->nTimeStamp; outHeader->nOffset = 0; outHeader->nFilledLen = n * sizeof(int16_t); outHeader->nFlags = 0; inInfo->mOwnedByUs = false; inQueue.erase(inQueue.begin()); inInfo = NULL; notifyEmptyBufferDone(inHeader); inHeader = NULL; outInfo->mOwnedByUs = false; outQueue.erase(outQueue.begin()); outInfo = NULL; notifyFillBufferDone(outHeader); outHeader = NULL; } } Vulnerability Type: Overflow +Priv CWE ID: CWE-119 Summary: libstagefright in mediaserver in Android 4.x before 4.4.4, 5.0.x before 5.0.2, 5.1.x before 5.1.1, and 6.x before 2016-06-01 does not validate OMX buffer sizes for the GSM and G711 codecs, which allows attackers to gain privileges via a crafted application, as demonstrated by obtaining Signature or SignatureOrSystem access, aka internal bug 27793367. Commit Message: codecs: check OMX buffer size before use in (gsm|g711)dec Bug: 27793163 Bug: 27793367 Change-Id: Iec3de8a237ee2379d87a8371c13e543878c6652c
High
173,779
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: int mp_pack(lua_State *L) { int nargs = lua_gettop(L); int i; mp_buf *buf; if (nargs == 0) return luaL_argerror(L, 0, "MessagePack pack needs input."); if (!lua_checkstack(L, nargs)) return luaL_argerror(L, 0, "Too many arguments for MessagePack pack."); buf = mp_buf_new(L); for(i = 1; i <= nargs; i++) { /* Copy argument i to top of stack for _encode processing; * the encode function pops it from the stack when complete. */ lua_pushvalue(L, i); mp_encode_lua_type(L,buf,0); lua_pushlstring(L,(char*)buf->b,buf->len); /* Reuse the buffer for the next operation by * setting its free count to the total buffer size * and the current position to zero. */ buf->free += buf->len; buf->len = 0; } mp_buf_free(L, buf); /* Concatenate all nargs buffers together */ lua_concat(L, nargs); return 1; } Vulnerability Type: Overflow Mem. Corr. CWE ID: CWE-119 Summary: Memory Corruption was discovered in the cmsgpack library in the Lua subsystem in Redis before 3.2.12, 4.x before 4.0.10, and 5.x before 5.0 RC2 because of stack-based buffer overflows. Commit Message: Security: more cmsgpack fixes by @soloestoy. @soloestoy sent me this additional fixes, after searching for similar problems to the one reported in mp_pack(). I'm committing the changes because it was not possible during to make a public PR to protect Redis users and give Redis providers some time to patch their systems.
High
169,241
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: bool CCLayerTreeHost::initialize() { TRACE_EVENT("CCLayerTreeHost::initialize", this, 0); if (m_settings.enableCompositorThread) { m_settings.acceleratePainting = false; m_settings.showFPSCounter = false; m_settings.showPlatformLayerTree = false; m_proxy = CCThreadProxy::create(this); } else m_proxy = CCSingleThreadProxy::create(this); m_proxy->start(); if (!m_proxy->initializeLayerRenderer()) return false; m_compositorIdentifier = m_proxy->compositorIdentifier(); m_settings.acceleratePainting = m_proxy->layerRendererCapabilities().usingAcceleratedPainting; setNeedsCommitThenRedraw(); m_contentsTextureManager = TextureManager::create(TextureManager::highLimitBytes(), m_proxy->layerRendererCapabilities().maxTextureSize); return true; } Vulnerability Type: DoS Overflow Mem. Corr. CWE ID: CWE-119 Summary: Google Chrome before 14.0.835.202 does not properly handle Google V8 hidden objects, which allows remote attackers to cause a denial of service (memory corruption) or possibly have unspecified other impact via crafted JavaScript code. Commit Message: [chromium] Fix shutdown race when posting main thread task to CCThreadProxy and enable tests https://bugs.webkit.org/show_bug.cgi?id=70161 Reviewed by David Levin. Source/WebCore: Adds a weak pointer mechanism to cancel main thread tasks posted to CCThreadProxy instances from the compositor thread. Previously there was a race condition where main thread tasks could run even after the CCThreadProxy was destroyed. This race does not exist in the other direction because when tearing down a CCThreadProxy we first post a quit task to the compositor thread and then suspend execution of the main thread until all compositor tasks for the CCThreadProxy have been drained. Covered by the now-enabled CCLayerTreeHostTest* unit tests. * WebCore.gypi: * platform/graphics/chromium/cc/CCScopedMainThreadProxy.h: Added. (WebCore::CCScopedMainThreadProxy::create): (WebCore::CCScopedMainThreadProxy::postTask): (WebCore::CCScopedMainThreadProxy::shutdown): (WebCore::CCScopedMainThreadProxy::CCScopedMainThreadProxy): (WebCore::CCScopedMainThreadProxy::runTaskIfNotShutdown): * platform/graphics/chromium/cc/CCThreadProxy.cpp: (WebCore::CCThreadProxy::CCThreadProxy): (WebCore::CCThreadProxy::~CCThreadProxy): (WebCore::CCThreadProxy::createBeginFrameAndCommitTaskOnCCThread): * platform/graphics/chromium/cc/CCThreadProxy.h: Source/WebKit/chromium: Enables the CCLayerTreeHostTest* tests by default. Most tests are run twice in a single thread and multiple thread configuration. Some tests run only in the multiple thread configuration if they depend on the compositor thread scheduling draws by itself. * tests/CCLayerTreeHostTest.cpp: (::CCLayerTreeHostTest::timeout): (::CCLayerTreeHostTest::clearTimeout): (::CCLayerTreeHostTest::CCLayerTreeHostTest): (::CCLayerTreeHostTest::onEndTest): (::CCLayerTreeHostTest::TimeoutTask::TimeoutTask): (::CCLayerTreeHostTest::TimeoutTask::clearTest): (::CCLayerTreeHostTest::TimeoutTask::~TimeoutTask): (::CCLayerTreeHostTest::TimeoutTask::Run): (::CCLayerTreeHostTest::runTest): (::CCLayerTreeHostTest::doBeginTest): (::CCLayerTreeHostTestThreadOnly::runTest): (::CCLayerTreeHostTestSetNeedsRedraw::commitCompleteOnCCThread): git-svn-id: svn://svn.chromium.org/blink/trunk@97784 bbb929c8-8fbe-4397-9dbb-9b2b20218538
Medium
170,286
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: nf_ct_frag6_reasm(struct nf_ct_frag6_queue *fq, struct net_device *dev) { struct sk_buff *fp, *op, *head = fq->q.fragments; int payload_len; fq_kill(fq); WARN_ON(head == NULL); WARN_ON(NFCT_FRAG6_CB(head)->offset != 0); /* Unfragmented part is taken from the first segment. */ payload_len = ((head->data - skb_network_header(head)) - sizeof(struct ipv6hdr) + fq->q.len - sizeof(struct frag_hdr)); if (payload_len > IPV6_MAXPLEN) { pr_debug("payload len is too large.\n"); goto out_oversize; } /* Head of list must not be cloned. */ if (skb_cloned(head) && pskb_expand_head(head, 0, 0, GFP_ATOMIC)) { pr_debug("skb is cloned but can't expand head"); goto out_oom; } /* If the first fragment is fragmented itself, we split * it to two chunks: the first with data and paged part * and the second, holding only fragments. */ if (skb_has_frags(head)) { struct sk_buff *clone; int i, plen = 0; if ((clone = alloc_skb(0, GFP_ATOMIC)) == NULL) { pr_debug("Can't alloc skb\n"); goto out_oom; } clone->next = head->next; head->next = clone; skb_shinfo(clone)->frag_list = skb_shinfo(head)->frag_list; skb_frag_list_init(head); for (i=0; i<skb_shinfo(head)->nr_frags; i++) plen += skb_shinfo(head)->frags[i].size; clone->len = clone->data_len = head->data_len - plen; head->data_len -= clone->len; head->len -= clone->len; clone->csum = 0; clone->ip_summed = head->ip_summed; NFCT_FRAG6_CB(clone)->orig = NULL; atomic_add(clone->truesize, &nf_init_frags.mem); } /* We have to remove fragment header from datagram and to relocate * header in order to calculate ICV correctly. */ skb_network_header(head)[fq->nhoffset] = skb_transport_header(head)[0]; memmove(head->head + sizeof(struct frag_hdr), head->head, (head->data - head->head) - sizeof(struct frag_hdr)); head->mac_header += sizeof(struct frag_hdr); head->network_header += sizeof(struct frag_hdr); skb_shinfo(head)->frag_list = head->next; skb_reset_transport_header(head); skb_push(head, head->data - skb_network_header(head)); atomic_sub(head->truesize, &nf_init_frags.mem); for (fp=head->next; fp; fp = fp->next) { head->data_len += fp->len; head->len += fp->len; if (head->ip_summed != fp->ip_summed) head->ip_summed = CHECKSUM_NONE; else if (head->ip_summed == CHECKSUM_COMPLETE) head->csum = csum_add(head->csum, fp->csum); head->truesize += fp->truesize; atomic_sub(fp->truesize, &nf_init_frags.mem); } head->next = NULL; head->dev = dev; head->tstamp = fq->q.stamp; ipv6_hdr(head)->payload_len = htons(payload_len); /* Yes, and fold redundant checksum back. 8) */ if (head->ip_summed == CHECKSUM_COMPLETE) head->csum = csum_partial(skb_network_header(head), skb_network_header_len(head), head->csum); fq->q.fragments = NULL; /* all original skbs are linked into the NFCT_FRAG6_CB(head).orig */ fp = skb_shinfo(head)->frag_list; if (NFCT_FRAG6_CB(fp)->orig == NULL) /* at above code, head skb is divided into two skbs. */ fp = fp->next; op = NFCT_FRAG6_CB(head)->orig; for (; fp; fp = fp->next) { struct sk_buff *orig = NFCT_FRAG6_CB(fp)->orig; op->next = orig; op = orig; NFCT_FRAG6_CB(fp)->orig = NULL; } return head; out_oversize: if (net_ratelimit()) printk(KERN_DEBUG "nf_ct_frag6_reasm: payload len = %d\n", payload_len); goto out_fail; out_oom: if (net_ratelimit()) printk(KERN_DEBUG "nf_ct_frag6_reasm: no memory for reassembly\n"); out_fail: return NULL; } Vulnerability Type: DoS CWE ID: Summary: net/ipv6/netfilter/nf_conntrack_reasm.c in the Linux kernel before 2.6.34, when the nf_conntrack_ipv6 module is enabled, allows remote attackers to cause a denial of service (NULL pointer dereference and system crash) via certain types of fragmented IPv6 packets. Commit Message: netfilter: nf_conntrack_reasm: properly handle packets fragmented into a single fragment When an ICMPV6_PKT_TOOBIG message is received with a MTU below 1280, all further packets include a fragment header. Unlike regular defragmentation, conntrack also needs to "reassemble" those fragments in order to obtain a packet without the fragment header for connection tracking. Currently nf_conntrack_reasm checks whether a fragment has either IP6_MF set or an offset != 0, which makes it ignore those fragments. Remove the invalid check and make reassembly handle fragment queues containing only a single fragment. Reported-and-tested-by: Ulrich Weber <[email protected]> Signed-off-by: Patrick McHardy <[email protected]>
High
165,591
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: recvauth_common(krb5_context context, krb5_auth_context * auth_context, /* IN */ krb5_pointer fd, char *appl_version, krb5_principal server, krb5_int32 flags, krb5_keytab keytab, /* OUT */ krb5_ticket ** ticket, krb5_data *version) { krb5_auth_context new_auth_context; krb5_flags ap_option = 0; krb5_error_code retval, problem; krb5_data inbuf; krb5_data outbuf; krb5_rcache rcache = 0; krb5_octet response; krb5_data null_server; int need_error_free = 0; int local_rcache = 0, local_authcon = 0; /* * Zero out problem variable. If problem is set at the end of * the intial version negotiation section, it means that we * need to send an error code back to the client application * and exit. */ problem = 0; response = 0; if (!(flags & KRB5_RECVAUTH_SKIP_VERSION)) { /* * First read the sendauth version string and check it. */ if ((retval = krb5_read_message(context, fd, &inbuf))) return(retval); if (strcmp(inbuf.data, sendauth_version)) { problem = KRB5_SENDAUTH_BADAUTHVERS; response = 1; } free(inbuf.data); } if (flags & KRB5_RECVAUTH_BADAUTHVERS) { problem = KRB5_SENDAUTH_BADAUTHVERS; response = 1; } /* * Do the same thing for the application version string. */ if ((retval = krb5_read_message(context, fd, &inbuf))) return(retval); if (appl_version && strcmp(inbuf.data, appl_version)) { if (!problem) { problem = KRB5_SENDAUTH_BADAPPLVERS; response = 2; } } if (version && !problem) *version = inbuf; else free(inbuf.data); /* * Now we actually write the response. If the response is non-zero, * exit with a return value of problem */ if ((krb5_net_write(context, *((int *)fd), (char *)&response, 1)) < 0) { return(problem); /* We'll return the top-level problem */ } if (problem) return(problem); /* We are clear of errors here */ /* * Now, let's read the AP_REQ message and decode it */ if ((retval = krb5_read_message(context, fd, &inbuf))) return retval; if (*auth_context == NULL) { problem = krb5_auth_con_init(context, &new_auth_context); *auth_context = new_auth_context; local_authcon = 1; } krb5_auth_con_getrcache(context, *auth_context, &rcache); if ((!problem) && rcache == NULL) { /* * Setup the replay cache. */ if (server != NULL && server->length > 0) { problem = krb5_get_server_rcache(context, &server->data[0], &rcache); } else { null_server.length = 7; null_server.data = "default"; problem = krb5_get_server_rcache(context, &null_server, &rcache); } if (!problem) problem = krb5_auth_con_setrcache(context, *auth_context, rcache); local_rcache = 1; } if (!problem) { problem = krb5_rd_req(context, auth_context, &inbuf, server, keytab, &ap_option, ticket); free(inbuf.data); } /* * If there was a problem, send back a krb5_error message, * preceeded by the length of the krb5_error message. If * everything's ok, send back 0 for the length. */ if (problem) { krb5_error error; const char *message; memset(&error, 0, sizeof(error)); krb5_us_timeofday(context, &error.stime, &error.susec); if(server) error.server = server; else { /* If this fails - ie. ENOMEM we are hosed we cannot even send the error if we wanted to... */ (void) krb5_parse_name(context, "????", &error.server); need_error_free = 1; } error.error = problem - ERROR_TABLE_BASE_krb5; if (error.error > 127) error.error = KRB_ERR_GENERIC; message = error_message(problem); error.text.length = strlen(message) + 1; error.text.data = strdup(message); if (!error.text.data) { retval = ENOMEM; goto cleanup; } if ((retval = krb5_mk_error(context, &error, &outbuf))) { free(error.text.data); goto cleanup; } free(error.text.data); if(need_error_free) krb5_free_principal(context, error.server); } else { outbuf.length = 0; outbuf.data = 0; } retval = krb5_write_message(context, fd, &outbuf); if (outbuf.data) { free(outbuf.data); /* We sent back an error, we need cleanup then return */ retval = problem; goto cleanup; } if (retval) goto cleanup; /* Here lies the mutual authentication stuff... */ if ((ap_option & AP_OPTS_MUTUAL_REQUIRED)) { if ((retval = krb5_mk_rep(context, *auth_context, &outbuf))) { return(retval); } retval = krb5_write_message(context, fd, &outbuf); free(outbuf.data); } cleanup:; if (retval) { if (local_authcon) { krb5_auth_con_free(context, *auth_context); } else if (local_rcache && rcache != NULL) { krb5_rc_close(context, rcache); krb5_auth_con_setrcache(context, *auth_context, NULL); } } return retval; } Vulnerability Type: DoS CWE ID: Summary: MIT Kerberos 5 (aka krb5) through 1.13.1 incorrectly expects that a krb5_read_message data field is represented as a string ending with a '0' character, which allows remote attackers to (1) cause a denial of service (NULL pointer dereference) via a zero-byte version string or (2) cause a denial of service (out-of-bounds read) by omitting the '0' character, related to appl/user_user/server.c and lib/krb5/krb/recvauth.c. Commit Message: Fix krb5_read_message handling [CVE-2014-5355] In recvauth_common, do not use strcmp against the data fields of krb5_data objects populated by krb5_read_message(), as there is no guarantee that they are C strings. Instead, create an expected krb5_data value and use data_eq(). In the sample user-to-user server application, check that the received client principal name is null-terminated before using it with printf and krb5_parse_name. CVE-2014-5355: In MIT krb5, when a server process uses the krb5_recvauth function, an unauthenticated remote attacker can cause a NULL dereference by sending a zero-byte version string, or a read beyond the end of allocated storage by sending a non-null-terminated version string. The example user-to-user server application (uuserver) is similarly vulnerable to a zero-length or non-null-terminated principal name string. The krb5_recvauth function reads two version strings from the client using krb5_read_message(), which produces a krb5_data structure containing a length and a pointer to an octet sequence. krb5_recvauth assumes that the data pointer is a valid C string and passes it to strcmp() to verify the versions. If the client sends an empty octet sequence, the data pointer will be NULL and strcmp() will dereference a NULL pointer, causing the process to crash. If the client sends a non-null-terminated octet sequence, strcmp() will read beyond the end of the allocated storage, possibly causing the process to crash. uuserver similarly uses krb5_read_message() to read a client principal name, and then passes it to printf() and krb5_parse_name() without verifying that it is a valid C string. The krb5_recvauth function is used by kpropd and the Kerberized versions of the BSD rlogin and rsh daemons. These daemons are usually run out of inetd or in a mode which forks before processing incoming connections, so a process crash will generally not result in a complete denial of service. Thanks to Tim Uglow for discovering this issue. CVSSv2: AV:N/AC:L/Au:N/C:N/I:N/A:P/E:POC/RL:OF/RC:C [[email protected]: CVSS score] ticket: 8050 (new) target_version: 1.13.1 tags: pullup
Medium
166,812
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: struct bpf_prog *bpf_prog_get(u32 ufd) { struct fd f = fdget(ufd); struct bpf_prog *prog; prog = __bpf_prog_get(f); if (IS_ERR(prog)) return prog; atomic_inc(&prog->aux->refcnt); fdput(f); return prog; } Vulnerability Type: DoS CWE ID: Summary: The BPF subsystem in the Linux kernel before 4.5.5 mishandles reference counts, which allows local users to cause a denial of service (use-after-free) or possibly have unspecified other impact via a crafted application on (1) a system with more than 32 Gb of memory, related to the program reference count or (2) a 1 Tb system, related to the map reference count. Commit Message: bpf: fix refcnt overflow On a system with >32Gbyte of phyiscal memory and infinite RLIMIT_MEMLOCK, the malicious application may overflow 32-bit bpf program refcnt. It's also possible to overflow map refcnt on 1Tb system. Impose 32k hard limit which means that the same bpf program or map cannot be shared by more than 32k processes. Fixes: 1be7f75d1668 ("bpf: enable non-root eBPF programs") Reported-by: Jann Horn <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Acked-by: Daniel Borkmann <[email protected]> Signed-off-by: David S. Miller <[email protected]>
Medium
167,254
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: void SavePayload(size_t handle, uint32_t *payload, uint32_t index) { mp4object *mp4 = (mp4object *)handle; if (mp4 == NULL) return; uint32_t *MP4buffer = NULL; if (index < mp4->indexcount && mp4->mediafp && payload) { LONGSEEK(mp4->mediafp, mp4->metaoffsets[index], SEEK_SET); fwrite(payload, 1, mp4->metasizes[index], mp4->mediafp); } return; } Vulnerability Type: CWE ID: CWE-787 Summary: GoPro GPMF-parser 1.2.2 has an out-of-bounds write in OpenMP4Source in demo/GPMF_mp4reader.c. Commit Message: fixed many security issues with the too crude mp4 reader
Medium
169,552
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: static int audit_log_single_execve_arg(struct audit_context *context, struct audit_buffer **ab, int arg_num, size_t *len_sent, const char __user *p, char *buf) { char arg_num_len_buf[12]; const char __user *tmp_p = p; /* how many digits are in arg_num? 5 is the length of ' a=""' */ size_t arg_num_len = snprintf(arg_num_len_buf, 12, "%d", arg_num) + 5; size_t len, len_left, to_send; size_t max_execve_audit_len = MAX_EXECVE_AUDIT_LEN; unsigned int i, has_cntl = 0, too_long = 0; int ret; /* strnlen_user includes the null we don't want to send */ len_left = len = strnlen_user(p, MAX_ARG_STRLEN) - 1; /* * We just created this mm, if we can't find the strings * we just copied into it something is _very_ wrong. Similar * for strings that are too long, we should not have created * any. */ if (WARN_ON_ONCE(len < 0 || len > MAX_ARG_STRLEN - 1)) { send_sig(SIGKILL, current, 0); return -1; } /* walk the whole argument looking for non-ascii chars */ do { if (len_left > MAX_EXECVE_AUDIT_LEN) to_send = MAX_EXECVE_AUDIT_LEN; else to_send = len_left; ret = copy_from_user(buf, tmp_p, to_send); /* * There is no reason for this copy to be short. We just * copied them here, and the mm hasn't been exposed to user- * space yet. */ if (ret) { WARN_ON(1); send_sig(SIGKILL, current, 0); return -1; } buf[to_send] = '\0'; has_cntl = audit_string_contains_control(buf, to_send); if (has_cntl) { /* * hex messages get logged as 2 bytes, so we can only * send half as much in each message */ max_execve_audit_len = MAX_EXECVE_AUDIT_LEN / 2; break; } len_left -= to_send; tmp_p += to_send; } while (len_left > 0); len_left = len; if (len > max_execve_audit_len) too_long = 1; /* rewalk the argument actually logging the message */ for (i = 0; len_left > 0; i++) { int room_left; if (len_left > max_execve_audit_len) to_send = max_execve_audit_len; else to_send = len_left; /* do we have space left to send this argument in this ab? */ room_left = MAX_EXECVE_AUDIT_LEN - arg_num_len - *len_sent; if (has_cntl) room_left -= (to_send * 2); else room_left -= to_send; if (room_left < 0) { *len_sent = 0; audit_log_end(*ab); *ab = audit_log_start(context, GFP_KERNEL, AUDIT_EXECVE); if (!*ab) return 0; } /* * first record needs to say how long the original string was * so we can be sure nothing was lost. */ if ((i == 0) && (too_long)) audit_log_format(*ab, " a%d_len=%zu", arg_num, has_cntl ? 2*len : len); /* * normally arguments are small enough to fit and we already * filled buf above when we checked for control characters * so don't bother with another copy_from_user */ if (len >= max_execve_audit_len) ret = copy_from_user(buf, p, to_send); else ret = 0; if (ret) { WARN_ON(1); send_sig(SIGKILL, current, 0); return -1; } buf[to_send] = '\0'; /* actually log it */ audit_log_format(*ab, " a%d", arg_num); if (too_long) audit_log_format(*ab, "[%d]", i); audit_log_format(*ab, "="); if (has_cntl) audit_log_n_hex(*ab, buf, to_send); else audit_log_string(*ab, buf); p += to_send; len_left -= to_send; *len_sent += arg_num_len; if (has_cntl) *len_sent += to_send * 2; else *len_sent += to_send; } /* include the null we didn't log */ return len + 1; } Vulnerability Type: Bypass CWE ID: CWE-362 Summary: Race condition in the audit_log_single_execve_arg function in kernel/auditsc.c in the Linux kernel through 4.7 allows local users to bypass intended character-set restrictions or disrupt system-call auditing by changing a certain string, aka a *double fetch* vulnerability. Commit Message: audit: fix a double fetch in audit_log_single_execve_arg() There is a double fetch problem in audit_log_single_execve_arg() where we first check the execve(2) argumnets for any "bad" characters which would require hex encoding and then re-fetch the arguments for logging in the audit record[1]. Of course this leaves a window of opportunity for an unsavory application to munge with the data. This patch reworks things by only fetching the argument data once[2] into a buffer where it is scanned and logged into the audit records(s). In addition to fixing the double fetch, this patch improves on the original code in a few other ways: better handling of large arguments which require encoding, stricter record length checking, and some performance improvements (completely unverified, but we got rid of some strlen() calls, that's got to be a good thing). As part of the development of this patch, I've also created a basic regression test for the audit-testsuite, the test can be tracked on GitHub at the following link: * https://github.com/linux-audit/audit-testsuite/issues/25 [1] If you pay careful attention, there is actually a triple fetch problem due to a strnlen_user() call at the top of the function. [2] This is a tiny white lie, we do make a call to strnlen_user() prior to fetching the argument data. I don't like it, but due to the way the audit record is structured we really have no choice unless we copy the entire argument at once (which would require a rather wasteful allocation). The good news is that with this patch the kernel no longer relies on this strnlen_user() value for anything beyond recording it in the log, we also update it with a trustworthy value whenever possible. Reported-by: Pengfei Wang <[email protected]> Cc: <[email protected]> Signed-off-by: Paul Moore <[email protected]>
Low
167,019
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: void MediaInterfaceProxy::OnConnectionError() { DVLOG(1) << __FUNCTION__; DCHECK(thread_checker_.CalledOnValidThread()); interface_factory_ptr_.reset(); } Vulnerability Type: DoS Overflow Mem. Corr. CWE ID: CWE-119 Summary: SkPictureShader.cpp in Skia, as used in Google Chrome before 44.0.2403.89, allows remote attackers to cause a denial of service (memory corruption) or possibly have unspecified other impact by leveraging access to a renderer process and providing crafted serialized data. Commit Message: media: Support hosting mojo CDM in a standalone service Currently when mojo CDM is enabled it is hosted in the MediaService running in the process specified by "mojo_media_host". However, on some platforms we need to run mojo CDM and other mojo media services in different processes. For example, on desktop platforms, we want to run mojo video decoder in the GPU process, but run the mojo CDM in the utility process. This CL adds a new build flag "enable_standalone_cdm_service". When enabled, the mojo CDM service will be hosted in a standalone "cdm" service running in the utility process. All other mojo media services will sill be hosted in the "media" servie running in the process specified by "mojo_media_host". BUG=664364 TEST=Encrypted media browser tests using mojo CDM is still working. Change-Id: I95be6e05adc9ebcff966b26958ef1d7becdfb487 Reviewed-on: https://chromium-review.googlesource.com/567172 Commit-Queue: Xiaohan Wang <[email protected]> Reviewed-by: Daniel Cheng <[email protected]> Reviewed-by: John Abd-El-Malek <[email protected]> Reviewed-by: Dan Sanders <[email protected]> Cr-Commit-Position: refs/heads/master@{#486947}
High
171,938
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: pdf_read_new_xref_section(fz_context *ctx, pdf_document *doc, fz_stream *stm, int64_t i0, int i1, int w0, int w1, int w2) { pdf_xref_entry *table; pdf_xref_entry *table; int i, n; if (i0 < 0 || i1 < 0 || i0 > INT_MAX - i1) fz_throw(ctx, FZ_ERROR_GENERIC, "negative xref stream entry index"); table = pdf_xref_find_subsection(ctx, doc, i0, i1); for (i = i0; i < i0 + i1; i++) for (i = i0; i < i0 + i1; i++) { pdf_xref_entry *entry = &table[i-i0]; int a = 0; int64_t b = 0; int c = 0; if (fz_is_eof(ctx, stm)) fz_throw(ctx, FZ_ERROR_GENERIC, "truncated xref stream"); for (n = 0; n < w0; n++) a = (a << 8) + fz_read_byte(ctx, stm); for (n = 0; n < w1; n++) b = (b << 8) + fz_read_byte(ctx, stm); for (n = 0; n < w2; n++) c = (c << 8) + fz_read_byte(ctx, stm); if (!entry->type) { int t = w0 ? a : 1; entry->type = t == 0 ? 'f' : t == 1 ? 'n' : t == 2 ? 'o' : 0; entry->ofs = w1 ? b : 0; entry->gen = w2 ? c : 0; entry->num = i; } } doc->has_xref_streams = 1; } Vulnerability Type: Exec Code Overflow CWE ID: CWE-119 Summary: Heap-based buffer overflow in the ensure_solid_xref function in pdf/pdf-xref.c in Artifex MuPDF 1.12.0 allows a remote attacker to potentially execute arbitrary code via a crafted PDF file, because xref subsection object numbers are unrestricted. Commit Message:
Medium
165,390
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: void LocalFileSystem::deleteFileSystem(ExecutionContext* context, FileSystemType type, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) { RefPtrWillBeRawPtr<ExecutionContext> contextPtr(context); ASSERT(context); ASSERT_WITH_SECURITY_IMPLICATION(context->isDocument()); RefPtr<CallbackWrapper> wrapper = adoptRef(new CallbackWrapper(callbacks)); requestFileSystemAccessInternal(context, bind(&LocalFileSystem::deleteFileSystemInternal, this, contextPtr, type, wrapper), bind(&LocalFileSystem::fileSystemNotAllowedInternal, this, contextPtr, wrapper)); } Vulnerability Type: DoS Overflow CWE ID: CWE-119 Summary: The URL loader in Google Chrome before 26.0.1410.43 allows remote attackers to cause a denial of service (out-of-bounds read) via unspecified vectors. Commit Message: Oilpan: Ship Oilpan for SyncCallbackHelper, CreateFileResult and CallbackWrapper in filesystem/ These are leftovers when we shipped Oilpan for filesystem/ once. BUG=340522 Review URL: https://codereview.chromium.org/501263003 git-svn-id: svn://svn.chromium.org/blink/trunk@180909 bbb929c8-8fbe-4397-9dbb-9b2b20218538
Medium
171,424
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: nfssvc_decode_readlinkargs(struct svc_rqst *rqstp, __be32 *p, struct nfsd_readlinkargs *args) { p = decode_fh(p, &args->fh); if (!p) return 0; args->buffer = page_address(*(rqstp->rq_next_page++)); return xdr_argsize_check(rqstp, p); } Vulnerability Type: DoS CWE ID: CWE-404 Summary: The NFSv4 implementation in the Linux kernel through 4.11.1 allows local users to cause a denial of service (resource consumption) by leveraging improper channel callback shutdown when unmounting an NFSv4 filesystem, aka a *module reference and kernel daemon* leak. Commit Message: Merge tag 'nfsd-4.12' of git://linux-nfs.org/~bfields/linux Pull nfsd updates from Bruce Fields: "Another RDMA update from Chuck Lever, and a bunch of miscellaneous bugfixes" * tag 'nfsd-4.12' of git://linux-nfs.org/~bfields/linux: (26 commits) nfsd: Fix up the "supattr_exclcreat" attributes nfsd: encoders mustn't use unitialized values in error cases nfsd: fix undefined behavior in nfsd4_layout_verify lockd: fix lockd shutdown race NFSv4: Fix callback server shutdown SUNRPC: Refactor svc_set_num_threads() NFSv4.x/callback: Create the callback service through svc_create_pooled lockd: remove redundant check on block svcrdma: Clean out old XDR encoders svcrdma: Remove the req_map cache svcrdma: Remove unused RDMA Write completion handler svcrdma: Reduce size of sge array in struct svc_rdma_op_ctxt svcrdma: Clean up RPC-over-RDMA backchannel reply processing svcrdma: Report Write/Reply chunk overruns svcrdma: Clean up RDMA_ERROR path svcrdma: Use rdma_rw API in RPC reply path svcrdma: Introduce local rdma_rw API helpers svcrdma: Clean up svc_rdma_get_inv_rkey() svcrdma: Add helper to save pages under I/O svcrdma: Eliminate RPCRDMA_SQ_DEPTH_MULT ...
Medium
168,152
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: OMX_ERRORTYPE omx_vdec::set_parameter(OMX_IN OMX_HANDLETYPE hComp, OMX_IN OMX_INDEXTYPE paramIndex, OMX_IN OMX_PTR paramData) { OMX_ERRORTYPE eRet = OMX_ErrorNone; int ret=0; struct v4l2_format fmt; #ifdef _ANDROID_ char property_value[PROPERTY_VALUE_MAX] = {0}; #endif if (m_state == OMX_StateInvalid) { DEBUG_PRINT_ERROR("Set Param in Invalid State"); return OMX_ErrorInvalidState; } if (paramData == NULL) { DEBUG_PRINT_ERROR("Get Param in Invalid paramData"); return OMX_ErrorBadParameter; } if ((m_state != OMX_StateLoaded) && BITMASK_ABSENT(&m_flags,OMX_COMPONENT_OUTPUT_ENABLE_PENDING) && (m_out_bEnabled == OMX_TRUE) && BITMASK_ABSENT(&m_flags, OMX_COMPONENT_INPUT_ENABLE_PENDING) && (m_inp_bEnabled == OMX_TRUE)) { DEBUG_PRINT_ERROR("Set Param in Invalid State"); return OMX_ErrorIncorrectStateOperation; } switch ((unsigned long)paramIndex) { case OMX_IndexParamPortDefinition: { VALIDATE_OMX_PARAM_DATA(paramData, OMX_PARAM_PORTDEFINITIONTYPE); OMX_PARAM_PORTDEFINITIONTYPE *portDefn; portDefn = (OMX_PARAM_PORTDEFINITIONTYPE *) paramData; DEBUG_PRINT_LOW("set_parameter: OMX_IndexParamPortDefinition H= %d, W = %d", (int)portDefn->format.video.nFrameHeight, (int)portDefn->format.video.nFrameWidth); if (OMX_DirOutput == portDefn->eDir) { DEBUG_PRINT_LOW("set_parameter: OMX_IndexParamPortDefinition OP port"); bool port_format_changed = false; m_display_id = portDefn->format.video.pNativeWindow; unsigned int buffer_size; /* update output port resolution with client supplied dimensions in case scaling is enabled, else it follows input resolution set */ if (is_down_scalar_enabled) { DEBUG_PRINT_LOW("SetParam OP: WxH(%u x %u)", (unsigned int)portDefn->format.video.nFrameWidth, (unsigned int)portDefn->format.video.nFrameHeight); if (portDefn->format.video.nFrameHeight != 0x0 && portDefn->format.video.nFrameWidth != 0x0) { memset(&fmt, 0x0, sizeof(struct v4l2_format)); fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; fmt.fmt.pix_mp.pixelformat = capture_capability; ret = ioctl(drv_ctx.video_driver_fd, VIDIOC_G_FMT, &fmt); if (ret) { DEBUG_PRINT_ERROR("Get Resolution failed"); eRet = OMX_ErrorHardware; break; } if ((portDefn->format.video.nFrameHeight != (unsigned int)fmt.fmt.pix_mp.height) || (portDefn->format.video.nFrameWidth != (unsigned int)fmt.fmt.pix_mp.width)) { port_format_changed = true; } update_resolution(portDefn->format.video.nFrameWidth, portDefn->format.video.nFrameHeight, portDefn->format.video.nFrameWidth, portDefn->format.video.nFrameHeight); /* set crop info */ rectangle.nLeft = 0; rectangle.nTop = 0; rectangle.nWidth = portDefn->format.video.nFrameWidth; rectangle.nHeight = portDefn->format.video.nFrameHeight; eRet = is_video_session_supported(); if (eRet) break; memset(&fmt, 0x0, sizeof(struct v4l2_format)); fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; fmt.fmt.pix_mp.height = drv_ctx.video_resolution.frame_height; fmt.fmt.pix_mp.width = drv_ctx.video_resolution.frame_width; fmt.fmt.pix_mp.pixelformat = capture_capability; DEBUG_PRINT_LOW("fmt.fmt.pix_mp.height = %d , fmt.fmt.pix_mp.width = %d", fmt.fmt.pix_mp.height, fmt.fmt.pix_mp.width); ret = ioctl(drv_ctx.video_driver_fd, VIDIOC_S_FMT, &fmt); if (ret) { DEBUG_PRINT_ERROR("Set Resolution failed"); eRet = OMX_ErrorUnsupportedSetting; } else eRet = get_buffer_req(&drv_ctx.op_buf); } if (eRet) { break; } if (secure_mode) { struct v4l2_control control; control.id = V4L2_CID_MPEG_VIDC_VIDEO_SECURE_SCALING_THRESHOLD; if (ioctl(drv_ctx.video_driver_fd, VIDIOC_G_CTRL, &control) < 0) { DEBUG_PRINT_ERROR("Failed getting secure scaling threshold : %d, id was : %x", errno, control.id); eRet = OMX_ErrorHardware; } else { /* This is a workaround for a bug in fw which uses stride * and slice instead of width and height to check against * the threshold. */ OMX_U32 stride, slice; if (drv_ctx.output_format == VDEC_YUV_FORMAT_NV12) { stride = VENUS_Y_STRIDE(COLOR_FMT_NV12, portDefn->format.video.nFrameWidth); slice = VENUS_Y_SCANLINES(COLOR_FMT_NV12, portDefn->format.video.nFrameHeight); } else { stride = portDefn->format.video.nFrameWidth; slice = portDefn->format.video.nFrameHeight; } DEBUG_PRINT_LOW("Stride is %d, slice is %d, sxs is %d\n", stride, slice, stride * slice); DEBUG_PRINT_LOW("Threshold value is %d\n", control.value); if (stride * slice <= (OMX_U32)control.value) { secure_scaling_to_non_secure_opb = true; DEBUG_PRINT_HIGH("Enabling secure scalar out of CPZ"); control.id = V4L2_CID_MPEG_VIDC_VIDEO_NON_SECURE_OUTPUT2; control.value = 1; if (ioctl(drv_ctx.video_driver_fd, VIDIOC_S_CTRL, &control) < 0) { DEBUG_PRINT_ERROR("Enabling non-secure output2 failed"); eRet = OMX_ErrorUnsupportedSetting; } } } } } if (eRet) { break; } if (!client_buffers.get_buffer_req(buffer_size)) { DEBUG_PRINT_ERROR("Error in getting buffer requirements"); eRet = OMX_ErrorBadParameter; } else if (!port_format_changed) { if ( portDefn->nBufferCountActual >= drv_ctx.op_buf.mincount && portDefn->nBufferSize >= drv_ctx.op_buf.buffer_size ) { drv_ctx.op_buf.actualcount = portDefn->nBufferCountActual; drv_ctx.op_buf.buffer_size = portDefn->nBufferSize; drv_ctx.extradata_info.count = drv_ctx.op_buf.actualcount; drv_ctx.extradata_info.size = drv_ctx.extradata_info.count * drv_ctx.extradata_info.buffer_size; eRet = set_buffer_req(&drv_ctx.op_buf); if (eRet == OMX_ErrorNone) m_port_def = *portDefn; } else { DEBUG_PRINT_ERROR("ERROR: OP Requirements(#%d: %u) Requested(#%u: %u)", drv_ctx.op_buf.mincount, (unsigned int)drv_ctx.op_buf.buffer_size, (unsigned int)portDefn->nBufferCountActual, (unsigned int)portDefn->nBufferSize); eRet = OMX_ErrorBadParameter; } } } else if (OMX_DirInput == portDefn->eDir) { DEBUG_PRINT_LOW("set_parameter: OMX_IndexParamPortDefinition IP port"); bool port_format_changed = false; if ((portDefn->format.video.xFramerate >> 16) > 0 && (portDefn->format.video.xFramerate >> 16) <= MAX_SUPPORTED_FPS) { DEBUG_PRINT_HIGH("set_parameter: frame rate set by omx client : %u", (unsigned int)portDefn->format.video.xFramerate >> 16); Q16ToFraction(portDefn->format.video.xFramerate, drv_ctx.frame_rate.fps_numerator, drv_ctx.frame_rate.fps_denominator); if (!drv_ctx.frame_rate.fps_numerator) { DEBUG_PRINT_ERROR("Numerator is zero setting to 30"); drv_ctx.frame_rate.fps_numerator = 30; } if (drv_ctx.frame_rate.fps_denominator) drv_ctx.frame_rate.fps_numerator = (int) drv_ctx.frame_rate.fps_numerator / drv_ctx.frame_rate.fps_denominator; drv_ctx.frame_rate.fps_denominator = 1; frm_int = drv_ctx.frame_rate.fps_denominator * 1e6 / drv_ctx.frame_rate.fps_numerator; DEBUG_PRINT_LOW("set_parameter: frm_int(%u) fps(%.2f)", (unsigned int)frm_int, drv_ctx.frame_rate.fps_numerator / (float)drv_ctx.frame_rate.fps_denominator); struct v4l2_outputparm oparm; /*XXX: we're providing timing info as seconds per frame rather than frames * per second.*/ oparm.timeperframe.numerator = drv_ctx.frame_rate.fps_denominator; oparm.timeperframe.denominator = drv_ctx.frame_rate.fps_numerator; struct v4l2_streamparm sparm; sparm.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; sparm.parm.output = oparm; if (ioctl(drv_ctx.video_driver_fd, VIDIOC_S_PARM, &sparm)) { DEBUG_PRINT_ERROR("Unable to convey fps info to driver, performance might be affected"); eRet = OMX_ErrorHardware; break; } } if (drv_ctx.video_resolution.frame_height != portDefn->format.video.nFrameHeight || drv_ctx.video_resolution.frame_width != portDefn->format.video.nFrameWidth) { DEBUG_PRINT_LOW("SetParam IP: WxH(%u x %u)", (unsigned int)portDefn->format.video.nFrameWidth, (unsigned int)portDefn->format.video.nFrameHeight); port_format_changed = true; OMX_U32 frameWidth = portDefn->format.video.nFrameWidth; OMX_U32 frameHeight = portDefn->format.video.nFrameHeight; if (frameHeight != 0x0 && frameWidth != 0x0) { if (m_smoothstreaming_mode && ((frameWidth * frameHeight) < (m_smoothstreaming_width * m_smoothstreaming_height))) { frameWidth = m_smoothstreaming_width; frameHeight = m_smoothstreaming_height; DEBUG_PRINT_LOW("NOTE: Setting resolution %u x %u " "for adaptive-playback/smooth-streaming", (unsigned int)frameWidth, (unsigned int)frameHeight); } update_resolution(frameWidth, frameHeight, frameWidth, frameHeight); eRet = is_video_session_supported(); if (eRet) break; memset(&fmt, 0x0, sizeof(struct v4l2_format)); fmt.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; fmt.fmt.pix_mp.height = drv_ctx.video_resolution.frame_height; fmt.fmt.pix_mp.width = drv_ctx.video_resolution.frame_width; fmt.fmt.pix_mp.pixelformat = output_capability; DEBUG_PRINT_LOW("fmt.fmt.pix_mp.height = %d , fmt.fmt.pix_mp.width = %d",fmt.fmt.pix_mp.height,fmt.fmt.pix_mp.width); ret = ioctl(drv_ctx.video_driver_fd, VIDIOC_S_FMT, &fmt); if (ret) { DEBUG_PRINT_ERROR("Set Resolution failed"); eRet = OMX_ErrorUnsupportedSetting; } else { if (!is_down_scalar_enabled) eRet = get_buffer_req(&drv_ctx.op_buf); } } } if (m_custom_buffersize.input_buffersize && (portDefn->nBufferSize > m_custom_buffersize.input_buffersize)) { DEBUG_PRINT_ERROR("ERROR: Custom buffer size set by client: %d, trying to set: %d", m_custom_buffersize.input_buffersize, portDefn->nBufferSize); eRet = OMX_ErrorBadParameter; break; } if (portDefn->nBufferCountActual >= drv_ctx.ip_buf.mincount || portDefn->nBufferSize != drv_ctx.ip_buf.buffer_size) { port_format_changed = true; vdec_allocatorproperty *buffer_prop = &drv_ctx.ip_buf; drv_ctx.ip_buf.actualcount = portDefn->nBufferCountActual; drv_ctx.ip_buf.buffer_size = (portDefn->nBufferSize + buffer_prop->alignment - 1) & (~(buffer_prop->alignment - 1)); eRet = set_buffer_req(buffer_prop); } if (false == port_format_changed) { DEBUG_PRINT_ERROR("ERROR: IP Requirements(#%d: %u) Requested(#%u: %u)", drv_ctx.ip_buf.mincount, (unsigned int)drv_ctx.ip_buf.buffer_size, (unsigned int)portDefn->nBufferCountActual, (unsigned int)portDefn->nBufferSize); eRet = OMX_ErrorBadParameter; } } else if (portDefn->eDir == OMX_DirMax) { DEBUG_PRINT_ERROR(" Set_parameter: Bad Port idx %d", (int)portDefn->nPortIndex); eRet = OMX_ErrorBadPortIndex; } } break; case OMX_IndexParamVideoPortFormat: { VALIDATE_OMX_PARAM_DATA(paramData, OMX_VIDEO_PARAM_PORTFORMATTYPE); OMX_VIDEO_PARAM_PORTFORMATTYPE *portFmt = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)paramData; int ret=0; struct v4l2_format fmt; DEBUG_PRINT_LOW("set_parameter: OMX_IndexParamVideoPortFormat 0x%x, port: %u", portFmt->eColorFormat, (unsigned int)portFmt->nPortIndex); memset(&fmt, 0x0, sizeof(struct v4l2_format)); if (1 == portFmt->nPortIndex) { fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; fmt.fmt.pix_mp.height = drv_ctx.video_resolution.frame_height; fmt.fmt.pix_mp.width = drv_ctx.video_resolution.frame_width; fmt.fmt.pix_mp.pixelformat = capture_capability; enum vdec_output_fromat op_format; if (portFmt->eColorFormat == (OMX_COLOR_FORMATTYPE) QOMX_COLOR_FORMATYUV420PackedSemiPlanar32m || portFmt->eColorFormat == (OMX_COLOR_FORMATTYPE) QOMX_COLOR_FORMATYUV420PackedSemiPlanar32mMultiView || portFmt->eColorFormat == OMX_COLOR_FormatYUV420Planar || portFmt->eColorFormat == OMX_COLOR_FormatYUV420SemiPlanar) op_format = (enum vdec_output_fromat)VDEC_YUV_FORMAT_NV12; else eRet = OMX_ErrorBadParameter; if (eRet == OMX_ErrorNone) { drv_ctx.output_format = op_format; ret = ioctl(drv_ctx.video_driver_fd, VIDIOC_S_FMT, &fmt); if (ret) { DEBUG_PRINT_ERROR("Set output format failed"); eRet = OMX_ErrorUnsupportedSetting; /*TODO: How to handle this case */ } else { eRet = get_buffer_req(&drv_ctx.op_buf); } } if (eRet == OMX_ErrorNone) { if (!client_buffers.set_color_format(portFmt->eColorFormat)) { DEBUG_PRINT_ERROR("Set color format failed"); eRet = OMX_ErrorBadParameter; } } } } break; case OMX_QcomIndexPortDefn: { VALIDATE_OMX_PARAM_DATA(paramData, OMX_QCOM_PARAM_PORTDEFINITIONTYPE); OMX_QCOM_PARAM_PORTDEFINITIONTYPE *portFmt = (OMX_QCOM_PARAM_PORTDEFINITIONTYPE *) paramData; DEBUG_PRINT_LOW("set_parameter: OMX_IndexQcomParamPortDefinitionType %u", (unsigned int)portFmt->nFramePackingFormat); /* Input port */ if (portFmt->nPortIndex == 0) { if (portFmt->nFramePackingFormat == OMX_QCOM_FramePacking_Arbitrary) { if (secure_mode) { arbitrary_bytes = false; DEBUG_PRINT_ERROR("setparameter: cannot set to arbitary bytes mode in secure session"); eRet = OMX_ErrorUnsupportedSetting; } else { arbitrary_bytes = true; } } else if (portFmt->nFramePackingFormat == OMX_QCOM_FramePacking_OnlyOneCompleteFrame) { arbitrary_bytes = false; #ifdef _ANDROID_ property_get("vidc.dec.debug.arbitrarybytes.mode", property_value, "0"); if (atoi(property_value)) { DEBUG_PRINT_HIGH("arbitrary_bytes enabled via property command"); arbitrary_bytes = true; } #endif } else { DEBUG_PRINT_ERROR("Setparameter: unknown FramePacking format %u", (unsigned int)portFmt->nFramePackingFormat); eRet = OMX_ErrorUnsupportedSetting; } } else if (portFmt->nPortIndex == OMX_CORE_OUTPUT_PORT_INDEX) { DEBUG_PRINT_HIGH("set_parameter: OMX_IndexQcomParamPortDefinitionType OP Port"); if ( (portFmt->nMemRegion > OMX_QCOM_MemRegionInvalid && portFmt->nMemRegion < OMX_QCOM_MemRegionMax) && portFmt->nCacheAttr == OMX_QCOM_CacheAttrNone) { m_out_mem_region_smi = OMX_TRUE; if ((m_out_mem_region_smi && m_out_pvt_entry_pmem)) { DEBUG_PRINT_HIGH("set_parameter: OMX_IndexQcomParamPortDefinitionType OP Port: out pmem set"); m_use_output_pmem = OMX_TRUE; } } } } break; case OMX_IndexParamStandardComponentRole: { VALIDATE_OMX_PARAM_DATA(paramData, OMX_PARAM_COMPONENTROLETYPE); OMX_PARAM_COMPONENTROLETYPE *comp_role; comp_role = (OMX_PARAM_COMPONENTROLETYPE *) paramData; DEBUG_PRINT_LOW("set_parameter: OMX_IndexParamStandardComponentRole %s", comp_role->cRole); if ((m_state == OMX_StateLoaded)&& !BITMASK_PRESENT(&m_flags,OMX_COMPONENT_IDLE_PENDING)) { DEBUG_PRINT_LOW("Set Parameter called in valid state"); } else { DEBUG_PRINT_ERROR("Set Parameter called in Invalid State"); return OMX_ErrorIncorrectStateOperation; } if (!strncmp(drv_ctx.kind, "OMX.qcom.video.decoder.avc",OMX_MAX_STRINGNAME_SIZE)) { if (!strncmp((char*)comp_role->cRole,"video_decoder.avc",OMX_MAX_STRINGNAME_SIZE)) { strlcpy((char*)m_cRole,"video_decoder.avc",OMX_MAX_STRINGNAME_SIZE); } else { DEBUG_PRINT_ERROR("Setparameter: unknown Index %s", comp_role->cRole); eRet =OMX_ErrorUnsupportedSetting; } } else if (!strncmp(drv_ctx.kind, "OMX.qcom.video.decoder.mvc", OMX_MAX_STRINGNAME_SIZE)) { if (!strncmp((char*)comp_role->cRole, "video_decoder.mvc", OMX_MAX_STRINGNAME_SIZE)) { strlcpy((char*)m_cRole, "video_decoder.mvc", OMX_MAX_STRINGNAME_SIZE); } else { DEBUG_PRINT_ERROR("Setparameter: unknown Index %s", comp_role->cRole); eRet =OMX_ErrorUnsupportedSetting; } } else if (!strncmp(drv_ctx.kind, "OMX.qcom.video.decoder.mpeg4",OMX_MAX_STRINGNAME_SIZE)) { if (!strncmp((const char*)comp_role->cRole,"video_decoder.mpeg4",OMX_MAX_STRINGNAME_SIZE)) { strlcpy((char*)m_cRole,"video_decoder.mpeg4",OMX_MAX_STRINGNAME_SIZE); } else { DEBUG_PRINT_ERROR("Setparameter: unknown Index %s", comp_role->cRole); eRet = OMX_ErrorUnsupportedSetting; } } else if (!strncmp(drv_ctx.kind, "OMX.qcom.video.decoder.h263",OMX_MAX_STRINGNAME_SIZE)) { if (!strncmp((const char*)comp_role->cRole,"video_decoder.h263",OMX_MAX_STRINGNAME_SIZE)) { strlcpy((char*)m_cRole,"video_decoder.h263",OMX_MAX_STRINGNAME_SIZE); } else { DEBUG_PRINT_ERROR("Setparameter: unknown Index %s", comp_role->cRole); eRet =OMX_ErrorUnsupportedSetting; } } else if (!strncmp(drv_ctx.kind, "OMX.qcom.video.decoder.mpeg2",OMX_MAX_STRINGNAME_SIZE)) { if (!strncmp((const char*)comp_role->cRole,"video_decoder.mpeg2",OMX_MAX_STRINGNAME_SIZE)) { strlcpy((char*)m_cRole,"video_decoder.mpeg2",OMX_MAX_STRINGNAME_SIZE); } else { DEBUG_PRINT_ERROR("Setparameter: unknown Index %s", comp_role->cRole); eRet = OMX_ErrorUnsupportedSetting; } } else if ((!strncmp(drv_ctx.kind, "OMX.qcom.video.decoder.divx",OMX_MAX_STRINGNAME_SIZE)) || (!strncmp(drv_ctx.kind, "OMX.qcom.video.decoder.divx311", OMX_MAX_STRINGNAME_SIZE)) || (!strncmp(drv_ctx.kind, "OMX.qcom.video.decoder.divx4", OMX_MAX_STRINGNAME_SIZE)) ) { if (!strncmp((const char*)comp_role->cRole,"video_decoder.divx",OMX_MAX_STRINGNAME_SIZE)) { strlcpy((char*)m_cRole,"video_decoder.divx",OMX_MAX_STRINGNAME_SIZE); } else { DEBUG_PRINT_ERROR("Setparameter: unknown Index %s", comp_role->cRole); eRet =OMX_ErrorUnsupportedSetting; } } else if ( (!strncmp(drv_ctx.kind, "OMX.qcom.video.decoder.vc1",OMX_MAX_STRINGNAME_SIZE)) || (!strncmp(drv_ctx.kind, "OMX.qcom.video.decoder.wmv",OMX_MAX_STRINGNAME_SIZE)) ) { if (!strncmp((const char*)comp_role->cRole,"video_decoder.vc1",OMX_MAX_STRINGNAME_SIZE)) { strlcpy((char*)m_cRole,"video_decoder.vc1",OMX_MAX_STRINGNAME_SIZE); } else { DEBUG_PRINT_ERROR("Setparameter: unknown Index %s", comp_role->cRole); eRet =OMX_ErrorUnsupportedSetting; } } else if (!strncmp(drv_ctx.kind, "OMX.qcom.video.decoder.vp8",OMX_MAX_STRINGNAME_SIZE)) { if (!strncmp((const char*)comp_role->cRole,"video_decoder.vp8",OMX_MAX_STRINGNAME_SIZE) || (!strncmp((const char*)comp_role->cRole,"video_decoder.vpx",OMX_MAX_STRINGNAME_SIZE))) { strlcpy((char*)m_cRole,"video_decoder.vp8",OMX_MAX_STRINGNAME_SIZE); } else { DEBUG_PRINT_ERROR("Setparameter: unknown Index %s", comp_role->cRole); eRet = OMX_ErrorUnsupportedSetting; } } else if (!strncmp(drv_ctx.kind, "OMX.qcom.video.decoder.hevc", OMX_MAX_STRINGNAME_SIZE)) { if (!strncmp((const char*)comp_role->cRole, "video_decoder.hevc", OMX_MAX_STRINGNAME_SIZE)) { strlcpy((char*)m_cRole, "video_decoder.hevc", OMX_MAX_STRINGNAME_SIZE); } else { DEBUG_PRINT_ERROR("Setparameter: unknown Index %s", comp_role->cRole); eRet = OMX_ErrorUnsupportedSetting; } } else { DEBUG_PRINT_ERROR("Setparameter: unknown param %s", drv_ctx.kind); eRet = OMX_ErrorInvalidComponentName; } break; } case OMX_IndexParamPriorityMgmt: { VALIDATE_OMX_PARAM_DATA(paramData, OMX_PRIORITYMGMTTYPE); if (m_state != OMX_StateLoaded) { DEBUG_PRINT_ERROR("Set Parameter called in Invalid State"); return OMX_ErrorIncorrectStateOperation; } OMX_PRIORITYMGMTTYPE *priorityMgmtype = (OMX_PRIORITYMGMTTYPE*) paramData; DEBUG_PRINT_LOW("set_parameter: OMX_IndexParamPriorityMgmt %u", (unsigned int)priorityMgmtype->nGroupID); DEBUG_PRINT_LOW("set_parameter: priorityMgmtype %u", (unsigned int)priorityMgmtype->nGroupPriority); m_priority_mgm.nGroupID = priorityMgmtype->nGroupID; m_priority_mgm.nGroupPriority = priorityMgmtype->nGroupPriority; break; } case OMX_IndexParamCompBufferSupplier: { VALIDATE_OMX_PARAM_DATA(paramData, OMX_PARAM_BUFFERSUPPLIERTYPE); OMX_PARAM_BUFFERSUPPLIERTYPE *bufferSupplierType = (OMX_PARAM_BUFFERSUPPLIERTYPE*) paramData; DEBUG_PRINT_LOW("set_parameter: OMX_IndexParamCompBufferSupplier %d", bufferSupplierType->eBufferSupplier); if (bufferSupplierType->nPortIndex == 0 || bufferSupplierType->nPortIndex ==1) m_buffer_supplier.eBufferSupplier = bufferSupplierType->eBufferSupplier; else eRet = OMX_ErrorBadPortIndex; break; } case OMX_IndexParamVideoAvc: { DEBUG_PRINT_LOW("set_parameter: OMX_IndexParamVideoAvc %d", paramIndex); break; } case (OMX_INDEXTYPE)QOMX_IndexParamVideoMvc: { DEBUG_PRINT_LOW("set_parameter: QOMX_IndexParamVideoMvc %d", paramIndex); break; } case OMX_IndexParamVideoH263: { DEBUG_PRINT_LOW("set_parameter: OMX_IndexParamVideoH263 %d", paramIndex); break; } case OMX_IndexParamVideoMpeg4: { DEBUG_PRINT_LOW("set_parameter: OMX_IndexParamVideoMpeg4 %d", paramIndex); break; } case OMX_IndexParamVideoMpeg2: { DEBUG_PRINT_LOW("set_parameter: OMX_IndexParamVideoMpeg2 %d", paramIndex); break; } case OMX_QcomIndexParamVideoDecoderPictureOrder: { VALIDATE_OMX_PARAM_DATA(paramData, QOMX_VIDEO_DECODER_PICTURE_ORDER); QOMX_VIDEO_DECODER_PICTURE_ORDER *pictureOrder = (QOMX_VIDEO_DECODER_PICTURE_ORDER *)paramData; struct v4l2_control control; int pic_order,rc=0; DEBUG_PRINT_HIGH("set_parameter: OMX_QcomIndexParamVideoDecoderPictureOrder %d", pictureOrder->eOutputPictureOrder); if (pictureOrder->eOutputPictureOrder == QOMX_VIDEO_DISPLAY_ORDER) { pic_order = V4L2_MPEG_VIDC_VIDEO_OUTPUT_ORDER_DISPLAY; } else if (pictureOrder->eOutputPictureOrder == QOMX_VIDEO_DECODE_ORDER) { pic_order = V4L2_MPEG_VIDC_VIDEO_OUTPUT_ORDER_DECODE; time_stamp_dts.set_timestamp_reorder_mode(false); } else eRet = OMX_ErrorBadParameter; if (eRet == OMX_ErrorNone) { control.id = V4L2_CID_MPEG_VIDC_VIDEO_OUTPUT_ORDER; control.value = pic_order; rc = ioctl(drv_ctx.video_driver_fd, VIDIOC_S_CTRL, &control); if (rc) { DEBUG_PRINT_ERROR("Set picture order failed"); eRet = OMX_ErrorUnsupportedSetting; } } break; } case OMX_QcomIndexParamConcealMBMapExtraData: VALIDATE_OMX_PARAM_DATA(paramData, QOMX_ENABLETYPE); eRet = enable_extradata(VDEC_EXTRADATA_MB_ERROR_MAP, false, ((QOMX_ENABLETYPE *)paramData)->bEnable); break; case OMX_QcomIndexParamFrameInfoExtraData: VALIDATE_OMX_PARAM_DATA(paramData, QOMX_ENABLETYPE); eRet = enable_extradata(OMX_FRAMEINFO_EXTRADATA, false, ((QOMX_ENABLETYPE *)paramData)->bEnable); break; case OMX_ExtraDataFrameDimension: VALIDATE_OMX_PARAM_DATA(paramData, QOMX_ENABLETYPE); eRet = enable_extradata(OMX_FRAMEDIMENSION_EXTRADATA, false, ((QOMX_ENABLETYPE *)paramData)->bEnable); break; case OMX_QcomIndexParamInterlaceExtraData: VALIDATE_OMX_PARAM_DATA(paramData, QOMX_ENABLETYPE); eRet = enable_extradata(OMX_INTERLACE_EXTRADATA, false, ((QOMX_ENABLETYPE *)paramData)->bEnable); break; case OMX_QcomIndexParamH264TimeInfo: VALIDATE_OMX_PARAM_DATA(paramData, QOMX_ENABLETYPE); eRet = enable_extradata(OMX_TIMEINFO_EXTRADATA, false, ((QOMX_ENABLETYPE *)paramData)->bEnable); break; case OMX_QcomIndexParamVideoFramePackingExtradata: VALIDATE_OMX_PARAM_DATA(paramData, QOMX_ENABLETYPE); eRet = enable_extradata(OMX_FRAMEPACK_EXTRADATA, false, ((QOMX_ENABLETYPE *)paramData)->bEnable); break; case OMX_QcomIndexParamVideoQPExtraData: VALIDATE_OMX_PARAM_DATA(paramData, QOMX_ENABLETYPE); eRet = enable_extradata(OMX_QP_EXTRADATA, false, ((QOMX_ENABLETYPE *)paramData)->bEnable); break; case OMX_QcomIndexParamVideoInputBitsInfoExtraData: VALIDATE_OMX_PARAM_DATA(paramData, QOMX_ENABLETYPE); eRet = enable_extradata(OMX_BITSINFO_EXTRADATA, false, ((QOMX_ENABLETYPE *)paramData)->bEnable); break; case OMX_QcomIndexEnableExtnUserData: VALIDATE_OMX_PARAM_DATA(paramData, QOMX_ENABLETYPE); eRet = enable_extradata(OMX_EXTNUSER_EXTRADATA, false, ((QOMX_ENABLETYPE *)paramData)->bEnable); break; case OMX_QcomIndexParamMpeg2SeqDispExtraData: VALIDATE_OMX_PARAM_DATA(paramData, QOMX_ENABLETYPE); eRet = enable_extradata(OMX_MPEG2SEQDISP_EXTRADATA, false, ((QOMX_ENABLETYPE *)paramData)->bEnable); break; case OMX_QcomIndexParamVideoDivx: { QOMX_VIDEO_PARAM_DIVXTYPE* divXType = (QOMX_VIDEO_PARAM_DIVXTYPE *) paramData; } break; case OMX_QcomIndexPlatformPvt: { VALIDATE_OMX_PARAM_DATA(paramData, OMX_QCOM_PLATFORMPRIVATE_EXTN); DEBUG_PRINT_HIGH("set_parameter: OMX_QcomIndexPlatformPvt OP Port"); OMX_QCOM_PLATFORMPRIVATE_EXTN* entryType = (OMX_QCOM_PLATFORMPRIVATE_EXTN *) paramData; if (entryType->type != OMX_QCOM_PLATFORM_PRIVATE_PMEM) { DEBUG_PRINT_HIGH("set_parameter: Platform Private entry type (%d) not supported.", entryType->type); eRet = OMX_ErrorUnsupportedSetting; } else { m_out_pvt_entry_pmem = OMX_TRUE; if ((m_out_mem_region_smi && m_out_pvt_entry_pmem)) { DEBUG_PRINT_HIGH("set_parameter: OMX_QcomIndexPlatformPvt OP Port: out pmem set"); m_use_output_pmem = OMX_TRUE; } } } break; case OMX_QcomIndexParamVideoSyncFrameDecodingMode: { DEBUG_PRINT_HIGH("set_parameter: OMX_QcomIndexParamVideoSyncFrameDecodingMode"); DEBUG_PRINT_HIGH("set idr only decoding for thumbnail mode"); struct v4l2_control control; int rc; drv_ctx.idr_only_decoding = 1; control.id = V4L2_CID_MPEG_VIDC_VIDEO_OUTPUT_ORDER; control.value = V4L2_MPEG_VIDC_VIDEO_OUTPUT_ORDER_DECODE; rc = ioctl(drv_ctx.video_driver_fd, VIDIOC_S_CTRL, &control); if (rc) { DEBUG_PRINT_ERROR("Set picture order failed"); eRet = OMX_ErrorUnsupportedSetting; } else { control.id = V4L2_CID_MPEG_VIDC_VIDEO_SYNC_FRAME_DECODE; control.value = V4L2_MPEG_VIDC_VIDEO_SYNC_FRAME_DECODE_ENABLE; rc = ioctl(drv_ctx.video_driver_fd, VIDIOC_S_CTRL, &control); if (rc) { DEBUG_PRINT_ERROR("Sync frame setting failed"); eRet = OMX_ErrorUnsupportedSetting; } /*Setting sync frame decoding on driver might change buffer * requirements so update them here*/ if (get_buffer_req(&drv_ctx.ip_buf)) { DEBUG_PRINT_ERROR("Sync frame setting failed: falied to get buffer i/p requirements"); eRet = OMX_ErrorUnsupportedSetting; } if (get_buffer_req(&drv_ctx.op_buf)) { DEBUG_PRINT_ERROR("Sync frame setting failed: falied to get buffer o/p requirements"); eRet = OMX_ErrorUnsupportedSetting; } } } break; case OMX_QcomIndexParamIndexExtraDataType: { VALIDATE_OMX_PARAM_DATA(paramData, QOMX_INDEXEXTRADATATYPE); QOMX_INDEXEXTRADATATYPE *extradataIndexType = (QOMX_INDEXEXTRADATATYPE *) paramData; if ((extradataIndexType->nIndex == OMX_IndexParamPortDefinition) && (extradataIndexType->bEnabled == OMX_TRUE) && (extradataIndexType->nPortIndex == 1)) { DEBUG_PRINT_HIGH("set_parameter: OMX_QcomIndexParamIndexExtraDataType SmoothStreaming"); eRet = enable_extradata(OMX_PORTDEF_EXTRADATA, false, extradataIndexType->bEnabled); } } break; case OMX_QcomIndexParamEnableSmoothStreaming: { #ifndef SMOOTH_STREAMING_DISABLED eRet = enable_smoothstreaming(); #else eRet = OMX_ErrorUnsupportedSetting; #endif } break; #if defined (_ANDROID_HONEYCOMB_) || defined (_ANDROID_ICS_) /* Need to allow following two set_parameters even in Idle * state. This is ANDROID architecture which is not in sync * with openmax standard. */ case OMX_GoogleAndroidIndexEnableAndroidNativeBuffers: { VALIDATE_OMX_PARAM_DATA(paramData, EnableAndroidNativeBuffersParams); EnableAndroidNativeBuffersParams* enableNativeBuffers = (EnableAndroidNativeBuffersParams *) paramData; if (enableNativeBuffers) { m_enable_android_native_buffers = enableNativeBuffers->enable; } #if !defined(FLEXYUV_SUPPORTED) if (m_enable_android_native_buffers) { if(!client_buffers.set_color_format(getPreferredColorFormatDefaultMode(0))) { DEBUG_PRINT_ERROR("Failed to set native color format!"); eRet = OMX_ErrorUnsupportedSetting; } } #endif } break; case OMX_GoogleAndroidIndexUseAndroidNativeBuffer: { VALIDATE_OMX_PARAM_DATA(paramData, UseAndroidNativeBufferParams); eRet = use_android_native_buffer(hComp, paramData); } break; #endif case OMX_QcomIndexParamEnableTimeStampReorder: { VALIDATE_OMX_PARAM_DATA(paramData, QOMX_INDEXTIMESTAMPREORDER); QOMX_INDEXTIMESTAMPREORDER *reorder = (QOMX_INDEXTIMESTAMPREORDER *)paramData; if (drv_ctx.picture_order == (vdec_output_order)QOMX_VIDEO_DISPLAY_ORDER) { if (reorder->bEnable == OMX_TRUE) { frm_int =0; time_stamp_dts.set_timestamp_reorder_mode(true); } else time_stamp_dts.set_timestamp_reorder_mode(false); } else { time_stamp_dts.set_timestamp_reorder_mode(false); if (reorder->bEnable == OMX_TRUE) { eRet = OMX_ErrorUnsupportedSetting; } } } break; case OMX_IndexParamVideoProfileLevelCurrent: { VALIDATE_OMX_PARAM_DATA(paramData, OMX_VIDEO_PARAM_PROFILELEVELTYPE); OMX_VIDEO_PARAM_PROFILELEVELTYPE* pParam = (OMX_VIDEO_PARAM_PROFILELEVELTYPE*)paramData; if (pParam) { m_profile_lvl.eProfile = pParam->eProfile; m_profile_lvl.eLevel = pParam->eLevel; } break; } case OMX_QcomIndexParamVideoMetaBufferMode: { VALIDATE_OMX_PARAM_DATA(paramData, StoreMetaDataInBuffersParams); StoreMetaDataInBuffersParams *metabuffer = (StoreMetaDataInBuffersParams *)paramData; if (!metabuffer) { DEBUG_PRINT_ERROR("Invalid param: %p", metabuffer); eRet = OMX_ErrorBadParameter; break; } if (m_disable_dynamic_buf_mode) { DEBUG_PRINT_HIGH("Dynamic buffer mode disabled by setprop"); eRet = OMX_ErrorUnsupportedSetting; break; } if (metabuffer->nPortIndex == OMX_CORE_OUTPUT_PORT_INDEX) { struct v4l2_control control; struct v4l2_format fmt; control.id = V4L2_CID_MPEG_VIDC_VIDEO_ALLOC_MODE_OUTPUT; if (metabuffer->bStoreMetaData == true) { control.value = V4L2_MPEG_VIDC_VIDEO_DYNAMIC; } else { control.value = V4L2_MPEG_VIDC_VIDEO_STATIC; } int rc = ioctl(drv_ctx.video_driver_fd, VIDIOC_S_CTRL,&control); if (!rc) { DEBUG_PRINT_HIGH("%s buffer mode", (metabuffer->bStoreMetaData == true)? "Enabled dynamic" : "Disabled dynamic"); dynamic_buf_mode = metabuffer->bStoreMetaData; } else { DEBUG_PRINT_ERROR("Failed to %s buffer mode", (metabuffer->bStoreMetaData == true)? "enable dynamic" : "disable dynamic"); eRet = OMX_ErrorUnsupportedSetting; } } else { DEBUG_PRINT_ERROR( "OMX_QcomIndexParamVideoMetaBufferMode not supported for port: %u", (unsigned int)metabuffer->nPortIndex); eRet = OMX_ErrorUnsupportedSetting; } break; } case OMX_QcomIndexParamVideoDownScalar: { VALIDATE_OMX_PARAM_DATA(paramData, QOMX_INDEXDOWNSCALAR); QOMX_INDEXDOWNSCALAR* pParam = (QOMX_INDEXDOWNSCALAR*)paramData; struct v4l2_control control; int rc; if (pParam) { is_down_scalar_enabled = pParam->bEnable; if (is_down_scalar_enabled) { control.id = V4L2_CID_MPEG_VIDC_VIDEO_STREAM_OUTPUT_MODE; control.value = V4L2_CID_MPEG_VIDC_VIDEO_STREAM_OUTPUT_SECONDARY; DEBUG_PRINT_LOW("set_parameter: OMX_QcomIndexParamVideoDownScalar value = %d", pParam->bEnable); rc = ioctl(drv_ctx.video_driver_fd, VIDIOC_S_CTRL, &control); if (rc < 0) { DEBUG_PRINT_ERROR("Failed to set down scalar on driver."); eRet = OMX_ErrorUnsupportedSetting; } control.id = V4L2_CID_MPEG_VIDC_VIDEO_KEEP_ASPECT_RATIO; control.value = 1; rc = ioctl(drv_ctx.video_driver_fd, VIDIOC_S_CTRL, &control); if (rc < 0) { DEBUG_PRINT_ERROR("Failed to set keep aspect ratio on driver."); eRet = OMX_ErrorUnsupportedSetting; } } } break; } #ifdef ADAPTIVE_PLAYBACK_SUPPORTED case OMX_QcomIndexParamVideoAdaptivePlaybackMode: { VALIDATE_OMX_PARAM_DATA(paramData, PrepareForAdaptivePlaybackParams); DEBUG_PRINT_LOW("set_parameter: OMX_GoogleAndroidIndexPrepareForAdaptivePlayback"); PrepareForAdaptivePlaybackParams* pParams = (PrepareForAdaptivePlaybackParams *) paramData; if (pParams->nPortIndex == OMX_CORE_OUTPUT_PORT_INDEX) { if (!pParams->bEnable) { return OMX_ErrorNone; } if (pParams->nMaxFrameWidth > maxSmoothStreamingWidth || pParams->nMaxFrameHeight > maxSmoothStreamingHeight) { DEBUG_PRINT_ERROR( "Adaptive playback request exceeds max supported resolution : [%u x %u] vs [%u x %u]", (unsigned int)pParams->nMaxFrameWidth, (unsigned int)pParams->nMaxFrameHeight, (unsigned int)maxSmoothStreamingWidth, (unsigned int)maxSmoothStreamingHeight); eRet = OMX_ErrorBadParameter; } else { eRet = enable_adaptive_playback(pParams->nMaxFrameWidth, pParams->nMaxFrameHeight); } } else { DEBUG_PRINT_ERROR( "Prepare for adaptive playback supported only on output port"); eRet = OMX_ErrorBadParameter; } break; } #endif case OMX_QcomIndexParamVideoCustomBufferSize: { VALIDATE_OMX_PARAM_DATA(paramData, QOMX_VIDEO_CUSTOM_BUFFERSIZE); DEBUG_PRINT_LOW("set_parameter: OMX_QcomIndexParamVideoCustomBufferSize"); QOMX_VIDEO_CUSTOM_BUFFERSIZE* pParam = (QOMX_VIDEO_CUSTOM_BUFFERSIZE*)paramData; if (pParam->nPortIndex == OMX_CORE_INPUT_PORT_INDEX) { struct v4l2_control control; control.id = V4L2_CID_MPEG_VIDC_VIDEO_BUFFER_SIZE_LIMIT; control.value = pParam->nBufferSize; if (ioctl(drv_ctx.video_driver_fd, VIDIOC_S_CTRL, &control)) { DEBUG_PRINT_ERROR("Failed to set input buffer size"); eRet = OMX_ErrorUnsupportedSetting; } else { eRet = get_buffer_req(&drv_ctx.ip_buf); if (eRet == OMX_ErrorNone) { m_custom_buffersize.input_buffersize = drv_ctx.ip_buf.buffer_size; DEBUG_PRINT_HIGH("Successfully set custom input buffer size = %d", m_custom_buffersize.input_buffersize); } else { DEBUG_PRINT_ERROR("Failed to get buffer requirement"); } } } else { DEBUG_PRINT_ERROR("ERROR: Custom buffer size in not supported on output port"); eRet = OMX_ErrorBadParameter; } break; } default: { DEBUG_PRINT_ERROR("Setparameter: unknown param %d", paramIndex); eRet = OMX_ErrorUnsupportedIndex; } } if (eRet != OMX_ErrorNone) DEBUG_PRINT_ERROR("set_parameter: Error: 0x%x, setting param 0x%x", eRet, paramIndex); return eRet; } Vulnerability Type: Overflow +Priv CWE ID: CWE-119 Summary: The mm-video-v4l2 vdec component in mediaserver in Android 4.x before 4.4.4, 5.0.x before 5.0.2, 5.1.x before 5.1.1, and 6.x before 2016-06-01 mishandles a buffer count, which allows attackers to gain privileges via a crafted application, as demonstrated by obtaining Signature or SignatureOrSystem access, aka internal bug 27661749. Commit Message: DO NOT MERGE mm-video-v4l2: vdec: add safety checks for freeing buffers Allow only up to 64 buffers on input/output port (since the allocation bitmap is only 64-wide). Do not allow changing theactual buffer count while still holding allocation (Client can technically negotiate buffer count on a free/disabled port) Add safety checks to free only as many buffers were allocated. Fixes: Security Vulnerability - Heap Overflow and Possible Local Privilege Escalation in MediaServer (libOmxVdec problem #3) Bug: 27532282 27661749 Change-Id: I06dd680d43feaef3efdc87311e8a6703e234b523
High
173,787
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: WORD32 ih264d_mark_err_slice_skip(dec_struct_t * ps_dec, WORD32 num_mb_skip, UWORD8 u1_is_idr_slice, UWORD16 u2_frame_num, pocstruct_t *ps_cur_poc, WORD32 prev_slice_err) { WORD32 i2_cur_mb_addr; UWORD32 u1_num_mbs, u1_num_mbsNby2; UWORD32 u1_mb_idx = ps_dec->u1_mb_idx; UWORD32 i2_mb_skip_run; UWORD32 u1_num_mbs_next, u1_end_of_row; const UWORD32 i2_pic_wdin_mbs = ps_dec->u2_frm_wd_in_mbs; UWORD32 u1_slice_end; UWORD32 u1_tfr_n_mb; UWORD32 u1_decode_nmb; dec_bit_stream_t * const ps_bitstrm = ps_dec->ps_bitstrm; dec_slice_params_t * ps_slice = ps_dec->ps_cur_slice; UWORD32 *pu4_bitstrm_buf = ps_bitstrm->pu4_buffer; UWORD32 *pu4_bitstrm_ofst = &ps_bitstrm->u4_ofst; deblk_mb_t *ps_cur_deblk_mb; dec_mb_info_t *ps_cur_mb_info; parse_pmbarams_t *ps_parse_mb_data; UWORD32 u1_inter_mb_type; UWORD32 u1_deblk_mb_type; UWORD16 u2_total_mbs_coded; UWORD32 u1_mbaff = ps_slice->u1_mbaff_frame_flag; parse_part_params_t *ps_part_info; WORD32 ret; if(ps_dec->ps_dec_err_status->u1_err_flag & REJECT_CUR_PIC) { ih264d_err_pic_dispbuf_mgr(ps_dec); return 0; } ps_dec->ps_dpb_cmds->u1_long_term_reference_flag = 0; if(prev_slice_err == 1) { /* first slice - missing/header corruption */ ps_dec->ps_cur_slice->u2_frame_num = u2_frame_num; if(!ps_dec->u1_first_slice_in_stream) { ih264d_end_of_pic(ps_dec, u1_is_idr_slice, ps_dec->ps_cur_slice->u2_frame_num); ps_dec->s_cur_pic_poc.u2_frame_num = ps_dec->ps_cur_slice->u2_frame_num; } { WORD32 i, j, poc = 0; ps_dec->ps_cur_slice->u2_first_mb_in_slice = 0; ps_dec->pf_mvpred = ih264d_mvpred_nonmbaff; ps_dec->p_form_mb_part_info = ih264d_form_mb_part_info_bp; ps_dec->p_motion_compensate = ih264d_motion_compensate_bp; if(ps_dec->ps_cur_pic != NULL) poc = ps_dec->ps_cur_pic->i4_poc + 2; j = 0; for(i = 0; i < MAX_NUM_PIC_PARAMS; i++) if(ps_dec->ps_pps[i].u1_is_valid == TRUE) j = i; { ps_dec->ps_cur_slice->u1_bottom_field_flag = 0; ps_dec->ps_cur_slice->u1_field_pic_flag = 0; ps_dec->ps_cur_slice->u1_slice_type = P_SLICE; ps_dec->ps_cur_slice->u1_nal_ref_idc = 1; ps_dec->ps_cur_slice->u1_nal_unit_type = 1; ret = ih264d_start_of_pic(ps_dec, poc, ps_cur_poc, ps_dec->ps_cur_slice->u2_frame_num, &ps_dec->ps_pps[j]); if(ret != OK) { return ret; } } ps_dec->ps_ref_pic_buf_lx[0][0]->u1_pic_buf_id = 0; ps_dec->u4_output_present = 0; { ih264d_get_next_display_field(ps_dec, ps_dec->ps_out_buffer, &(ps_dec->s_disp_op)); /* If error code is non-zero then there is no buffer available for display, hence avoid format conversion */ if(0 != ps_dec->s_disp_op.u4_error_code) { ps_dec->u4_fmt_conv_cur_row = ps_dec->s_disp_frame_info.u4_y_ht; } else ps_dec->u4_output_present = 1; } if(ps_dec->u1_separate_parse == 1) { if(ps_dec->u4_dec_thread_created == 0) { ithread_create(ps_dec->pv_dec_thread_handle, NULL, (void *)ih264d_decode_picture_thread, (void *)ps_dec); ps_dec->u4_dec_thread_created = 1; } if((ps_dec->u4_num_cores == 3) && ((ps_dec->u4_app_disable_deblk_frm == 0) || ps_dec->i1_recon_in_thread3_flag) && (ps_dec->u4_bs_deblk_thread_created == 0)) { ps_dec->u4_start_recon_deblk = 0; ithread_create(ps_dec->pv_bs_deblk_thread_handle, NULL, (void *)ih264d_recon_deblk_thread, (void *)ps_dec); ps_dec->u4_bs_deblk_thread_created = 1; } } } } else { dec_slice_struct_t *ps_parse_cur_slice; ps_parse_cur_slice = ps_dec->ps_dec_slice_buf + ps_dec->u2_cur_slice_num; if(ps_dec->u1_slice_header_done && ps_parse_cur_slice == ps_dec->ps_parse_cur_slice) { u1_num_mbs = ps_dec->u4_num_mbs_cur_nmb; if(u1_num_mbs) { ps_cur_mb_info = ps_dec->ps_nmb_info + u1_num_mbs - 1; } else { if(ps_dec->u1_separate_parse) { ps_cur_mb_info = ps_dec->ps_nmb_info - 1; } else { ps_cur_mb_info = ps_dec->ps_nmb_info + ps_dec->u4_num_mbs_prev_nmb - 1; } } ps_dec->u2_mby = ps_cur_mb_info->u2_mby; ps_dec->u2_mbx = ps_cur_mb_info->u2_mbx; ps_dec->u1_mb_ngbr_availablity = ps_cur_mb_info->u1_mb_ngbr_availablity; ps_dec->pv_parse_tu_coeff_data = ps_dec->pv_prev_mb_parse_tu_coeff_data; ps_dec->u2_cur_mb_addr--; ps_dec->i4_submb_ofst -= SUB_BLK_SIZE; if(u1_num_mbs) { if (ps_dec->u1_pr_sl_type == P_SLICE || ps_dec->u1_pr_sl_type == B_SLICE) { ps_dec->pf_mvpred_ref_tfr_nby2mb(ps_dec, u1_mb_idx, u1_num_mbs); ps_dec->ps_part = ps_dec->ps_parse_part_params; } u1_num_mbs_next = i2_pic_wdin_mbs - ps_dec->u2_mbx - 1; u1_end_of_row = (!u1_num_mbs_next) && (!(u1_mbaff && (u1_num_mbs & 0x01))); u1_slice_end = 1; u1_tfr_n_mb = 1; ps_cur_mb_info->u1_end_of_slice = u1_slice_end; if(ps_dec->u1_separate_parse) { ih264d_parse_tfr_nmb(ps_dec, u1_mb_idx, u1_num_mbs, u1_num_mbs_next, u1_tfr_n_mb, u1_end_of_row); ps_dec->ps_nmb_info += u1_num_mbs; } else { ih264d_decode_recon_tfr_nmb(ps_dec, u1_mb_idx, u1_num_mbs, u1_num_mbs_next, u1_tfr_n_mb, u1_end_of_row); } ps_dec->u2_total_mbs_coded += u1_num_mbs; ps_dec->u1_mb_idx = 0; ps_dec->u4_num_mbs_cur_nmb = 0; } if(ps_dec->u2_total_mbs_coded >= ps_dec->u2_frm_ht_in_mbs * ps_dec->u2_frm_wd_in_mbs) { ps_dec->u1_pic_decode_done = 1; return 0; } ps_dec->u2_cur_slice_num++; ps_dec->i2_prev_slice_mbx = ps_dec->u2_mbx; ps_dec->i2_prev_slice_mby = ps_dec->u2_mby; ps_dec->ps_parse_cur_slice++; } else { ps_dec->ps_parse_cur_slice = ps_dec->ps_dec_slice_buf + ps_dec->u2_cur_slice_num; } } /******************************************************/ /* Initializations to new slice */ /******************************************************/ { WORD32 num_entries; WORD32 size; UWORD8 *pu1_buf; num_entries = MAX_FRAMES; if((1 >= ps_dec->ps_cur_sps->u1_num_ref_frames) && (0 == ps_dec->i4_display_delay)) { num_entries = 1; } num_entries = ((2 * num_entries) + 1); if(BASE_PROFILE_IDC != ps_dec->ps_cur_sps->u1_profile_idc) { num_entries *= 2; } size = num_entries * sizeof(void *); size += PAD_MAP_IDX_POC * sizeof(void *); pu1_buf = (UWORD8 *)ps_dec->pv_map_ref_idx_to_poc_buf; pu1_buf += size * ps_dec->u2_cur_slice_num; ps_dec->ps_parse_cur_slice->ppv_map_ref_idx_to_poc = (volatile void **)pu1_buf; } ps_dec->ps_cur_slice->u2_first_mb_in_slice = ps_dec->u2_total_mbs_coded << u1_mbaff; ps_dec->ps_cur_slice->i1_slice_alpha_c0_offset = 0; ps_dec->ps_cur_slice->i1_slice_beta_offset = 0; if(ps_dec->ps_cur_slice->u1_field_pic_flag) ps_dec->u2_prv_frame_num = ps_dec->ps_cur_slice->u2_frame_num; ps_dec->ps_parse_cur_slice->u4_first_mb_in_slice = ps_dec->u2_total_mbs_coded << u1_mbaff; ps_dec->ps_parse_cur_slice->u2_log2Y_crwd = ps_dec->ps_cur_slice->u2_log2Y_crwd; if(ps_dec->u1_separate_parse) { ps_dec->ps_parse_cur_slice->pv_tu_coeff_data_start = ps_dec->pv_parse_tu_coeff_data; } else { ps_dec->pv_proc_tu_coeff_data = ps_dec->pv_parse_tu_coeff_data; } /******************************************************/ /* Initializations specific to P slice */ /******************************************************/ u1_inter_mb_type = P_MB; u1_deblk_mb_type = D_INTER_MB; ps_dec->ps_cur_slice->u1_slice_type = P_SLICE; ps_dec->ps_parse_cur_slice->slice_type = P_SLICE; ps_dec->pf_mvpred_ref_tfr_nby2mb = ih264d_mv_pred_ref_tfr_nby2_pmb; ps_dec->ps_part = ps_dec->ps_parse_part_params; /******************************************************/ /* Parsing / decoding the slice */ /******************************************************/ ps_dec->u1_slice_header_done = 2; ps_dec->u1_qp = ps_slice->u1_slice_qp; ih264d_update_qp(ps_dec, 0); u1_mb_idx = ps_dec->u1_mb_idx; ps_parse_mb_data = ps_dec->ps_parse_mb_data; u1_num_mbs = u1_mb_idx; u1_slice_end = 0; u1_tfr_n_mb = 0; u1_decode_nmb = 0; u1_num_mbsNby2 = 0; i2_cur_mb_addr = ps_dec->u2_total_mbs_coded; i2_mb_skip_run = num_mb_skip; while(!u1_slice_end) { UWORD8 u1_mb_type; if(i2_cur_mb_addr > ps_dec->ps_cur_sps->u2_max_mb_addr) break; ps_cur_mb_info = ps_dec->ps_nmb_info + u1_num_mbs; ps_dec->u4_num_mbs_cur_nmb = u1_num_mbs; ps_cur_mb_info->u1_Mux = 0; ps_dec->u4_num_pmbair = (u1_num_mbs >> u1_mbaff); ps_cur_deblk_mb = ps_dec->ps_deblk_mbn + u1_num_mbs; ps_cur_mb_info->u1_end_of_slice = 0; /* Storing Default partition info */ ps_parse_mb_data->u1_num_part = 1; ps_parse_mb_data->u1_isI_mb = 0; /**************************************************************/ /* Get the required information for decoding of MB */ /**************************************************************/ /* mb_x, mb_y, neighbor availablity, */ if (u1_mbaff) ih264d_get_mb_info_cavlc_mbaff(ps_dec, i2_cur_mb_addr, ps_cur_mb_info, i2_mb_skip_run); else ih264d_get_mb_info_cavlc_nonmbaff(ps_dec, i2_cur_mb_addr, ps_cur_mb_info, i2_mb_skip_run); /* Set the deblocking parameters for this MB */ if(ps_dec->u4_app_disable_deblk_frm == 0) { ih264d_set_deblocking_parameters(ps_cur_deblk_mb, ps_slice, ps_dec->u1_mb_ngbr_availablity, ps_dec->u1_cur_mb_fld_dec_flag); } /* Set appropriate flags in ps_cur_mb_info and ps_dec */ ps_dec->i1_prev_mb_qp_delta = 0; ps_dec->u1_sub_mb_num = 0; ps_cur_mb_info->u1_mb_type = MB_SKIP; ps_cur_mb_info->u1_mb_mc_mode = PRED_16x16; ps_cur_mb_info->u1_cbp = 0; /* Storing Skip partition info */ ps_part_info = ps_dec->ps_part; ps_part_info->u1_is_direct = PART_DIRECT_16x16; ps_part_info->u1_sub_mb_num = 0; ps_dec->ps_part++; /* Update Nnzs */ ih264d_update_nnz_for_skipmb(ps_dec, ps_cur_mb_info, CAVLC); ps_cur_mb_info->ps_curmb->u1_mb_type = u1_inter_mb_type; ps_cur_deblk_mb->u1_mb_type |= u1_deblk_mb_type; i2_mb_skip_run--; ps_cur_deblk_mb->u1_mb_qp = ps_dec->u1_qp; if (u1_mbaff) { ih264d_update_mbaff_left_nnz(ps_dec, ps_cur_mb_info); } /**************************************************************/ /* Get next Macroblock address */ /**************************************************************/ i2_cur_mb_addr++; u1_num_mbs++; u1_num_mbsNby2++; ps_parse_mb_data++; /****************************************************************/ /* Check for End Of Row and other flags that determine when to */ /* do DMA setup for N/2-Mb, Decode for N-Mb, and Transfer for */ /* N-Mb */ /****************************************************************/ u1_num_mbs_next = i2_pic_wdin_mbs - ps_dec->u2_mbx - 1; u1_end_of_row = (!u1_num_mbs_next) && (!(u1_mbaff && (u1_num_mbs & 0x01))); u1_slice_end = !i2_mb_skip_run; u1_tfr_n_mb = (u1_num_mbs == ps_dec->u1_recon_mb_grp) || u1_end_of_row || u1_slice_end; u1_decode_nmb = u1_tfr_n_mb || u1_slice_end; ps_cur_mb_info->u1_end_of_slice = u1_slice_end; if(u1_decode_nmb) { ps_dec->pf_mvpred_ref_tfr_nby2mb(ps_dec, u1_mb_idx, u1_num_mbs); u1_num_mbsNby2 = 0; ps_parse_mb_data = ps_dec->ps_parse_mb_data; ps_dec->ps_part = ps_dec->ps_parse_part_params; if(ps_dec->u1_separate_parse) { ih264d_parse_tfr_nmb(ps_dec, u1_mb_idx, u1_num_mbs, u1_num_mbs_next, u1_tfr_n_mb, u1_end_of_row); ps_dec->ps_nmb_info += u1_num_mbs; } else { ih264d_decode_recon_tfr_nmb(ps_dec, u1_mb_idx, u1_num_mbs, u1_num_mbs_next, u1_tfr_n_mb, u1_end_of_row); } ps_dec->u2_total_mbs_coded += u1_num_mbs; if(u1_tfr_n_mb) u1_num_mbs = 0; u1_mb_idx = u1_num_mbs; ps_dec->u1_mb_idx = u1_num_mbs; } } ps_dec->u4_num_mbs_cur_nmb = 0; ps_dec->ps_cur_slice->u4_mbs_in_slice = i2_cur_mb_addr - ps_dec->ps_parse_cur_slice->u4_first_mb_in_slice; H264_DEC_DEBUG_PRINT("Mbs in slice: %d\n", ps_dec->ps_cur_slice->u4_mbs_in_slice); ps_dec->u2_cur_slice_num++; /* incremented here only if first slice is inserted */ if(ps_dec->u4_first_slice_in_pic != 0) ps_dec->ps_parse_cur_slice++; ps_dec->i2_prev_slice_mbx = ps_dec->u2_mbx; ps_dec->i2_prev_slice_mby = ps_dec->u2_mby; if(ps_dec->u2_total_mbs_coded >= ps_dec->u2_frm_ht_in_mbs * ps_dec->u2_frm_wd_in_mbs) { ps_dec->u1_pic_decode_done = 1; } return 0; } Vulnerability Type: DoS Exec Code Mem. Corr. CWE ID: CWE-20 Summary: The H.264 decoder in mediaserver in Android 6.x before 2016-07-01 does not initialize certain slice data, which allows remote attackers to execute arbitrary code or cause a denial of service (memory corruption) via a crafted media file, aka internal bug 28165661. Commit Message: Fix slice params for interlaced video Bug: 28165661 Change-Id: I912a86bd78ebf0617fd2bc6eb2b5a61afc17bf53
High
173,761
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: DefragIPv4TooLargeTest(void) { DefragContext *dc = NULL; Packet *p = NULL; int ret = 0; DefragInit(); dc = DefragContextNew(); if (dc == NULL) goto end; /* Create a fragment that would extend past the max allowable size * for an IPv4 packet. */ p = BuildTestPacket(1, 8183, 0, 'A', 71); if (p == NULL) goto end; /* We do not expect a packet returned. */ if (Defrag(NULL, NULL, p, NULL) != NULL) goto end; if (!ENGINE_ISSET_EVENT(p, IPV4_FRAG_PKT_TOO_LARGE)) goto end; /* The fragment should have been ignored so no fragments should have * been allocated from the pool. */ if (dc->frag_pool->outstanding != 0) return 0; ret = 1; end: if (dc != NULL) DefragContextDestroy(dc); if (p != NULL) SCFree(p); DefragDestroy(); return ret; } Vulnerability Type: CWE ID: CWE-358 Summary: Suricata before 3.2.1 has an IPv4 defragmentation evasion issue caused by lack of a check for the IP protocol during fragment matching. Commit Message: defrag - take protocol into account during re-assembly The IP protocol was not being used to match fragments with their packets allowing a carefully constructed packet with a different protocol to be matched, allowing re-assembly to complete, creating a packet that would not be re-assembled by the destination host.
Medium
168,297
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: BGD_DECLARE(void) gdImageWebpCtx (gdImagePtr im, gdIOCtx * outfile, int quality) { uint8_t *argb; int x, y; uint8_t *p; uint8_t *out; size_t out_size; if (im == NULL) { return; } if (!gdImageTrueColor(im)) { gd_error("Paletter image not supported by webp"); return; } if (quality == -1) { quality = 80; } argb = (uint8_t *)gdMalloc(gdImageSX(im) * 4 * gdImageSY(im)); if (!argb) { return; } p = argb; for (y = 0; y < gdImageSY(im); y++) { for (x = 0; x < gdImageSX(im); x++) { register int c; register char a; c = im->tpixels[y][x]; a = gdTrueColorGetAlpha(c); if (a == 127) { a = 0; } else { a = 255 - ((a << 1) + (a >> 6)); } *(p++) = gdTrueColorGetRed(c); *(p++) = gdTrueColorGetGreen(c); *(p++) = gdTrueColorGetBlue(c); *(p++) = a; } } out_size = WebPEncodeRGBA(argb, gdImageSX(im), gdImageSY(im), gdImageSX(im) * 4, quality, &out); if (out_size == 0) { gd_error("gd-webp encoding failed"); goto freeargb; } gdPutBuf(out, out_size, outfile); free(out); freeargb: gdFree(argb); } Vulnerability Type: DoS Overflow CWE ID: CWE-190 Summary: Integer overflow in the gdImageWebpCtx function in gd_webp.c in the GD Graphics Library (aka libgd) through 2.2.3, as used in PHP through 7.0.11, allows remote attackers to cause a denial of service (heap-based buffer overflow) or possibly have unspecified other impact via crafted imagewebp and imagedestroy calls. Commit Message: Merge branch 'pull-request/296'
High
166,927
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: void VRDisplay::FocusChanged() { vr_v_sync_provider_.reset(); ConnectVSyncProvider(); } Vulnerability Type: DoS CWE ID: Summary: Multiple unspecified vulnerabilities in Google Chrome before 43.0.2357.65 allow attackers to cause a denial of service or possibly have other impact via unknown vectors. Commit Message: WebVR: fix initial vsync Applications sometimes use window.rAF while not presenting, then switch to vrDisplay.rAF after presentation starts. Depending on the animation loop's timing, this can cause a race condition where presentation has been started but there's no vrDisplay.rAF pending yet. Ensure there's at least vsync being processed after presentation starts so that a queued window.rAF can run and schedule a vrDisplay.rAF. BUG=711789 Review-Url: https://codereview.chromium.org/2848483003 Cr-Commit-Position: refs/heads/master@{#468167}
High
171,993
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: void MojoJpegDecodeAccelerator::Decode( const BitstreamBuffer& bitstream_buffer, const scoped_refptr<VideoFrame>& video_frame) { DCHECK(io_task_runner_->BelongsToCurrentThread()); DCHECK(jpeg_decoder_.is_bound()); DCHECK( base::SharedMemory::IsHandleValid(video_frame->shared_memory_handle())); base::SharedMemoryHandle output_handle = base::SharedMemory::DuplicateHandle(video_frame->shared_memory_handle()); if (!base::SharedMemory::IsHandleValid(output_handle)) { DLOG(ERROR) << "Failed to duplicate handle of VideoFrame"; return; } size_t output_buffer_size = VideoFrame::AllocationSize( video_frame->format(), video_frame->coded_size()); mojo::ScopedSharedBufferHandle output_frame_handle = mojo::WrapSharedMemoryHandle(output_handle, output_buffer_size, false /* read_only */); jpeg_decoder_->Decode(bitstream_buffer, video_frame->coded_size(), std::move(output_frame_handle), base::checked_cast<uint32_t>(output_buffer_size), base::Bind(&MojoJpegDecodeAccelerator::OnDecodeAck, base::Unretained(this))); } Vulnerability Type: CWE ID: CWE-787 Summary: Incorrect use of mojo::WrapSharedMemoryHandle in Mojo in Google Chrome prior to 65.0.3325.146 allowed a remote attacker who had compromised the renderer process to perform an out of bounds memory write via a crafted HTML page. Commit Message: Correct mojo::WrapSharedMemoryHandle usage Fixes some incorrect uses of mojo::WrapSharedMemoryHandle which were assuming that the call actually has any control over the memory protection applied to a handle when mapped. Where fixing usage is infeasible for this CL, TODOs are added to annotate follow-up work. Also updates the API and documentation to (hopefully) improve clarity and avoid similar mistakes from being made in the future. BUG=792900 Cq-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 Change-Id: I0578aaa9ca3bfcb01aaf2451315d1ede95458477 Reviewed-on: https://chromium-review.googlesource.com/818282 Reviewed-by: Wei Li <[email protected]> Reviewed-by: Lei Zhang <[email protected]> Reviewed-by: John Abd-El-Malek <[email protected]> Reviewed-by: Daniel Cheng <[email protected]> Reviewed-by: Sadrul Chowdhury <[email protected]> Reviewed-by: Yuzhu Shen <[email protected]> Reviewed-by: Robert Sesek <[email protected]> Commit-Queue: Ken Rockot <[email protected]> Cr-Commit-Position: refs/heads/master@{#530268}
Medium
172,872
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: static void MSLStartElement(void *context,const xmlChar *tag, const xmlChar **attributes) { AffineMatrix affine, current; ChannelType channel; char key[MaxTextExtent], *value; const char *attribute, *keyword; double angle; DrawInfo *draw_info; ExceptionInfo *exception; GeometryInfo geometry_info; Image *image; int flags; ssize_t option, j, n, x, y; MSLInfo *msl_info; RectangleInfo geometry; register ssize_t i; size_t height, width; /* Called when an opening tag has been processed. */ (void) LogMagickEvent(CoderEvent,GetMagickModule(), " SAX.startElement(%s",tag); exception=AcquireExceptionInfo(); msl_info=(MSLInfo *) context; n=msl_info->n; keyword=(const char *) NULL; value=(char *) NULL; SetGeometryInfo(&geometry_info); (void) ResetMagickMemory(&geometry,0,sizeof(geometry)); channel=DefaultChannels; switch (*tag) { case 'A': case 'a': { if (LocaleCompare((const char *) tag,"add-noise") == 0) { Image *noise_image; NoiseType noise; /* Add noise image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } noise=UniformNoise; if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'C': case 'c': { if (LocaleCompare(keyword,"channel") == 0) { option=ParseChannelOption(value); if (option < 0) ThrowMSLException(OptionError,"UnrecognizedChannelType", value); channel=(ChannelType) option; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'N': case 'n': { if (LocaleCompare(keyword,"noise") == 0) { option=ParseCommandOption(MagickNoiseOptions,MagickFalse, value); if (option < 0) ThrowMSLException(OptionError,"UnrecognizedNoiseType", value); noise=(NoiseType) option; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } noise_image=AddNoiseImageChannel(msl_info->image[n],channel,noise, &msl_info->image[n]->exception); if (noise_image == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); msl_info->image[n]=noise_image; break; } if (LocaleCompare((const char *) tag,"annotate") == 0) { char text[MaxTextExtent]; /* Annotate image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } draw_info=CloneDrawInfo(msl_info->image_info[n], msl_info->draw_info[n]); angle=0.0; current=draw_info->affine; GetAffineMatrix(&affine); if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'A': case 'a': { if (LocaleCompare(keyword,"affine") == 0) { char *p; p=value; draw_info->affine.sx=StringToDouble(p,&p); if (*p ==',') p++; draw_info->affine.rx=StringToDouble(p,&p); if (*p ==',') p++; draw_info->affine.ry=StringToDouble(p,&p); if (*p ==',') p++; draw_info->affine.sy=StringToDouble(p,&p); if (*p ==',') p++; draw_info->affine.tx=StringToDouble(p,&p); if (*p ==',') p++; draw_info->affine.ty=StringToDouble(p,&p); break; } if (LocaleCompare(keyword,"align") == 0) { option=ParseCommandOption(MagickAlignOptions,MagickFalse, value); if (option < 0) ThrowMSLException(OptionError,"UnrecognizedAlignType", value); draw_info->align=(AlignType) option; break; } if (LocaleCompare(keyword,"antialias") == 0) { option=ParseCommandOption(MagickBooleanOptions, MagickFalse,value); if (option < 0) ThrowMSLException(OptionError,"UnrecognizedBooleanType", value); draw_info->stroke_antialias=(MagickBooleanType) option; draw_info->text_antialias=(MagickBooleanType) option; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'D': case 'd': { if (LocaleCompare(keyword,"density") == 0) { CloneString(&draw_info->density,value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'E': case 'e': { if (LocaleCompare(keyword,"encoding") == 0) { CloneString(&draw_info->encoding,value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'F': case 'f': { if (LocaleCompare(keyword, "fill") == 0) { (void) QueryColorDatabase(value,&draw_info->fill, exception); break; } if (LocaleCompare(keyword,"family") == 0) { CloneString(&draw_info->family,value); break; } if (LocaleCompare(keyword,"font") == 0) { CloneString(&draw_info->font,value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'G': case 'g': { if (LocaleCompare(keyword,"geometry") == 0) { flags=ParsePageGeometry(msl_info->image[n],value, &geometry,exception); if ((flags & HeightValue) == 0) geometry.height=geometry.width; break; } if (LocaleCompare(keyword,"gravity") == 0) { option=ParseCommandOption(MagickGravityOptions, MagickFalse,value); if (option < 0) ThrowMSLException(OptionError,"UnrecognizedGravityType", value); draw_info->gravity=(GravityType) option; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'P': case 'p': { if (LocaleCompare(keyword,"pointsize") == 0) { draw_info->pointsize=StringToDouble(value,(char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'R': case 'r': { if (LocaleCompare(keyword,"rotate") == 0) { angle=StringToDouble(value,(char **) NULL); affine.sx=cos(DegreesToRadians(fmod(angle,360.0))); affine.rx=sin(DegreesToRadians(fmod(angle,360.0))); affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0)))); affine.sy=cos(DegreesToRadians(fmod(angle,360.0))); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'S': case 's': { if (LocaleCompare(keyword,"scale") == 0) { flags=ParseGeometry(value,&geometry_info); if ((flags & SigmaValue) == 0) geometry_info.sigma=1.0; affine.sx=geometry_info.rho; affine.sy=geometry_info.sigma; break; } if (LocaleCompare(keyword,"skewX") == 0) { angle=StringToDouble(value,(char **) NULL); affine.ry=tan(DegreesToRadians(fmod((double) angle, 360.0))); break; } if (LocaleCompare(keyword,"skewY") == 0) { angle=StringToDouble(value,(char **) NULL); affine.rx=tan(DegreesToRadians(fmod((double) angle, 360.0))); break; } if (LocaleCompare(keyword,"stretch") == 0) { option=ParseCommandOption(MagickStretchOptions, MagickFalse,value); if (option < 0) ThrowMSLException(OptionError,"UnrecognizedStretchType", value); draw_info->stretch=(StretchType) option; break; } if (LocaleCompare(keyword, "stroke") == 0) { (void) QueryColorDatabase(value,&draw_info->stroke, exception); break; } if (LocaleCompare(keyword,"strokewidth") == 0) { draw_info->stroke_width=StringToLong(value); break; } if (LocaleCompare(keyword,"style") == 0) { option=ParseCommandOption(MagickStyleOptions,MagickFalse, value); if (option < 0) ThrowMSLException(OptionError,"UnrecognizedStyleType", value); draw_info->style=(StyleType) option; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'T': case 't': { if (LocaleCompare(keyword,"text") == 0) { CloneString(&draw_info->text,value); break; } if (LocaleCompare(keyword,"translate") == 0) { flags=ParseGeometry(value,&geometry_info); if ((flags & SigmaValue) == 0) geometry_info.sigma=1.0; affine.tx=geometry_info.rho; affine.ty=geometry_info.sigma; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'U': case 'u': { if (LocaleCompare(keyword, "undercolor") == 0) { (void) QueryColorDatabase(value,&draw_info->undercolor, exception); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'W': case 'w': { if (LocaleCompare(keyword,"weight") == 0) { draw_info->weight=StringToLong(value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'X': case 'x': { if (LocaleCompare(keyword,"x") == 0) { geometry.x=StringToLong(value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'Y': case 'y': { if (LocaleCompare(keyword,"y") == 0) { geometry.y=StringToLong(value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } (void) FormatLocaleString(text,MaxTextExtent, "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double) geometry.height,(double) geometry.x,(double) geometry.y); CloneString(&draw_info->geometry,text); draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx; draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx; draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy; draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy; draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+ affine.tx; draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+ affine.ty; (void) AnnotateImage(msl_info->image[n],draw_info); draw_info=DestroyDrawInfo(draw_info); break; } if (LocaleCompare((const char *) tag,"append") == 0) { Image *append_image; MagickBooleanType stack; if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } stack=MagickFalse; if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'S': case 's': { if (LocaleCompare(keyword,"stack") == 0) { option=ParseCommandOption(MagickBooleanOptions,MagickFalse, value); if (option < 0) ThrowMSLException(OptionError,"UnrecognizedBooleanType", value); stack=(MagickBooleanType) option; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } append_image=AppendImages(msl_info->image[n],stack, &msl_info->image[n]->exception); if (append_image == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); msl_info->image[n]=append_image; break; } ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag); break; } case 'B': case 'b': { if (LocaleCompare((const char *) tag,"blur") == 0) { Image *blur_image; /* Blur image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'C': case 'c': { if (LocaleCompare(keyword,"channel") == 0) { option=ParseChannelOption(value); if (option < 0) ThrowMSLException(OptionError,"UnrecognizedChannelType", value); channel=(ChannelType) option; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'G': case 'g': { if (LocaleCompare(keyword,"geometry") == 0) { flags=ParseGeometry(value,&geometry_info); if ((flags & SigmaValue) == 0) geometry_info.sigma=1.0; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'R': case 'r': { if (LocaleCompare(keyword,"radius") == 0) { geometry_info.rho=StringToDouble(value,(char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'S': case 's': { if (LocaleCompare(keyword,"sigma") == 0) { geometry_info.sigma=StringToLong(value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } blur_image=BlurImageChannel(msl_info->image[n],channel, geometry_info.rho,geometry_info.sigma, &msl_info->image[n]->exception); if (blur_image == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); msl_info->image[n]=blur_image; break; } if (LocaleCompare((const char *) tag,"border") == 0) { Image *border_image; /* Border image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } SetGeometry(msl_info->image[n],&geometry); if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'C': case 'c': { if (LocaleCompare(keyword,"compose") == 0) { option=ParseCommandOption(MagickComposeOptions,MagickFalse, value); if (option < 0) ThrowMSLException(OptionError,"UnrecognizedComposeType", value); msl_info->image[n]->compose=(CompositeOperator) option; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'F': case 'f': { if (LocaleCompare(keyword, "fill") == 0) { (void) QueryColorDatabase(value, &msl_info->image[n]->border_color,exception); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'G': case 'g': { if (LocaleCompare(keyword,"geometry") == 0) { flags=ParsePageGeometry(msl_info->image[n],value, &geometry,exception); if ((flags & HeightValue) == 0) geometry.height=geometry.width; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'H': case 'h': { if (LocaleCompare(keyword,"height") == 0) { geometry.height=StringToLong(value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'W': case 'w': { if (LocaleCompare(keyword,"width") == 0) { geometry.width=StringToLong(value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } border_image=BorderImage(msl_info->image[n],&geometry, &msl_info->image[n]->exception); if (border_image == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); msl_info->image[n]=border_image; break; } ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag); } case 'C': case 'c': { if (LocaleCompare((const char *) tag,"colorize") == 0) { char opacity[MaxTextExtent]; Image *colorize_image; PixelPacket target; /* Add noise image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } target=msl_info->image[n]->background_color; (void) CopyMagickString(opacity,"100",MaxTextExtent); if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'F': case 'f': { if (LocaleCompare(keyword,"fill") == 0) { (void) QueryColorDatabase(value,&target, &msl_info->image[n]->exception); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'O': case 'o': { if (LocaleCompare(keyword,"opacity") == 0) { (void) CopyMagickString(opacity,value,MaxTextExtent); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } colorize_image=ColorizeImage(msl_info->image[n],opacity,target, &msl_info->image[n]->exception); if (colorize_image == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); msl_info->image[n]=colorize_image; break; } if (LocaleCompare((const char *) tag, "charcoal") == 0) { double radius = 0.0, sigma = 1.0; if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } /* NOTE: charcoal can have no attributes, since we use all the defaults! */ if (attributes != (const xmlChar **) NULL) { for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; CloneString(&value,InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i])); switch (*keyword) { case 'R': case 'r': { if (LocaleCompare(keyword,"radius") == 0) { radius=StringToDouble(value,(char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } case 'S': case 's': { if (LocaleCompare(keyword,"sigma") == 0) { sigma = StringToLong( value ); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } } } } /* charcoal image. */ { Image *newImage; newImage=CharcoalImage(msl_info->image[n],radius,sigma, &msl_info->image[n]->exception); if (newImage == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); msl_info->image[n]=newImage; break; } } if (LocaleCompare((const char *) tag,"chop") == 0) { Image *chop_image; /* Chop image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } SetGeometry(msl_info->image[n],&geometry); if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'G': case 'g': { if (LocaleCompare(keyword,"geometry") == 0) { flags=ParsePageGeometry(msl_info->image[n],value, &geometry,exception); if ((flags & HeightValue) == 0) geometry.height=geometry.width; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'H': case 'h': { if (LocaleCompare(keyword,"height") == 0) { geometry.height=StringToLong(value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'W': case 'w': { if (LocaleCompare(keyword,"width") == 0) { geometry.width=StringToLong(value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'X': case 'x': { if (LocaleCompare(keyword,"x") == 0) { geometry.x=StringToLong(value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'Y': case 'y': { if (LocaleCompare(keyword,"y") == 0) { geometry.y=StringToLong(value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } chop_image=ChopImage(msl_info->image[n],&geometry, &msl_info->image[n]->exception); if (chop_image == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); msl_info->image[n]=chop_image; break; } if (LocaleCompare((const char *) tag,"color-floodfill") == 0) { PaintMethod paint_method; MagickPixelPacket target; /* Color floodfill image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } draw_info=CloneDrawInfo(msl_info->image_info[n], msl_info->draw_info[n]); SetGeometry(msl_info->image[n],&geometry); paint_method=FloodfillMethod; if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'B': case 'b': { if (LocaleCompare(keyword,"bordercolor") == 0) { (void) QueryMagickColor(value,&target,exception); paint_method=FillToBorderMethod; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'F': case 'f': { if (LocaleCompare(keyword,"fill") == 0) { (void) QueryColorDatabase(value,&draw_info->fill, exception); break; } if (LocaleCompare(keyword,"fuzz") == 0) { msl_info->image[n]->fuzz=StringToDouble(value, (char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'G': case 'g': { if (LocaleCompare(keyword,"geometry") == 0) { flags=ParsePageGeometry(msl_info->image[n],value, &geometry,exception); if ((flags & HeightValue) == 0) geometry.height=geometry.width; (void) GetOneVirtualMagickPixel(msl_info->image[n], geometry.x,geometry.y,&target,exception); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'X': case 'x': { if (LocaleCompare(keyword,"x") == 0) { geometry.x=StringToLong(value); (void) GetOneVirtualMagickPixel(msl_info->image[n], geometry.x,geometry.y,&target,exception); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'Y': case 'y': { if (LocaleCompare(keyword,"y") == 0) { geometry.y=StringToLong(value); (void) GetOneVirtualMagickPixel(msl_info->image[n], geometry.x,geometry.y,&target,exception); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } (void) FloodfillPaintImage(msl_info->image[n],DefaultChannels, draw_info,&target,geometry.x,geometry.y, paint_method == FloodfillMethod ? MagickFalse : MagickTrue); draw_info=DestroyDrawInfo(draw_info); break; } if (LocaleCompare((const char *) tag,"comment") == 0) break; if (LocaleCompare((const char *) tag,"composite") == 0) { char composite_geometry[MaxTextExtent]; CompositeOperator compose; Image *composite_image, *rotate_image; PixelPacket target; /* Composite image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } composite_image=NewImageList(); compose=OverCompositeOp; if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'C': case 'c': { if (LocaleCompare(keyword,"compose") == 0) { option=ParseCommandOption(MagickComposeOptions,MagickFalse, value); if (option < 0) ThrowMSLException(OptionError,"UnrecognizedComposeType", value); compose=(CompositeOperator) option; break; } break; } case 'I': case 'i': { if (LocaleCompare(keyword,"image") == 0) for (j=0; j < msl_info->n; j++) { const char *attribute; attribute=GetImageProperty(msl_info->attributes[j],"id"); if ((attribute != (const char *) NULL) && (LocaleCompare(attribute,value) == 0)) { composite_image=CloneImage(msl_info->image[j],0,0, MagickFalse,exception); break; } } break; } default: break; } } if (composite_image == (Image *) NULL) break; rotate_image=NewImageList(); SetGeometry(msl_info->image[n],&geometry); if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'B': case 'b': { if (LocaleCompare(keyword,"blend") == 0) { (void) SetImageArtifact(composite_image, "compose:args",value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'C': case 'c': { if (LocaleCompare(keyword,"channel") == 0) { option=ParseChannelOption(value); if (option < 0) ThrowMSLException(OptionError,"UnrecognizedChannelType", value); channel=(ChannelType) option; break; } if (LocaleCompare(keyword, "color") == 0) { (void) QueryColorDatabase(value, &composite_image->background_color,exception); break; } if (LocaleCompare(keyword,"compose") == 0) break; ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'G': case 'g': { if (LocaleCompare(keyword,"geometry") == 0) { flags=ParsePageGeometry(msl_info->image[n],value, &geometry,exception); if ((flags & HeightValue) == 0) geometry.height=geometry.width; (void) GetOneVirtualPixel(msl_info->image[n],geometry.x, geometry.y,&target,exception); break; } if (LocaleCompare(keyword,"gravity") == 0) { option=ParseCommandOption(MagickGravityOptions,MagickFalse, value); if (option < 0) ThrowMSLException(OptionError,"UnrecognizedGravityType", value); msl_info->image[n]->gravity=(GravityType) option; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'I': case 'i': { if (LocaleCompare(keyword,"image") == 0) break; ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'M': case 'm': { if (LocaleCompare(keyword,"mask") == 0) for (j=0; j < msl_info->n; j++) { const char *attribute; attribute=GetImageProperty(msl_info->attributes[j],"id"); if ((attribute != (const char *) NULL) && (LocaleCompare(value,value) == 0)) { SetImageType(composite_image,TrueColorMatteType); (void) CompositeImage(composite_image, CopyOpacityCompositeOp,msl_info->image[j],0,0); break; } } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'O': case 'o': { if (LocaleCompare(keyword,"opacity") == 0) { ssize_t opacity, y; register ssize_t x; register PixelPacket *q; CacheView *composite_view; opacity=QuantumRange-StringToLong(value); if (compose != DissolveCompositeOp) { (void) SetImageOpacity(composite_image,(Quantum) opacity); break; } (void) SetImageArtifact(msl_info->image[n], "compose:args",value); if (composite_image->matte != MagickTrue) (void) SetImageOpacity(composite_image,OpaqueOpacity); composite_view=AcquireAuthenticCacheView(composite_image, exception); for (y=0; y < (ssize_t) composite_image->rows ; y++) { q=GetCacheViewAuthenticPixels(composite_view,0,y, (ssize_t) composite_image->columns,1,exception); for (x=0; x < (ssize_t) composite_image->columns; x++) { if (q->opacity == OpaqueOpacity) q->opacity=ClampToQuantum(opacity); q++; } if (SyncCacheViewAuthenticPixels(composite_view,exception) == MagickFalse) break; } composite_view=DestroyCacheView(composite_view); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'R': case 'r': { if (LocaleCompare(keyword,"rotate") == 0) { rotate_image=RotateImage(composite_image, StringToDouble(value,(char **) NULL),exception); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'T': case 't': { if (LocaleCompare(keyword,"tile") == 0) { MagickBooleanType tile; option=ParseCommandOption(MagickBooleanOptions,MagickFalse, value); if (option < 0) ThrowMSLException(OptionError,"UnrecognizedBooleanType", value); tile=(MagickBooleanType) option; (void) tile; if (rotate_image != (Image *) NULL) (void) SetImageArtifact(rotate_image, "compose:outside-overlay","false"); else (void) SetImageArtifact(composite_image, "compose:outside-overlay","false"); image=msl_info->image[n]; height=composite_image->rows; width=composite_image->columns; for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) height) for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) width) { if (rotate_image != (Image *) NULL) (void) CompositeImage(image,compose,rotate_image, x,y); else (void) CompositeImage(image,compose, composite_image,x,y); } if (rotate_image != (Image *) NULL) rotate_image=DestroyImage(rotate_image); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'X': case 'x': { if (LocaleCompare(keyword,"x") == 0) { geometry.x=StringToLong(value); (void) GetOneVirtualPixel(msl_info->image[n],geometry.x, geometry.y,&target,exception); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'Y': case 'y': { if (LocaleCompare(keyword,"y") == 0) { geometry.y=StringToLong(value); (void) GetOneVirtualPixel(msl_info->image[n],geometry.x, geometry.y,&target,exception); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } image=msl_info->image[n]; (void) FormatLocaleString(composite_geometry,MaxTextExtent, "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns, (double) composite_image->rows,(double) geometry.x,(double) geometry.y); flags=ParseGravityGeometry(image,composite_geometry,&geometry, exception); if (rotate_image == (Image *) NULL) CompositeImageChannel(image,channel,compose,composite_image, geometry.x,geometry.y); else { /* Rotate image. */ geometry.x-=(ssize_t) (rotate_image->columns- composite_image->columns)/2; geometry.y-=(ssize_t) (rotate_image->rows-composite_image->rows)/2; CompositeImageChannel(image,channel,compose,rotate_image, geometry.x,geometry.y); rotate_image=DestroyImage(rotate_image); } composite_image=DestroyImage(composite_image); break; } if (LocaleCompare((const char *) tag,"contrast") == 0) { MagickBooleanType sharpen; /* Contrast image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } sharpen=MagickFalse; if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'S': case 's': { if (LocaleCompare(keyword,"sharpen") == 0) { option=ParseCommandOption(MagickBooleanOptions,MagickFalse, value); if (option < 0) ThrowMSLException(OptionError,"UnrecognizedBooleanType", value); sharpen=(MagickBooleanType) option; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } (void) ContrastImage(msl_info->image[n],sharpen); break; } if (LocaleCompare((const char *) tag,"crop") == 0) { Image *crop_image; /* Crop image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } SetGeometry(msl_info->image[n],&geometry); if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'G': case 'g': { if (LocaleCompare(keyword,"geometry") == 0) { flags=ParseGravityGeometry(msl_info->image[n],value, &geometry,exception); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'H': case 'h': { if (LocaleCompare(keyword,"height") == 0) { geometry.height=StringToLong(value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'W': case 'w': { if (LocaleCompare(keyword,"width") == 0) { geometry.width=StringToLong(value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'X': case 'x': { if (LocaleCompare(keyword,"x") == 0) { geometry.x=StringToLong(value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'Y': case 'y': { if (LocaleCompare(keyword,"y") == 0) { geometry.y=StringToLong(value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } crop_image=CropImage(msl_info->image[n],&geometry, &msl_info->image[n]->exception); if (crop_image == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); msl_info->image[n]=crop_image; break; } if (LocaleCompare((const char *) tag,"cycle-colormap") == 0) { ssize_t display; /* Cycle-colormap image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } display=0; if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'D': case 'd': { if (LocaleCompare(keyword,"display") == 0) { display=StringToLong(value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } (void) CycleColormapImage(msl_info->image[n],display); break; } ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag); } case 'D': case 'd': { if (LocaleCompare((const char *) tag,"despeckle") == 0) { Image *despeckle_image; /* Despeckle image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); } despeckle_image=DespeckleImage(msl_info->image[n], &msl_info->image[n]->exception); if (despeckle_image == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); msl_info->image[n]=despeckle_image; break; } if (LocaleCompare((const char *) tag,"display") == 0) { if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } (void) DisplayImages(msl_info->image_info[n],msl_info->image[n]); break; } if (LocaleCompare((const char *) tag,"draw") == 0) { char text[MaxTextExtent]; /* Annotate image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } draw_info=CloneDrawInfo(msl_info->image_info[n], msl_info->draw_info[n]); angle=0.0; current=draw_info->affine; GetAffineMatrix(&affine); if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'A': case 'a': { if (LocaleCompare(keyword,"affine") == 0) { char *p; p=value; draw_info->affine.sx=StringToDouble(p,&p); if (*p ==',') p++; draw_info->affine.rx=StringToDouble(p,&p); if (*p ==',') p++; draw_info->affine.ry=StringToDouble(p,&p); if (*p ==',') p++; draw_info->affine.sy=StringToDouble(p,&p); if (*p ==',') p++; draw_info->affine.tx=StringToDouble(p,&p); if (*p ==',') p++; draw_info->affine.ty=StringToDouble(p,&p); break; } if (LocaleCompare(keyword,"align") == 0) { option=ParseCommandOption(MagickAlignOptions,MagickFalse, value); if (option < 0) ThrowMSLException(OptionError,"UnrecognizedAlignType", value); draw_info->align=(AlignType) option; break; } if (LocaleCompare(keyword,"antialias") == 0) { option=ParseCommandOption(MagickBooleanOptions,MagickFalse, value); if (option < 0) ThrowMSLException(OptionError,"UnrecognizedBooleanType", value); draw_info->stroke_antialias=(MagickBooleanType) option; draw_info->text_antialias=(MagickBooleanType) option; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'D': case 'd': { if (LocaleCompare(keyword,"density") == 0) { CloneString(&draw_info->density,value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'E': case 'e': { if (LocaleCompare(keyword,"encoding") == 0) { CloneString(&draw_info->encoding,value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'F': case 'f': { if (LocaleCompare(keyword, "fill") == 0) { (void) QueryColorDatabase(value,&draw_info->fill, exception); break; } if (LocaleCompare(keyword,"family") == 0) { CloneString(&draw_info->family,value); break; } if (LocaleCompare(keyword,"font") == 0) { CloneString(&draw_info->font,value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'G': case 'g': { if (LocaleCompare(keyword,"geometry") == 0) { flags=ParsePageGeometry(msl_info->image[n],value, &geometry,exception); if ((flags & HeightValue) == 0) geometry.height=geometry.width; break; } if (LocaleCompare(keyword,"gravity") == 0) { option=ParseCommandOption(MagickGravityOptions,MagickFalse, value); if (option < 0) ThrowMSLException(OptionError,"UnrecognizedGravityType", value); draw_info->gravity=(GravityType) option; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'P': case 'p': { if (LocaleCompare(keyword,"points") == 0) { if (LocaleCompare(draw_info->primitive,"path") == 0) { (void) ConcatenateString(&draw_info->primitive," '"); ConcatenateString(&draw_info->primitive,value); (void) ConcatenateString(&draw_info->primitive,"'"); } else { (void) ConcatenateString(&draw_info->primitive," "); ConcatenateString(&draw_info->primitive,value); } break; } if (LocaleCompare(keyword,"pointsize") == 0) { draw_info->pointsize=StringToDouble(value, (char **) NULL); break; } if (LocaleCompare(keyword,"primitive") == 0) { CloneString(&draw_info->primitive,value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'R': case 'r': { if (LocaleCompare(keyword,"rotate") == 0) { angle=StringToDouble(value,(char **) NULL); affine.sx=cos(DegreesToRadians(fmod(angle,360.0))); affine.rx=sin(DegreesToRadians(fmod(angle,360.0))); affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0)))); affine.sy=cos(DegreesToRadians(fmod(angle,360.0))); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'S': case 's': { if (LocaleCompare(keyword,"scale") == 0) { flags=ParseGeometry(value,&geometry_info); if ((flags & SigmaValue) == 0) geometry_info.sigma=1.0; affine.sx=geometry_info.rho; affine.sy=geometry_info.sigma; break; } if (LocaleCompare(keyword,"skewX") == 0) { angle=StringToDouble(value,(char **) NULL); affine.ry=cos(DegreesToRadians(fmod(angle,360.0))); break; } if (LocaleCompare(keyword,"skewY") == 0) { angle=StringToDouble(value,(char **) NULL); affine.rx=cos(DegreesToRadians(fmod(angle,360.0))); break; } if (LocaleCompare(keyword,"stretch") == 0) { option=ParseCommandOption(MagickStretchOptions,MagickFalse, value); if (option < 0) ThrowMSLException(OptionError,"UnrecognizedStretchType", value); draw_info->stretch=(StretchType) option; break; } if (LocaleCompare(keyword, "stroke") == 0) { (void) QueryColorDatabase(value,&draw_info->stroke, exception); break; } if (LocaleCompare(keyword,"strokewidth") == 0) { draw_info->stroke_width=StringToLong(value); break; } if (LocaleCompare(keyword,"style") == 0) { option=ParseCommandOption(MagickStyleOptions,MagickFalse, value); if (option < 0) ThrowMSLException(OptionError,"UnrecognizedStyleType", value); draw_info->style=(StyleType) option; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'T': case 't': { if (LocaleCompare(keyword,"text") == 0) { (void) ConcatenateString(&draw_info->primitive," '"); (void) ConcatenateString(&draw_info->primitive,value); (void) ConcatenateString(&draw_info->primitive,"'"); break; } if (LocaleCompare(keyword,"translate") == 0) { flags=ParseGeometry(value,&geometry_info); if ((flags & SigmaValue) == 0) geometry_info.sigma=1.0; affine.tx=geometry_info.rho; affine.ty=geometry_info.sigma; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'U': case 'u': { if (LocaleCompare(keyword, "undercolor") == 0) { (void) QueryColorDatabase(value,&draw_info->undercolor, exception); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'W': case 'w': { if (LocaleCompare(keyword,"weight") == 0) { draw_info->weight=StringToLong(value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'X': case 'x': { if (LocaleCompare(keyword,"x") == 0) { geometry.x=StringToLong(value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'Y': case 'y': { if (LocaleCompare(keyword,"y") == 0) { geometry.y=StringToLong(value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } (void) FormatLocaleString(text,MaxTextExtent, "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double) geometry.height,(double) geometry.x,(double) geometry.y); CloneString(&draw_info->geometry,text); draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx; draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx; draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy; draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy; draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+ affine.tx; draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+ affine.ty; (void) DrawImage(msl_info->image[n],draw_info); draw_info=DestroyDrawInfo(draw_info); break; } ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag); } case 'E': case 'e': { if (LocaleCompare((const char *) tag,"edge") == 0) { Image *edge_image; /* Edge image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'G': case 'g': { if (LocaleCompare(keyword,"geometry") == 0) { flags=ParseGeometry(value,&geometry_info); if ((flags & SigmaValue) == 0) geometry_info.sigma=1.0; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'R': case 'r': { if (LocaleCompare(keyword,"radius") == 0) { geometry_info.rho=StringToDouble(value, (char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } edge_image=EdgeImage(msl_info->image[n],geometry_info.rho, &msl_info->image[n]->exception); if (edge_image == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); msl_info->image[n]=edge_image; break; } if (LocaleCompare((const char *) tag,"emboss") == 0) { Image *emboss_image; /* Emboss image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'G': case 'g': { if (LocaleCompare(keyword,"geometry") == 0) { flags=ParseGeometry(value,&geometry_info); if ((flags & SigmaValue) == 0) geometry_info.sigma=1.0; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'R': case 'r': { if (LocaleCompare(keyword,"radius") == 0) { geometry_info.rho=StringToDouble(value, (char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'S': case 's': { if (LocaleCompare(keyword,"sigma") == 0) { geometry_info.sigma=StringToLong(value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } emboss_image=EmbossImage(msl_info->image[n],geometry_info.rho, geometry_info.sigma,&msl_info->image[n]->exception); if (emboss_image == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); msl_info->image[n]=emboss_image; break; } if (LocaleCompare((const char *) tag,"enhance") == 0) { Image *enhance_image; /* Enhance image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); } enhance_image=EnhanceImage(msl_info->image[n], &msl_info->image[n]->exception); if (enhance_image == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); msl_info->image[n]=enhance_image; break; } if (LocaleCompare((const char *) tag,"equalize") == 0) { /* Equalize image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } (void) EqualizeImage(msl_info->image[n]); break; } ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag); } case 'F': case 'f': { if (LocaleCompare((const char *) tag, "flatten") == 0) { if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } /* no attributes here */ /* process the image */ { Image *newImage; newImage=MergeImageLayers(msl_info->image[n],FlattenLayer, &msl_info->image[n]->exception); if (newImage == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); msl_info->image[n]=newImage; break; } } if (LocaleCompare((const char *) tag,"flip") == 0) { Image *flip_image; /* Flip image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); } flip_image=FlipImage(msl_info->image[n], &msl_info->image[n]->exception); if (flip_image == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); msl_info->image[n]=flip_image; break; } if (LocaleCompare((const char *) tag,"flop") == 0) { Image *flop_image; /* Flop image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); } flop_image=FlopImage(msl_info->image[n], &msl_info->image[n]->exception); if (flop_image == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); msl_info->image[n]=flop_image; break; } if (LocaleCompare((const char *) tag,"frame") == 0) { FrameInfo frame_info; Image *frame_image; /* Frame image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } (void) ResetMagickMemory(&frame_info,0,sizeof(frame_info)); SetGeometry(msl_info->image[n],&geometry); if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'C': case 'c': { if (LocaleCompare(keyword,"compose") == 0) { option=ParseCommandOption(MagickComposeOptions, MagickFalse,value); if (option < 0) ThrowMSLException(OptionError,"UnrecognizedComposeType", value); msl_info->image[n]->compose=(CompositeOperator) option; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'F': case 'f': { if (LocaleCompare(keyword, "fill") == 0) { (void) QueryColorDatabase(value, &msl_info->image[n]->matte_color,exception); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'G': case 'g': { if (LocaleCompare(keyword,"geometry") == 0) { flags=ParsePageGeometry(msl_info->image[n],value, &geometry,exception); if ((flags & HeightValue) == 0) geometry.height=geometry.width; frame_info.width=geometry.width; frame_info.height=geometry.height; frame_info.outer_bevel=geometry.x; frame_info.inner_bevel=geometry.y; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'H': case 'h': { if (LocaleCompare(keyword,"height") == 0) { frame_info.height=StringToLong(value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'I': case 'i': { if (LocaleCompare(keyword,"inner") == 0) { frame_info.inner_bevel=StringToLong(value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'O': case 'o': { if (LocaleCompare(keyword,"outer") == 0) { frame_info.outer_bevel=StringToLong(value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'W': case 'w': { if (LocaleCompare(keyword,"width") == 0) { frame_info.width=StringToLong(value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } frame_info.x=(ssize_t) frame_info.width; frame_info.y=(ssize_t) frame_info.height; frame_info.width=msl_info->image[n]->columns+2*frame_info.x; frame_info.height=msl_info->image[n]->rows+2*frame_info.y; frame_image=FrameImage(msl_info->image[n],&frame_info, &msl_info->image[n]->exception); if (frame_image == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); msl_info->image[n]=frame_image; break; } ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag); } case 'G': case 'g': { if (LocaleCompare((const char *) tag,"gamma") == 0) { char gamma[MaxTextExtent]; MagickPixelPacket pixel; /* Gamma image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } channel=UndefinedChannel; pixel.red=0.0; pixel.green=0.0; pixel.blue=0.0; *gamma='\0'; if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'B': case 'b': { if (LocaleCompare(keyword,"blue") == 0) { pixel.blue=StringToDouble(value,(char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'C': case 'c': { if (LocaleCompare(keyword,"channel") == 0) { option=ParseChannelOption(value); if (option < 0) ThrowMSLException(OptionError,"UnrecognizedChannelType", value); channel=(ChannelType) option; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'G': case 'g': { if (LocaleCompare(keyword,"gamma") == 0) { (void) CopyMagickString(gamma,value,MaxTextExtent); break; } if (LocaleCompare(keyword,"green") == 0) { pixel.green=StringToDouble(value,(char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'R': case 'r': { if (LocaleCompare(keyword,"red") == 0) { pixel.red=StringToDouble(value,(char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } if (*gamma == '\0') (void) FormatLocaleString(gamma,MaxTextExtent,"%g,%g,%g", (double) pixel.red,(double) pixel.green,(double) pixel.blue); switch (channel) { default: { (void) GammaImage(msl_info->image[n],gamma); break; } case RedChannel: { (void) GammaImageChannel(msl_info->image[n],RedChannel,pixel.red); break; } case GreenChannel: { (void) GammaImageChannel(msl_info->image[n],GreenChannel, pixel.green); break; } case BlueChannel: { (void) GammaImageChannel(msl_info->image[n],BlueChannel, pixel.blue); break; } } break; } else if (LocaleCompare((const char *) tag,"get") == 0) { if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } if (attributes == (const xmlChar **) NULL) break; for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; CloneString(&value,(const char *) attributes[i]); (void) CopyMagickString(key,value,MaxTextExtent); switch (*keyword) { case 'H': case 'h': { if (LocaleCompare(keyword,"height") == 0) { (void) FormatLocaleString(value,MaxTextExtent,"%.20g", (double) msl_info->image[n]->rows); (void) SetImageProperty(msl_info->attributes[n],key,value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); } case 'W': case 'w': { if (LocaleCompare(keyword,"width") == 0) { (void) FormatLocaleString(value,MaxTextExtent,"%.20g", (double) msl_info->image[n]->columns); (void) SetImageProperty(msl_info->attributes[n],key,value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } } } break; } else if (LocaleCompare((const char *) tag, "group") == 0) { msl_info->number_groups++; msl_info->group_info=(MSLGroupInfo *) ResizeQuantumMemory( msl_info->group_info,msl_info->number_groups+1UL, sizeof(*msl_info->group_info)); break; } ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag); } case 'I': case 'i': { if (LocaleCompare((const char *) tag,"image") == 0) { MSLPushImage(msl_info,(Image *) NULL); if (attributes == (const xmlChar **) NULL) break; for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; CloneString(&value,InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i])); switch (*keyword) { case 'C': case 'c': { if (LocaleCompare(keyword,"color") == 0) { Image *next_image; (void) CopyMagickString(msl_info->image_info[n]->filename, "xc:",MaxTextExtent); (void) ConcatenateMagickString(msl_info->image_info[n]-> filename,value,MaxTextExtent); next_image=ReadImage(msl_info->image_info[n],exception); CatchException(exception); if (next_image == (Image *) NULL) continue; if (msl_info->image[n] == (Image *) NULL) msl_info->image[n]=next_image; else { register Image *p; /* Link image into image list. */ p=msl_info->image[n]; while (p->next != (Image *) NULL) p=GetNextImageInList(p); next_image->previous=p; p->next=next_image; } break; } (void) SetMSLAttributes(msl_info,keyword,value); break; } default: { (void) SetMSLAttributes(msl_info,keyword,value); break; } } } break; } if (LocaleCompare((const char *) tag,"implode") == 0) { Image *implode_image; /* Implode image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'A': case 'a': { if (LocaleCompare(keyword,"amount") == 0) { geometry_info.rho=StringToDouble(value, (char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'G': case 'g': { if (LocaleCompare(keyword,"geometry") == 0) { flags=ParseGeometry(value,&geometry_info); if ((flags & SigmaValue) == 0) geometry_info.sigma=1.0; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } implode_image=ImplodeImage(msl_info->image[n],geometry_info.rho, &msl_info->image[n]->exception); if (implode_image == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); msl_info->image[n]=implode_image; break; } ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag); } case 'L': case 'l': { if (LocaleCompare((const char *) tag,"label") == 0) break; if (LocaleCompare((const char *) tag, "level") == 0) { double levelBlack = 0, levelGamma = 1, levelWhite = QuantumRange; if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } if (attributes == (const xmlChar **) NULL) break; for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; CloneString(&value,(const char *) attributes[i]); (void) CopyMagickString(key,value,MaxTextExtent); switch (*keyword) { case 'B': case 'b': { if (LocaleCompare(keyword,"black") == 0) { levelBlack = StringToDouble(value,(char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } case 'G': case 'g': { if (LocaleCompare(keyword,"gamma") == 0) { levelGamma = StringToDouble(value,(char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } case 'W': case 'w': { if (LocaleCompare(keyword,"white") == 0) { levelWhite = StringToDouble(value,(char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } } } /* process image */ { char level[MaxTextExtent + 1]; (void) FormatLocaleString(level,MaxTextExtent,"%3.6f/%3.6f/%3.6f/", levelBlack,levelGamma,levelWhite); LevelImage ( msl_info->image[n], level ); break; } } } case 'M': case 'm': { if (LocaleCompare((const char *) tag,"magnify") == 0) { Image *magnify_image; /* Magnify image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); } magnify_image=MagnifyImage(msl_info->image[n], &msl_info->image[n]->exception); if (magnify_image == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); msl_info->image[n]=magnify_image; break; } if (LocaleCompare((const char *) tag,"map") == 0) { Image *affinity_image; MagickBooleanType dither; QuantizeInfo *quantize_info; /* Map image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } affinity_image=NewImageList(); dither=MagickFalse; if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'D': case 'd': { if (LocaleCompare(keyword,"dither") == 0) { option=ParseCommandOption(MagickBooleanOptions,MagickFalse, value); if (option < 0) ThrowMSLException(OptionError,"UnrecognizedBooleanType", value); dither=(MagickBooleanType) option; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'I': case 'i': { if (LocaleCompare(keyword,"image") == 0) for (j=0; j < msl_info->n; j++) { const char *attribute; attribute=GetImageProperty(msl_info->attributes[j],"id"); if ((attribute != (const char *) NULL) && (LocaleCompare(attribute,value) == 0)) { affinity_image=CloneImage(msl_info->image[j],0,0, MagickFalse,exception); break; } } break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } quantize_info=AcquireQuantizeInfo(msl_info->image_info[n]); quantize_info->dither=dither; (void) RemapImages(quantize_info,msl_info->image[n], affinity_image); quantize_info=DestroyQuantizeInfo(quantize_info); affinity_image=DestroyImage(affinity_image); break; } if (LocaleCompare((const char *) tag,"matte-floodfill") == 0) { double opacity; MagickPixelPacket target; PaintMethod paint_method; /* Matte floodfill image. */ opacity=0.0; if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } SetGeometry(msl_info->image[n],&geometry); paint_method=FloodfillMethod; if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'B': case 'b': { if (LocaleCompare(keyword,"bordercolor") == 0) { (void) QueryMagickColor(value,&target,exception); paint_method=FillToBorderMethod; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'F': case 'f': { if (LocaleCompare(keyword,"fuzz") == 0) { msl_info->image[n]->fuzz=StringToDouble(value, (char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'G': case 'g': { if (LocaleCompare(keyword,"geometry") == 0) { flags=ParsePageGeometry(msl_info->image[n],value, &geometry,exception); if ((flags & HeightValue) == 0) geometry.height=geometry.width; (void) GetOneVirtualMagickPixel(msl_info->image[n], geometry.x,geometry.y,&target,exception); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'O': case 'o': { if (LocaleCompare(keyword,"opacity") == 0) { opacity=StringToDouble(value,(char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'X': case 'x': { if (LocaleCompare(keyword,"x") == 0) { geometry.x=StringToLong(value); (void) GetOneVirtualMagickPixel(msl_info->image[n], geometry.x,geometry.y,&target,exception); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'Y': case 'y': { if (LocaleCompare(keyword,"y") == 0) { geometry.y=StringToLong(value); (void) GetOneVirtualMagickPixel(msl_info->image[n], geometry.x,geometry.y,&target,exception); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } draw_info=CloneDrawInfo(msl_info->image_info[n], msl_info->draw_info[n]); draw_info->fill.opacity=ClampToQuantum(opacity); (void) FloodfillPaintImage(msl_info->image[n],OpacityChannel, draw_info,&target,geometry.x,geometry.y, paint_method == FloodfillMethod ? MagickFalse : MagickTrue); draw_info=DestroyDrawInfo(draw_info); break; } if (LocaleCompare((const char *) tag,"median-filter") == 0) { Image *median_image; /* Median-filter image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'G': case 'g': { if (LocaleCompare(keyword,"geometry") == 0) { flags=ParseGeometry(value,&geometry_info); if ((flags & SigmaValue) == 0) geometry_info.sigma=1.0; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'R': case 'r': { if (LocaleCompare(keyword,"radius") == 0) { geometry_info.rho=StringToDouble(value, (char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } median_image=StatisticImage(msl_info->image[n],MedianStatistic, (size_t) geometry_info.rho,(size_t) geometry_info.sigma, &msl_info->image[n]->exception); if (median_image == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); msl_info->image[n]=median_image; break; } if (LocaleCompare((const char *) tag,"minify") == 0) { Image *minify_image; /* Minify image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); } minify_image=MinifyImage(msl_info->image[n], &msl_info->image[n]->exception); if (minify_image == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); msl_info->image[n]=minify_image; break; } if (LocaleCompare((const char *) tag,"msl") == 0 ) break; if (LocaleCompare((const char *) tag,"modulate") == 0) { char modulate[MaxTextExtent]; /* Modulate image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } geometry_info.rho=100.0; geometry_info.sigma=100.0; geometry_info.xi=100.0; if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'B': case 'b': { if (LocaleCompare(keyword,"blackness") == 0) { geometry_info.rho=StringToDouble(value, (char **) NULL); break; } if (LocaleCompare(keyword,"brightness") == 0) { geometry_info.rho=StringToDouble(value, (char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'F': case 'f': { if (LocaleCompare(keyword,"factor") == 0) { flags=ParseGeometry(value,&geometry_info); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'H': case 'h': { if (LocaleCompare(keyword,"hue") == 0) { geometry_info.xi=StringToDouble(value, (char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'L': case 'l': { if (LocaleCompare(keyword,"lightness") == 0) { geometry_info.rho=StringToDouble(value, (char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'S': case 's': { if (LocaleCompare(keyword,"saturation") == 0) { geometry_info.sigma=StringToDouble(value, (char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'W': case 'w': { if (LocaleCompare(keyword,"whiteness") == 0) { geometry_info.sigma=StringToDouble(value, (char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } (void) FormatLocaleString(modulate,MaxTextExtent,"%g,%g,%g", geometry_info.rho,geometry_info.sigma,geometry_info.xi); (void) ModulateImage(msl_info->image[n],modulate); break; } ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag); } case 'N': case 'n': { if (LocaleCompare((const char *) tag,"negate") == 0) { MagickBooleanType gray; /* Negate image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } gray=MagickFalse; if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'C': case 'c': { if (LocaleCompare(keyword,"channel") == 0) { option=ParseChannelOption(value); if (option < 0) ThrowMSLException(OptionError,"UnrecognizedChannelType", value); channel=(ChannelType) option; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'G': case 'g': { if (LocaleCompare(keyword,"gray") == 0) { option=ParseCommandOption(MagickBooleanOptions,MagickFalse, value); if (option < 0) ThrowMSLException(OptionError,"UnrecognizedBooleanType", value); gray=(MagickBooleanType) option; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } (void) NegateImageChannel(msl_info->image[n],channel,gray); break; } if (LocaleCompare((const char *) tag,"normalize") == 0) { /* Normalize image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'C': case 'c': { if (LocaleCompare(keyword,"channel") == 0) { option=ParseChannelOption(value); if (option < 0) ThrowMSLException(OptionError,"UnrecognizedChannelType", value); channel=(ChannelType) option; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } (void) NormalizeImageChannel(msl_info->image[n],channel); break; } ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag); } case 'O': case 'o': { if (LocaleCompare((const char *) tag,"oil-paint") == 0) { Image *paint_image; /* Oil-paint image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'G': case 'g': { if (LocaleCompare(keyword,"geometry") == 0) { flags=ParseGeometry(value,&geometry_info); if ((flags & SigmaValue) == 0) geometry_info.sigma=1.0; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'R': case 'r': { if (LocaleCompare(keyword,"radius") == 0) { geometry_info.rho=StringToDouble(value, (char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } paint_image=OilPaintImage(msl_info->image[n],geometry_info.rho, &msl_info->image[n]->exception); if (paint_image == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); msl_info->image[n]=paint_image; break; } if (LocaleCompare((const char *) tag,"opaque") == 0) { MagickPixelPacket fill_color, target; /* Opaque image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } (void) QueryMagickColor("none",&target,exception); (void) QueryMagickColor("none",&fill_color,exception); if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'C': case 'c': { if (LocaleCompare(keyword,"channel") == 0) { option=ParseChannelOption(value); if (option < 0) ThrowMSLException(OptionError,"UnrecognizedChannelType", value); channel=(ChannelType) option; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'F': case 'f': { if (LocaleCompare(keyword,"fill") == 0) { (void) QueryMagickColor(value,&fill_color,exception); break; } if (LocaleCompare(keyword,"fuzz") == 0) { msl_info->image[n]->fuzz=StringToDouble(value, (char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } (void) OpaquePaintImageChannel(msl_info->image[n],channel, &target,&fill_color,MagickFalse); break; } ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag); } case 'P': case 'p': { if (LocaleCompare((const char *) tag,"print") == 0) { if (attributes == (const xmlChar **) NULL) break; for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'O': case 'o': { if (LocaleCompare(keyword,"output") == 0) { (void) FormatLocaleFile(stdout,"%s",value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } } } break; } if (LocaleCompare((const char *) tag, "profile") == 0) { if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } if (attributes == (const xmlChar **) NULL) break; for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { const char *name; const StringInfo *profile; Image *profile_image; ImageInfo *profile_info; keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); if (*keyword == '!') { /* Remove a profile from the image. */ (void) ProfileImage(msl_info->image[n],keyword, (const unsigned char *) NULL,0,MagickTrue); continue; } /* Associate a profile with the image. */ profile_info=CloneImageInfo(msl_info->image_info[n]); profile=GetImageProfile(msl_info->image[n],"iptc"); if (profile != (StringInfo *) NULL) profile_info->profile=(void *) CloneStringInfo(profile); profile_image=GetImageCache(profile_info,keyword,exception); profile_info=DestroyImageInfo(profile_info); if (profile_image == (Image *) NULL) { char name[MaxTextExtent], filename[MaxTextExtent]; register char *p; StringInfo *profile; (void) CopyMagickString(filename,keyword,MaxTextExtent); (void) CopyMagickString(name,keyword,MaxTextExtent); for (p=filename; *p != '\0'; p++) if ((*p == ':') && (IsPathDirectory(keyword) < 0) && (IsPathAccessible(keyword) == MagickFalse)) { register char *q; /* Look for profile name (e.g. name:profile). */ (void) CopyMagickString(name,filename,(size_t) (p-filename+1)); for (q=filename; *q != '\0'; q++) *q=(*++p); break; } profile=FileToStringInfo(filename,~0UL,exception); if (profile != (StringInfo *) NULL) { (void) ProfileImage(msl_info->image[n],name, GetStringInfoDatum(profile),(size_t) GetStringInfoLength(profile),MagickFalse); profile=DestroyStringInfo(profile); } continue; } ResetImageProfileIterator(profile_image); name=GetNextImageProfile(profile_image); while (name != (const char *) NULL) { profile=GetImageProfile(profile_image,name); if (profile != (StringInfo *) NULL) (void) ProfileImage(msl_info->image[n],name, GetStringInfoDatum(profile),(size_t) GetStringInfoLength(profile),MagickFalse); name=GetNextImageProfile(profile_image); } profile_image=DestroyImage(profile_image); } break; } ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag); } case 'Q': case 'q': { if (LocaleCompare((const char *) tag,"quantize") == 0) { QuantizeInfo quantize_info; /* Quantize image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } GetQuantizeInfo(&quantize_info); if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'C': case 'c': { if (LocaleCompare(keyword,"colors") == 0) { quantize_info.number_colors=StringToLong(value); break; } if (LocaleCompare(keyword,"colorspace") == 0) { option=ParseCommandOption(MagickColorspaceOptions, MagickFalse,value); if (option < 0) ThrowMSLException(OptionError, "UnrecognizedColorspaceType",value); quantize_info.colorspace=(ColorspaceType) option; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'D': case 'd': { if (LocaleCompare(keyword,"dither") == 0) { option=ParseCommandOption(MagickBooleanOptions,MagickFalse, value); if (option < 0) ThrowMSLException(OptionError,"UnrecognizedBooleanType", value); quantize_info.dither=(MagickBooleanType) option; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'M': case 'm': { if (LocaleCompare(keyword,"measure") == 0) { option=ParseCommandOption(MagickBooleanOptions,MagickFalse, value); if (option < 0) ThrowMSLException(OptionError,"UnrecognizedBooleanType", value); quantize_info.measure_error=(MagickBooleanType) option; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'T': case 't': { if (LocaleCompare(keyword,"treedepth") == 0) { quantize_info.tree_depth=StringToLong(value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } (void) QuantizeImage(&quantize_info,msl_info->image[n]); break; } if (LocaleCompare((const char *) tag,"query-font-metrics") == 0) { char text[MaxTextExtent]; MagickBooleanType status; TypeMetric metrics; /* Query font metrics. */ draw_info=CloneDrawInfo(msl_info->image_info[n], msl_info->draw_info[n]); angle=0.0; current=draw_info->affine; GetAffineMatrix(&affine); if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'A': case 'a': { if (LocaleCompare(keyword,"affine") == 0) { char *p; p=value; draw_info->affine.sx=StringToDouble(p,&p); if (*p ==',') p++; draw_info->affine.rx=StringToDouble(p,&p); if (*p ==',') p++; draw_info->affine.ry=StringToDouble(p,&p); if (*p ==',') p++; draw_info->affine.sy=StringToDouble(p,&p); if (*p ==',') p++; draw_info->affine.tx=StringToDouble(p,&p); if (*p ==',') p++; draw_info->affine.ty=StringToDouble(p,&p); break; } if (LocaleCompare(keyword,"align") == 0) { option=ParseCommandOption(MagickAlignOptions,MagickFalse, value); if (option < 0) ThrowMSLException(OptionError,"UnrecognizedAlignType", value); draw_info->align=(AlignType) option; break; } if (LocaleCompare(keyword,"antialias") == 0) { option=ParseCommandOption(MagickBooleanOptions,MagickFalse, value); if (option < 0) ThrowMSLException(OptionError,"UnrecognizedBooleanType", value); draw_info->stroke_antialias=(MagickBooleanType) option; draw_info->text_antialias=(MagickBooleanType) option; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'D': case 'd': { if (LocaleCompare(keyword,"density") == 0) { CloneString(&draw_info->density,value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'E': case 'e': { if (LocaleCompare(keyword,"encoding") == 0) { CloneString(&draw_info->encoding,value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'F': case 'f': { if (LocaleCompare(keyword, "fill") == 0) { (void) QueryColorDatabase(value,&draw_info->fill, exception); break; } if (LocaleCompare(keyword,"family") == 0) { CloneString(&draw_info->family,value); break; } if (LocaleCompare(keyword,"font") == 0) { CloneString(&draw_info->font,value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'G': case 'g': { if (LocaleCompare(keyword,"geometry") == 0) { flags=ParsePageGeometry(msl_info->image[n],value, &geometry,exception); if ((flags & HeightValue) == 0) geometry.height=geometry.width; break; } if (LocaleCompare(keyword,"gravity") == 0) { option=ParseCommandOption(MagickGravityOptions,MagickFalse, value); if (option < 0) ThrowMSLException(OptionError,"UnrecognizedGravityType", value); draw_info->gravity=(GravityType) option; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'P': case 'p': { if (LocaleCompare(keyword,"pointsize") == 0) { draw_info->pointsize=StringToDouble(value, (char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'R': case 'r': { if (LocaleCompare(keyword,"rotate") == 0) { angle=StringToDouble(value,(char **) NULL); affine.sx=cos(DegreesToRadians(fmod(angle,360.0))); affine.rx=sin(DegreesToRadians(fmod(angle,360.0))); affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0)))); affine.sy=cos(DegreesToRadians(fmod(angle,360.0))); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'S': case 's': { if (LocaleCompare(keyword,"scale") == 0) { flags=ParseGeometry(value,&geometry_info); if ((flags & SigmaValue) == 0) geometry_info.sigma=1.0; affine.sx=geometry_info.rho; affine.sy=geometry_info.sigma; break; } if (LocaleCompare(keyword,"skewX") == 0) { angle=StringToDouble(value,(char **) NULL); affine.ry=cos(DegreesToRadians(fmod(angle,360.0))); break; } if (LocaleCompare(keyword,"skewY") == 0) { angle=StringToDouble(value,(char **) NULL); affine.rx=cos(DegreesToRadians(fmod(angle,360.0))); break; } if (LocaleCompare(keyword,"stretch") == 0) { option=ParseCommandOption(MagickStretchOptions,MagickFalse, value); if (option < 0) ThrowMSLException(OptionError,"UnrecognizedStretchType", value); draw_info->stretch=(StretchType) option; break; } if (LocaleCompare(keyword, "stroke") == 0) { (void) QueryColorDatabase(value,&draw_info->stroke, exception); break; } if (LocaleCompare(keyword,"strokewidth") == 0) { draw_info->stroke_width=StringToLong(value); break; } if (LocaleCompare(keyword,"style") == 0) { option=ParseCommandOption(MagickStyleOptions,MagickFalse, value); if (option < 0) ThrowMSLException(OptionError,"UnrecognizedStyleType", value); draw_info->style=(StyleType) option; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'T': case 't': { if (LocaleCompare(keyword,"text") == 0) { CloneString(&draw_info->text,value); break; } if (LocaleCompare(keyword,"translate") == 0) { flags=ParseGeometry(value,&geometry_info); if ((flags & SigmaValue) == 0) geometry_info.sigma=1.0; affine.tx=geometry_info.rho; affine.ty=geometry_info.sigma; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'U': case 'u': { if (LocaleCompare(keyword, "undercolor") == 0) { (void) QueryColorDatabase(value,&draw_info->undercolor, exception); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'W': case 'w': { if (LocaleCompare(keyword,"weight") == 0) { draw_info->weight=StringToLong(value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'X': case 'x': { if (LocaleCompare(keyword,"x") == 0) { geometry.x=StringToLong(value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'Y': case 'y': { if (LocaleCompare(keyword,"y") == 0) { geometry.y=StringToLong(value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } (void) FormatLocaleString(text,MaxTextExtent, "%.20gx%.20g%+.20g%+.20g",(double) geometry.width,(double) geometry.height,(double) geometry.x,(double) geometry.y); CloneString(&draw_info->geometry,text); draw_info->affine.sx=affine.sx*current.sx+affine.ry*current.rx; draw_info->affine.rx=affine.rx*current.sx+affine.sy*current.rx; draw_info->affine.ry=affine.sx*current.ry+affine.ry*current.sy; draw_info->affine.sy=affine.rx*current.ry+affine.sy*current.sy; draw_info->affine.tx=affine.sx*current.tx+affine.ry*current.ty+ affine.tx; draw_info->affine.ty=affine.rx*current.tx+affine.sy*current.ty+ affine.ty; status=GetTypeMetrics(msl_info->attributes[n],draw_info,&metrics); if (status != MagickFalse) { Image *image; image=msl_info->attributes[n]; FormatImageProperty(image,"msl:font-metrics.pixels_per_em.x", "%g",metrics.pixels_per_em.x); FormatImageProperty(image,"msl:font-metrics.pixels_per_em.y", "%g",metrics.pixels_per_em.y); FormatImageProperty(image,"msl:font-metrics.ascent","%g", metrics.ascent); FormatImageProperty(image,"msl:font-metrics.descent","%g", metrics.descent); FormatImageProperty(image,"msl:font-metrics.width","%g", metrics.width); FormatImageProperty(image,"msl:font-metrics.height","%g", metrics.height); FormatImageProperty(image,"msl:font-metrics.max_advance","%g", metrics.max_advance); FormatImageProperty(image,"msl:font-metrics.bounds.x1","%g", metrics.bounds.x1); FormatImageProperty(image,"msl:font-metrics.bounds.y1","%g", metrics.bounds.y1); FormatImageProperty(image,"msl:font-metrics.bounds.x2","%g", metrics.bounds.x2); FormatImageProperty(image,"msl:font-metrics.bounds.y2","%g", metrics.bounds.y2); FormatImageProperty(image,"msl:font-metrics.origin.x","%g", metrics.origin.x); FormatImageProperty(image,"msl:font-metrics.origin.y","%g", metrics.origin.y); } draw_info=DestroyDrawInfo(draw_info); break; } ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag); } case 'R': case 'r': { if (LocaleCompare((const char *) tag,"raise") == 0) { MagickBooleanType raise; /* Raise image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } raise=MagickFalse; SetGeometry(msl_info->image[n],&geometry); if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'G': case 'g': { if (LocaleCompare(keyword,"geometry") == 0) { flags=ParsePageGeometry(msl_info->image[n],value, &geometry,exception); if ((flags & HeightValue) == 0) geometry.height=geometry.width; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'H': case 'h': { if (LocaleCompare(keyword,"height") == 0) { geometry.height=StringToLong(value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'R': case 'r': { if (LocaleCompare(keyword,"raise") == 0) { option=ParseCommandOption(MagickBooleanOptions,MagickFalse, value); if (option < 0) ThrowMSLException(OptionError,"UnrecognizedNoiseType", value); raise=(MagickBooleanType) option; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'W': case 'w': { if (LocaleCompare(keyword,"width") == 0) { geometry.width=StringToLong(value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } (void) RaiseImage(msl_info->image[n],&geometry,raise); break; } if (LocaleCompare((const char *) tag,"read") == 0) { if (attributes == (const xmlChar **) NULL) break; for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; CloneString(&value,InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i])); switch (*keyword) { case 'F': case 'f': { if (LocaleCompare(keyword,"filename") == 0) { Image *image; (void) CopyMagickString(msl_info->image_info[n]->filename, value,MaxTextExtent); image=ReadImage(msl_info->image_info[n],exception); CatchException(exception); if (image == (Image *) NULL) continue; AppendImageToList(&msl_info->image[n],image); break; } (void) SetMSLAttributes(msl_info,keyword,value); break; } default: { (void) SetMSLAttributes(msl_info,keyword,value); break; } } } break; } if (LocaleCompare((const char *) tag,"reduce-noise") == 0) { Image *paint_image; /* Reduce-noise image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'G': case 'g': { if (LocaleCompare(keyword,"geometry") == 0) { flags=ParseGeometry(value,&geometry_info); if ((flags & SigmaValue) == 0) geometry_info.sigma=1.0; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'R': case 'r': { if (LocaleCompare(keyword,"radius") == 0) { geometry_info.rho=StringToDouble(value, (char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } paint_image=StatisticImage(msl_info->image[n],NonpeakStatistic, (size_t) geometry_info.rho,(size_t) geometry_info.sigma, &msl_info->image[n]->exception); if (paint_image == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); msl_info->image[n]=paint_image; break; } else if (LocaleCompare((const char *) tag,"repage") == 0) { /* init the values */ width=msl_info->image[n]->page.width; height=msl_info->image[n]->page.height; x=msl_info->image[n]->page.x; y=msl_info->image[n]->page.y; if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } if (attributes == (const xmlChar **) NULL) break; for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; CloneString(&value,InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i])); switch (*keyword) { case 'G': case 'g': { if (LocaleCompare(keyword,"geometry") == 0) { int flags; RectangleInfo geometry; flags=ParseAbsoluteGeometry(value,&geometry); if ((flags & WidthValue) != 0) { if ((flags & HeightValue) == 0) geometry.height=geometry.width; width=geometry.width; height=geometry.height; } if ((flags & AspectValue) != 0) { if ((flags & XValue) != 0) x+=geometry.x; if ((flags & YValue) != 0) y+=geometry.y; } else { if ((flags & XValue) != 0) { x=geometry.x; if ((width == 0) && (geometry.x > 0)) width=msl_info->image[n]->columns+geometry.x; } if ((flags & YValue) != 0) { y=geometry.y; if ((height == 0) && (geometry.y > 0)) height=msl_info->image[n]->rows+geometry.y; } } break; } ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } case 'H': case 'h': { if (LocaleCompare(keyword,"height") == 0) { height = StringToLong( value ); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } case 'W': case 'w': { if (LocaleCompare(keyword,"width") == 0) { width = StringToLong( value ); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } case 'X': case 'x': { if (LocaleCompare(keyword,"x") == 0) { x = StringToLong( value ); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } case 'Y': case 'y': { if (LocaleCompare(keyword,"y") == 0) { y = StringToLong( value ); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } } } msl_info->image[n]->page.width=width; msl_info->image[n]->page.height=height; msl_info->image[n]->page.x=x; msl_info->image[n]->page.y=y; break; } else if (LocaleCompare((const char *) tag,"resample") == 0) { double x_resolution, y_resolution; if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } if (attributes == (const xmlChar **) NULL) break; x_resolution=DefaultResolution; y_resolution=DefaultResolution; for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; CloneString(&value,InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i])); switch (*keyword) { case 'b': { if (LocaleCompare(keyword,"blur") == 0) { msl_info->image[n]->blur=StringToDouble(value, (char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } case 'G': case 'g': { if (LocaleCompare(keyword,"geometry") == 0) { ssize_t flags; flags=ParseGeometry(value,&geometry_info); if ((flags & SigmaValue) == 0) geometry_info.sigma*=geometry_info.rho; x_resolution=geometry_info.rho; y_resolution=geometry_info.sigma; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } case 'X': case 'x': { if (LocaleCompare(keyword,"x-resolution") == 0) { x_resolution=StringToDouble(value,(char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } case 'Y': case 'y': { if (LocaleCompare(keyword,"y-resolution") == 0) { y_resolution=StringToDouble(value,(char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } } } /* Resample image. */ { double factor; Image *resample_image; factor=1.0; if (msl_info->image[n]->units == PixelsPerCentimeterResolution) factor=2.54; width=(size_t) (x_resolution*msl_info->image[n]->columns/ (factor*(msl_info->image[n]->x_resolution == 0.0 ? DefaultResolution : msl_info->image[n]->x_resolution))+0.5); height=(size_t) (y_resolution*msl_info->image[n]->rows/ (factor*(msl_info->image[n]->y_resolution == 0.0 ? DefaultResolution : msl_info->image[n]->y_resolution))+0.5); resample_image=ResizeImage(msl_info->image[n],width,height, msl_info->image[n]->filter,msl_info->image[n]->blur, &msl_info->image[n]->exception); if (resample_image == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); msl_info->image[n]=resample_image; } break; } if (LocaleCompare((const char *) tag,"resize") == 0) { double blur; FilterTypes filter; Image *resize_image; /* Resize image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } filter=UndefinedFilter; blur=1.0; if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'F': case 'f': { if (LocaleCompare(keyword,"filter") == 0) { option=ParseCommandOption(MagickFilterOptions,MagickFalse, value); if (option < 0) ThrowMSLException(OptionError,"UnrecognizedNoiseType", value); filter=(FilterTypes) option; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'G': case 'g': { if (LocaleCompare(keyword,"geometry") == 0) { flags=ParseRegionGeometry(msl_info->image[n],value, &geometry,exception); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'H': case 'h': { if (LocaleCompare(keyword,"height") == 0) { geometry.height=StringToUnsignedLong(value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'S': case 's': { if (LocaleCompare(keyword,"support") == 0) { blur=StringToDouble(value,(char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'W': case 'w': { if (LocaleCompare(keyword,"width") == 0) { geometry.width=StringToLong(value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } resize_image=ResizeImage(msl_info->image[n],geometry.width, geometry.height,filter,blur,&msl_info->image[n]->exception); if (resize_image == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); msl_info->image[n]=resize_image; break; } if (LocaleCompare((const char *) tag,"roll") == 0) { Image *roll_image; /* Roll image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } SetGeometry(msl_info->image[n],&geometry); if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'G': case 'g': { if (LocaleCompare(keyword,"geometry") == 0) { flags=ParsePageGeometry(msl_info->image[n],value, &geometry,exception); if ((flags & HeightValue) == 0) geometry.height=geometry.width; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'X': case 'x': { if (LocaleCompare(keyword,"x") == 0) { geometry.x=StringToLong(value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'Y': case 'y': { if (LocaleCompare(keyword,"y") == 0) { geometry.y=StringToLong(value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } roll_image=RollImage(msl_info->image[n],geometry.x,geometry.y, &msl_info->image[n]->exception); if (roll_image == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); msl_info->image[n]=roll_image; break; } else if (LocaleCompare((const char *) tag,"roll") == 0) { /* init the values */ width=msl_info->image[n]->columns; height=msl_info->image[n]->rows; x = y = 0; if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } if (attributes == (const xmlChar **) NULL) break; for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; CloneString(&value,InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i])); switch (*keyword) { case 'G': case 'g': { if (LocaleCompare(keyword,"geometry") == 0) { (void) ParseMetaGeometry(value,&x,&y,&width,&height); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } case 'X': case 'x': { if (LocaleCompare(keyword,"x") == 0) { x = StringToLong( value ); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } case 'Y': case 'y': { if (LocaleCompare(keyword,"y") == 0) { y = StringToLong( value ); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } } } /* process image. */ { Image *newImage; newImage=RollImage(msl_info->image[n], x, y, &msl_info->image[n]->exception); if (newImage == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); msl_info->image[n]=newImage; } break; } if (LocaleCompare((const char *) tag,"rotate") == 0) { Image *rotate_image; /* Rotate image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'D': case 'd': { if (LocaleCompare(keyword,"degrees") == 0) { geometry_info.rho=StringToDouble(value, (char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'G': case 'g': { if (LocaleCompare(keyword,"geometry") == 0) { flags=ParseGeometry(value,&geometry_info); if ((flags & SigmaValue) == 0) geometry_info.sigma=1.0; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } rotate_image=RotateImage(msl_info->image[n],geometry_info.rho, &msl_info->image[n]->exception); if (rotate_image == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); msl_info->image[n]=rotate_image; break; } else if (LocaleCompare((const char *) tag,"rotate") == 0) { /* init the values */ double degrees = 0; if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } if (attributes == (const xmlChar **) NULL) break; for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; CloneString(&value,InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i])); switch (*keyword) { case 'D': case 'd': { if (LocaleCompare(keyword,"degrees") == 0) { degrees = StringToDouble(value,(char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } } } /* process image. */ { Image *newImage; newImage=RotateImage(msl_info->image[n], degrees, &msl_info->image[n]->exception); if (newImage == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); msl_info->image[n]=newImage; } break; } ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag); } case 'S': case 's': { if (LocaleCompare((const char *) tag,"sample") == 0) { Image *sample_image; /* Sample image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'G': case 'g': { if (LocaleCompare(keyword,"geometry") == 0) { flags=ParseRegionGeometry(msl_info->image[n],value, &geometry,exception); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'H': case 'h': { if (LocaleCompare(keyword,"height") == 0) { geometry.height=StringToUnsignedLong(value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'W': case 'w': { if (LocaleCompare(keyword,"width") == 0) { geometry.width=StringToLong(value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } sample_image=SampleImage(msl_info->image[n],geometry.width, geometry.height,&msl_info->image[n]->exception); if (sample_image == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); msl_info->image[n]=sample_image; break; } if (LocaleCompare((const char *) tag,"scale") == 0) { Image *scale_image; /* Scale image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'G': case 'g': { if (LocaleCompare(keyword,"geometry") == 0) { flags=ParseRegionGeometry(msl_info->image[n],value, &geometry,exception); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'H': case 'h': { if (LocaleCompare(keyword,"height") == 0) { geometry.height=StringToUnsignedLong(value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'W': case 'w': { if (LocaleCompare(keyword,"width") == 0) { geometry.width=StringToLong(value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } scale_image=ScaleImage(msl_info->image[n],geometry.width, geometry.height,&msl_info->image[n]->exception); if (scale_image == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); msl_info->image[n]=scale_image; break; } if (LocaleCompare((const char *) tag,"segment") == 0) { ColorspaceType colorspace; MagickBooleanType verbose; /* Segment image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } geometry_info.rho=1.0; geometry_info.sigma=1.5; colorspace=sRGBColorspace; verbose=MagickFalse; if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'C': case 'c': { if (LocaleCompare(keyword,"cluster-threshold") == 0) { geometry_info.rho=StringToDouble(value, (char **) NULL); break; } if (LocaleCompare(keyword,"colorspace") == 0) { option=ParseCommandOption(MagickColorspaceOptions, MagickFalse,value); if (option < 0) ThrowMSLException(OptionError, "UnrecognizedColorspaceType",value); colorspace=(ColorspaceType) option; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'G': case 'g': { if (LocaleCompare(keyword,"geometry") == 0) { flags=ParseGeometry(value,&geometry_info); if ((flags & SigmaValue) == 0) geometry_info.sigma=1.5; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'S': case 's': { if (LocaleCompare(keyword,"smoothing-threshold") == 0) { geometry_info.sigma=StringToDouble(value, (char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } (void) SegmentImage(msl_info->image[n],colorspace,verbose, geometry_info.rho,geometry_info.sigma); break; } else if (LocaleCompare((const char *) tag, "set") == 0) { if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag); break; } if (attributes == (const xmlChar **) NULL) break; for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; CloneString(&value,InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i])); switch (*keyword) { case 'C': case 'c': { if (LocaleCompare(keyword,"clip-mask") == 0) { for (j=0; j < msl_info->n; j++) { const char *property; property=GetImageProperty(msl_info->attributes[j],"id"); if (LocaleCompare(property,value) == 0) { SetImageMask(msl_info->image[n],msl_info->image[j]); break; } } break; } if (LocaleCompare(keyword,"clip-path") == 0) { for (j=0; j < msl_info->n; j++) { const char *property; property=GetImageProperty(msl_info->attributes[j],"id"); if (LocaleCompare(property,value) == 0) { SetImageClipMask(msl_info->image[n],msl_info->image[j]); break; } } break; } if (LocaleCompare(keyword,"colorspace") == 0) { ssize_t colorspace; colorspace=(ColorspaceType) ParseCommandOption( MagickColorspaceOptions,MagickFalse,value); if (colorspace < 0) ThrowMSLException(OptionError,"UnrecognizedColorspace", value); (void) TransformImageColorspace(msl_info->image[n], (ColorspaceType) colorspace); break; } (void) SetMSLAttributes(msl_info,keyword,value); (void) SetImageProperty(msl_info->image[n],keyword,value); break; } case 'D': case 'd': { if (LocaleCompare(keyword,"density") == 0) { flags=ParseGeometry(value,&geometry_info); msl_info->image[n]->x_resolution=geometry_info.rho; msl_info->image[n]->y_resolution=geometry_info.sigma; if ((flags & SigmaValue) == 0) msl_info->image[n]->y_resolution= msl_info->image[n]->x_resolution; break; } (void) SetMSLAttributes(msl_info,keyword,value); (void) SetImageProperty(msl_info->image[n],keyword,value); break; } case 'O': case 'o': { if (LocaleCompare(keyword, "opacity") == 0) { ssize_t opac = OpaqueOpacity, len = (ssize_t) strlen( value ); if (value[len-1] == '%') { char tmp[100]; (void) CopyMagickString(tmp,value,len); opac = StringToLong( tmp ); opac = (int)(QuantumRange * ((float)opac/100)); } else opac = StringToLong( value ); (void) SetImageOpacity( msl_info->image[n], (Quantum) opac ); break; } (void) SetMSLAttributes(msl_info,keyword,value); (void) SetImageProperty(msl_info->image[n],keyword,value); break; } case 'P': case 'p': { if (LocaleCompare(keyword, "page") == 0) { char page[MaxTextExtent]; const char *image_option; MagickStatusType flags; RectangleInfo geometry; (void) ResetMagickMemory(&geometry,0,sizeof(geometry)); image_option=GetImageArtifact(msl_info->image[n],"page"); if (image_option != (const char *) NULL) flags=ParseAbsoluteGeometry(image_option,&geometry); flags=ParseAbsoluteGeometry(value,&geometry); (void) FormatLocaleString(page,MaxTextExtent,"%.20gx%.20g", (double) geometry.width,(double) geometry.height); if (((flags & XValue) != 0) || ((flags & YValue) != 0)) (void) FormatLocaleString(page,MaxTextExtent, "%.20gx%.20g%+.20g%+.20g",(double) geometry.width, (double) geometry.height,(double) geometry.x,(double) geometry.y); (void) SetImageOption(msl_info->image_info[n],keyword,page); msl_info->image_info[n]->page=GetPageGeometry(page); break; } (void) SetMSLAttributes(msl_info,keyword,value); (void) SetImageProperty(msl_info->image[n],keyword,value); break; } default: { (void) SetMSLAttributes(msl_info,keyword,value); (void) SetImageProperty(msl_info->image[n],keyword,value); break; } } } break; } if (LocaleCompare((const char *) tag,"shade") == 0) { Image *shade_image; MagickBooleanType gray; /* Shade image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } gray=MagickFalse; if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'A': case 'a': { if (LocaleCompare(keyword,"azimuth") == 0) { geometry_info.rho=StringToDouble(value, (char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'E': case 'e': { if (LocaleCompare(keyword,"elevation") == 0) { geometry_info.sigma=StringToDouble(value, (char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'G': case 'g': { if (LocaleCompare(keyword,"geometry") == 0) { flags=ParseGeometry(value,&geometry_info); if ((flags & SigmaValue) == 0) geometry_info.sigma=1.0; break; } if (LocaleCompare(keyword,"gray") == 0) { option=ParseCommandOption(MagickBooleanOptions,MagickFalse, value); if (option < 0) ThrowMSLException(OptionError,"UnrecognizedNoiseType", value); gray=(MagickBooleanType) option; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } shade_image=ShadeImage(msl_info->image[n],gray,geometry_info.rho, geometry_info.sigma,&msl_info->image[n]->exception); if (shade_image == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); msl_info->image[n]=shade_image; break; } if (LocaleCompare((const char *) tag,"shadow") == 0) { Image *shadow_image; /* Shear image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'G': case 'g': { if (LocaleCompare(keyword,"geometry") == 0) { flags=ParseGeometry(value,&geometry_info); if ((flags & SigmaValue) == 0) geometry_info.sigma=1.0; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'O': case 'o': { if (LocaleCompare(keyword,"opacity") == 0) { geometry_info.rho=StringToLong(value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'S': case 's': { if (LocaleCompare(keyword,"sigma") == 0) { geometry_info.sigma=StringToLong(value); break; } break; } case 'X': case 'x': { if (LocaleCompare(keyword,"x") == 0) { geometry_info.xi=StringToDouble(value, (char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'Y': case 'y': { if (LocaleCompare(keyword,"y") == 0) { geometry_info.psi=StringToLong(value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } shadow_image=ShadowImage(msl_info->image[n],geometry_info.rho, geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-0.5),&msl_info->image[n]->exception); if (shadow_image == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); msl_info->image[n]=shadow_image; break; } if (LocaleCompare((const char *) tag,"sharpen") == 0) { double radius = 0.0, sigma = 1.0; if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } /* NOTE: sharpen can have no attributes, since we use all the defaults! */ if (attributes != (const xmlChar **) NULL) { for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; CloneString(&value,InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i])); switch (*keyword) { case 'R': case 'r': { if (LocaleCompare(keyword, "radius") == 0) { radius = StringToDouble(value,(char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } case 'S': case 's': { if (LocaleCompare(keyword,"sigma") == 0) { sigma = StringToLong( value ); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } } } } /* sharpen image. */ { Image *newImage; newImage=SharpenImage(msl_info->image[n],radius,sigma,&msl_info->image[n]->exception); if (newImage == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); msl_info->image[n]=newImage; break; } } else if (LocaleCompare((const char *) tag,"shave") == 0) { /* init the values */ width = height = 0; x = y = 0; if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } if (attributes == (const xmlChar **) NULL) break; for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; CloneString(&value,InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i])); switch (*keyword) { case 'G': case 'g': { if (LocaleCompare(keyword,"geometry") == 0) { (void) ParseMetaGeometry(value,&x,&y,&width,&height); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } case 'H': case 'h': { if (LocaleCompare(keyword,"height") == 0) { height = StringToLong( value ); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } case 'W': case 'w': { if (LocaleCompare(keyword,"width") == 0) { width = StringToLong( value ); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } } } /* process image. */ { Image *newImage; RectangleInfo rectInfo; rectInfo.height = height; rectInfo.width = width; rectInfo.x = x; rectInfo.y = y; newImage=ShaveImage(msl_info->image[n], &rectInfo, &msl_info->image[n]->exception); if (newImage == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); msl_info->image[n]=newImage; } break; } if (LocaleCompare((const char *) tag,"shear") == 0) { Image *shear_image; /* Shear image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'F': case 'f': { if (LocaleCompare(keyword, "fill") == 0) { (void) QueryColorDatabase(value, &msl_info->image[n]->background_color,exception); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'G': case 'g': { if (LocaleCompare(keyword,"geometry") == 0) { flags=ParseGeometry(value,&geometry_info); if ((flags & SigmaValue) == 0) geometry_info.sigma=1.0; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'X': case 'x': { if (LocaleCompare(keyword,"x") == 0) { geometry_info.rho=StringToDouble(value, (char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'Y': case 'y': { if (LocaleCompare(keyword,"y") == 0) { geometry_info.sigma=StringToLong(value); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } shear_image=ShearImage(msl_info->image[n],geometry_info.rho, geometry_info.sigma,&msl_info->image[n]->exception); if (shear_image == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); msl_info->image[n]=shear_image; break; } if (LocaleCompare((const char *) tag,"signature") == 0) { /* Signature image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } (void) SignatureImage(msl_info->image[n]); break; } if (LocaleCompare((const char *) tag,"solarize") == 0) { /* Solarize image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } geometry_info.rho=QuantumRange/2.0; if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'G': case 'g': { if (LocaleCompare(keyword,"geometry") == 0) { flags=ParseGeometry(value,&geometry_info); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'T': case 't': { if (LocaleCompare(keyword,"threshold") == 0) { geometry_info.rho=StringToDouble(value, (char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } (void) SolarizeImage(msl_info->image[n],geometry_info.rho); break; } if (LocaleCompare((const char *) tag,"spread") == 0) { Image *spread_image; /* Spread image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'G': case 'g': { if (LocaleCompare(keyword,"geometry") == 0) { flags=ParseGeometry(value,&geometry_info); if ((flags & SigmaValue) == 0) geometry_info.sigma=1.0; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'R': case 'r': { if (LocaleCompare(keyword,"radius") == 0) { geometry_info.rho=StringToDouble(value, (char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } spread_image=SpreadImage(msl_info->image[n],geometry_info.rho, &msl_info->image[n]->exception); if (spread_image == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); msl_info->image[n]=spread_image; break; } else if (LocaleCompare((const char *) tag,"stegano") == 0) { Image * watermark = (Image*) NULL; if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } if (attributes == (const xmlChar **) NULL) break; for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; CloneString(&value,InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i])); switch (*keyword) { case 'I': case 'i': { if (LocaleCompare(keyword,"image") == 0) { for (j=0; j<msl_info->n;j++) { const char * theAttr = GetImageProperty(msl_info->attributes[j], "id"); if (theAttr && LocaleCompare(theAttr, value) == 0) { watermark = msl_info->image[j]; break; } } break; } ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } } } /* process image. */ if ( watermark != (Image*) NULL ) { Image *newImage; newImage=SteganoImage(msl_info->image[n], watermark, &msl_info->image[n]->exception); if (newImage == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); msl_info->image[n]=newImage; break; } else ThrowMSLException(OptionError,"MissingWatermarkImage",keyword); } else if (LocaleCompare((const char *) tag,"stereo") == 0) { Image * stereoImage = (Image*) NULL; if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag); break; } if (attributes == (const xmlChar **) NULL) break; for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; CloneString(&value,InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i])); switch (*keyword) { case 'I': case 'i': { if (LocaleCompare(keyword,"image") == 0) { for (j=0; j<msl_info->n;j++) { const char * theAttr = GetImageProperty(msl_info->attributes[j], "id"); if (theAttr && LocaleCompare(theAttr, value) == 0) { stereoImage = msl_info->image[j]; break; } } break; } ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } } } /* process image. */ if ( stereoImage != (Image*) NULL ) { Image *newImage; newImage=StereoImage(msl_info->image[n], stereoImage, &msl_info->image[n]->exception); if (newImage == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); msl_info->image[n]=newImage; break; } else ThrowMSLException(OptionError,"Missing stereo image",keyword); } if (LocaleCompare((const char *) tag,"strip") == 0) { /* Strip image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); } (void) StripImage(msl_info->image[n]); break; } if (LocaleCompare((const char *) tag,"swap") == 0) { Image *p, *q, *swap; ssize_t index, swap_index; if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } index=(-1); swap_index=(-2); if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'G': case 'g': { if (LocaleCompare(keyword,"indexes") == 0) { flags=ParseGeometry(value,&geometry_info); index=(ssize_t) geometry_info.rho; if ((flags & SigmaValue) == 0) swap_index=(ssize_t) geometry_info.sigma; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } /* Swap images. */ p=GetImageFromList(msl_info->image[n],index); q=GetImageFromList(msl_info->image[n],swap_index); if ((p == (Image *) NULL) || (q == (Image *) NULL)) { ThrowMSLException(OptionError,"NoSuchImage",(const char *) tag); break; } swap=CloneImage(p,0,0,MagickTrue,&p->exception); ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,&q->exception)); ReplaceImageInList(&q,swap); msl_info->image[n]=GetFirstImageInList(q); break; } if (LocaleCompare((const char *) tag,"swirl") == 0) { Image *swirl_image; /* Swirl image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'D': case 'd': { if (LocaleCompare(keyword,"degrees") == 0) { geometry_info.rho=StringToDouble(value, (char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } case 'G': case 'g': { if (LocaleCompare(keyword,"geometry") == 0) { flags=ParseGeometry(value,&geometry_info); if ((flags & SigmaValue) == 0) geometry_info.sigma=1.0; break; } ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } swirl_image=SwirlImage(msl_info->image[n],geometry_info.rho, &msl_info->image[n]->exception); if (swirl_image == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); msl_info->image[n]=swirl_image; break; } if (LocaleCompare((const char *) tag,"sync") == 0) { /* Sync image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } (void) SyncImage(msl_info->image[n]); break; } ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag); } case 'T': case 't': { if (LocaleCompare((const char *) tag,"map") == 0) { Image *texture_image; /* Texture image. */ if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } texture_image=NewImageList(); if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; attribute=InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i]); CloneString(&value,attribute); switch (*keyword) { case 'I': case 'i': { if (LocaleCompare(keyword,"image") == 0) for (j=0; j < msl_info->n; j++) { const char *attribute; attribute=GetImageProperty(msl_info->attributes[j],"id"); if ((attribute != (const char *) NULL) && (LocaleCompare(attribute,value) == 0)) { texture_image=CloneImage(msl_info->image[j],0,0, MagickFalse,exception); break; } } break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute", keyword); break; } } } (void) TextureImage(msl_info->image[n],texture_image); texture_image=DestroyImage(texture_image); break; } else if (LocaleCompare((const char *) tag,"threshold") == 0) { /* init the values */ double threshold = 0; if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag); break; } if (attributes == (const xmlChar **) NULL) break; for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; CloneString(&value,InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i])); switch (*keyword) { case 'T': case 't': { if (LocaleCompare(keyword,"threshold") == 0) { threshold = StringToDouble(value,(char **) NULL); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } } } /* process image. */ { BilevelImageChannel(msl_info->image[n], (ChannelType) ((ssize_t) (CompositeChannels &~ (ssize_t) OpacityChannel)), threshold); break; } } else if (LocaleCompare((const char *) tag, "transparent") == 0) { if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag); break; } if (attributes == (const xmlChar **) NULL) break; for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; CloneString(&value,InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i])); switch (*keyword) { case 'C': case 'c': { if (LocaleCompare(keyword,"color") == 0) { MagickPixelPacket target; (void) QueryMagickColor(value,&target,exception); (void) TransparentPaintImage(msl_info->image[n],&target, TransparentOpacity,MagickFalse); break; } ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } default: { ThrowMSLException(OptionError,"UnrecognizedAttribute",keyword); break; } } } break; } else if (LocaleCompare((const char *) tag, "trim") == 0) { if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag); break; } /* no attributes here */ /* process the image */ { Image *newImage; RectangleInfo rectInfo; /* all zeros on a crop == trim edges! */ rectInfo.height = rectInfo.width = 0; rectInfo.x = rectInfo.y = 0; newImage=CropImage(msl_info->image[n],&rectInfo, &msl_info->image[n]->exception); if (newImage == (Image *) NULL) break; msl_info->image[n]=DestroyImage(msl_info->image[n]); msl_info->image[n]=newImage; break; } } ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag); } case 'W': case 'w': { if (LocaleCompare((const char *) tag,"write") == 0) { if (msl_info->image[n] == (Image *) NULL) { ThrowMSLException(OptionError,"NoImagesDefined", (const char *) tag); break; } if (attributes == (const xmlChar **) NULL) break; for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) { keyword=(const char *) attributes[i++]; CloneString(&value,InterpretImageProperties(msl_info->image_info[n], msl_info->attributes[n],(const char *) attributes[i])); switch (*keyword) { case 'F': case 'f': { if (LocaleCompare(keyword,"filename") == 0) { (void) CopyMagickString(msl_info->image[n]->filename,value, MaxTextExtent); break; } (void) SetMSLAttributes(msl_info,keyword,value); } default: { (void) SetMSLAttributes(msl_info,keyword,value); break; } } } /* process */ { *msl_info->image_info[n]->magick='\0'; (void) WriteImage(msl_info->image_info[n], msl_info->image[n]); break; } } ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag); } default: { ThrowMSLException(OptionError,"UnrecognizedElement",(const char *) tag); break; } } if ( value != NULL ) value=DestroyString(value); exception=DestroyExceptionInfo(exception); (void) LogMagickEvent(CoderEvent,GetMagickModule()," )"); } Vulnerability Type: DoS CWE ID: CWE-20 Summary: The MSL interpreter in ImageMagick before 6.9.6-4 allows remote attackers to cause a denial of service (segmentation fault and application crash) via a crafted XML file. Commit Message: Prevent fault in MSL interpreter
Medium
168,537
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: PreconnectedRequestStats::PreconnectedRequestStats(const GURL& origin, bool was_preconnected) : origin(origin), was_preconnected(was_preconnected) {} Vulnerability Type: CWE ID: CWE-125 Summary: Insufficient validation of untrusted input in Skia in Google Chrome prior to 59.0.3071.86 for Linux, Windows, and Mac, and 59.0.3071.92 for Android, allowed a remote attacker to perform an out of bounds memory read via a crafted HTML page. Commit Message: Origins should be represented as url::Origin (not as GURL). As pointed out in //docs/security/origin-vs-url.md, origins should be represented as url::Origin (not as GURL). This CL applies this guideline to predictor-related code and changes the type of the following fields from GURL to url::Origin: - OriginRequestSummary::origin - PreconnectedRequestStats::origin - PreconnectRequest::origin The old code did not depend on any non-origin parts of GURL (like path and/or query). Therefore, this CL has no intended behavior change. Bug: 973885 Change-Id: Idd14590b4834cb9d50c74ed747b595fe1a4ba357 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1895167 Commit-Queue: Łukasz Anforowicz <[email protected]> Reviewed-by: Alex Ilin <[email protected]> Cr-Commit-Position: refs/heads/master@{#716311}
Medium
172,375
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: void lxc_execute_bind_init(struct lxc_conf *conf) { int ret; char path[PATH_MAX], destpath[PATH_MAX], *p; /* If init exists in the container, don't bind mount a static one */ p = choose_init(conf->rootfs.mount); if (p) { free(p); return; } ret = snprintf(path, PATH_MAX, SBINDIR "/init.lxc.static"); if (ret < 0 || ret >= PATH_MAX) { WARN("Path name too long searching for lxc.init.static"); return; } if (!file_exists(path)) { INFO("%s does not exist on host", path); return; } ret = snprintf(destpath, PATH_MAX, "%s%s", conf->rootfs.mount, "/init.lxc.static"); if (ret < 0 || ret >= PATH_MAX) { WARN("Path name too long for container's lxc.init.static"); return; } if (!file_exists(destpath)) { FILE * pathfile = fopen(destpath, "wb"); if (!pathfile) { SYSERROR("Failed to create mount target '%s'", destpath); return; } fclose(pathfile); } ret = mount(path, destpath, "none", MS_BIND, NULL); if (ret < 0) SYSERROR("Failed to bind lxc.init.static into container"); INFO("lxc.init.static bound into container at %s", path); } Vulnerability Type: CWE ID: CWE-59 Summary: lxc-start in lxc before 1.0.8 and 1.1.x before 1.1.4 allows local container administrators to escape AppArmor confinement via a symlink attack on a (1) mount target or (2) bind mount source. Commit Message: CVE-2015-1335: Protect container mounts against symlinks When a container starts up, lxc sets up the container's inital fstree by doing a bunch of mounting, guided by the container configuration file. The container config is owned by the admin or user on the host, so we do not try to guard against bad entries. However, since the mount target is in the container, it's possible that the container admin could divert the mount with symbolic links. This could bypass proper container startup (i.e. confinement of a root-owned container by the restrictive apparmor policy, by diverting the required write to /proc/self/attr/current), or bypass the (path-based) apparmor policy by diverting, say, /proc to /mnt in the container. To prevent this, 1. do not allow mounts to paths containing symbolic links 2. do not allow bind mounts from relative paths containing symbolic links. Details: Define safe_mount which ensures that the container has not inserted any symbolic links into any mount targets for mounts to be done during container setup. The host's mount path may contain symbolic links. As it is under the control of the administrator, that's ok. So safe_mount begins the check for symbolic links after the rootfs->mount, by opening that directory. It opens each directory along the path using openat() relative to the parent directory using O_NOFOLLOW. When the target is reached, it mounts onto /proc/self/fd/<targetfd>. Use safe_mount() in mount_entry(), when mounting container proc, and when needed. In particular, safe_mount() need not be used in any case where: 1. the mount is done in the container's namespace 2. the mount is for the container's rootfs 3. the mount is relative to a tmpfs or proc/sysfs which we have just safe_mount()ed ourselves Since we were using proc/net as a temporary placeholder for /proc/sys/net during container startup, and proc/net is a symbolic link, use proc/tty instead. Update the lxc.container.conf manpage with details about the new restrictions. Finally, add a testcase to test some symbolic link possibilities. Reported-by: Roman Fiedler Signed-off-by: Serge Hallyn <[email protected]> Acked-by: Stéphane Graber <[email protected]>
High
166,712
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: long Chapters::Edition::ParseAtom( IMkvReader* pReader, long long pos, long long size) { if (!ExpandAtomsArray()) return -1; Atom& a = m_atoms[m_atoms_count++]; a.Init(); return a.Parse(pReader, pos, size); } Vulnerability Type: DoS Exec Code Overflow Mem. Corr. CWE ID: CWE-119 Summary: libvpx in mediaserver in Android 4.x before 4.4.4, 5.x before 5.1.1 LMY49H, and 6.0 before 2016-03-01 allows remote attackers to execute arbitrary code or cause a denial of service (memory corruption) via a crafted media file, related to libwebm/mkvparser.cpp and other files, aka internal bug 23452792. Commit Message: libwebm: Pull from upstream Rolling mkvparser from upstream. Primarily for fixing a bug on parsing failures with certain Opus WebM files. Upstream commit hash of this pull: 574045edd4ecbeb802ee3f1d214b5510269852ae The diff is so huge because there were some style clean ups upstream. But it was ensured that there were no breaking changes when the style clean ups was done upstream. Change-Id: Ib6e907175484b4b0ae1b55ab39522ea3188ad039
High
174,415
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: check_entry_size_and_hooks(struct ip6t_entry *e, struct xt_table_info *newinfo, const unsigned char *base, const unsigned char *limit, const unsigned int *hook_entries, const unsigned int *underflows, unsigned int valid_hooks) { unsigned int h; int err; if ((unsigned long)e % __alignof__(struct ip6t_entry) != 0 || (unsigned char *)e + sizeof(struct ip6t_entry) >= limit) { duprintf("Bad offset %p\n", e); return -EINVAL; } if (e->next_offset < sizeof(struct ip6t_entry) + sizeof(struct xt_entry_target)) { duprintf("checking: element %p size %u\n", e, e->next_offset); return -EINVAL; } err = check_entry(e); if (err) return err; /* Check hooks & underflows */ for (h = 0; h < NF_INET_NUMHOOKS; h++) { if (!(valid_hooks & (1 << h))) continue; if ((unsigned char *)e - base == hook_entries[h]) newinfo->hook_entry[h] = hook_entries[h]; if ((unsigned char *)e - base == underflows[h]) { if (!check_underflow(e)) { pr_err("Underflows must be unconditional and " "use the STANDARD target with " "ACCEPT/DROP\n"); return -EINVAL; } newinfo->underflow[h] = underflows[h]; } } /* Clear counters and comefrom */ e->counters = ((struct xt_counters) { 0, 0 }); e->comefrom = 0; return 0; } Vulnerability Type: DoS Overflow +Info CWE ID: CWE-119 Summary: The IPT_SO_SET_REPLACE setsockopt implementation in the netfilter subsystem in the Linux kernel before 4.6 allows local users to cause a denial of service (out-of-bounds read) or possibly obtain sensitive information from kernel heap memory by leveraging in-container root access to provide a crafted offset value that leads to crossing a ruleset blob boundary. Commit Message: netfilter: x_tables: make sure e->next_offset covers remaining blob size Otherwise this function may read data beyond the ruleset blob. Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
Medium
167,214
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: UnacceleratedStaticBitmapImage::UnacceleratedStaticBitmapImage( sk_sp<SkImage> image) { CHECK(image); DCHECK(!image->isLazyGenerated()); paint_image_ = CreatePaintImageBuilder() .set_image(std::move(image), cc::PaintImage::GetNextContentId()) .TakePaintImage(); } Vulnerability Type: Overflow CWE ID: CWE-119 Summary: Incorrect, thread-unsafe use of SkImage in Canvas in Google Chrome prior to 71.0.3578.80 allowed a remote attacker to potentially exploit heap corruption via a crafted HTML page. Commit Message: Fix *StaticBitmapImage ThreadChecker and unaccelerated SkImage destroy - AcceleratedStaticBitmapImage was misusing ThreadChecker by having its own detach logic. Using proper DetachThread is simpler, cleaner and correct. - UnacceleratedStaticBitmapImage didn't destroy the SkImage in the proper thread, leading to GrContext/SkSp problems. Bug: 890576 Change-Id: Ic71e7f7322b0b851774628247aa5256664bc0723 Reviewed-on: https://chromium-review.googlesource.com/c/1307775 Reviewed-by: Gabriel Charette <[email protected]> Reviewed-by: Jeremy Roman <[email protected]> Commit-Queue: Fernando Serboncini <[email protected]> Cr-Commit-Position: refs/heads/master@{#604427}
Medium
172,602
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: static long perf_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { struct perf_event *event = file->private_data; void (*func)(struct perf_event *); u32 flags = arg; switch (cmd) { case PERF_EVENT_IOC_ENABLE: func = perf_event_enable; break; case PERF_EVENT_IOC_DISABLE: func = perf_event_disable; break; case PERF_EVENT_IOC_RESET: func = perf_event_reset; break; case PERF_EVENT_IOC_REFRESH: return perf_event_refresh(event, arg); case PERF_EVENT_IOC_PERIOD: return perf_event_period(event, (u64 __user *)arg); case PERF_EVENT_IOC_ID: { u64 id = primary_event_id(event); if (copy_to_user((void __user *)arg, &id, sizeof(id))) return -EFAULT; return 0; } case PERF_EVENT_IOC_SET_OUTPUT: { int ret; if (arg != -1) { struct perf_event *output_event; struct fd output; ret = perf_fget_light(arg, &output); if (ret) return ret; output_event = output.file->private_data; ret = perf_event_set_output(event, output_event); fdput(output); } else { ret = perf_event_set_output(event, NULL); } return ret; } case PERF_EVENT_IOC_SET_FILTER: return perf_event_set_filter(event, (void __user *)arg); default: return -ENOTTY; } if (flags & PERF_IOC_FLAG_GROUP) perf_event_for_each(event, func); else perf_event_for_each_child(event, func); return 0; } Vulnerability Type: +Priv CWE ID: CWE-264 Summary: kernel/events/core.c in the performance subsystem in the Linux kernel before 4.0 mismanages locks during certain migrations, which allows local users to gain privileges via a crafted application, aka Android internal bug 31095224. Commit Message: perf: Fix event->ctx locking There have been a few reported issues wrt. the lack of locking around changing event->ctx. This patch tries to address those. It avoids the whole rwsem thing; and while it appears to work, please give it some thought in review. What I did fail at is sensible runtime checks on the use of event->ctx, the RCU use makes it very hard. Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Paul E. McKenney <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Linus Torvalds <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
Medium
166,991
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: bool PrintRenderFrameHelper::PreviewPageRendered(int page_number, PdfMetafileSkia* metafile) { DCHECK_GE(page_number, FIRST_PAGE_INDEX); if (!print_preview_context_.IsModifiable() || !print_preview_context_.generate_draft_pages()) { DCHECK(!metafile); return true; } if (!metafile) { NOTREACHED(); print_preview_context_.set_error( PREVIEW_ERROR_PAGE_RENDERED_WITHOUT_METAFILE); return false; } PrintHostMsg_DidPreviewPage_Params preview_page_params; if (!CopyMetafileDataToSharedMem(*metafile, &preview_page_params.metafile_data_handle)) { LOG(ERROR) << "CopyMetafileDataToSharedMem failed"; print_preview_context_.set_error(PREVIEW_ERROR_METAFILE_COPY_FAILED); return false; } preview_page_params.data_size = metafile->GetDataSize(); preview_page_params.page_number = page_number; preview_page_params.preview_request_id = print_pages_params_->params.preview_request_id; Send(new PrintHostMsg_DidPreviewPage(routing_id(), preview_page_params)); return true; } Vulnerability Type: CWE ID: CWE-787 Summary: Incorrect use of mojo::WrapSharedMemoryHandle in Mojo in Google Chrome prior to 65.0.3325.146 allowed a remote attacker who had compromised the renderer process to perform an out of bounds memory write via a crafted HTML page. Commit Message: Correct mojo::WrapSharedMemoryHandle usage Fixes some incorrect uses of mojo::WrapSharedMemoryHandle which were assuming that the call actually has any control over the memory protection applied to a handle when mapped. Where fixing usage is infeasible for this CL, TODOs are added to annotate follow-up work. Also updates the API and documentation to (hopefully) improve clarity and avoid similar mistakes from being made in the future. BUG=792900 Cq-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 Change-Id: I0578aaa9ca3bfcb01aaf2451315d1ede95458477 Reviewed-on: https://chromium-review.googlesource.com/818282 Reviewed-by: Wei Li <[email protected]> Reviewed-by: Lei Zhang <[email protected]> Reviewed-by: John Abd-El-Malek <[email protected]> Reviewed-by: Daniel Cheng <[email protected]> Reviewed-by: Sadrul Chowdhury <[email protected]> Reviewed-by: Yuzhu Shen <[email protected]> Reviewed-by: Robert Sesek <[email protected]> Commit-Queue: Ken Rockot <[email protected]> Cr-Commit-Position: refs/heads/master@{#530268}
Medium
172,853
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: TestWCDelegateForDialogsAndFullscreen() : is_fullscreen_(false), message_loop_runner_(new MessageLoopRunner) {} Vulnerability Type: CWE ID: Summary: A JavaScript focused window could overlap the fullscreen notification in Fullscreen in Google Chrome prior to 66.0.3359.117 allowed a remote attacker to obscure the full screen warning via a crafted HTML page. Commit Message: If a page calls |window.focus()|, kick it out of fullscreen. BUG=776418, 800056 Change-Id: I1880fe600e4814c073f247c43b1c1ac80c8fc017 Reviewed-on: https://chromium-review.googlesource.com/852378 Reviewed-by: Nasko Oskov <[email protected]> Reviewed-by: Philip Jägenstedt <[email protected]> Commit-Queue: Avi Drissman <[email protected]> Cr-Commit-Position: refs/heads/master@{#533790}
Low
172,718
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: static MagickBooleanType SkipDXTMipmaps(Image *image,DDSInfo *dds_info, int texel_size,ExceptionInfo *exception) { register ssize_t i; MagickOffsetType offset; size_t h, w; /* Only skip mipmaps for textures and cube maps */ if (EOFBlob(image) != MagickFalse) { ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile", image->filename); return(MagickFalse); } if (dds_info->ddscaps1 & DDSCAPS_MIPMAP && (dds_info->ddscaps1 & DDSCAPS_TEXTURE || dds_info->ddscaps2 & DDSCAPS2_CUBEMAP)) { w = DIV2(dds_info->width); h = DIV2(dds_info->height); /* Mipmapcount includes the main image, so start from one */ for (i = 1; (i < (ssize_t) dds_info->mipmapcount) && w && h; i++) { offset = (MagickOffsetType) ((w + 3) / 4) * ((h + 3) / 4) * texel_size; (void) SeekBlob(image, offset, SEEK_CUR); w = DIV2(w); h = DIV2(h); } } return(MagickTrue); } Vulnerability Type: DoS CWE ID: CWE-399 Summary: coders/dds.c in ImageMagick before 6.9.0-4 Beta allows remote attackers to cause a denial of service (CPU consumption) via a crafted DDS file. Commit Message:
High
168,853
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: static void gx_ttfReader__Read(ttfReader *self, void *p, int n) { gx_ttfReader *r = (gx_ttfReader *)self; const byte *q; if (!r->error) { if (r->extra_glyph_index != -1) { q = r->glyph_data.bits.data + r->pos; r->error = (r->glyph_data.bits.size - r->pos < n ? gs_note_error(gs_error_invalidfont) : 0); if (r->error == 0) memcpy(p, q, n); unsigned int cnt; for (cnt = 0; cnt < (uint)n; cnt += r->error) { r->error = r->pfont->data.string_proc(r->pfont, (ulong)r->pos + cnt, (ulong)n - cnt, &q); if (r->error < 0) break; else if ( r->error == 0) { memcpy((char *)p + cnt, q, n - cnt); break; } else { memcpy((char *)p + cnt, q, r->error); } } } } if (r->error) { memset(p, 0, n); return; } r->pos += n; } Vulnerability Type: DoS CWE ID: CWE-125 Summary: The gx_ttfReader__Read function in base/gxttfb.c in Artifex Ghostscript GhostXPS 9.21 allows remote attackers to cause a denial of service (heap-based buffer over-read and application crash) or possibly have unspecified other impact via a crafted document. Commit Message:
Medium
164,779
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: void BlobURLRequestJob::DidGetFileItemLength(size_t index, int64 result) { if (error_) return; if (result == net::ERR_UPLOAD_FILE_CHANGED) { NotifyFailure(net::ERR_FILE_NOT_FOUND); return; } else if (result < 0) { NotifyFailure(result); return; } DCHECK_LT(index, blob_data_->items().size()); const BlobData::Item& item = blob_data_->items().at(index); DCHECK(IsFileType(item.type())); int64 item_length = static_cast<int64>(item.length()); if (item_length == -1) item_length = result - item.offset(); DCHECK_LT(index, item_length_list_.size()); item_length_list_[index] = item_length; total_size_ += item_length; if (--pending_get_file_info_count_ == 0) DidCountSize(net::OK); } Vulnerability Type: DoS Overflow CWE ID: CWE-189 Summary: Integer overflow in Google Chrome before 25.0.1364.97 on Windows and Linux, and before 25.0.1364.99 on Mac OS X, allows remote attackers to cause a denial of service or possibly have unspecified other impact via a blob. Commit Message: Avoid integer overflows in BlobURLRequestJob. BUG=169685 Review URL: https://chromiumcodereview.appspot.com/12047012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@179154 0039d316-1c4b-4281-b951-d872f2087c98
High
171,399
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: bdfReadCharacters(FontFilePtr file, FontPtr pFont, bdfFileState *pState, int bit, int byte, int glyph, int scan) { unsigned char *line; register CharInfoPtr ci; int i, ndx, nchars, nignored; unsigned int char_row, char_col; int numEncodedGlyphs = 0; CharInfoPtr *bdfEncoding[256]; BitmapFontPtr bitmapFont; BitmapExtraPtr bitmapExtra; CARD32 *bitmapsSizes; unsigned char lineBuf[BDFLINELEN]; int nencoding; bitmapFont = (BitmapFontPtr) pFont->fontPrivate; bitmapExtra = (BitmapExtraPtr) bitmapFont->bitmapExtra; if (bitmapExtra) { bitmapsSizes = bitmapExtra->bitmapsSizes; for (i = 0; i < GLYPHPADOPTIONS; i++) bitmapsSizes[i] = 0; } else bitmapsSizes = NULL; bzero(bdfEncoding, sizeof(bdfEncoding)); bitmapFont->metrics = NULL; ndx = 0; line = bdfGetLine(file, lineBuf, BDFLINELEN); if ((!line) || (sscanf((char *) line, "CHARS %d", &nchars) != 1)) { bdfError("bad 'CHARS' in bdf file\n"); return (FALSE); } if (nchars < 1) { bdfError("invalid number of CHARS in BDF file\n"); return (FALSE); } if (nchars > INT32_MAX / sizeof(CharInfoRec)) { bdfError("Couldn't allocate pCI (%d*%d)\n", nchars, (int) sizeof(CharInfoRec)); goto BAILOUT; } ci = calloc(nchars, sizeof(CharInfoRec)); if (!ci) { bdfError("Couldn't allocate pCI (%d*%d)\n", nchars, (int) sizeof(CharInfoRec)); goto BAILOUT; } bitmapFont->metrics = ci; if (bitmapExtra) { bitmapExtra->glyphNames = malloc(nchars * sizeof(Atom)); if (!bitmapExtra->glyphNames) { bdfError("Couldn't allocate glyphNames (%d*%d)\n", nchars, (int) sizeof(Atom)); goto BAILOUT; } } if (bitmapExtra) { bitmapExtra->sWidths = malloc(nchars * sizeof(int)); if (!bitmapExtra->sWidths) { bdfError("Couldn't allocate sWidth (%d *%d)\n", nchars, (int) sizeof(int)); return FALSE; } } line = bdfGetLine(file, lineBuf, BDFLINELEN); pFont->info.firstRow = 256; pFont->info.lastRow = 0; pFont->info.firstCol = 256; pFont->info.lastCol = 0; nignored = 0; for (ndx = 0; (ndx < nchars) && (line) && (bdfIsPrefix(line, "STARTCHAR"));) { int t; int wx; /* x component of width */ int wy; /* y component of width */ int bw; /* bounding-box width */ int bh; /* bounding-box height */ int bl; /* bounding-box left */ int bb; /* bounding-box bottom */ int enc, enc2; /* encoding */ unsigned char *p; /* temp pointer into line */ char charName[100]; int ignore; if (sscanf((char *) line, "STARTCHAR %s", charName) != 1) { bdfError("bad character name in BDF file\n"); goto BAILOUT; /* bottom of function, free and return error */ } if (bitmapExtra) bitmapExtra->glyphNames[ndx] = bdfForceMakeAtom(charName, NULL); line = bdfGetLine(file, lineBuf, BDFLINELEN); if (!line || (t = sscanf((char *) line, "ENCODING %d %d", &enc, &enc2)) < 1) { bdfError("bad 'ENCODING' in BDF file\n"); goto BAILOUT; } if (enc < -1 || (t == 2 && enc2 < -1)) { bdfError("bad ENCODING value"); goto BAILOUT; } if (t == 2 && enc == -1) enc = enc2; ignore = 0; if (enc == -1) { if (!bitmapExtra) { nignored++; ignore = 1; } } else if (enc > MAXENCODING) { bdfError("char '%s' has encoding too large (%d)\n", charName, enc); } else { char_row = (enc >> 8) & 0xFF; char_col = enc & 0xFF; if (char_row < pFont->info.firstRow) pFont->info.firstRow = char_row; if (char_row > pFont->info.lastRow) pFont->info.lastRow = char_row; if (char_col < pFont->info.firstCol) pFont->info.firstCol = char_col; if (char_col > pFont->info.lastCol) pFont->info.lastCol = char_col; if (bdfEncoding[char_row] == (CharInfoPtr *) NULL) { bdfEncoding[char_row] = malloc(256 * sizeof(CharInfoPtr)); if (!bdfEncoding[char_row]) { bdfError("Couldn't allocate row %d of encoding (%d*%d)\n", char_row, INDICES, (int) sizeof(CharInfoPtr)); goto BAILOUT; } for (i = 0; i < 256; i++) bdfEncoding[char_row][i] = (CharInfoPtr) NULL; } if (bdfEncoding[char_row] != NULL) { bdfEncoding[char_row][char_col] = ci; numEncodedGlyphs++; } } line = bdfGetLine(file, lineBuf, BDFLINELEN); if ((!line) || (sscanf((char *) line, "SWIDTH %d %d", &wx, &wy) != 2)) { bdfError("bad 'SWIDTH'\n"); goto BAILOUT; } if (wy != 0) { bdfError("SWIDTH y value must be zero\n"); goto BAILOUT; } if (bitmapExtra) bitmapExtra->sWidths[ndx] = wx; /* 5/31/89 (ef) -- we should be able to ditch the character and recover */ /* from all of these. */ line = bdfGetLine(file, lineBuf, BDFLINELEN); if ((!line) || (sscanf((char *) line, "DWIDTH %d %d", &wx, &wy) != 2)) { bdfError("bad 'DWIDTH'\n"); goto BAILOUT; } if (wy != 0) { bdfError("DWIDTH y value must be zero\n"); goto BAILOUT; } line = bdfGetLine(file, lineBuf, BDFLINELEN); if ((!line) || (sscanf((char *) line, "BBX %d %d %d %d", &bw, &bh, &bl, &bb) != 4)) { bdfError("bad 'BBX'\n"); goto BAILOUT; } if ((bh < 0) || (bw < 0)) { bdfError("character '%s' has a negative sized bitmap, %dx%d\n", charName, bw, bh); goto BAILOUT; } line = bdfGetLine(file, lineBuf, BDFLINELEN); if ((line) && (bdfIsPrefix(line, "ATTRIBUTES"))) { for (p = line + strlen("ATTRIBUTES "); (*p == ' ') || (*p == '\t'); p++) /* empty for loop */ ; ci->metrics.attributes = (bdfHexByte(p) << 8) + bdfHexByte(p + 2); line = bdfGetLine(file, lineBuf, BDFLINELEN); } else ci->metrics.attributes = 0; if (!line || !bdfIsPrefix(line, "BITMAP")) { bdfError("missing 'BITMAP'\n"); goto BAILOUT; } /* collect data for generated properties */ if ((strlen(charName) == 1)) { if ((charName[0] >= '0') && (charName[0] <= '9')) { pState->digitWidths += wx; pState->digitCount++; } else if (charName[0] == 'x') { pState->exHeight = (bh + bb) <= 0 ? bh : bh + bb; } } if (!ignore) { ci->metrics.leftSideBearing = bl; ci->metrics.rightSideBearing = bl + bw; ci->metrics.ascent = bh + bb; ci->metrics.descent = -bb; ci->metrics.characterWidth = wx; ci->bits = NULL; bdfReadBitmap(ci, file, bit, byte, glyph, scan, bitmapsSizes); ci++; ndx++; } else bdfSkipBitmap(file, bh); line = bdfGetLine(file, lineBuf, BDFLINELEN); /* get STARTCHAR or * ENDFONT */ } if (ndx + nignored != nchars) { bdfError("%d too few characters\n", nchars - (ndx + nignored)); goto BAILOUT; } nchars = ndx; bitmapFont->num_chars = nchars; if ((line) && (bdfIsPrefix(line, "STARTCHAR"))) { bdfError("more characters than specified\n"); goto BAILOUT; } if ((!line) || (!bdfIsPrefix(line, "ENDFONT"))) { bdfError("missing 'ENDFONT'\n"); goto BAILOUT; } if (numEncodedGlyphs == 0) bdfWarning("No characters with valid encodings\n"); nencoding = (pFont->info.lastRow - pFont->info.firstRow + 1) * (pFont->info.lastCol - pFont->info.firstCol + 1); bitmapFont->encoding = calloc(NUM_SEGMENTS(nencoding),sizeof(CharInfoPtr*)); if (!bitmapFont->encoding) { bdfError("Couldn't allocate ppCI (%d,%d)\n", NUM_SEGMENTS(nencoding), (int) sizeof(CharInfoPtr*)); goto BAILOUT; } pFont->info.allExist = TRUE; i = 0; for (char_row = pFont->info.firstRow; char_row <= pFont->info.lastRow; char_row++) { if (bdfEncoding[char_row] == (CharInfoPtr *) NULL) { pFont->info.allExist = FALSE; i += pFont->info.lastCol - pFont->info.firstCol + 1; } else { for (char_col = pFont->info.firstCol; char_col <= pFont->info.lastCol; char_col++) { if (!bdfEncoding[char_row][char_col]) pFont->info.allExist = FALSE; else { if (!bitmapFont->encoding[SEGMENT_MAJOR(i)]) { bitmapFont->encoding[SEGMENT_MAJOR(i)]= calloc(BITMAP_FONT_SEGMENT_SIZE, sizeof(CharInfoPtr)); if (!bitmapFont->encoding[SEGMENT_MAJOR(i)]) goto BAILOUT; } ACCESSENCODINGL(bitmapFont->encoding,i) = bdfEncoding[char_row][char_col]; } i++; } } } for (i = 0; i < 256; i++) if (bdfEncoding[i]) free(bdfEncoding[i]); return (TRUE); BAILOUT: for (i = 0; i < 256; i++) if (bdfEncoding[i]) free(bdfEncoding[i]); /* bdfFreeFontBits will clean up the rest */ return (FALSE); } Vulnerability Type: DoS Exec Code Overflow CWE ID: CWE-119 Summary: Stack-based buffer overflow in the bdfReadCharacters function in bitmap/bdfread.c in X.Org libXfont 1.1 through 1.4.6 allows remote attackers to cause a denial of service (crash) or possibly execute arbitrary code via a long string in a character name in a BDF font file. Commit Message:
High
165,333
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: static int sockfs_setattr(struct dentry *dentry, struct iattr *iattr) { int err = simple_setattr(dentry, iattr); if (!err && (iattr->ia_valid & ATTR_UID)) { struct socket *sock = SOCKET_I(d_inode(dentry)); sock->sk->sk_uid = iattr->ia_uid; } return err; } Vulnerability Type: CWE ID: CWE-362 Summary: In net/socket.c in the Linux kernel through 4.17.1, there is a race condition between fchownat and close in cases where they target the same socket file descriptor, related to the sock_close and sockfs_setattr functions. fchownat does not increment the file descriptor reference count, which allows close to set the socket to NULL during fchownat's execution, leading to a NULL pointer dereference and system crash. Commit Message: socket: close race condition between sock_close() and sockfs_setattr() fchownat() doesn't even hold refcnt of fd until it figures out fd is really needed (otherwise is ignored) and releases it after it resolves the path. This means sock_close() could race with sockfs_setattr(), which leads to a NULL pointer dereference since typically we set sock->sk to NULL in ->release(). As pointed out by Al, this is unique to sockfs. So we can fix this in socket layer by acquiring inode_lock in sock_close() and checking against NULL in sockfs_setattr(). sock_release() is called in many places, only the sock_close() path matters here. And fortunately, this should not affect normal sock_close() as it is only called when the last fd refcnt is gone. It only affects sock_close() with a parallel sockfs_setattr() in progress, which is not common. Fixes: 86741ec25462 ("net: core: Add a UID field to struct sock.") Reported-by: shankarapailoor <[email protected]> Cc: Tetsuo Handa <[email protected]> Cc: Lorenzo Colitti <[email protected]> Cc: Al Viro <[email protected]> Signed-off-by: Cong Wang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
High
169,205
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: const Chapters::Atom* Chapters::Edition::GetAtom(int index) const { if (index < 0) return NULL; if (index >= m_atoms_count) return NULL; return m_atoms + index; } Vulnerability Type: DoS Exec Code Overflow Mem. Corr. CWE ID: CWE-119 Summary: libvpx in mediaserver in Android 4.x before 4.4.4, 5.x before 5.1.1 LMY49H, and 6.0 before 2016-03-01 allows remote attackers to execute arbitrary code or cause a denial of service (memory corruption) via a crafted media file, related to libwebm/mkvparser.cpp and other files, aka internal bug 23452792. Commit Message: libwebm: Pull from upstream Rolling mkvparser from upstream. Primarily for fixing a bug on parsing failures with certain Opus WebM files. Upstream commit hash of this pull: 574045edd4ecbeb802ee3f1d214b5510269852ae The diff is so huge because there were some style clean ups upstream. But it was ensured that there were no breaking changes when the style clean ups was done upstream. Change-Id: Ib6e907175484b4b0ae1b55ab39522ea3188ad039
High
174,281
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: static int ovl_copy_up_locked(struct dentry *workdir, struct dentry *upperdir, struct dentry *dentry, struct path *lowerpath, struct kstat *stat, struct iattr *attr, const char *link) { struct inode *wdir = workdir->d_inode; struct inode *udir = upperdir->d_inode; struct dentry *newdentry = NULL; struct dentry *upper = NULL; umode_t mode = stat->mode; int err; newdentry = ovl_lookup_temp(workdir, dentry); err = PTR_ERR(newdentry); if (IS_ERR(newdentry)) goto out; upper = lookup_one_len(dentry->d_name.name, upperdir, dentry->d_name.len); err = PTR_ERR(upper); if (IS_ERR(upper)) goto out1; /* Can't properly set mode on creation because of the umask */ stat->mode &= S_IFMT; err = ovl_create_real(wdir, newdentry, stat, link, NULL, true); stat->mode = mode; if (err) goto out2; if (S_ISREG(stat->mode)) { struct path upperpath; ovl_path_upper(dentry, &upperpath); BUG_ON(upperpath.dentry != NULL); upperpath.dentry = newdentry; err = ovl_copy_up_data(lowerpath, &upperpath, stat->size); if (err) goto out_cleanup; } err = ovl_copy_xattr(lowerpath->dentry, newdentry); if (err) goto out_cleanup; mutex_lock(&newdentry->d_inode->i_mutex); err = ovl_set_attr(newdentry, stat); if (!err && attr) err = notify_change(newdentry, attr, NULL); mutex_unlock(&newdentry->d_inode->i_mutex); if (err) goto out_cleanup; err = ovl_do_rename(wdir, newdentry, udir, upper, 0); if (err) goto out_cleanup; ovl_dentry_update(dentry, newdentry); newdentry = NULL; /* * Non-directores become opaque when copied up. */ if (!S_ISDIR(stat->mode)) ovl_dentry_set_opaque(dentry, true); out2: dput(upper); out1: dput(newdentry); out: return err; out_cleanup: ovl_cleanup(wdir, newdentry); goto out; } Vulnerability Type: DoS CWE ID: CWE-399 Summary: fs/overlayfs/copy_up.c in the Linux kernel before 4.2.6 uses an incorrect cleanup code path, which allows local users to cause a denial of service (dentry reference leak) via filesystem operations on a large file in a lower overlayfs layer. Commit Message: ovl: fix dentry reference leak In ovl_copy_up_locked(), newdentry is leaked if the function exits through out_cleanup as this just to out after calling ovl_cleanup() - which doesn't actually release the ref on newdentry. The out_cleanup segment should instead exit through out2 as certainly newdentry leaks - and possibly upper does also, though this isn't caught given the catch of newdentry. Without this fix, something like the following is seen: BUG: Dentry ffff880023e9eb20{i=f861,n=#ffff880023e82d90} still in use (1) [unmount of tmpfs tmpfs] BUG: Dentry ffff880023ece640{i=0,n=bigfile} still in use (1) [unmount of tmpfs tmpfs] when unmounting the upper layer after an error occurred in copyup. An error can be induced by creating a big file in a lower layer with something like: dd if=/dev/zero of=/lower/a/bigfile bs=65536 count=1 seek=$((0xf000)) to create a large file (4.1G). Overlay an upper layer that is too small (on tmpfs might do) and then induce a copy up by opening it writably. Reported-by: Ulrich Obergfell <[email protected]> Signed-off-by: David Howells <[email protected]> Signed-off-by: Miklos Szeredi <[email protected]> Cc: <[email protected]> # v3.18+
Medium
167,469
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: static struct sk_buff **gre_gro_receive(struct sk_buff **head, struct sk_buff *skb) { struct sk_buff **pp = NULL; struct sk_buff *p; const struct gre_base_hdr *greh; unsigned int hlen, grehlen; unsigned int off; int flush = 1; struct packet_offload *ptype; __be16 type; off = skb_gro_offset(skb); hlen = off + sizeof(*greh); greh = skb_gro_header_fast(skb, off); if (skb_gro_header_hard(skb, hlen)) { greh = skb_gro_header_slow(skb, hlen, off); if (unlikely(!greh)) goto out; } /* Only support version 0 and K (key), C (csum) flags. Note that * although the support for the S (seq#) flag can be added easily * for GRO, this is problematic for GSO hence can not be enabled * here because a GRO pkt may end up in the forwarding path, thus * requiring GSO support to break it up correctly. */ if ((greh->flags & ~(GRE_KEY|GRE_CSUM)) != 0) goto out; type = greh->protocol; rcu_read_lock(); ptype = gro_find_receive_by_type(type); if (!ptype) goto out_unlock; grehlen = GRE_HEADER_SECTION; if (greh->flags & GRE_KEY) grehlen += GRE_HEADER_SECTION; if (greh->flags & GRE_CSUM) grehlen += GRE_HEADER_SECTION; hlen = off + grehlen; if (skb_gro_header_hard(skb, hlen)) { greh = skb_gro_header_slow(skb, hlen, off); if (unlikely(!greh)) goto out_unlock; } /* Don't bother verifying checksum if we're going to flush anyway. */ if ((greh->flags & GRE_CSUM) && !NAPI_GRO_CB(skb)->flush) { if (skb_gro_checksum_simple_validate(skb)) goto out_unlock; skb_gro_checksum_try_convert(skb, IPPROTO_GRE, 0, null_compute_pseudo); } for (p = *head; p; p = p->next) { const struct gre_base_hdr *greh2; if (!NAPI_GRO_CB(p)->same_flow) continue; /* The following checks are needed to ensure only pkts * from the same tunnel are considered for aggregation. * The criteria for "the same tunnel" includes: * 1) same version (we only support version 0 here) * 2) same protocol (we only support ETH_P_IP for now) * 3) same set of flags * 4) same key if the key field is present. */ greh2 = (struct gre_base_hdr *)(p->data + off); if (greh2->flags != greh->flags || greh2->protocol != greh->protocol) { NAPI_GRO_CB(p)->same_flow = 0; continue; } if (greh->flags & GRE_KEY) { /* compare keys */ if (*(__be32 *)(greh2+1) != *(__be32 *)(greh+1)) { NAPI_GRO_CB(p)->same_flow = 0; continue; } } } skb_gro_pull(skb, grehlen); /* Adjusted NAPI_GRO_CB(skb)->csum after skb_gro_pull()*/ skb_gro_postpull_rcsum(skb, greh, grehlen); pp = ptype->callbacks.gro_receive(head, skb); flush = 0; out_unlock: rcu_read_unlock(); out: NAPI_GRO_CB(skb)->flush |= flush; return pp; } Vulnerability Type: DoS CWE ID: CWE-400 Summary: The IP stack in the Linux kernel before 4.6 allows remote attackers to cause a denial of service (stack consumption and panic) or possibly have unspecified other impact by triggering use of the GRO path for packets with tunnel stacking, as demonstrated by interleaved IPv4 headers and GRE headers, a related issue to CVE-2016-7039. Commit Message: tunnels: Don't apply GRO to multiple layers of encapsulation. When drivers express support for TSO of encapsulated packets, they only mean that they can do it for one layer of encapsulation. Supporting additional levels would mean updating, at a minimum, more IP length fields and they are unaware of this. No encapsulation device expresses support for handling offloaded encapsulated packets, so we won't generate these types of frames in the transmit path. However, GRO doesn't have a check for multiple levels of encapsulation and will attempt to build them. UDP tunnel GRO actually does prevent this situation but it only handles multiple UDP tunnels stacked on top of each other. This generalizes that solution to prevent any kind of tunnel stacking that would cause problems. Fixes: bf5a755f ("net-gre-gro: Add GRE support to the GRO stack") Signed-off-by: Jesse Gross <[email protected]> Signed-off-by: David S. Miller <[email protected]>
High
166,906
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: mfr_print(netdissect_options *ndo, register const u_char *p, u_int length) { u_int tlen,idx,hdr_len = 0; uint16_t sequence_num; uint8_t ie_type,ie_len; const uint8_t *tptr; /* * FRF.16 Link Integrity Control Frame * * 7 6 5 4 3 2 1 0 * +----+----+----+----+----+----+----+----+ * | B | E | C=1| 0 0 0 0 | EA | * +----+----+----+----+----+----+----+----+ * | 0 0 0 0 0 0 0 0 | * +----+----+----+----+----+----+----+----+ * | message type | * +----+----+----+----+----+----+----+----+ */ ND_TCHECK2(*p, 4); /* minimum frame header length */ if ((p[0] & MFR_BEC_MASK) == MFR_CTRL_FRAME && p[1] == 0) { ND_PRINT((ndo, "FRF.16 Control, Flags [%s], %s, length %u", bittok2str(frf_flag_values,"none",(p[0] & MFR_BEC_MASK)), tok2str(mfr_ctrl_msg_values,"Unknown Message (0x%02x)",p[2]), length)); tptr = p + 3; tlen = length -3; hdr_len = 3; if (!ndo->ndo_vflag) return hdr_len; while (tlen>sizeof(struct ie_tlv_header_t)) { ND_TCHECK2(*tptr, sizeof(struct ie_tlv_header_t)); ie_type=tptr[0]; ie_len=tptr[1]; ND_PRINT((ndo, "\n\tIE %s (%u), length %u: ", tok2str(mfr_ctrl_ie_values,"Unknown",ie_type), ie_type, ie_len)); /* infinite loop check */ if (ie_type == 0 || ie_len <= sizeof(struct ie_tlv_header_t)) return hdr_len; ND_TCHECK2(*tptr, ie_len); tptr+=sizeof(struct ie_tlv_header_t); /* tlv len includes header */ ie_len-=sizeof(struct ie_tlv_header_t); tlen-=sizeof(struct ie_tlv_header_t); switch (ie_type) { case MFR_CTRL_IE_MAGIC_NUM: ND_PRINT((ndo, "0x%08x", EXTRACT_32BITS(tptr))); break; case MFR_CTRL_IE_BUNDLE_ID: /* same message format */ case MFR_CTRL_IE_LINK_ID: for (idx = 0; idx < ie_len && idx < MFR_ID_STRING_MAXLEN; idx++) { if (*(tptr+idx) != 0) /* don't print null termination */ safeputchar(ndo, *(tptr + idx)); else break; } break; case MFR_CTRL_IE_TIMESTAMP: if (ie_len == sizeof(struct timeval)) { ts_print(ndo, (const struct timeval *)tptr); break; } /* fall through and hexdump if no unix timestamp */ /* * FIXME those are the defined IEs that lack a decoder * you are welcome to contribute code ;-) */ case MFR_CTRL_IE_VENDOR_EXT: case MFR_CTRL_IE_CAUSE: default: if (ndo->ndo_vflag <= 1) print_unknown_data(ndo, tptr, "\n\t ", ie_len); break; } /* do we want to see a hexdump of the IE ? */ if (ndo->ndo_vflag > 1 ) print_unknown_data(ndo, tptr, "\n\t ", ie_len); tlen-=ie_len; tptr+=ie_len; } return hdr_len; } /* * FRF.16 Fragmentation Frame * * 7 6 5 4 3 2 1 0 * +----+----+----+----+----+----+----+----+ * | B | E | C=0|seq. (high 4 bits) | EA | * +----+----+----+----+----+----+----+----+ * | sequence (low 8 bits) | * +----+----+----+----+----+----+----+----+ * | DLCI (6 bits) | CR | EA | * +----+----+----+----+----+----+----+----+ * | DLCI (4 bits) |FECN|BECN| DE | EA | * +----+----+----+----+----+----+----+----+ */ sequence_num = (p[0]&0x1e)<<7 | p[1]; /* whole packet or first fragment ? */ if ((p[0] & MFR_BEC_MASK) == MFR_FRAG_FRAME || (p[0] & MFR_BEC_MASK) == MFR_B_BIT) { ND_PRINT((ndo, "FRF.16 Frag, seq %u, Flags [%s], ", sequence_num, bittok2str(frf_flag_values,"none",(p[0] & MFR_BEC_MASK)))); hdr_len = 2; fr_print(ndo, p+hdr_len,length-hdr_len); return hdr_len; } /* must be a middle or the last fragment */ ND_PRINT((ndo, "FRF.16 Frag, seq %u, Flags [%s]", sequence_num, bittok2str(frf_flag_values,"none",(p[0] & MFR_BEC_MASK)))); print_unknown_data(ndo, p, "\n\t", length); return hdr_len; trunc: ND_PRINT((ndo, "[|mfr]")); return length; } Vulnerability Type: CWE ID: CWE-125 Summary: The FRF.16 parser in tcpdump before 4.9.3 has a buffer over-read in print-fr.c:mfr_print(). Commit Message: (for 4.9.3) CVE-2018-14468/FRF.16: Add a missing length check. The specification says in a well-formed Magic Number information element the data is exactly 4 bytes long. In mfr_print() check this before trying to read those 4 bytes. This fixes a buffer over-read discovered by Bhargava Shastry, SecT/TU Berlin. Add a test using the capture file supplied by the reporter(s).
High
169,843
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: SYSCALL_DEFINE2(timerfd_create, int, clockid, int, flags) { int ufd; struct timerfd_ctx *ctx; /* Check the TFD_* constants for consistency. */ BUILD_BUG_ON(TFD_CLOEXEC != O_CLOEXEC); BUILD_BUG_ON(TFD_NONBLOCK != O_NONBLOCK); if ((flags & ~TFD_CREATE_FLAGS) || (clockid != CLOCK_MONOTONIC && clockid != CLOCK_REALTIME && clockid != CLOCK_REALTIME_ALARM && clockid != CLOCK_BOOTTIME && clockid != CLOCK_BOOTTIME_ALARM)) return -EINVAL; if (!capable(CAP_WAKE_ALARM) && (clockid == CLOCK_REALTIME_ALARM || clockid == CLOCK_BOOTTIME_ALARM)) return -EPERM; ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); if (!ctx) return -ENOMEM; init_waitqueue_head(&ctx->wqh); ctx->clockid = clockid; if (isalarm(ctx)) alarm_init(&ctx->t.alarm, ctx->clockid == CLOCK_REALTIME_ALARM ? ALARM_REALTIME : ALARM_BOOTTIME, timerfd_alarmproc); else hrtimer_init(&ctx->t.tmr, clockid, HRTIMER_MODE_ABS); ctx->moffs = ktime_mono_to_real(0); ufd = anon_inode_getfd("[timerfd]", &timerfd_fops, ctx, O_RDWR | (flags & TFD_SHARED_FCNTL_FLAGS)); if (ufd < 0) kfree(ctx); return ufd; } Vulnerability Type: DoS +Priv CWE ID: CWE-416 Summary: Race condition in fs/timerfd.c in the Linux kernel before 4.10.15 allows local users to gain privileges or cause a denial of service (list corruption or use-after-free) via simultaneous file-descriptor operations that leverage improper might_cancel queueing. Commit Message: timerfd: Protect the might cancel mechanism proper The handling of the might_cancel queueing is not properly protected, so parallel operations on the file descriptor can race with each other and lead to list corruptions or use after free. Protect the context for these operations with a seperate lock. The wait queue lock cannot be reused for this because that would create a lock inversion scenario vs. the cancel lock. Replacing might_cancel with an atomic (atomic_t or atomic bit) does not help either because it still can race vs. the actual list operation. Reported-by: Dmitry Vyukov <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: "[email protected]" Cc: syzkaller <[email protected]> Cc: Al Viro <[email protected]> Cc: [email protected] Link: http://lkml.kernel.org/r/alpine.DEB.2.20.1701311521430.3457@nanos Signed-off-by: Thomas Gleixner <[email protected]>
High
168,066
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: pax_decode_header (struct tar_sparse_file *file) { if (file->stat_info->sparse_major > 0) { uintmax_t u; char nbuf[UINTMAX_STRSIZE_BOUND]; union block *blk; char *p; size_t i; off_t start; #define COPY_BUF(b,buf,src) do \ { \ char *endp = b->buffer + BLOCKSIZE; \ char *dst = buf; \ do \ { \ if (dst == buf + UINTMAX_STRSIZE_BOUND -1) \ { \ ERROR ((0, 0, _("%s: numeric overflow in sparse archive member"), \ file->stat_info->orig_file_name)); \ return false; \ } \ if (src == endp) \ { \ set_next_block_after (b); \ b = find_next_block (); \ src = b->buffer; \ endp = b->buffer + BLOCKSIZE; \ } \ while (*dst++ != '\n'); \ dst[-1] = 0; \ } while (0) start = current_block_ordinal (); set_next_block_after (current_header); start = current_block_ordinal (); set_next_block_after (current_header); blk = find_next_block (); p = blk->buffer; COPY_BUF (blk,nbuf,p); if (!decode_num (&u, nbuf, TYPE_MAXIMUM (size_t))) } file->stat_info->sparse_map_size = u; file->stat_info->sparse_map = xcalloc (file->stat_info->sparse_map_size, sizeof (*file->stat_info->sparse_map)); file->stat_info->sparse_map_avail = 0; for (i = 0; i < file->stat_info->sparse_map_size; i++) { struct sp_array sp; COPY_BUF (blk,nbuf,p); if (!decode_num (&u, nbuf, TYPE_MAXIMUM (off_t))) { ERROR ((0, 0, _("%s: malformed sparse archive member"), file->stat_info->orig_file_name)); return false; } sp.offset = u; COPY_BUF (blk,nbuf,p); if (!decode_num (&u, nbuf, TYPE_MAXIMUM (off_t))) { ERROR ((0, 0, _("%s: malformed sparse archive member"), file->stat_info->orig_file_name)); return false; } sp.numbytes = u; sparse_add_map (file->stat_info, &sp); } set_next_block_after (blk); file->dumped_size += BLOCKSIZE * (current_block_ordinal () - start); } return true; } Vulnerability Type: CWE ID: CWE-476 Summary: pax_decode_header in sparse.c in GNU Tar before 1.32 had a NULL pointer dereference when parsing certain archives that have malformed extended headers. Commit Message:
Medium
164,776
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: static struct mount *clone_mnt(struct mount *old, struct dentry *root, int flag) { struct super_block *sb = old->mnt.mnt_sb; struct mount *mnt; int err; mnt = alloc_vfsmnt(old->mnt_devname); if (!mnt) return ERR_PTR(-ENOMEM); if (flag & (CL_SLAVE | CL_PRIVATE | CL_SHARED_TO_SLAVE)) mnt->mnt_group_id = 0; /* not a peer of original */ else mnt->mnt_group_id = old->mnt_group_id; if ((flag & CL_MAKE_SHARED) && !mnt->mnt_group_id) { err = mnt_alloc_group_id(mnt); if (err) goto out_free; } mnt->mnt.mnt_flags = old->mnt.mnt_flags & ~MNT_WRITE_HOLD; atomic_inc(&sb->s_active); mnt->mnt.mnt_sb = sb; mnt->mnt.mnt_root = dget(root); mnt->mnt_mountpoint = mnt->mnt.mnt_root; mnt->mnt_parent = mnt; br_write_lock(&vfsmount_lock); list_add_tail(&mnt->mnt_instance, &sb->s_mounts); br_write_unlock(&vfsmount_lock); if ((flag & CL_SLAVE) || ((flag & CL_SHARED_TO_SLAVE) && IS_MNT_SHARED(old))) { list_add(&mnt->mnt_slave, &old->mnt_slave_list); mnt->mnt_master = old; CLEAR_MNT_SHARED(mnt); } else if (!(flag & CL_PRIVATE)) { if ((flag & CL_MAKE_SHARED) || IS_MNT_SHARED(old)) list_add(&mnt->mnt_share, &old->mnt_share); if (IS_MNT_SLAVE(old)) list_add(&mnt->mnt_slave, &old->mnt_slave); mnt->mnt_master = old->mnt_master; } if (flag & CL_MAKE_SHARED) set_mnt_shared(mnt); /* stick the duplicate mount on the same expiry list * as the original if that was on one */ if (flag & CL_EXPIRE) { if (!list_empty(&old->mnt_expire)) list_add(&mnt->mnt_expire, &old->mnt_expire); } return mnt; out_free: free_vfsmnt(mnt); return ERR_PTR(err); } Vulnerability Type: Bypass CWE ID: CWE-264 Summary: The clone_mnt function in fs/namespace.c in the Linux kernel before 3.8.6 does not properly restrict changes to the MNT_READONLY flag, which allows local users to bypass an intended read-only property of a filesystem by leveraging a separate mount namespace. Commit Message: vfs: Carefully propogate mounts across user namespaces As a matter of policy MNT_READONLY should not be changable if the original mounter had more privileges than creator of the mount namespace. Add the flag CL_UNPRIVILEGED to note when we are copying a mount from a mount namespace that requires more privileges to a mount namespace that requires fewer privileges. When the CL_UNPRIVILEGED flag is set cause clone_mnt to set MNT_NO_REMOUNT if any of the mnt flags that should never be changed are set. This protects both mount propagation and the initial creation of a less privileged mount namespace. Cc: [email protected] Acked-by: Serge Hallyn <[email protected]> Reported-by: Andy Lutomirski <[email protected]> Signed-off-by: "Eric W. Biederman" <[email protected]>
Medium
166,094
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: hfs_cat_traverse(HFS_INFO * hfs, TSK_HFS_BTREE_CB a_cb, void *ptr) { TSK_FS_INFO *fs = &(hfs->fs_info); uint32_t cur_node; /* node id of the current node */ char *node; uint16_t nodesize; uint8_t is_done = 0; tsk_error_reset(); nodesize = tsk_getu16(fs->endian, hfs->catalog_header.nodesize); if ((node = (char *) tsk_malloc(nodesize)) == NULL) return 1; /* start at root node */ cur_node = tsk_getu32(fs->endian, hfs->catalog_header.rootNode); /* if the root node is zero, then the extents btree is empty */ /* if no files have overflow extents, the Extents B-tree still exists on disk, but is an empty B-tree containing only the header node */ if (cur_node == 0) { if (tsk_verbose) tsk_fprintf(stderr, "hfs_cat_traverse: " "empty extents btree\n"); free(node); return 1; } if (tsk_verbose) tsk_fprintf(stderr, "hfs_cat_traverse: starting at " "root node %" PRIu32 "; nodesize = %" PRIu16 "\n", cur_node, nodesize); /* Recurse down to the needed leaf nodes and then go forward */ is_done = 0; while (is_done == 0) { TSK_OFF_T cur_off; /* start address of cur_node */ uint16_t num_rec; /* number of records in this node */ ssize_t cnt; hfs_btree_node *node_desc; if (cur_node > tsk_getu32(fs->endian, hfs->catalog_header.totalNodes)) { tsk_error_set_errno(TSK_ERR_FS_GENFS); tsk_error_set_errstr ("hfs_cat_traverse: Node %d too large for file", cur_node); free(node); return 1; } cur_off = cur_node * nodesize; cnt = tsk_fs_attr_read(hfs->catalog_attr, cur_off, node, nodesize, 0); if (cnt != nodesize) { if (cnt >= 0) { tsk_error_reset(); tsk_error_set_errno(TSK_ERR_FS_READ); } tsk_error_set_errstr2 ("hfs_cat_traverse: Error reading node %d at offset %" PRIuOFF, cur_node, cur_off); free(node); return 1; } if (nodesize < sizeof(hfs_btree_node)) { tsk_error_set_errno(TSK_ERR_FS_GENFS); tsk_error_set_errstr ("hfs_cat_traverse: Node size %d is too small to be valid", nodesize); free(node); return 1; } node_desc = (hfs_btree_node *) node; num_rec = tsk_getu16(fs->endian, node_desc->num_rec); if (tsk_verbose) tsk_fprintf(stderr, "hfs_cat_traverse: node %" PRIu32 " @ %" PRIu64 " has %" PRIu16 " records\n", cur_node, cur_off, num_rec); if (num_rec == 0) { tsk_error_set_errno(TSK_ERR_FS_GENFS); tsk_error_set_errstr("hfs_cat_traverse: zero records in node %" PRIu32, cur_node); free(node); return 1; } /* With an index node, find the record with the largest key that is smaller * to or equal to cnid */ if (node_desc->type == HFS_BT_NODE_TYPE_IDX) { uint32_t next_node = 0; int rec; for (rec = 0; rec < num_rec; ++rec) { size_t rec_off; hfs_btree_key_cat *key; uint8_t retval; uint16_t keylen; rec_off = tsk_getu16(fs->endian, &node[nodesize - (rec + 1) * 2]); if (rec_off > nodesize) { tsk_error_set_errno(TSK_ERR_FS_GENFS); tsk_error_set_errstr ("hfs_cat_traverse: offset of record %d in index node %d too large (%d vs %" PRIu16 ")", rec, cur_node, (int) rec_off, nodesize); free(node); return 1; } key = (hfs_btree_key_cat *) & node[rec_off]; keylen = 2 + tsk_getu16(hfs->fs_info.endian, key->key_len); if ((keylen) > nodesize) { tsk_error_set_errno(TSK_ERR_FS_GENFS); tsk_error_set_errstr ("hfs_cat_traverse: length of key %d in index node %d too large (%d vs %" PRIu16 ")", rec, cur_node, keylen, nodesize); free(node); return 1; } /* if (tsk_verbose) tsk_fprintf(stderr, "hfs_cat_traverse: record %" PRIu16 " ; keylen %" PRIu16 " (%" PRIu32 ")\n", rec, tsk_getu16(fs->endian, key->key_len), tsk_getu32(fs->endian, key->parent_cnid)); */ /* save the info from this record unless it is too big */ retval = a_cb(hfs, HFS_BT_NODE_TYPE_IDX, key, cur_off + rec_off, ptr); if (retval == HFS_BTREE_CB_ERR) { tsk_error_set_errno(TSK_ERR_FS_GENFS); tsk_error_set_errstr2 ("hfs_cat_traverse: Callback returned error"); free(node); return 1; } else if ((retval == HFS_BTREE_CB_IDX_LT) || (next_node == 0)) { hfs_btree_index_record *idx_rec; int keylen = 2 + hfs_get_idxkeylen(hfs, tsk_getu16(fs->endian, key->key_len), &(hfs->catalog_header)); if (rec_off + keylen > nodesize) { tsk_error_set_errno(TSK_ERR_FS_GENFS); tsk_error_set_errstr ("hfs_cat_traverse: offset of record and keylength %d in index node %d too large (%d vs %" PRIu16 ")", rec, cur_node, (int) rec_off + keylen, nodesize); free(node); return 1; } idx_rec = (hfs_btree_index_record *) & node[rec_off + keylen]; next_node = tsk_getu32(fs->endian, idx_rec->childNode); } if (retval == HFS_BTREE_CB_IDX_EQGT) { break; } } if (next_node == 0) { tsk_error_set_errno(TSK_ERR_FS_GENFS); tsk_error_set_errstr ("hfs_cat_traverse: did not find any keys in index node %d", cur_node); is_done = 1; break; } if (next_node == cur_node) { tsk_error_set_errno(TSK_ERR_FS_GENFS); tsk_error_set_errstr ("hfs_cat_traverse: node %d references itself as next node", cur_node); is_done = 1; break; } cur_node = next_node; } /* With a leaf, we look for the specific record. */ else if (node_desc->type == HFS_BT_NODE_TYPE_LEAF) { int rec; for (rec = 0; rec < num_rec; ++rec) { size_t rec_off; hfs_btree_key_cat *key; uint8_t retval; uint16_t keylen; rec_off = tsk_getu16(fs->endian, &node[nodesize - (rec + 1) * 2]); if (rec_off > nodesize) { tsk_error_set_errno(TSK_ERR_FS_GENFS); tsk_error_set_errstr ("hfs_cat_traverse: offset of record %d in leaf node %d too large (%d vs %" PRIu16 ")", rec, cur_node, (int) rec_off, nodesize); free(node); return 1; } key = (hfs_btree_key_cat *) & node[rec_off]; keylen = 2 + tsk_getu16(hfs->fs_info.endian, key->key_len); if ((keylen) > nodesize) { tsk_error_set_errno(TSK_ERR_FS_GENFS); tsk_error_set_errstr ("hfs_cat_traverse: length of key %d in leaf node %d too large (%d vs %" PRIu16 ")", rec, cur_node, keylen, nodesize); free(node); return 1; } /* if (tsk_verbose) tsk_fprintf(stderr, "hfs_cat_traverse: record %" PRIu16 "; keylen %" PRIu16 " (%" PRIu32 ")\n", rec, tsk_getu16(fs->endian, key->key_len), tsk_getu32(fs->endian, key->parent_cnid)); */ retval = a_cb(hfs, HFS_BT_NODE_TYPE_LEAF, key, cur_off + rec_off, ptr); if (retval == HFS_BTREE_CB_LEAF_STOP) { is_done = 1; break; } else if (retval == HFS_BTREE_CB_ERR) { tsk_error_set_errno(TSK_ERR_FS_GENFS); tsk_error_set_errstr2 ("hfs_cat_traverse: Callback returned error"); free(node); return 1; } } if (is_done == 0) { cur_node = tsk_getu32(fs->endian, node_desc->flink); if (cur_node == 0) { is_done = 1; } if (tsk_verbose) tsk_fprintf(stderr, "hfs_cat_traverse: moving forward to next leaf"); } } else { tsk_error_set_errno(TSK_ERR_FS_GENFS); tsk_error_set_errstr("hfs_cat_traverse: btree node %" PRIu32 " (%" PRIu64 ") is neither index nor leaf (%" PRIu8 ")", cur_node, cur_off, node_desc->type); free(node); return 1; } } free(node); return 0; } Vulnerability Type: Overflow CWE ID: CWE-190 Summary: The Sleuth Kit 4.6.0 and earlier is affected by: Integer Overflow. The impact is: Opening crafted disk image triggers crash in tsk/fs/hfs_dent.c:237. The component is: Overflow in fls tool used on HFS image. Bug is in tsk/fs/hfs.c file in function hfs_cat_traverse() in lines: 952, 1062. The attack vector is: Victim must open a crafted HFS filesystem image. Commit Message: hfs: fix keylen check in hfs_cat_traverse() If key->key_len is 65535, calculating "uint16_t keylen' would cause an overflow: uint16_t keylen; ... keylen = 2 + tsk_getu16(hfs->fs_info.endian, key->key_len) so the code bypasses the sanity check "if (keylen > nodesize)" which results in crash later: ./toolfs/fstools/fls -b 512 -f hfs <image> ================================================================= ==16==ERROR: AddressSanitizer: SEGV on unknown address 0x6210000256a4 (pc 0x00000054812b bp 0x7ffca548a8f0 sp 0x7ffca548a480 T0) ==16==The signal is caused by a READ memory access. #0 0x54812a in hfs_dir_open_meta_cb /fuzzing/sleuthkit/tsk/fs/hfs_dent.c:237:20 #1 0x51a96c in hfs_cat_traverse /fuzzing/sleuthkit/tsk/fs/hfs.c:1082:21 #2 0x547785 in hfs_dir_open_meta /fuzzing/sleuthkit/tsk/fs/hfs_dent.c:480:9 #3 0x50f57d in tsk_fs_dir_open_meta /fuzzing/sleuthkit/tsk/fs/fs_dir.c:290:14 #4 0x54af17 in tsk_fs_path2inum /fuzzing/sleuthkit/tsk/fs/ifind_lib.c:237:23 #5 0x522266 in hfs_open /fuzzing/sleuthkit/tsk/fs/hfs.c:6579:9 #6 0x508e89 in main /fuzzing/sleuthkit/tools/fstools/fls.cpp:267:19 #7 0x7f9daf67c2b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0) #8 0x41d679 in _start (/fuzzing/sleuthkit/tools/fstools/fls+0x41d679) Make 'keylen' int type to prevent the overflow and fix that. Now, I get proper error message instead of crash: ./toolfs/fstools/fls -b 512 -f hfs <image> General file system error (hfs_cat_traverse: length of key 3 in leaf node 1 too large (65537 vs 4096))
Medium
169,482
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: void FileBrowserHandlerCustomBindings::GetEntryURL( const v8::FunctionCallbackInfo<v8::Value>& args) { CHECK(args.Length() == 1); CHECK(args[0]->IsObject()); const blink::WebURL& url = blink::WebDOMFileSystem::createFileSystemURL(args[0]); args.GetReturnValue().Set(v8_helpers::ToV8StringUnsafe( args.GetIsolate(), url.string().utf8().c_str())); } Vulnerability Type: Bypass CWE ID: Summary: The extensions subsystem in Google Chrome before 51.0.2704.63 allows remote attackers to bypass the Same Origin Policy via unspecified vectors. Commit Message: [Extensions] Add more bindings access checks BUG=598165 Review URL: https://codereview.chromium.org/1854983002 Cr-Commit-Position: refs/heads/master@{#385282}
Medium
173,272
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: static v8::Handle<v8::Value> dispatchEventCallback(const v8::Arguments& args) { INC_STATS("DOM.TestEventTarget.dispatchEvent"); if (args.Length() < 1) return V8Proxy::throwNotEnoughArgumentsError(); TestEventTarget* imp = V8TestEventTarget::toNative(args.Holder()); ExceptionCode ec = 0; { EXCEPTION_BLOCK(Event*, evt, V8Event::HasInstance(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)) ? V8Event::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))) : 0); bool result = imp->dispatchEvent(evt, ec); if (UNLIKELY(ec)) goto fail; return v8Boolean(result); } fail: V8Proxy::setDOMException(ec, args.GetIsolate()); return v8::Handle<v8::Value>(); } Vulnerability Type: CWE ID: Summary: The browser native UI in Google Chrome before 17.0.963.83 does not require user confirmation before an unpacked extension installation, which allows user-assisted remote attackers to have an unspecified impact via a crafted extension. Commit Message: [V8] Pass Isolate to throwNotEnoughArgumentsError() https://bugs.webkit.org/show_bug.cgi?id=86983 Reviewed by Adam Barth. The objective is to pass Isolate around in V8 bindings. This patch passes Isolate to throwNotEnoughArgumentsError(). No tests. No change in behavior. * bindings/scripts/CodeGeneratorV8.pm: (GenerateArgumentsCountCheck): (GenerateEventConstructorCallback): * bindings/scripts/test/V8/V8Float64Array.cpp: (WebCore::Float64ArrayV8Internal::fooCallback): * bindings/scripts/test/V8/V8TestActiveDOMObject.cpp: (WebCore::TestActiveDOMObjectV8Internal::excitingFunctionCallback): (WebCore::TestActiveDOMObjectV8Internal::postMessageCallback): * bindings/scripts/test/V8/V8TestCustomNamedGetter.cpp: (WebCore::TestCustomNamedGetterV8Internal::anotherFunctionCallback): * bindings/scripts/test/V8/V8TestEventConstructor.cpp: (WebCore::V8TestEventConstructor::constructorCallback): * bindings/scripts/test/V8/V8TestEventTarget.cpp: (WebCore::TestEventTargetV8Internal::itemCallback): (WebCore::TestEventTargetV8Internal::dispatchEventCallback): * bindings/scripts/test/V8/V8TestInterface.cpp: (WebCore::TestInterfaceV8Internal::supplementalMethod2Callback): (WebCore::V8TestInterface::constructorCallback): * bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp: (WebCore::TestMediaQueryListListenerV8Internal::methodCallback): * bindings/scripts/test/V8/V8TestNamedConstructor.cpp: (WebCore::V8TestNamedConstructorConstructorCallback): * bindings/scripts/test/V8/V8TestObj.cpp: (WebCore::TestObjV8Internal::voidMethodWithArgsCallback): (WebCore::TestObjV8Internal::intMethodWithArgsCallback): (WebCore::TestObjV8Internal::objMethodWithArgsCallback): (WebCore::TestObjV8Internal::methodWithSequenceArgCallback): (WebCore::TestObjV8Internal::methodReturningSequenceCallback): (WebCore::TestObjV8Internal::methodThatRequiresAllArgsAndThrowsCallback): (WebCore::TestObjV8Internal::serializedValueCallback): (WebCore::TestObjV8Internal::idbKeyCallback): (WebCore::TestObjV8Internal::optionsObjectCallback): (WebCore::TestObjV8Internal::methodWithNonOptionalArgAndOptionalArgCallback): (WebCore::TestObjV8Internal::methodWithNonOptionalArgAndTwoOptionalArgsCallback): (WebCore::TestObjV8Internal::methodWithCallbackArgCallback): (WebCore::TestObjV8Internal::methodWithNonCallbackArgAndCallbackArgCallback): (WebCore::TestObjV8Internal::overloadedMethod1Callback): (WebCore::TestObjV8Internal::overloadedMethod2Callback): (WebCore::TestObjV8Internal::overloadedMethod3Callback): (WebCore::TestObjV8Internal::overloadedMethod4Callback): (WebCore::TestObjV8Internal::overloadedMethod5Callback): (WebCore::TestObjV8Internal::overloadedMethod6Callback): (WebCore::TestObjV8Internal::overloadedMethod7Callback): (WebCore::TestObjV8Internal::overloadedMethod11Callback): (WebCore::TestObjV8Internal::overloadedMethod12Callback): (WebCore::TestObjV8Internal::enabledAtRuntimeMethod1Callback): (WebCore::TestObjV8Internal::enabledAtRuntimeMethod2Callback): (WebCore::TestObjV8Internal::convert1Callback): (WebCore::TestObjV8Internal::convert2Callback): (WebCore::TestObjV8Internal::convert3Callback): (WebCore::TestObjV8Internal::convert4Callback): (WebCore::TestObjV8Internal::convert5Callback): (WebCore::TestObjV8Internal::strictFunctionCallback): (WebCore::V8TestObj::constructorCallback): * bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp: (WebCore::TestSerializedScriptValueInterfaceV8Internal::acceptTransferListCallback): (WebCore::V8TestSerializedScriptValueInterface::constructorCallback): * bindings/v8/ScriptController.cpp: (WebCore::setValueAndClosePopupCallback): * bindings/v8/V8Proxy.cpp: (WebCore::V8Proxy::throwNotEnoughArgumentsError): * bindings/v8/V8Proxy.h: (V8Proxy): * bindings/v8/custom/V8AudioContextCustom.cpp: (WebCore::V8AudioContext::constructorCallback): * bindings/v8/custom/V8DataViewCustom.cpp: (WebCore::V8DataView::getInt8Callback): (WebCore::V8DataView::getUint8Callback): (WebCore::V8DataView::setInt8Callback): (WebCore::V8DataView::setUint8Callback): * bindings/v8/custom/V8DirectoryEntryCustom.cpp: (WebCore::V8DirectoryEntry::getDirectoryCallback): (WebCore::V8DirectoryEntry::getFileCallback): * bindings/v8/custom/V8IntentConstructor.cpp: (WebCore::V8Intent::constructorCallback): * bindings/v8/custom/V8SVGLengthCustom.cpp: (WebCore::V8SVGLength::convertToSpecifiedUnitsCallback): * bindings/v8/custom/V8WebGLRenderingContextCustom.cpp: (WebCore::getObjectParameter): (WebCore::V8WebGLRenderingContext::getAttachedShadersCallback): (WebCore::V8WebGLRenderingContext::getExtensionCallback): (WebCore::V8WebGLRenderingContext::getFramebufferAttachmentParameterCallback): (WebCore::V8WebGLRenderingContext::getParameterCallback): (WebCore::V8WebGLRenderingContext::getProgramParameterCallback): (WebCore::V8WebGLRenderingContext::getShaderParameterCallback): (WebCore::V8WebGLRenderingContext::getUniformCallback): (WebCore::vertexAttribAndUniformHelperf): (WebCore::uniformHelperi): (WebCore::uniformMatrixHelper): * bindings/v8/custom/V8WebKitMutationObserverCustom.cpp: (WebCore::V8WebKitMutationObserver::constructorCallback): (WebCore::V8WebKitMutationObserver::observeCallback): * bindings/v8/custom/V8WebSocketCustom.cpp: (WebCore::V8WebSocket::constructorCallback): (WebCore::V8WebSocket::sendCallback): * bindings/v8/custom/V8XMLHttpRequestCustom.cpp: (WebCore::V8XMLHttpRequest::openCallback): git-svn-id: svn://svn.chromium.org/blink/trunk@117736 bbb929c8-8fbe-4397-9dbb-9b2b20218538
Medium
171,070
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: void CrosLibrary::TestApi::SetSyslogsLibrary( SyslogsLibrary* library, bool own) { library_->syslogs_lib_.SetImpl(library, own); } Vulnerability Type: Exec Code CWE ID: CWE-189 Summary: The Program::getActiveUniformMaxLength function in libGLESv2/Program.cpp in libGLESv2.dll in the WebGLES library in Almost Native Graphics Layer Engine (ANGLE), as used in Mozilla Firefox 4.x before 4.0.1 on Windows and in the GPU process in Google Chrome before 10.0.648.205 on Windows, allows remote attackers to execute arbitrary code via unspecified vectors, related to an *off-by-three* error. Commit Message: chromeos: Replace copy-and-pasted code with macros. This replaces a bunch of duplicated-per-library cros function definitions and comments. BUG=none TEST=built it Review URL: http://codereview.chromium.org/6086007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70070 0039d316-1c4b-4281-b951-d872f2087c98
High
170,646
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: StateBase* writeFile(v8::Handle<v8::Value> value, StateBase* next) { File* file = V8File::toNative(value.As<v8::Object>()); if (!file) return 0; if (file->hasBeenClosed()) return handleError(DataCloneError, "A File object has been closed, and could therefore not be cloned.", next); int blobIndex = -1; m_blobDataHandles.add(file->uuid(), file->blobDataHandle()); if (appendFileInfo(file, &blobIndex)) { ASSERT(blobIndex >= 0); m_writer.writeFileIndex(blobIndex); } else { m_writer.writeFile(*file); } return 0; } Vulnerability Type: DoS CWE ID: Summary: Use-after-free vulnerability in the V8 bindings in Blink, as used in Google Chrome before 37.0.2062.94, allows remote attackers to cause a denial of service or possibly have unspecified other impact by leveraging improper use of HashMap add operations instead of HashMap set operations, related to bindings/core/v8/DOMWrapperMap.h and bindings/core/v8/SerializedScriptValue.cpp. Commit Message: Replace further questionable HashMap::add usages in bindings BUG=390928 [email protected] Review URL: https://codereview.chromium.org/411273002 git-svn-id: svn://svn.chromium.org/blink/trunk@178823 bbb929c8-8fbe-4397-9dbb-9b2b20218538
High
171,651
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: fd_read_body (const char *downloaded_filename, int fd, FILE *out, wgint toread, wgint startpos, wgint *qtyread, wgint *qtywritten, double *elapsed, int flags, FILE *out2) { int ret = 0; #undef max #define max(a,b) ((a) > (b) ? (a) : (b)) int dlbufsize = max (BUFSIZ, 8 * 1024); char *dlbuf = xmalloc (dlbufsize); struct ptimer *timer = NULL; double last_successful_read_tm = 0; /* The progress gauge, set according to the user preferences. */ void *progress = NULL; /* Non-zero if the progress gauge is interactive, i.e. if it can continually update the display. When true, smaller timeout values are used so that the gauge can update the display when data arrives slowly. */ bool progress_interactive = false; bool exact = !!(flags & rb_read_exactly); /* Used only by HTTP/HTTPS chunked transfer encoding. */ bool chunked = flags & rb_chunked_transfer_encoding; wgint skip = 0; /* How much data we've read/written. */ wgint sum_read = 0; wgint sum_written = 0; wgint remaining_chunk_size = 0; #ifdef HAVE_LIBZ /* try to minimize the number of calls to inflate() and write_data() per call to fd_read() */ unsigned int gzbufsize = dlbufsize * 4; char *gzbuf = NULL; z_stream gzstream; if (flags & rb_compressed_gzip) { gzbuf = xmalloc (gzbufsize); if (gzbuf != NULL) { gzstream.zalloc = zalloc; gzstream.zfree = zfree; gzstream.opaque = Z_NULL; gzstream.next_in = Z_NULL; gzstream.avail_in = 0; #define GZIP_DETECT 32 /* gzip format detection */ #define GZIP_WINDOW 15 /* logarithmic window size (default: 15) */ ret = inflateInit2 (&gzstream, GZIP_DETECT | GZIP_WINDOW); if (ret != Z_OK) { xfree (gzbuf); errno = (ret == Z_MEM_ERROR) ? ENOMEM : EINVAL; ret = -1; goto out; } } else { errno = ENOMEM; ret = -1; goto out; } } #endif if (flags & rb_skip_startpos) skip = startpos; if (opt.show_progress) { const char *filename_progress; /* If we're skipping STARTPOS bytes, pass 0 as the INITIAL argument to progress_create because the indicator doesn't (yet) know about "skipping" data. */ wgint start = skip ? 0 : startpos; if (opt.dir_prefix) filename_progress = downloaded_filename + strlen (opt.dir_prefix) + 1; else filename_progress = downloaded_filename; progress = progress_create (filename_progress, start, start + toread); progress_interactive = progress_interactive_p (progress); } if (opt.limit_rate) limit_bandwidth_reset (); /* A timer is needed for tracking progress, for throttling, and for tracking elapsed time. If either of these are requested, start the timer. */ if (progress || opt.limit_rate || elapsed) { timer = ptimer_new (); last_successful_read_tm = 0; } /* Use a smaller buffer for low requested bandwidths. For example, with --limit-rate=2k, it doesn't make sense to slurp in 16K of data and then sleep for 8s. With buffer size equal to the limit, we never have to sleep for more than one second. */ if (opt.limit_rate && opt.limit_rate < dlbufsize) dlbufsize = opt.limit_rate; /* Read from FD while there is data to read. Normally toread==0 means that it is unknown how much data is to arrive. However, if EXACT is set, then toread==0 means what it says: that no data should be read. */ while (!exact || (sum_read < toread)) { int rdsize; double tmout = opt.read_timeout; if (chunked) { if (remaining_chunk_size == 0) { char *line = fd_read_line (fd); char *endl; if (line == NULL) { ret = -1; break; } else if (out2 != NULL) fwrite (line, 1, strlen (line), out2); remaining_chunk_size = strtol (line, &endl, 16); xfree (line); if (remaining_chunk_size == 0) { ret = 0; fwrite (line, 1, strlen (line), out2); xfree (line); } break; } } rdsize = MIN (remaining_chunk_size, dlbufsize); } else rdsize = exact ? MIN (toread - sum_read, dlbufsize) : dlbufsize; if (progress_interactive) { /* For interactive progress gauges, always specify a ~1s timeout, so that the gauge can be updated regularly even when the data arrives very slowly or stalls. */ tmout = 0.95; if (opt.read_timeout) { double waittm; waittm = ptimer_read (timer) - last_successful_read_tm; if (waittm + tmout > opt.read_timeout) { /* Don't let total idle time exceed read timeout. */ tmout = opt.read_timeout - waittm; if (tmout < 0) { /* We've already exceeded the timeout. */ ret = -1, errno = ETIMEDOUT; break; } } } } ret = fd_read (fd, dlbuf, rdsize, tmout); if (progress_interactive && ret < 0 && errno == ETIMEDOUT) ret = 0; /* interactive timeout, handled above */ else if (ret <= 0) break; /* EOF or read error */ if (progress || opt.limit_rate || elapsed) { ptimer_measure (timer); if (ret > 0) last_successful_read_tm = ptimer_read (timer); } if (ret > 0) { int write_res; sum_read += ret; #ifdef HAVE_LIBZ if (gzbuf != NULL) { int err; int towrite; gzstream.avail_in = ret; gzstream.next_in = (unsigned char *) dlbuf; do { gzstream.avail_out = gzbufsize; gzstream.next_out = (unsigned char *) gzbuf; err = inflate (&gzstream, Z_NO_FLUSH); switch (err) { case Z_MEM_ERROR: errno = ENOMEM; ret = -1; goto out; case Z_NEED_DICT: case Z_DATA_ERROR: errno = EINVAL; ret = -1; goto out; case Z_STREAM_END: if (exact && sum_read != toread) { DEBUGP(("zlib stream ended unexpectedly after " "%ld/%ld bytes\n", sum_read, toread)); } } towrite = gzbufsize - gzstream.avail_out; write_res = write_data (out, out2, gzbuf, towrite, &skip, &sum_written); if (write_res < 0) { ret = (write_res == -3) ? -3 : -2; goto out; } } while (gzstream.avail_out == 0); } else #endif { write_res = write_data (out, out2, dlbuf, ret, &skip, &sum_written); if (write_res < 0) { ret = (write_res == -3) ? -3 : -2; goto out; } } if (chunked) { remaining_chunk_size -= ret; if (remaining_chunk_size == 0) { char *line = fd_read_line (fd); if (line == NULL) { ret = -1; break; } else { if (out2 != NULL) fwrite (line, 1, strlen (line), out2); xfree (line); } } } } if (opt.limit_rate) limit_bandwidth (ret, timer); if (progress) progress_update (progress, ret, ptimer_read (timer)); #ifdef WINDOWS if (toread > 0 && opt.show_progress) ws_percenttitle (100.0 * (startpos + sum_read) / (startpos + toread)); #endif } Vulnerability Type: Overflow CWE ID: CWE-119 Summary: The retr.c:fd_read_body() function is called when processing OK responses. When the response is sent chunked in wget before 1.19.2, the chunk parser uses strtol() to read each chunk's length, but doesn't check that the chunk length is a non-negative number. The code then tries to read the chunk in pieces of 8192 bytes by using the MIN() macro, but ends up passing the negative chunk length to retr.c:fd_read(). As fd_read() takes an int argument, the high 32 bits of the chunk length are discarded, leaving fd_read() with a completely attacker controlled length argument. The attacker can corrupt malloc metadata after the allocated buffer. Commit Message:
High
164,701
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: _gcry_ecc_eddsa_sign (gcry_mpi_t input, ECC_secret_key *skey, gcry_mpi_t r_r, gcry_mpi_t s, int hashalgo, gcry_mpi_t pk) { int rc; mpi_ec_t ctx = NULL; int b; unsigned int tmp; unsigned char *digest = NULL; gcry_buffer_t hvec[3]; const void *mbuf; size_t mlen; unsigned char *rawmpi = NULL; unsigned int rawmpilen; unsigned char *encpk = NULL; /* Encoded public key. */ unsigned int encpklen; mpi_point_struct I; /* Intermediate value. */ mpi_point_struct Q; /* Public key. */ gcry_mpi_t a, x, y, r; memset (hvec, 0, sizeof hvec); if (!mpi_is_opaque (input)) return GPG_ERR_INV_DATA; /* Initialize some helpers. */ point_init (&I); point_init (&Q); a = mpi_snew (0); x = mpi_new (0); y = mpi_new (0); r = mpi_new (0); ctx = _gcry_mpi_ec_p_internal_new (skey->E.model, skey->E.dialect, 0, skey->E.p, skey->E.a, skey->E.b); b = (ctx->nbits+7)/8; if (b != 256/8) { rc = GPG_ERR_INTERNAL; /* We only support 256 bit. */ goto leave; } rc = _gcry_ecc_eddsa_compute_h_d (&digest, skey->d, ctx); if (rc) goto leave; _gcry_mpi_set_buffer (a, digest, 32, 0); /* Compute the public key if it has not been supplied as optional parameter. */ if (pk) { rc = _gcry_ecc_eddsa_decodepoint (pk, ctx, &Q, &encpk, &encpklen); if (rc) goto leave; if (DBG_CIPHER) log_printhex ("* e_pk", encpk, encpklen); if (!_gcry_mpi_ec_curve_point (&Q, ctx)) { rc = GPG_ERR_BROKEN_PUBKEY; goto leave; } } else { _gcry_mpi_ec_mul_point (&Q, a, &skey->E.G, ctx); rc = _gcry_ecc_eddsa_encodepoint (&Q, ctx, x, y, 0, &encpk, &encpklen); if (rc) goto leave; if (DBG_CIPHER) log_printhex (" e_pk", encpk, encpklen); } /* Compute R. */ mbuf = mpi_get_opaque (input, &tmp); mlen = (tmp +7)/8; if (DBG_CIPHER) log_printhex (" m", mbuf, mlen); hvec[0].data = digest; hvec[0].off = 32; hvec[0].len = 32; hvec[1].data = (char*)mbuf; hvec[1].len = mlen; rc = _gcry_md_hash_buffers (hashalgo, 0, digest, hvec, 2); if (rc) goto leave; reverse_buffer (digest, 64); if (DBG_CIPHER) log_printhex (" r", digest, 64); _gcry_mpi_set_buffer (r, digest, 64, 0); _gcry_mpi_ec_mul_point (&I, r, &skey->E.G, ctx); if (DBG_CIPHER) log_printpnt (" r", &I, ctx); /* Convert R into affine coordinates and apply encoding. */ rc = _gcry_ecc_eddsa_encodepoint (&I, ctx, x, y, 0, &rawmpi, &rawmpilen); if (rc) goto leave; if (DBG_CIPHER) log_printhex (" e_r", rawmpi, rawmpilen); /* S = r + a * H(encodepoint(R) + encodepoint(pk) + m) mod n */ hvec[0].data = rawmpi; /* (this is R) */ hvec[0].off = 0; hvec[0].len = rawmpilen; hvec[1].data = encpk; hvec[1].off = 0; hvec[1].len = encpklen; hvec[2].data = (char*)mbuf; hvec[2].off = 0; hvec[2].len = mlen; rc = _gcry_md_hash_buffers (hashalgo, 0, digest, hvec, 3); if (rc) goto leave; /* No more need for RAWMPI thus we now transfer it to R_R. */ mpi_set_opaque (r_r, rawmpi, rawmpilen*8); rawmpi = NULL; reverse_buffer (digest, 64); if (DBG_CIPHER) log_printhex (" H(R+)", digest, 64); _gcry_mpi_set_buffer (s, digest, 64, 0); mpi_mulm (s, s, a, skey->E.n); mpi_addm (s, s, r, skey->E.n); rc = eddsa_encodempi (s, b, &rawmpi, &rawmpilen); if (rc) goto leave; if (DBG_CIPHER) log_printhex (" e_s", rawmpi, rawmpilen); mpi_set_opaque (s, rawmpi, rawmpilen*8); rawmpi = NULL; rc = 0; leave: _gcry_mpi_release (a); _gcry_mpi_release (x); _gcry_mpi_release (y); _gcry_mpi_release (r); xfree (digest); _gcry_mpi_ec_free (ctx); point_free (&I); point_free (&Q); xfree (encpk); xfree (rawmpi); return rc; } Vulnerability Type: +Info CWE ID: CWE-200 Summary: In Libgcrypt before 1.7.7, an attacker who learns the EdDSA session key (from side-channel observation during the signing process) can easily recover the long-term secret key. 1.7.7 makes a cipher/ecc-eddsa.c change to store this session key in secure memory, to ensure that constant-time point operations are used in the MPI library. Commit Message:
Medium
164,790
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: SPL_METHOD(SplFileInfo, __construct) { spl_filesystem_object *intern; char *path; int len; zend_error_handling error_handling; zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling TSRMLS_CC); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &path, &len) == FAILURE) { zend_restore_error_handling(&error_handling TSRMLS_CC); return; } intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); spl_filesystem_info_set_filename(intern, path, len, 1 TSRMLS_CC); zend_restore_error_handling(&error_handling TSRMLS_CC); /* intern->type = SPL_FS_INFO; already set */ } Vulnerability Type: DoS Overflow CWE ID: CWE-190 Summary: Integer overflow in the SplFileObject::fread function in spl_directory.c in the SPL extension in PHP before 5.5.37 and 5.6.x before 5.6.23 allows remote attackers to cause a denial of service or possibly have unspecified other impact via a large integer argument, a related issue to CVE-2016-5096. Commit Message: Fix bug #72262 - do not overflow int
High
167,038
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: bool GLSurfaceEGLSurfaceControl::ScheduleOverlayPlane( int z_order, gfx::OverlayTransform transform, GLImage* image, const gfx::Rect& bounds_rect, const gfx::RectF& crop_rect, bool enable_blend, std::unique_ptr<gfx::GpuFence> gpu_fence) { if (!pending_transaction_) pending_transaction_.emplace(); bool uninitialized = false; if (pending_surfaces_count_ == surface_list_.size()) { uninitialized = true; surface_list_.emplace_back(*root_surface_); } pending_surfaces_count_++; auto& surface_state = surface_list_.at(pending_surfaces_count_ - 1); if (uninitialized || surface_state.z_order != z_order) { surface_state.z_order = z_order; pending_transaction_->SetZOrder(*surface_state.surface, z_order); } AHardwareBuffer* hardware_buffer = nullptr; base::ScopedFD fence_fd; auto scoped_hardware_buffer = image->GetAHardwareBuffer(); if (scoped_hardware_buffer) { hardware_buffer = scoped_hardware_buffer->buffer(); fence_fd = scoped_hardware_buffer->TakeFence(); auto* a_surface = surface_state.surface->surface(); DCHECK_EQ(pending_frame_resources_.count(a_surface), 0u); auto& resource_ref = pending_frame_resources_[a_surface]; resource_ref.surface = surface_state.surface; resource_ref.scoped_buffer = std::move(scoped_hardware_buffer); } if (uninitialized || surface_state.hardware_buffer != hardware_buffer) { surface_state.hardware_buffer = hardware_buffer; if (!fence_fd.is_valid() && gpu_fence && surface_state.hardware_buffer) { auto fence_handle = gfx::CloneHandleForIPC(gpu_fence->GetGpuFenceHandle()); DCHECK(!fence_handle.is_null()); fence_fd = base::ScopedFD(fence_handle.native_fd.fd); } pending_transaction_->SetBuffer(*surface_state.surface, surface_state.hardware_buffer, std::move(fence_fd)); } if (hardware_buffer) { gfx::Rect dst = bounds_rect; gfx::Size buffer_size = GetBufferSize(hardware_buffer); gfx::RectF scaled_rect = gfx::RectF(crop_rect.x() * buffer_size.width(), crop_rect.y() * buffer_size.height(), crop_rect.width() * buffer_size.width(), crop_rect.height() * buffer_size.height()); gfx::Rect src = gfx::ToEnclosedRect(scaled_rect); if (uninitialized || surface_state.src != src || surface_state.dst != dst || surface_state.transform != transform) { surface_state.src = src; surface_state.dst = dst; surface_state.transform = transform; pending_transaction_->SetGeometry(*surface_state.surface, src, dst, transform); } } bool opaque = !enable_blend; if (uninitialized || surface_state.opaque != opaque) { surface_state.opaque = opaque; pending_transaction_->SetOpaque(*surface_state.surface, opaque); } return true; } Vulnerability Type: DoS CWE ID: Summary: Multiple unspecified vulnerabilities in Google Chrome before 52.0.2743.82 allow attackers to cause a denial of service or possibly have other impact via unknown vectors. Commit Message: gpu/android : Add support for partial swap with surface control. Add support for PostSubBuffer to GLSurfaceEGLSurfaceControl. This should allow the display compositor to draw the minimum sub-rect necessary from the damage tracking in BufferQueue on the client-side, and also to pass this damage rect to the framework. [email protected] Bug: 926020 Change-Id: I73d3320cab68250d4c6865bf21c5531682d8bf61 Reviewed-on: https://chromium-review.googlesource.com/c/1457467 Commit-Queue: Khushal <[email protected]> Commit-Queue: Antoine Labour <[email protected]> Reviewed-by: Antoine Labour <[email protected]> Auto-Submit: Khushal <[email protected]> Cr-Commit-Position: refs/heads/master@{#629852}
Medium
172,111
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: void UnloadController::TabDetachedAt(TabContents* contents, int index) { TabDetachedImpl(contents); } Vulnerability Type: CWE ID: CWE-20 Summary: The hyphenation functionality in Google Chrome before 24.0.1312.52 does not properly validate file names, which has unspecified impact and attack vectors. Commit Message: Remove TabContents from TabStripModelObserver::TabDetachedAt. BUG=107201 TEST=no visible change Review URL: https://chromiumcodereview.appspot.com/11293205 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167122 0039d316-1c4b-4281-b951-d872f2087c98
High
171,519
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: InRegionScrollableArea::InRegionScrollableArea(WebPagePrivate* webPage, RenderLayer* layer) : m_webPage(webPage) , m_layer(layer) { ASSERT(webPage); ASSERT(layer); m_isNull = false; RenderObject* layerRenderer = layer->renderer(); ASSERT(layerRenderer); if (layerRenderer->isRenderView()) { // #document case FrameView* view = toRenderView(layerRenderer)->frameView(); ASSERT(view); Frame* frame = view->frame(); ASSERT_UNUSED(frame, frame); m_scrollPosition = m_webPage->mapToTransformed(view->scrollPosition()); m_contentsSize = m_webPage->mapToTransformed(view->contentsSize()); m_viewportSize = m_webPage->mapToTransformed(view->visibleContentRect(false /*includeScrollbars*/)).size(); m_visibleWindowRect = m_webPage->mapToTransformed(m_webPage->getRecursiveVisibleWindowRect(view)); IntRect transformedWindowRect = IntRect(IntPoint::zero(), m_webPage->transformedViewportSize()); m_visibleWindowRect.intersect(transformedWindowRect); m_scrollsHorizontally = view->contentsWidth() > view->visibleWidth(); m_scrollsVertically = view->contentsHeight() > view->visibleHeight(); m_minimumScrollPosition = m_webPage->mapToTransformed(calculateMinimumScrollPosition( view->visibleContentRect().size(), 0.0 /*overscrollLimit*/)); m_maximumScrollPosition = m_webPage->mapToTransformed(calculateMaximumScrollPosition( view->visibleContentRect().size(), view->contentsSize(), 0.0 /*overscrollLimit*/)); } else { // RenderBox-based elements case (scrollable boxes (div's, p's, textarea's, etc)). RenderBox* box = m_layer->renderBox(); ASSERT(box); ASSERT(box->canBeScrolledAndHasScrollableArea()); ScrollableArea* scrollableArea = static_cast<ScrollableArea*>(m_layer); m_scrollPosition = m_webPage->mapToTransformed(scrollableArea->scrollPosition()); m_contentsSize = m_webPage->mapToTransformed(scrollableArea->contentsSize()); m_viewportSize = m_webPage->mapToTransformed(scrollableArea->visibleContentRect(false /*includeScrollbars*/)).size(); m_visibleWindowRect = m_layer->renderer()->absoluteClippedOverflowRect(); m_visibleWindowRect = m_layer->renderer()->frame()->view()->contentsToWindow(m_visibleWindowRect); IntRect visibleFrameWindowRect = m_webPage->getRecursiveVisibleWindowRect(m_layer->renderer()->frame()->view()); m_visibleWindowRect.intersect(visibleFrameWindowRect); m_visibleWindowRect = m_webPage->mapToTransformed(m_visibleWindowRect); IntRect transformedWindowRect = IntRect(IntPoint::zero(), m_webPage->transformedViewportSize()); m_visibleWindowRect.intersect(transformedWindowRect); m_scrollsHorizontally = box->scrollWidth() != box->clientWidth() && box->scrollsOverflowX(); m_scrollsVertically = box->scrollHeight() != box->clientHeight() && box->scrollsOverflowY(); m_minimumScrollPosition = m_webPage->mapToTransformed(calculateMinimumScrollPosition( Platform::IntSize(box->clientWidth(), box->clientHeight()), 0.0 /*overscrollLimit*/)); m_maximumScrollPosition = m_webPage->mapToTransformed(calculateMaximumScrollPosition( Platform::IntSize(box->clientWidth(), box->clientHeight()), Platform::IntSize(box->scrollWidth(), box->scrollHeight()), 0.0 /*overscrollLimit*/)); } } Vulnerability Type: DoS Overflow CWE ID: CWE-119 Summary: Google Chrome before 13.0.782.107 does not properly perform text iteration, which allows remote attackers to cause a denial of service (out-of-bounds read) via unspecified vectors. Commit Message: Remove minimum and maximum scroll position as they are no longer required due to changes in ScrollViewBase. https://bugs.webkit.org/show_bug.cgi?id=87298 Patch by Genevieve Mak <[email protected]> on 2012-05-23 Reviewed by Antonio Gomes. * WebKitSupport/InRegionScrollableArea.cpp: (BlackBerry::WebKit::InRegionScrollableArea::InRegionScrollableArea): * WebKitSupport/InRegionScrollableArea.h: (InRegionScrollableArea): git-svn-id: svn://svn.chromium.org/blink/trunk@118233 bbb929c8-8fbe-4397-9dbb-9b2b20218538
Medium
170,431
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: v8::Local<v8::Value> ModuleSystem::LoadModule(const std::string& module_name) { v8::EscapableHandleScope handle_scope(GetIsolate()); v8::Local<v8::Context> v8_context = context()->v8_context(); v8::Context::Scope context_scope(v8_context); v8::Local<v8::Value> source(GetSource(module_name)); if (source.IsEmpty() || source->IsUndefined()) { Fatal(context_, "No source for require(" + module_name + ")"); return v8::Undefined(GetIsolate()); } v8::Local<v8::String> wrapped_source( WrapSource(v8::Local<v8::String>::Cast(source))); v8::Local<v8::String> v8_module_name; if (!ToV8String(GetIsolate(), module_name.c_str(), &v8_module_name)) { NOTREACHED() << "module_name is too long"; return v8::Undefined(GetIsolate()); } v8::Local<v8::Value> func_as_value = RunString(wrapped_source, v8_module_name); if (func_as_value.IsEmpty() || func_as_value->IsUndefined()) { Fatal(context_, "Bad source for require(" + module_name + ")"); return v8::Undefined(GetIsolate()); } v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(func_as_value); v8::Local<v8::Object> define_object = v8::Object::New(GetIsolate()); gin::ModuleRegistry::InstallGlobals(GetIsolate(), define_object); v8::Local<v8::Value> exports = v8::Object::New(GetIsolate()); v8::Local<v8::Object> natives(NewInstance()); CHECK(!natives.IsEmpty()); // this can fail if v8 has issues v8::Local<v8::Value> args[] = { GetPropertyUnsafe(v8_context, define_object, "define"), GetPropertyUnsafe(v8_context, natives, "require", v8::NewStringType::kInternalized), GetPropertyUnsafe(v8_context, natives, "requireNative", v8::NewStringType::kInternalized), GetPropertyUnsafe(v8_context, natives, "requireAsync", v8::NewStringType::kInternalized), exports, console::AsV8Object(GetIsolate()), GetPropertyUnsafe(v8_context, natives, "privates", v8::NewStringType::kInternalized), context_->safe_builtins()->GetArray(), context_->safe_builtins()->GetFunction(), context_->safe_builtins()->GetJSON(), context_->safe_builtins()->GetObjekt(), context_->safe_builtins()->GetRegExp(), context_->safe_builtins()->GetString(), context_->safe_builtins()->GetError(), }; { v8::TryCatch try_catch(GetIsolate()); try_catch.SetCaptureMessage(true); context_->CallFunction(func, arraysize(args), args); if (try_catch.HasCaught()) { HandleException(try_catch); return v8::Undefined(GetIsolate()); } } return handle_scope.Escape(exports); } Vulnerability Type: Bypass CWE ID: CWE-264 Summary: The Extensions subsystem in Google Chrome before 48.0.2564.109 does not prevent use of the Object.defineProperty method to override intended extension behavior, which allows remote attackers to bypass the Same Origin Policy via crafted JavaScript code. Commit Message: [Extensions] Don't allow built-in extensions code to be overridden BUG=546677 Review URL: https://codereview.chromium.org/1417513003 Cr-Commit-Position: refs/heads/master@{#356654}
Medium
172,287
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: static struct desc_struct *get_desc(unsigned short sel) { struct desc_ptr gdt_desc = {0, 0}; unsigned long desc_base; #ifdef CONFIG_MODIFY_LDT_SYSCALL if ((sel & SEGMENT_TI_MASK) == SEGMENT_LDT) { struct desc_struct *desc = NULL; struct ldt_struct *ldt; /* Bits [15:3] contain the index of the desired entry. */ sel >>= 3; mutex_lock(&current->active_mm->context.lock); ldt = current->active_mm->context.ldt; if (ldt && sel < ldt->nr_entries) desc = &ldt->entries[sel]; mutex_unlock(&current->active_mm->context.lock); return desc; } #endif native_store_gdt(&gdt_desc); /* * Segment descriptors have a size of 8 bytes. Thus, the index is * multiplied by 8 to obtain the memory offset of the desired descriptor * from the base of the GDT. As bits [15:3] of the segment selector * contain the index, it can be regarded as multiplied by 8 already. * All that remains is to clear bits [2:0]. */ desc_base = sel & ~(SEGMENT_RPL_MASK | SEGMENT_TI_MASK); if (desc_base > gdt_desc.size) return NULL; return (struct desc_struct *)(gdt_desc.address + desc_base); } Vulnerability Type: CWE ID: CWE-362 Summary: In arch/x86/lib/insn-eval.c in the Linux kernel before 5.1.9, there is a use-after-free for access to an LDT entry because of a race condition between modify_ldt() and a #BR exception for an MPX bounds violation. Commit Message: x86/insn-eval: Fix use-after-free access to LDT entry get_desc() computes a pointer into the LDT while holding a lock that protects the LDT from being freed, but then drops the lock and returns the (now potentially dangling) pointer to its caller. Fix it by giving the caller a copy of the LDT entry instead. Fixes: 670f928ba09b ("x86/insn-eval: Add utility function to get segment descriptor") Cc: [email protected] Signed-off-by: Jann Horn <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
Medium
169,607
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: OMX_ERRORTYPE SoftAACEncoder2::internalSetParameter( OMX_INDEXTYPE index, const OMX_PTR params) { switch (index) { case OMX_IndexParamStandardComponentRole: { const OMX_PARAM_COMPONENTROLETYPE *roleParams = (const OMX_PARAM_COMPONENTROLETYPE *)params; if (strncmp((const char *)roleParams->cRole, "audio_encoder.aac", OMX_MAX_STRINGNAME_SIZE - 1)) { return OMX_ErrorUndefined; } return OMX_ErrorNone; } case OMX_IndexParamAudioPortFormat: { const OMX_AUDIO_PARAM_PORTFORMATTYPE *formatParams = (const OMX_AUDIO_PARAM_PORTFORMATTYPE *)params; if (formatParams->nPortIndex > 1) { return OMX_ErrorUndefined; } if (formatParams->nIndex > 0) { return OMX_ErrorNoMore; } if ((formatParams->nPortIndex == 0 && formatParams->eEncoding != OMX_AUDIO_CodingPCM) || (formatParams->nPortIndex == 1 && formatParams->eEncoding != OMX_AUDIO_CodingAAC)) { return OMX_ErrorUndefined; } return OMX_ErrorNone; } case OMX_IndexParamAudioAac: { OMX_AUDIO_PARAM_AACPROFILETYPE *aacParams = (OMX_AUDIO_PARAM_AACPROFILETYPE *)params; if (aacParams->nPortIndex != 1) { return OMX_ErrorUndefined; } mBitRate = aacParams->nBitRate; mNumChannels = aacParams->nChannels; mSampleRate = aacParams->nSampleRate; if (aacParams->eAACProfile != OMX_AUDIO_AACObjectNull) { mAACProfile = aacParams->eAACProfile; } if (!(aacParams->nAACtools & OMX_AUDIO_AACToolAndroidSSBR) && !(aacParams->nAACtools & OMX_AUDIO_AACToolAndroidDSBR)) { mSBRMode = 0; mSBRRatio = 0; } else if ((aacParams->nAACtools & OMX_AUDIO_AACToolAndroidSSBR) && !(aacParams->nAACtools & OMX_AUDIO_AACToolAndroidDSBR)) { mSBRMode = 1; mSBRRatio = 1; } else if (!(aacParams->nAACtools & OMX_AUDIO_AACToolAndroidSSBR) && (aacParams->nAACtools & OMX_AUDIO_AACToolAndroidDSBR)) { mSBRMode = 1; mSBRRatio = 2; } else { mSBRMode = -1; // codec default sbr mode mSBRRatio = 0; } if (setAudioParams() != OK) { return OMX_ErrorUndefined; } return OMX_ErrorNone; } case OMX_IndexParamAudioPcm: { OMX_AUDIO_PARAM_PCMMODETYPE *pcmParams = (OMX_AUDIO_PARAM_PCMMODETYPE *)params; if (pcmParams->nPortIndex != 0) { return OMX_ErrorUndefined; } mNumChannels = pcmParams->nChannels; mSampleRate = pcmParams->nSamplingRate; if (setAudioParams() != OK) { return OMX_ErrorUndefined; } return OMX_ErrorNone; } default: return SimpleSoftOMXComponent::internalSetParameter(index, params); } } Vulnerability Type: Overflow +Priv CWE ID: CWE-119 Summary: mediaserver in Android 4.x before 4.4.4, 5.0.x before 5.0.2, 5.1.x before 5.1.1, and 6.x before 2016-06-01 does not validate OMX buffer sizes, which allows attackers to gain privileges via a crafted application, as demonstrated by obtaining Signature or SignatureOrSystem access, aka internal bug 27207275. Commit Message: DO NOT MERGE Verify OMX buffer sizes prior to access Bug: 27207275 Change-Id: I4412825d1ee233d993af0a67708bea54304ff62d
High
174,191
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: bool IsSensitiveURL(const GURL& url, bool is_request_from_browser_or_webui_renderer) { bool sensitive_chrome_url = false; const char kGoogleCom[] = "google.com"; const char kClient[] = "clients"; url::Origin origin = url::Origin::Create(url); if (origin.DomainIs(kGoogleCom)) { base::StringPiece host = url.host_piece(); while (host.ends_with(".")) host.remove_suffix(1u); if (is_request_from_browser_or_webui_renderer) { base::StringPiece::size_type pos = host.rfind(kClient); if (pos != base::StringPiece::npos) { bool match = true; if (pos > 0 && host[pos - 1] != '.') { match = false; } else { for (base::StringPiece::const_iterator i = host.begin() + pos + strlen(kClient), end = host.end() - (strlen(kGoogleCom) + 1); i != end; ++i) { if (!isdigit(*i)) { match = false; break; } } } sensitive_chrome_url = sensitive_chrome_url || match; } } sensitive_chrome_url = sensitive_chrome_url || (url.DomainIs("chrome.google.com") && base::StartsWith(url.path_piece(), "/webstore", base::CompareCase::SENSITIVE)); } return sensitive_chrome_url || extension_urls::IsWebstoreUpdateUrl(url) || extension_urls::IsBlacklistUpdateUrl(url) || extension_urls::IsSafeBrowsingUrl(origin, url.path_piece()); } Vulnerability Type: +Info CWE ID: CWE-200 Summary: Insufficient policy enforcement in DevTools in Google Chrome prior to 64.0.3282.119 allowed a remote attacker to potentially leak user local file data via a crafted Chrome Extension. Commit Message: Hide DevTools frontend from webRequest API Prevent extensions from observing requests for remote DevTools frontends and add regression tests. And update ExtensionTestApi to support initializing the embedded test server and port from SetUpCommandLine (before SetUpOnMainThread). BUG=797497,797500 TEST=browser_test --gtest_filter=DevToolsFrontendInWebRequestApiTest.HiddenRequests Cq-Include-Trybots: master.tryserver.chromium.linux:linux_mojo Change-Id: Ic8f44b5771f2d5796f8c3de128f0a7ab88a77735 Reviewed-on: https://chromium-review.googlesource.com/844316 Commit-Queue: Rob Wu <[email protected]> Reviewed-by: Devlin <[email protected]> Reviewed-by: Dmitry Gozman <[email protected]> Cr-Commit-Position: refs/heads/master@{#528187}
Medium
172,673
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: static InputMethodStatusConnection* GetInstance() { return Singleton<InputMethodStatusConnection, LeakySingletonTraits<InputMethodStatusConnection> >::get(); } Vulnerability Type: DoS CWE ID: CWE-399 Summary: Google Chrome before 13.0.782.107 does not properly handle nested functions in PDF documents, which allows remote attackers to cause a denial of service (application crash) or possibly have unspecified other impact via a crafted document. Commit Message: Remove use of libcros from InputMethodLibrary. BUG=chromium-os:16238 TEST==confirm that input methods work as before on the netbook. Also confirm that the chrome builds and works on the desktop as before. Review URL: http://codereview.chromium.org/7003086 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89142 0039d316-1c4b-4281-b951-d872f2087c98
High
170,535
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: DECLAREcpFunc(cpContig2SeparateByRow) { tsize_t scanlinesizein = TIFFScanlineSize(in); tsize_t scanlinesizeout = TIFFScanlineSize(out); tdata_t inbuf; tdata_t outbuf; register uint8 *inp, *outp; register uint32 n; uint32 row; tsample_t s; inbuf = _TIFFmalloc(scanlinesizein); outbuf = _TIFFmalloc(scanlinesizeout); if (!inbuf || !outbuf) goto bad; _TIFFmemset(inbuf, 0, scanlinesizein); _TIFFmemset(outbuf, 0, scanlinesizeout); /* unpack channels */ for (s = 0; s < spp; s++) { for (row = 0; row < imagelength; row++) { if (TIFFReadScanline(in, inbuf, row, 0) < 0 && !ignore) { TIFFError(TIFFFileName(in), "Error, can't read scanline %lu", (unsigned long) row); goto bad; } inp = ((uint8*)inbuf) + s; outp = (uint8*)outbuf; for (n = imagewidth; n-- > 0;) { *outp++ = *inp; inp += spp; } if (TIFFWriteScanline(out, outbuf, row, s) < 0) { TIFFError(TIFFFileName(out), "Error, can't write scanline %lu", (unsigned long) row); goto bad; } } } if (inbuf) _TIFFfree(inbuf); if (outbuf) _TIFFfree(outbuf); return 1; bad: if (inbuf) _TIFFfree(inbuf); if (outbuf) _TIFFfree(outbuf); return 0; } Vulnerability Type: Exec Code Overflow CWE ID: CWE-119 Summary: LibTIFF version 4.0.7 is vulnerable to a heap buffer overflow in the tools/tiffcp resulting in DoS or code execution via a crafted BitsPerSample value. Commit Message: * tools/tiffcp.c: error out cleanly in cpContig2SeparateByRow and cpSeparate2ContigByRow if BitsPerSample != 8 to avoid heap based overflow. Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2656 and http://bugzilla.maptools.org/show_bug.cgi?id=2657
High
168,412
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb, u32 features) { struct sk_buff *segs = ERR_PTR(-EINVAL); unsigned int mss; unsigned int unfrag_ip6hlen, unfrag_len; struct frag_hdr *fptr; u8 *mac_start, *prevhdr; u8 nexthdr; u8 frag_hdr_sz = sizeof(struct frag_hdr); int offset; __wsum csum; mss = skb_shinfo(skb)->gso_size; if (unlikely(skb->len <= mss)) goto out; if (skb_gso_ok(skb, features | NETIF_F_GSO_ROBUST)) { /* Packet is from an untrusted source, reset gso_segs. */ int type = skb_shinfo(skb)->gso_type; if (unlikely(type & ~(SKB_GSO_UDP | SKB_GSO_DODGY) || !(type & (SKB_GSO_UDP)))) goto out; skb_shinfo(skb)->gso_segs = DIV_ROUND_UP(skb->len, mss); segs = NULL; goto out; } /* Do software UFO. Complete and fill in the UDP checksum as HW cannot * do checksum of UDP packets sent as multiple IP fragments. */ offset = skb_checksum_start_offset(skb); csum = skb_checksum(skb, offset, skb->len- offset, 0); offset += skb->csum_offset; *(__sum16 *)(skb->data + offset) = csum_fold(csum); skb->ip_summed = CHECKSUM_NONE; /* Check if there is enough headroom to insert fragment header. */ if ((skb_mac_header(skb) < skb->head + frag_hdr_sz) && pskb_expand_head(skb, frag_hdr_sz, 0, GFP_ATOMIC)) goto out; /* Find the unfragmentable header and shift it left by frag_hdr_sz * bytes to insert fragment header. */ unfrag_ip6hlen = ip6_find_1stfragopt(skb, &prevhdr); nexthdr = *prevhdr; *prevhdr = NEXTHDR_FRAGMENT; unfrag_len = skb_network_header(skb) - skb_mac_header(skb) + unfrag_ip6hlen; mac_start = skb_mac_header(skb); memmove(mac_start-frag_hdr_sz, mac_start, unfrag_len); skb->mac_header -= frag_hdr_sz; skb->network_header -= frag_hdr_sz; fptr = (struct frag_hdr *)(skb_network_header(skb) + unfrag_ip6hlen); fptr->nexthdr = nexthdr; fptr->reserved = 0; ipv6_select_ident(fptr); /* Fragment the skb. ipv6 header and the remaining fields of the * fragment header are updated in ipv6_gso_segment() */ segs = skb_segment(skb, features); out: return segs; } Vulnerability Type: DoS CWE ID: Summary: The IPv6 implementation in the Linux kernel before 3.1 does not generate Fragment Identification values separately for each destination, which makes it easier for remote attackers to cause a denial of service (disrupted networking) by predicting these values and sending crafted packets. Commit Message: ipv6: make fragment identifications less predictable IPv6 fragment identification generation is way beyond what we use for IPv4 : It uses a single generator. Its not scalable and allows DOS attacks. Now inetpeer is IPv6 aware, we can use it to provide a more secure and scalable frag ident generator (per destination, instead of system wide) This patch : 1) defines a new secure_ipv6_id() helper 2) extends inet_getid() to provide 32bit results 3) extends ipv6_select_ident() with a new dest parameter Reported-by: Fernando Gont <[email protected]> Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
High
165,854
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: virtual void FramePktHook(const vpx_codec_cx_pkt_t *pkt) { if (pkt->data.frame.flags & VPX_FRAME_IS_KEY) { } } Vulnerability Type: DoS Exec Code Overflow Mem. Corr. CWE ID: CWE-119 Summary: libvpx in mediaserver in Android 4.x before 4.4.4, 5.x before 5.1.1 LMY49H, and 6.0 before 2016-03-01 allows remote attackers to execute arbitrary code or cause a denial of service (memory corruption) via a crafted media file, related to libwebm/mkvparser.cpp and other files, aka internal bug 23452792. Commit Message: Merge Conflict Fix CL to lmp-mr1-release for ag/849478 DO NOT MERGE - libvpx: Pull from upstream Current HEAD: 7105df53d7dc13d5e575bc8df714ec8d1da36b06 BUG=23452792 Change-Id: Ic78176fc369e0bacc71d423e0e2e6075d004aaec
High
174,502
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: intuit_diff_type (bool need_header, mode_t *p_file_type) { file_offset this_line = 0; file_offset first_command_line = -1; char first_ed_command_letter = 0; lin fcl_line = 0; /* Pacify 'gcc -W'. */ bool this_is_a_command = false; bool stars_this_line = false; bool extended_headers = false; enum nametype i; struct stat st[3]; int stat_errno[3]; int version_controlled[3]; enum diff retval; mode_t file_type; for (i = OLD; i <= INDEX; i++) if (p_name[i]) { free (p_name[i]); p_name[i] = 0; } for (i = 0; i < ARRAY_SIZE (invalid_names); i++) invalid_names[i] = NULL; for (i = OLD; i <= NEW; i++) if (p_timestr[i]) { free(p_timestr[i]); p_timestr[i] = 0; } for (i = OLD; i <= NEW; i++) if (p_sha1[i]) { free (p_sha1[i]); p_sha1[i] = 0; } p_git_diff = false; for (i = OLD; i <= NEW; i++) { p_mode[i] = 0; p_copy[i] = false; p_rename[i] = false; } /* Ed and normal format patches don't have filename headers. */ if (diff_type == ED_DIFF || diff_type == NORMAL_DIFF) need_header = false; version_controlled[OLD] = -1; version_controlled[NEW] = -1; version_controlled[INDEX] = -1; p_rfc934_nesting = 0; p_timestamp[OLD].tv_sec = p_timestamp[NEW].tv_sec = -1; p_says_nonexistent[OLD] = p_says_nonexistent[NEW] = 0; Fseek (pfp, p_base, SEEK_SET); p_input_line = p_bline - 1; for (;;) { char *s; char *t; file_offset previous_line = this_line; bool last_line_was_command = this_is_a_command; bool stars_last_line = stars_this_line; size_t indent = 0; char ed_command_letter; bool strip_trailing_cr; size_t chars_read; this_line = file_tell (pfp); chars_read = pget_line (0, 0, false, false); if (chars_read == (size_t) -1) xalloc_die (); if (! chars_read) { if (first_ed_command_letter) { /* nothing but deletes!? */ p_start = first_command_line; p_sline = fcl_line; retval = ED_DIFF; goto scan_exit; } else { p_start = this_line; p_sline = p_input_line; if (extended_headers) { /* Patch contains no hunks; any diff type will do. */ retval = UNI_DIFF; goto scan_exit; } return NO_DIFF; } } strip_trailing_cr = 2 <= chars_read && buf[chars_read - 2] == '\r'; for (s = buf; *s == ' ' || *s == '\t' || *s == 'X'; s++) { if (*s == '\t') indent = (indent + 8) & ~7; else indent++; } if (ISDIGIT (*s)) { for (t = s + 1; ISDIGIT (*t) || *t == ','; t++) /* do nothing */ ; if (*t == 'd' || *t == 'c' || *t == 'a') { for (t++; ISDIGIT (*t) || *t == ','; t++) /* do nothing */ ; for (; *t == ' ' || *t == '\t'; t++) /* do nothing */ ; if (*t == '\r') t++; this_is_a_command = (*t == '\n'); } } if (! need_header && first_command_line < 0 && ((ed_command_letter = get_ed_command_letter (s)) || this_is_a_command)) { first_command_line = this_line; first_ed_command_letter = ed_command_letter; fcl_line = p_input_line; p_indent = indent; /* assume this for now */ p_strip_trailing_cr = strip_trailing_cr; } if (!stars_last_line && strnEQ(s, "*** ", 4)) { fetchname (s+4, strippath, &p_name[OLD], &p_timestr[OLD], &p_timestamp[OLD]); need_header = false; } else if (strnEQ(s, "+++ ", 4)) { /* Swap with NEW below. */ fetchname (s+4, strippath, &p_name[OLD], &p_timestr[OLD], &p_timestamp[OLD]); need_header = false; p_strip_trailing_cr = strip_trailing_cr; } else if (strnEQ(s, "Index:", 6)) { fetchname (s+6, strippath, &p_name[INDEX], (char **) 0, NULL); need_header = false; p_strip_trailing_cr = strip_trailing_cr; } else if (strnEQ(s, "Prereq:", 7)) { for (t = s + 7; ISSPACE ((unsigned char) *t); t++) /* do nothing */ ; revision = t; for (t = revision; *t; t++) if (ISSPACE ((unsigned char) *t)) { char const *u; for (u = t + 1; ISSPACE ((unsigned char) *u); u++) /* do nothing */ ; if (*u) { char numbuf[LINENUM_LENGTH_BOUND + 1]; say ("Prereq: with multiple words at line %s of patch\n", format_linenum (numbuf, this_line)); } break; } if (t == revision) revision = 0; else { char oldc = *t; *t = '\0'; revision = xstrdup (revision); *t = oldc; } } else if (strnEQ (s, "diff --git ", 11)) { char const *u; if (extended_headers) { p_start = this_line; p_sline = p_input_line; /* Patch contains no hunks; any diff type will do. */ retval = UNI_DIFF; goto scan_exit; } for (i = OLD; i <= NEW; i++) { free (p_name[i]); p_name[i] = 0; } if (! ((p_name[OLD] = parse_name (s + 11, strippath, &u)) && ISSPACE ((unsigned char) *u) && (p_name[NEW] = parse_name (u, strippath, &u)) && (u = skip_spaces (u), ! *u))) for (i = OLD; i <= NEW; i++) { free (p_name[i]); p_name[i] = 0; } p_git_diff = true; } else if (p_git_diff && strnEQ (s, "index ", 6)) { char const *u, *v; if ((u = skip_hex_digits (s + 6)) && u[0] == '.' && u[1] == '.' && (v = skip_hex_digits (u + 2)) && (! *v || ISSPACE ((unsigned char) *v))) { get_sha1(&p_sha1[OLD], s + 6, u); get_sha1(&p_sha1[NEW], u + 2, v); p_says_nonexistent[OLD] = sha1_says_nonexistent (p_sha1[OLD]); p_says_nonexistent[NEW] = sha1_says_nonexistent (p_sha1[NEW]); if (*(v = skip_spaces (v))) p_mode[OLD] = p_mode[NEW] = fetchmode (v); extended_headers = true; } } else if (p_git_diff && strnEQ (s, "old mode ", 9)) { p_mode[OLD] = fetchmode (s + 9); extended_headers = true; } else if (p_git_diff && strnEQ (s, "new mode ", 9)) { p_mode[NEW] = fetchmode (s + 9); extended_headers = true; } else if (p_git_diff && strnEQ (s, "deleted file mode ", 18)) { p_mode[OLD] = fetchmode (s + 18); p_says_nonexistent[NEW] = 2; extended_headers = true; } else if (p_git_diff && strnEQ (s, "new file mode ", 14)) { p_mode[NEW] = fetchmode (s + 14); p_says_nonexistent[OLD] = 2; extended_headers = true; } else if (p_git_diff && strnEQ (s, "rename from ", 12)) { /* Git leaves out the prefix in the file name in this header, so we can only ignore the file name. */ p_rename[OLD] = true; extended_headers = true; } else if (p_git_diff && strnEQ (s, "rename to ", 10)) { /* Git leaves out the prefix in the file name in this header, so we can only ignore the file name. */ p_rename[NEW] = true; extended_headers = true; } else if (p_git_diff && strnEQ (s, "copy from ", 10)) { /* Git leaves out the prefix in the file name in this header, so we can only ignore the file name. */ p_copy[OLD] = true; extended_headers = true; } else if (p_git_diff && strnEQ (s, "copy to ", 8)) { /* Git leaves out the prefix in the file name in this header, so we can only ignore the file name. */ p_copy[NEW] = true; extended_headers = true; } else if (p_git_diff && strnEQ (s, "GIT binary patch", 16)) { p_start = this_line; p_sline = p_input_line; retval = GIT_BINARY_DIFF; goto scan_exit; } else { for (t = s; t[0] == '-' && t[1] == ' '; t += 2) /* do nothing */ ; if (strnEQ(t, "--- ", 4)) { struct timespec timestamp; timestamp.tv_sec = -1; fetchname (t+4, strippath, &p_name[NEW], &p_timestr[NEW], &timestamp); need_header = false; if (timestamp.tv_sec != -1) { p_timestamp[NEW] = timestamp; p_rfc934_nesting = (t - s) >> 1; } p_strip_trailing_cr = strip_trailing_cr; } } if (need_header) continue; if ((diff_type == NO_DIFF || diff_type == ED_DIFF) && first_command_line >= 0 && strEQ(s, ".\n") ) { p_start = first_command_line; p_sline = fcl_line; retval = ED_DIFF; goto scan_exit; } if ((diff_type == NO_DIFF || diff_type == UNI_DIFF) && strnEQ(s, "@@ -", 4)) { /* 'p_name', 'p_timestr', and 'p_timestamp' are backwards; swap them. */ struct timespec ti = p_timestamp[OLD]; p_timestamp[OLD] = p_timestamp[NEW]; p_timestamp[NEW] = ti; t = p_name[OLD]; p_name[OLD] = p_name[NEW]; p_name[NEW] = t; t = p_timestr[OLD]; p_timestr[OLD] = p_timestr[NEW]; p_timestr[NEW] = t; s += 4; if (s[0] == '0' && !ISDIGIT (s[1])) p_says_nonexistent[OLD] = 1 + ! p_timestamp[OLD].tv_sec; while (*s != ' ' && *s != '\n') s++; while (*s == ' ') s++; if (s[0] == '+' && s[1] == '0' && !ISDIGIT (s[2])) p_says_nonexistent[NEW] = 1 + ! p_timestamp[NEW].tv_sec; p_indent = indent; p_start = this_line; p_sline = p_input_line; retval = UNI_DIFF; if (! ((p_name[OLD] || ! p_timestamp[OLD].tv_sec) && (p_name[NEW] || ! p_timestamp[NEW].tv_sec)) && ! p_name[INDEX] && need_header) { char numbuf[LINENUM_LENGTH_BOUND + 1]; say ("missing header for unified diff at line %s of patch\n", format_linenum (numbuf, p_sline)); } goto scan_exit; } stars_this_line = strnEQ(s, "********", 8); if ((diff_type == NO_DIFF || diff_type == CONTEXT_DIFF || diff_type == NEW_CONTEXT_DIFF) && stars_last_line && strnEQ (s, "*** ", 4)) { s += 4; if (s[0] == '0' && !ISDIGIT (s[1])) p_says_nonexistent[OLD] = 1 + ! p_timestamp[OLD].tv_sec; /* if this is a new context diff the character just before */ /* the newline is a '*'. */ while (*s != '\n') s++; p_indent = indent; p_strip_trailing_cr = strip_trailing_cr; p_start = previous_line; p_sline = p_input_line - 1; retval = (*(s-1) == '*' ? NEW_CONTEXT_DIFF : CONTEXT_DIFF); { /* Scan the first hunk to see whether the file contents appear to have been deleted. */ file_offset saved_p_base = p_base; lin saved_p_bline = p_bline; Fseek (pfp, previous_line, SEEK_SET); p_input_line -= 2; if (another_hunk (retval, false) && ! p_repl_lines && p_newfirst == 1) p_says_nonexistent[NEW] = 1 + ! p_timestamp[NEW].tv_sec; next_intuit_at (saved_p_base, saved_p_bline); } if (! ((p_name[OLD] || ! p_timestamp[OLD].tv_sec) && (p_name[NEW] || ! p_timestamp[NEW].tv_sec)) && ! p_name[INDEX] && need_header) { char numbuf[LINENUM_LENGTH_BOUND + 1]; say ("missing header for context diff at line %s of patch\n", format_linenum (numbuf, p_sline)); } goto scan_exit; } if ((diff_type == NO_DIFF || diff_type == NORMAL_DIFF) && last_line_was_command && (strnEQ(s, "< ", 2) || strnEQ(s, "> ", 2)) ) { p_start = previous_line; p_sline = p_input_line - 1; p_indent = indent; retval = NORMAL_DIFF; goto scan_exit; } } scan_exit: /* The old, new, or old and new file types may be defined. When both file types are defined, make sure they are the same, or else assume we do not know the file type. */ file_type = p_mode[OLD] & S_IFMT; if (file_type) { mode_t new_file_type = p_mode[NEW] & S_IFMT; if (new_file_type && file_type != new_file_type) file_type = 0; } else { file_type = p_mode[NEW] & S_IFMT; if (! file_type) file_type = S_IFREG; } *p_file_type = file_type; /* To intuit 'inname', the name of the file to patch, use the algorithm specified by POSIX 1003.1-2001 XCU lines 25680-26599 (with some modifications if posixly_correct is zero): - Take the old and new names from the context header if present, and take the index name from the 'Index:' line if present and if either the old and new names are both absent or posixly_correct is nonzero. Consider the file names to be in the order (old, new, index). - If some named files exist, use the first one if posixly_correct is nonzero, the best one otherwise. - If patch_get is nonzero, and no named files exist, but an RCS or SCCS master file exists, use the first named file with an RCS or SCCS master. - If no named files exist, no RCS or SCCS master was found, some names are given, posixly_correct is zero, and the patch appears to create a file, then use the best name requiring the creation of the fewest directories. - Otherwise, report failure by setting 'inname' to 0; this causes our invoker to ask the user for a file name. */ i = NONE; if (!inname) { enum nametype i0 = NONE; if (! posixly_correct && (p_name[OLD] || p_name[NEW]) && p_name[INDEX]) { free (p_name[INDEX]); p_name[INDEX] = 0; } for (i = OLD; i <= INDEX; i++) if (p_name[i]) { if (i0 != NONE && strcmp (p_name[i0], p_name[i]) == 0) { /* It's the same name as before; reuse stat results. */ stat_errno[i] = stat_errno[i0]; if (! stat_errno[i]) st[i] = st[i0]; } else { stat_errno[i] = stat_file (p_name[i], &st[i]); if (! stat_errno[i]) { if (lookup_file_id (&st[i]) == DELETE_LATER) stat_errno[i] = ENOENT; else if (posixly_correct && name_is_valid (p_name[i])) break; } } i0 = i; } if (! posixly_correct) { /* The best of all existing files. */ i = best_name (p_name, stat_errno); if (i == NONE && patch_get) { enum nametype nope = NONE; for (i = OLD; i <= INDEX; i++) if (p_name[i]) { char const *cs; char *getbuf; char *diffbuf; bool readonly = (outfile && strcmp (outfile, p_name[i]) != 0); if (nope == NONE || strcmp (p_name[nope], p_name[i]) != 0) { cs = (version_controller (p_name[i], readonly, (struct stat *) 0, &getbuf, &diffbuf)); version_controlled[i] = !! cs; if (cs) { if (version_get (p_name[i], cs, false, readonly, getbuf, &st[i])) stat_errno[i] = 0; else version_controlled[i] = 0; free (getbuf); free (diffbuf); if (! stat_errno[i]) break; } } nope = i; } } if (i0 != NONE && (i == NONE || (st[i].st_mode & S_IFMT) == file_type) && maybe_reverse (p_name[i == NONE ? i0 : i], i == NONE, i == NONE || st[i].st_size == 0) && i == NONE) i = i0; if (i == NONE && p_says_nonexistent[reverse]) { int newdirs[3]; int newdirs_min = INT_MAX; int distance_from_minimum[3]; for (i = OLD; i <= INDEX; i++) if (p_name[i]) { newdirs[i] = (prefix_components (p_name[i], false) - prefix_components (p_name[i], true)); if (newdirs[i] < newdirs_min) newdirs_min = newdirs[i]; } for (i = OLD; i <= INDEX; i++) if (p_name[i]) distance_from_minimum[i] = newdirs[i] - newdirs_min; /* The best of the filenames which create the fewest directories. */ i = best_name (p_name, distance_from_minimum); } } } if (i == NONE) { if (inname) inname = xstrdup (p_name[i]); inerrno = stat_errno[i]; invc = version_controlled[i]; instat = st[i]; } return retval; } Vulnerability Type: Dir. Trav. CWE ID: CWE-22 Summary: Directory traversal vulnerability in GNU patch versions which support Git-style patching before 2.7.3 allows remote attackers to write to arbitrary files with the permissions of the target user via a .. (dot dot) in a diff file name. Commit Message:
High
165,397
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: sg_start_req(Sg_request *srp, unsigned char *cmd) { int res; struct request *rq; Sg_fd *sfp = srp->parentfp; sg_io_hdr_t *hp = &srp->header; int dxfer_len = (int) hp->dxfer_len; int dxfer_dir = hp->dxfer_direction; unsigned int iov_count = hp->iovec_count; Sg_scatter_hold *req_schp = &srp->data; Sg_scatter_hold *rsv_schp = &sfp->reserve; struct request_queue *q = sfp->parentdp->device->request_queue; struct rq_map_data *md, map_data; int rw = hp->dxfer_direction == SG_DXFER_TO_DEV ? WRITE : READ; unsigned char *long_cmdp = NULL; SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, sfp->parentdp, "sg_start_req: dxfer_len=%d\n", dxfer_len)); if (hp->cmd_len > BLK_MAX_CDB) { long_cmdp = kzalloc(hp->cmd_len, GFP_KERNEL); if (!long_cmdp) return -ENOMEM; } /* * NOTE * * With scsi-mq enabled, there are a fixed number of preallocated * requests equal in number to shost->can_queue. If all of the * preallocated requests are already in use, then using GFP_ATOMIC with * blk_get_request() will return -EWOULDBLOCK, whereas using GFP_KERNEL * will cause blk_get_request() to sleep until an active command * completes, freeing up a request. Neither option is ideal, but * GFP_KERNEL is the better choice to prevent userspace from getting an * unexpected EWOULDBLOCK. * * With scsi-mq disabled, blk_get_request() with GFP_KERNEL usually * does not sleep except under memory pressure. */ rq = blk_get_request(q, rw, GFP_KERNEL); if (IS_ERR(rq)) { kfree(long_cmdp); return PTR_ERR(rq); } blk_rq_set_block_pc(rq); if (hp->cmd_len > BLK_MAX_CDB) rq->cmd = long_cmdp; memcpy(rq->cmd, cmd, hp->cmd_len); rq->cmd_len = hp->cmd_len; srp->rq = rq; rq->end_io_data = srp; rq->sense = srp->sense_b; rq->retries = SG_DEFAULT_RETRIES; if ((dxfer_len <= 0) || (dxfer_dir == SG_DXFER_NONE)) return 0; if (sg_allow_dio && hp->flags & SG_FLAG_DIRECT_IO && dxfer_dir != SG_DXFER_UNKNOWN && !iov_count && !sfp->parentdp->device->host->unchecked_isa_dma && blk_rq_aligned(q, (unsigned long)hp->dxferp, dxfer_len)) md = NULL; else md = &map_data; if (md) { if (!sg_res_in_use(sfp) && dxfer_len <= rsv_schp->bufflen) sg_link_reserve(sfp, srp, dxfer_len); else { res = sg_build_indirect(req_schp, sfp, dxfer_len); if (res) return res; } md->pages = req_schp->pages; md->page_order = req_schp->page_order; md->nr_entries = req_schp->k_use_sg; md->offset = 0; md->null_mapped = hp->dxferp ? 0 : 1; if (dxfer_dir == SG_DXFER_TO_FROM_DEV) md->from_user = 1; else md->from_user = 0; } if (unlikely(iov_count > MAX_UIOVEC)) return -EINVAL; if (iov_count) { int size = sizeof(struct iovec) * iov_count; struct iovec *iov; struct iov_iter i; iov = memdup_user(hp->dxferp, size); if (IS_ERR(iov)) return PTR_ERR(iov); iov_iter_init(&i, rw, iov, iov_count, min_t(size_t, hp->dxfer_len, iov_length(iov, iov_count))); res = blk_rq_map_user_iov(q, rq, md, &i, GFP_ATOMIC); kfree(iov); } else res = blk_rq_map_user(q, rq, md, hp->dxferp, hp->dxfer_len, GFP_ATOMIC); if (!res) { srp->bio = rq->bio; if (!md) { req_schp->dio_in_use = 1; hp->info |= SG_INFO_DIRECT_IO; } } return res; } Vulnerability Type: DoS Overflow CWE ID: CWE-189 Summary: Integer overflow in the sg_start_req function in drivers/scsi/sg.c in the Linux kernel 2.6.x through 4.x before 4.1 allows local users to cause a denial of service or possibly have unspecified other impact via a large iov_count value in a write request. Commit Message: sg_start_req(): use import_iovec() Signed-off-by: Al Viro <[email protected]>
Medium
169,924
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: static bool nested_vmx_exit_handled(struct kvm_vcpu *vcpu) { u32 intr_info = vmcs_read32(VM_EXIT_INTR_INFO); struct vcpu_vmx *vmx = to_vmx(vcpu); struct vmcs12 *vmcs12 = get_vmcs12(vcpu); u32 exit_reason = vmx->exit_reason; trace_kvm_nested_vmexit(kvm_rip_read(vcpu), exit_reason, vmcs_readl(EXIT_QUALIFICATION), vmx->idt_vectoring_info, intr_info, vmcs_read32(VM_EXIT_INTR_ERROR_CODE), KVM_ISA_VMX); if (vmx->nested.nested_run_pending) return false; if (unlikely(vmx->fail)) { pr_info_ratelimited("%s failed vm entry %x\n", __func__, vmcs_read32(VM_INSTRUCTION_ERROR)); return true; } switch (exit_reason) { case EXIT_REASON_EXCEPTION_NMI: if (!is_exception(intr_info)) return false; else if (is_page_fault(intr_info)) return enable_ept; else if (is_no_device(intr_info) && !(vmcs12->guest_cr0 & X86_CR0_TS)) return false; else if (is_debug(intr_info) && vcpu->guest_debug & (KVM_GUESTDBG_SINGLESTEP | KVM_GUESTDBG_USE_HW_BP)) return false; else if (is_breakpoint(intr_info) && vcpu->guest_debug & KVM_GUESTDBG_USE_SW_BP) return false; return vmcs12->exception_bitmap & (1u << (intr_info & INTR_INFO_VECTOR_MASK)); case EXIT_REASON_EXTERNAL_INTERRUPT: return false; case EXIT_REASON_TRIPLE_FAULT: return true; case EXIT_REASON_PENDING_INTERRUPT: return nested_cpu_has(vmcs12, CPU_BASED_VIRTUAL_INTR_PENDING); case EXIT_REASON_NMI_WINDOW: return nested_cpu_has(vmcs12, CPU_BASED_VIRTUAL_NMI_PENDING); case EXIT_REASON_TASK_SWITCH: return true; case EXIT_REASON_CPUID: if (kvm_register_read(vcpu, VCPU_REGS_RAX) == 0xa) return false; return true; case EXIT_REASON_HLT: return nested_cpu_has(vmcs12, CPU_BASED_HLT_EXITING); case EXIT_REASON_INVD: return true; case EXIT_REASON_INVLPG: return nested_cpu_has(vmcs12, CPU_BASED_INVLPG_EXITING); case EXIT_REASON_RDPMC: return nested_cpu_has(vmcs12, CPU_BASED_RDPMC_EXITING); case EXIT_REASON_RDTSC: case EXIT_REASON_RDTSCP: return nested_cpu_has(vmcs12, CPU_BASED_RDTSC_EXITING); case EXIT_REASON_VMCALL: case EXIT_REASON_VMCLEAR: case EXIT_REASON_VMLAUNCH: case EXIT_REASON_VMPTRLD: case EXIT_REASON_VMPTRST: case EXIT_REASON_VMREAD: case EXIT_REASON_VMRESUME: case EXIT_REASON_VMWRITE: case EXIT_REASON_VMOFF: case EXIT_REASON_VMON: case EXIT_REASON_INVEPT: case EXIT_REASON_INVVPID: /* * VMX instructions trap unconditionally. This allows L1 to * emulate them for its L2 guest, i.e., allows 3-level nesting! */ return true; case EXIT_REASON_CR_ACCESS: return nested_vmx_exit_handled_cr(vcpu, vmcs12); case EXIT_REASON_DR_ACCESS: return nested_cpu_has(vmcs12, CPU_BASED_MOV_DR_EXITING); case EXIT_REASON_IO_INSTRUCTION: return nested_vmx_exit_handled_io(vcpu, vmcs12); case EXIT_REASON_GDTR_IDTR: case EXIT_REASON_LDTR_TR: return nested_cpu_has2(vmcs12, SECONDARY_EXEC_DESC); case EXIT_REASON_MSR_READ: case EXIT_REASON_MSR_WRITE: return nested_vmx_exit_handled_msr(vcpu, vmcs12, exit_reason); case EXIT_REASON_INVALID_STATE: return true; case EXIT_REASON_MWAIT_INSTRUCTION: return nested_cpu_has(vmcs12, CPU_BASED_MWAIT_EXITING); case EXIT_REASON_MONITOR_TRAP_FLAG: return nested_cpu_has(vmcs12, CPU_BASED_MONITOR_TRAP_FLAG); case EXIT_REASON_MONITOR_INSTRUCTION: return nested_cpu_has(vmcs12, CPU_BASED_MONITOR_EXITING); case EXIT_REASON_PAUSE_INSTRUCTION: return nested_cpu_has(vmcs12, CPU_BASED_PAUSE_EXITING) || nested_cpu_has2(vmcs12, SECONDARY_EXEC_PAUSE_LOOP_EXITING); case EXIT_REASON_MCE_DURING_VMENTRY: return false; case EXIT_REASON_TPR_BELOW_THRESHOLD: return nested_cpu_has(vmcs12, CPU_BASED_TPR_SHADOW); case EXIT_REASON_APIC_ACCESS: return nested_cpu_has2(vmcs12, SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES); case EXIT_REASON_APIC_WRITE: case EXIT_REASON_EOI_INDUCED: /* apic_write and eoi_induced should exit unconditionally. */ return true; case EXIT_REASON_EPT_VIOLATION: /* * L0 always deals with the EPT violation. If nested EPT is * used, and the nested mmu code discovers that the address is * missing in the guest EPT table (EPT12), the EPT violation * will be injected with nested_ept_inject_page_fault() */ return false; case EXIT_REASON_EPT_MISCONFIG: /* * L2 never uses directly L1's EPT, but rather L0's own EPT * table (shadow on EPT) or a merged EPT table that L0 built * (EPT on EPT). So any problems with the structure of the * table is L0's fault. */ return false; case EXIT_REASON_WBINVD: return nested_cpu_has2(vmcs12, SECONDARY_EXEC_WBINVD_EXITING); case EXIT_REASON_XSETBV: return true; case EXIT_REASON_XSAVES: case EXIT_REASON_XRSTORS: /* * This should never happen, since it is not possible to * set XSS to a non-zero value---neither in L1 nor in L2. * If if it were, XSS would have to be checked against * the XSS exit bitmap in vmcs12. */ return nested_cpu_has2(vmcs12, SECONDARY_EXEC_XSAVES); case EXIT_REASON_PREEMPTION_TIMER: return false; default: return true; } } Vulnerability Type: DoS CWE ID: CWE-388 Summary: arch/x86/kvm/vmx.c in the Linux kernel through 4.9 mismanages the #BP and #OF exceptions, which allows guest OS users to cause a denial of service (guest OS crash) by declining to handle an exception thrown by an L2 guest. Commit Message: kvm: nVMX: Allow L1 to intercept software exceptions (#BP and #OF) When L2 exits to L0 due to "exception or NMI", software exceptions (#BP and #OF) for which L1 has requested an intercept should be handled by L1 rather than L0. Previously, only hardware exceptions were forwarded to L1. Signed-off-by: Jim Mattson <[email protected]> Cc: [email protected] Signed-off-by: Paolo Bonzini <[email protected]>
Low
166,856
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: ProcXFixesSetCursorName(ClientPtr client) { CursorPtr pCursor; char *tchar; REQUEST(xXFixesSetCursorNameReq); REQUEST(xXFixesSetCursorNameReq); Atom atom; REQUEST_AT_LEAST_SIZE(xXFixesSetCursorNameReq); VERIFY_CURSOR(pCursor, stuff->cursor, client, DixSetAttrAccess); tchar = (char *) &stuff[1]; atom = MakeAtom(tchar, stuff->nbytes, TRUE); return BadAlloc; pCursor->name = atom; return Success; } Vulnerability Type: Exec Code CWE ID: CWE-20 Summary: xorg-x11-server before 1.19.5 was missing length validation in XFIXES extension allowing malicious X client to cause X server to crash or possibly execute arbitrary code. Commit Message:
High
165,439
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: my_object_increment_retval (MyObject *obj, gint32 x) { return x + 1; } Vulnerability Type: DoS Bypass CWE ID: CWE-264 Summary: DBus-GLib 0.73 disregards the access flag of exported GObject properties, which allows local users to bypass intended access restrictions and possibly cause a denial of service by modifying properties, as demonstrated by properties of the (1) DeviceKit-Power, (2) NetworkManager, and (3) ModemManager services. Commit Message:
Low
165,106
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: static void dma_rx(struct b43_dmaring *ring, int *slot) { const struct b43_dma_ops *ops = ring->ops; struct b43_dmadesc_generic *desc; struct b43_dmadesc_meta *meta; struct b43_rxhdr_fw4 *rxhdr; struct sk_buff *skb; u16 len; int err; dma_addr_t dmaaddr; desc = ops->idx2desc(ring, *slot, &meta); sync_descbuffer_for_cpu(ring, meta->dmaaddr, ring->rx_buffersize); skb = meta->skb; rxhdr = (struct b43_rxhdr_fw4 *)skb->data; len = le16_to_cpu(rxhdr->frame_len); if (len == 0) { int i = 0; do { udelay(2); barrier(); len = le16_to_cpu(rxhdr->frame_len); } while (len == 0 && i++ < 5); if (unlikely(len == 0)) { dmaaddr = meta->dmaaddr; goto drop_recycle_buffer; } } if (unlikely(b43_rx_buffer_is_poisoned(ring, skb))) { /* Something went wrong with the DMA. * The device did not touch the buffer and did not overwrite the poison. */ b43dbg(ring->dev->wl, "DMA RX: Dropping poisoned buffer.\n"); dmaaddr = meta->dmaaddr; goto drop_recycle_buffer; } if (unlikely(len > ring->rx_buffersize)) { /* The data did not fit into one descriptor buffer * and is split over multiple buffers. * This should never happen, as we try to allocate buffers * big enough. So simply ignore this packet. */ int cnt = 0; s32 tmp = len; while (1) { desc = ops->idx2desc(ring, *slot, &meta); /* recycle the descriptor buffer. */ b43_poison_rx_buffer(ring, meta->skb); sync_descbuffer_for_device(ring, meta->dmaaddr, ring->rx_buffersize); *slot = next_slot(ring, *slot); cnt++; tmp -= ring->rx_buffersize; if (tmp <= 0) break; } b43err(ring->dev->wl, "DMA RX buffer too small " "(len: %u, buffer: %u, nr-dropped: %d)\n", len, ring->rx_buffersize, cnt); goto drop; } dmaaddr = meta->dmaaddr; err = setup_rx_descbuffer(ring, desc, meta, GFP_ATOMIC); if (unlikely(err)) { b43dbg(ring->dev->wl, "DMA RX: setup_rx_descbuffer() failed\n"); goto drop_recycle_buffer; } unmap_descbuffer(ring, dmaaddr, ring->rx_buffersize, 0); skb_put(skb, len + ring->frameoffset); skb_pull(skb, ring->frameoffset); b43_rx(ring->dev, skb, rxhdr); drop: return; drop_recycle_buffer: /* Poison and recycle the RX buffer. */ b43_poison_rx_buffer(ring, skb); sync_descbuffer_for_device(ring, dmaaddr, ring->rx_buffersize); } Vulnerability Type: DoS Overflow CWE ID: CWE-119 Summary: The dma_rx function in drivers/net/wireless/b43/dma.c in the Linux kernel before 2.6.39 does not properly allocate receive buffers, which allows remote attackers to cause a denial of service (system crash) via a crafted frame. Commit Message: b43: allocate receive buffers big enough for max frame len + offset Otherwise, skb_put inside of dma_rx can fail... https://bugzilla.kernel.org/show_bug.cgi?id=32042 Signed-off-by: John W. Linville <[email protected]> Acked-by: Larry Finger <[email protected]> Cc: [email protected]
Medium
165,746
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: void br_mdb_notify(struct net_device *dev, struct net_bridge_port *port, struct br_ip *group, int type) { struct br_mdb_entry entry; entry.ifindex = port->dev->ifindex; entry.addr.proto = group->proto; entry.addr.u.ip4 = group->u.ip4; #if IS_ENABLED(CONFIG_IPV6) entry.addr.u.ip6 = group->u.ip6; #endif __br_mdb_notify(dev, &entry, type); } Vulnerability Type: +Info CWE ID: CWE-399 Summary: net/bridge/br_mdb.c in the Linux kernel before 3.8.4 does not initialize certain structures, which allows local users to obtain sensitive information from kernel memory via a crafted application. Commit Message: bridge: fix mdb info leaks The bridging code discloses heap and stack bytes via the RTM_GETMDB netlink interface and via the notify messages send to group RTNLGRP_MDB afer a successful add/del. Fix both cases by initializing all unset members/padding bytes with memset(0). Cc: Stephen Hemminger <[email protected]> Signed-off-by: Mathias Krause <[email protected]> Signed-off-by: David S. Miller <[email protected]>
Low
166,054
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: static int entersafe_gen_key(sc_card_t *card, sc_entersafe_gen_key_data *data) { int r; size_t len = data->key_length >> 3; sc_apdu_t apdu; u8 rbuf[300]; u8 sbuf[4],*p; SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE); /* MSE */ sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x22, 0x01, 0xB8); apdu.lc=0x04; sbuf[0]=0x83; sbuf[1]=0x02; sbuf[2]=data->key_id; sbuf[3]=0x2A; apdu.data = sbuf; apdu.datalen=4; apdu.lc=4; apdu.le=0; r=entersafe_transmit_apdu(card, &apdu, 0,0,0,0); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "APDU transmit failed"); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, sc_check_sw(card,apdu.sw1,apdu.sw2),"EnterSafe set MSE failed"); /* generate key */ sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x46, 0x00, 0x00); apdu.le = 0; sbuf[0] = (u8)(data->key_length >> 8); sbuf[1] = (u8)(data->key_length); apdu.data = sbuf; apdu.lc = 2; apdu.datalen = 2; r = entersafe_transmit_apdu(card, &apdu,0,0,0,0); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "APDU transmit failed"); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, sc_check_sw(card,apdu.sw1,apdu.sw2),"EnterSafe generate keypair failed"); /* read public key via READ PUBLIC KEY */ sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xE6, 0x2A, data->key_id); apdu.cla = 0x80; apdu.resp = rbuf; apdu.resplen = sizeof(rbuf); apdu.le = 256; r = entersafe_transmit_apdu(card, &apdu,0,0,0,0); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "APDU transmit failed"); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, sc_check_sw(card,apdu.sw1,apdu.sw2),"EnterSafe get pukey failed"); data->modulus = malloc(len); if (!data->modulus) SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE,SC_ERROR_OUT_OF_MEMORY); p=rbuf; assert(*p=='E'); p+=2+p[1]; /* N */ assert(*p=='N'); ++p; if(*p++>0x80) { u8 len_bytes=(*(p-1))&0x0f; size_t module_len=0; while(len_bytes!=0) { module_len=module_len<<8; module_len+=*p++; --len_bytes; } } entersafe_reverse_buffer(p,len); memcpy(data->modulus,p,len); SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE,SC_SUCCESS); } Vulnerability Type: CWE ID: CWE-125 Summary: Various out of bounds reads when handling responses in OpenSC before 0.19.0-rc1 could be used by attackers able to supply crafted smartcards to potentially crash the opensc library using programs. Commit Message: fixed out of bounds reads Thanks to Eric Sesterhenn from X41 D-SEC GmbH for reporting and suggesting security fixes.
Low
169,052
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: parse_array(JsonLexContext *lex, JsonSemAction *sem) { /* * an array is a possibly empty sequence of array elements, separated by * commas and surrounded by square brackets. */ json_struct_action astart = sem->array_start; json_struct_action aend = sem->array_end; json_struct_action astart = sem->array_start; json_struct_action aend = sem->array_end; if (astart != NULL) (*astart) (sem->semstate); * array end. */ lex->lex_level++; lex_expect(JSON_PARSE_ARRAY_START, lex, JSON_TOKEN_ARRAY_START); if (lex_peek(lex) != JSON_TOKEN_ARRAY_END) { parse_array_element(lex, sem); while (lex_accept(lex, JSON_TOKEN_COMMA, NULL)) parse_array_element(lex, sem); } lex_expect(JSON_PARSE_ARRAY_NEXT, lex, JSON_TOKEN_ARRAY_END); lex->lex_level--; if (aend != NULL) (*aend) (sem->semstate); } Vulnerability Type: DoS Overflow CWE ID: CWE-119 Summary: Multiple stack-based buffer overflows in json parsing in PostgreSQL before 9.3.x before 9.3.10 and 9.4.x before 9.4.5 allow attackers to cause a denial of service (server crash) via unspecified vectors, which are not properly handled in (1) json or (2) jsonb values. Commit Message:
Medium
164,679
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: static int hugetlbfs_statfs(struct dentry *dentry, struct kstatfs *buf) { struct hugetlbfs_sb_info *sbinfo = HUGETLBFS_SB(dentry->d_sb); struct hstate *h = hstate_inode(dentry->d_inode); buf->f_type = HUGETLBFS_MAGIC; buf->f_bsize = huge_page_size(h); if (sbinfo) { spin_lock(&sbinfo->stat_lock); /* If no limits set, just report 0 for max/free/used * blocks, like simple_statfs() */ if (sbinfo->max_blocks >= 0) { buf->f_blocks = sbinfo->max_blocks; buf->f_bavail = buf->f_bfree = sbinfo->free_blocks; buf->f_files = sbinfo->max_inodes; buf->f_ffree = sbinfo->free_inodes; } spin_unlock(&sbinfo->stat_lock); } buf->f_namelen = NAME_MAX; return 0; } Vulnerability Type: DoS +Priv CWE ID: CWE-399 Summary: Use-after-free vulnerability in the Linux kernel before 3.3.6, when huge pages are enabled, allows local users to cause a denial of service (system crash) or possibly gain privileges by interacting with a hugetlbfs filesystem, as demonstrated by a umount operation that triggers improper handling of quota data. Commit Message: hugepages: fix use after free bug in "quota" handling hugetlbfs_{get,put}_quota() are badly named. They don't interact with the general quota handling code, and they don't much resemble its behaviour. Rather than being about maintaining limits on on-disk block usage by particular users, they are instead about maintaining limits on in-memory page usage (including anonymous MAP_PRIVATE copied-on-write pages) associated with a particular hugetlbfs filesystem instance. Worse, they work by having callbacks to the hugetlbfs filesystem code from the low-level page handling code, in particular from free_huge_page(). This is a layering violation of itself, but more importantly, if the kernel does a get_user_pages() on hugepages (which can happen from KVM amongst others), then the free_huge_page() can be delayed until after the associated inode has already been freed. If an unmount occurs at the wrong time, even the hugetlbfs superblock where the "quota" limits are stored may have been freed. Andrew Barry proposed a patch to fix this by having hugepages, instead of storing a pointer to their address_space and reaching the superblock from there, had the hugepages store pointers directly to the superblock, bumping the reference count as appropriate to avoid it being freed. Andrew Morton rejected that version, however, on the grounds that it made the existing layering violation worse. This is a reworked version of Andrew's patch, which removes the extra, and some of the existing, layering violation. It works by introducing the concept of a hugepage "subpool" at the lower hugepage mm layer - that is a finite logical pool of hugepages to allocate from. hugetlbfs now creates a subpool for each filesystem instance with a page limit set, and a pointer to the subpool gets added to each allocated hugepage, instead of the address_space pointer used now. The subpool has its own lifetime and is only freed once all pages in it _and_ all other references to it (i.e. superblocks) are gone. subpools are optional - a NULL subpool pointer is taken by the code to mean that no subpool limits are in effect. Previous discussion of this bug found in: "Fix refcounting in hugetlbfs quota handling.". See: https://lkml.org/lkml/2011/8/11/28 or http://marc.info/?l=linux-mm&m=126928970510627&w=1 v2: Fixed a bug spotted by Hillf Danton, and removed the extra parameter to alloc_huge_page() - since it already takes the vma, it is not necessary. Signed-off-by: Andrew Barry <[email protected]> Signed-off-by: David Gibson <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Minchan Kim <[email protected]> Cc: Hillf Danton <[email protected]> Cc: Paul Mackerras <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
Medium
165,607
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: image_transform_png_set_palette_to_rgb_set(PNG_CONST image_transform *this, transform_display *that, png_structp pp, png_infop pi) { png_set_palette_to_rgb(pp); this->next->set(this->next, that, pp, pi); } Vulnerability Type: +Priv CWE ID: Summary: Unspecified vulnerability in libpng before 1.6.20, as used in Android 4.x before 4.4.4, 5.0.x before 5.0.2, 5.1.x before 5.1.1, and 6.x before 2016-07-01, allows attackers to gain privileges via a crafted application, as demonstrated by obtaining Signature or SignatureOrSystem access, aka internal bug 23265085. Commit Message: DO NOT MERGE Update libpng to 1.6.20 BUG:23265085 Change-Id: I85199805636d771f3597b691b63bc0bf46084833 (cherry picked from commit bbe98b40cda082024b669fa508931042eed18f82)
High
173,640
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: int create_user_ns(struct cred *new) { struct user_namespace *ns, *parent_ns = new->user_ns; kuid_t owner = new->euid; kgid_t group = new->egid; int ret; /* The creator needs a mapping in the parent user namespace * or else we won't be able to reasonably tell userspace who * created a user_namespace. */ if (!kuid_has_mapping(parent_ns, owner) || !kgid_has_mapping(parent_ns, group)) return -EPERM; ns = kmem_cache_zalloc(user_ns_cachep, GFP_KERNEL); if (!ns) return -ENOMEM; ret = proc_alloc_inum(&ns->proc_inum); if (ret) { kmem_cache_free(user_ns_cachep, ns); return ret; } atomic_set(&ns->count, 1); /* Leave the new->user_ns reference with the new user namespace. */ ns->parent = parent_ns; ns->owner = owner; ns->group = group; set_cred_user_ns(new, ns); return 0; } Vulnerability Type: Bypass CWE ID: CWE-264 Summary: The create_user_ns function in kernel/user_namespace.c in the Linux kernel before 3.8.6 does not check whether a chroot directory exists that differs from the namespace root directory, which allows local users to bypass intended filesystem restrictions via a crafted clone system call. Commit Message: userns: Don't allow creation if the user is chrooted Guarantee that the policy of which files may be access that is established by setting the root directory will not be violated by user namespaces by verifying that the root directory points to the root of the mount namespace at the time of user namespace creation. Changing the root is a privileged operation, and as a matter of policy it serves to limit unprivileged processes to files below the current root directory. For reasons of simplicity and comprehensibility the privilege to change the root directory is gated solely on the CAP_SYS_CHROOT capability in the user namespace. Therefore when creating a user namespace we must ensure that the policy of which files may be access can not be violated by changing the root directory. Anyone who runs a processes in a chroot and would like to use user namespace can setup the same view of filesystems with a mount namespace instead. With this result that this is not a practical limitation for using user namespaces. Cc: [email protected] Acked-by: Serge Hallyn <[email protected]> Reported-by: Andy Lutomirski <[email protected]> Signed-off-by: "Eric W. Biederman" <[email protected]>
Low
166,097
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: LIBOPENMPT_MODPLUG_API unsigned int ModPlug_SampleName(ModPlugFile* file, unsigned int qual, char* buff) { const char* str; unsigned int retval; size_t tmpretval; if(!file) return 0; str = openmpt_module_get_sample_name(file->mod,qual-1); if(!str){ if(buff){ *buff = '\0'; } return 0; } tmpretval = strlen(str); if(tmpretval>=INT_MAX){ tmpretval = INT_MAX-1; } retval = (int)tmpretval; if(buff){ memcpy(buff,str,retval+1); buff[retval] = '\0'; } openmpt_free_string(str); return retval; } Vulnerability Type: Overflow CWE ID: CWE-120 Summary: In libopenmpt before 0.3.19 and 0.4.x before 0.4.9, ModPlug_InstrumentName and ModPlug_SampleName in libopenmpt_modplug.c do not restrict the lengths of libmodplug output-buffer strings in the C API, leading to a buffer overflow. Commit Message: [Fix] libmodplug: C API: Limit the length of strings copied to the output buffer of ModPlug_InstrumentName() and ModPlug_SampleName() to 32 bytes (including terminating null) as is done by original libmodplug. This avoids potential buffer overflows in software relying on this limit instead of querying the required buffer size beforehand. libopenmpt can return strings longer than 32 bytes here beacuse the internal limit of 32 bytes applies to strings encoded in arbitrary character encodings but the API returns them converted to UTF-8, which can be longer. (reported by Antonio Morales Maldonado of Semmle Security Research Team) git-svn-id: https://source.openmpt.org/svn/openmpt/trunk/OpenMPT@12127 56274372-70c3-4bfc-bfc3-4c3a0b034d27
High
169,501
Analyze the following vulnerable code snippet, vulnerability type with description, the commit message and the CWE ID. Determine the severity score category of this vulnerability. Output 'High' or 'Medium' or 'Low' only. Remember, I want response in 'High' or 'Medium' or 'Low', No explanation.
Code: xmlStopParser(xmlParserCtxtPtr ctxt) { if (ctxt == NULL) return; ctxt->instate = XML_PARSER_EOF; ctxt->disableSAX = 1; if (ctxt->input != NULL) { ctxt->input->cur = BAD_CAST""; ctxt->input->base = ctxt->input->cur; } } Vulnerability Type: DoS Overflow CWE ID: CWE-119 Summary: parser.c in libxml2 before 2.9.0, as used in Google Chrome before 28.0.1500.71 and other products, allows remote attackers to cause a denial of service (out-of-bounds read) via a document that ends abruptly, related to the lack of certain checks for the XML_PARSER_EOF state. Commit Message: libxml: XML_PARSER_EOF checks from upstream BUG=229019 TBR=cpu Review URL: https://chromiumcodereview.appspot.com/14053009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@196804 0039d316-1c4b-4281-b951-d872f2087c98
Medium
171,310