void FontFace::InitializeSource(const StringOrArrayBufferOrArrayBufferView& aSource) { if (aSource.IsString()) { if (!ParseDescriptor(eCSSFontDesc_Src, aSource.GetAsString(), mDescriptors->mSrc)) { Reject(NS_ERROR_DOM_SYNTAX_ERR); SetStatus(FontFaceLoadStatus::Error); return; } mSourceType = eSourceType_URLs; return; } mSourceType = FontFace::eSourceType_Buffer; if (aSource.IsArrayBuffer()) { GetDataFrom(aSource.GetAsArrayBuffer(), mSourceBuffer, mSourceBufferLength); } else { MOZ_ASSERT(aSource.IsArrayBufferView()); GetDataFrom(aSource.GetAsArrayBufferView(), mSourceBuffer, mSourceBufferLength); } SetStatus(FontFaceLoadStatus::Loading); DoLoad(); }
M4Err ReadESDUpdate(BitStream *bs, ESDescriptorUpdate *esdUp, u32 ComSize) { Descriptor *tmp; u32 tmpSize = 0, nbBits = 0; M4Err e = M4OK; if (! esdUp) return M4BadParam; esdUp->ODID = BS_ReadInt(bs, 10); nbBits += 10; //very tricky, we're at the bit level here... while (1) { e = ParseDescriptor(bs, &tmp, &tmpSize); if (e) return e; e = AddToESDUpdate(esdUp, tmp); if (e) return e; nbBits += ( tmpSize + GetSizeFieldSize(tmpSize) ) * 8; //our com is aligned, so nbBits is between (ComSize-1)*8 and ComSize*8 if ( ( (nbBits >(ComSize-1)*8) && (nbBits <= ComSize * 8)) || (nbBits > ComSize*8) ) { //this one is a security break break; } } if (nbBits > ComSize * 8) return M4ReadODCommandFailed; //Align our bitstream nbBits += BS_Align(bs); if (nbBits != ComSize *8) return M4ReadODCommandFailed; return e; }
// // Reader // M4Err ReadOD(BitStream *bs, ObjectDescriptor *od, u32 DescSize) { M4Err e; u32 reserved, urlflag; u32 tmpSize, nbBytes = 0; if (! od) return M4BadParam; od->objectDescriptorID = BS_ReadInt(bs, 10); urlflag = BS_ReadInt(bs, 1); reserved = BS_ReadInt(bs, 5); nbBytes += 2; if (urlflag) { e = OD_ReadString(bs, & od->URLString, 1); if (e) return e; nbBytes += strlen(od->URLString) + 1; } while (nbBytes < DescSize) { Descriptor *tmp = NULL; e = ParseDescriptor(bs, &tmp, &tmpSize); if (e) return e; if (!tmp) return M4ReadDescriptorFailed; e = AddDescriptorToOD(od, tmp); if (e) return e; nbBytes += tmpSize + GetSizeFieldSize(tmpSize); } if (nbBytes != DescSize) return M4ReadDescriptorFailed; return M4OK; }
bool FontFace::SetDescriptors(const nsAString& aFamily, const FontFaceDescriptors& aDescriptors) { MOZ_ASSERT(!HasRule()); MOZ_ASSERT(!mDescriptors); mDescriptors = new CSSFontFaceDescriptors; // Parse all of the mDescriptors in aInitializer, which are the values // we got from the JS constructor. if (!ParseDescriptor(eCSSFontDesc_Family, aFamily, mDescriptors->mFamily) || *mDescriptors->mFamily.GetStringBufferValue() == 0 || !ParseDescriptor(eCSSFontDesc_Style, aDescriptors.mStyle, mDescriptors->mStyle) || !ParseDescriptor(eCSSFontDesc_Weight, aDescriptors.mWeight, mDescriptors->mWeight) || !ParseDescriptor(eCSSFontDesc_Stretch, aDescriptors.mStretch, mDescriptors->mStretch) || !ParseDescriptor(eCSSFontDesc_UnicodeRange, aDescriptors.mUnicodeRange, mDescriptors->mUnicodeRange) || !ParseDescriptor(eCSSFontDesc_FontFeatureSettings, aDescriptors.mFeatureSettings, mDescriptors->mFontFeatureSettings) || !ParseDescriptor(eCSSFontDesc_Display, aDescriptors.mDisplay, mDescriptors->mDisplay)) { // XXX Handle font-variant once we support it (bug 1055385). // If any of the descriptors failed to parse, none of them should be set // on the FontFace. mDescriptors = new CSSFontFaceDescriptors; if (mLoaded) { mLoaded->MaybeReject(NS_ERROR_DOM_SYNTAX_ERR); } SetStatus(FontFaceLoadStatus::Error); return false; } return true; }
M4Err ReadIPMPDUpdate(BitStream *bs, IPMPDescriptorUpdate *ipmpUp, u32 ComSize) { Descriptor *tmp; u32 tmpSize = 0, nbBytes = 0; M4Err e = M4OK; if (! ipmpUp) return M4BadParam; while (nbBytes < ComSize) { e = ParseDescriptor(bs, &tmp, &tmpSize); if (e) return e; e = AddToIPMPDUpdate(ipmpUp, tmp); if (e) return e; nbBytes += tmpSize + GetSizeFieldSize(tmpSize); } //OD commands are aligned BS_Align(bs); if (nbBytes != ComSize) return M4ReadODCommandFailed; return e; }
void FontFace::SetDescriptor(nsCSSFontDesc aFontDesc, const nsAString& aValue, ErrorResult& aRv) { NS_ASSERTION(!HasRule(), "we don't handle rule backed FontFace objects yet"); if (HasRule()) { return; } nsCSSValue parsedValue; if (!ParseDescriptor(aFontDesc, aValue, parsedValue)) { aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR); return; } mDescriptors->Get(aFontDesc) = parsedValue; // XXX Setting descriptors doesn't actually have any effect on FontFace // objects that have started loading or have already been loaded. }
// // Reader // M4Err ReadIOD(BitStream *bs, InitialObjectDescriptor *iod, u32 DescSize) { M4Err e; u32 reserved, urlflag; u32 tmp_size, nbBytes = 0; if (! iod) return M4BadParam; iod->objectDescriptorID = BS_ReadInt(bs, 10); urlflag = BS_ReadInt(bs, 1); iod->inlineProfileFlag = BS_ReadInt(bs, 1); reserved = BS_ReadInt(bs, 4); nbBytes += 2; if (urlflag) { e = OD_ReadString(bs, & iod->URLString, 1); if (e) return e; nbBytes += strlen(iod->URLString) + 1; } else { iod->OD_profileAndLevel = BS_ReadInt(bs, 8); iod->scene_profileAndLevel = BS_ReadInt(bs, 8); iod->audio_profileAndLevel = BS_ReadInt(bs, 8); iod->visual_profileAndLevel = BS_ReadInt(bs, 8); iod->graphics_profileAndLevel = BS_ReadInt(bs, 8); nbBytes += 5; } while (nbBytes < DescSize) { Descriptor *tmp = NULL; e = ParseDescriptor(bs, &tmp, &tmp_size); if (e) return e; if (!tmp) return M4ReadDescriptorFailed; e = AddDescriptorToIOD(iod, tmp); if (e) return e; nbBytes += tmp_size + GetSizeFieldSize(tmp_size); } if (DescSize != nbBytes) return M4ReadDescriptorFailed; return M4OK; }
void BulkRound::GenerateXorMessages() { QByteArray msg; QDataStream stream(&msg, QIODevice::WriteOnly); stream << BulkData << GetRoundId(); _expected_bulk_size = 0; for(int idx = 0; idx < _shuffle_sink.Count(); idx++) { QPair<QSharedPointer<ISender>, QByteArray> pair(_shuffle_sink.At(idx)); Descriptor des = ParseDescriptor(pair.second); _descriptors.append(des); if(_my_idx == -1 && _my_descriptor == des) { _my_idx = idx; } stream << GenerateXorMessage(idx); } if(_app_broadcast) { VerifiableSend(GetGroup().GetLeader(), msg); } else { VerifiableBroadcast(msg); } }
void FontFace::InitializeSource(const StringOrArrayBufferOrArrayBufferView& aSource) { if (aSource.IsString()) { if (!ParseDescriptor(eCSSFontDesc_Src, aSource.GetAsString(), mDescriptors->mSrc)) { if (mLoaded) { // The SetStatus call we are about to do assumes that for // FontFace objects with sources other than ArrayBuffer(View)s, that the // mLoaded Promise is rejected with a network error. We get // in here beforehand to set it to the required syntax error. mLoaded->MaybeReject(NS_ERROR_DOM_SYNTAX_ERR); } SetStatus(FontFaceLoadStatus::Error); return; } mSourceType = eSourceType_URLs; return; } mSourceType = FontFace::eSourceType_Buffer; if (aSource.IsArrayBuffer()) { GetDataFrom(aSource.GetAsArrayBuffer(), mSourceBuffer, mSourceBufferLength); } else { MOZ_ASSERT(aSource.IsArrayBufferView()); GetDataFrom(aSource.GetAsArrayBufferView(), mSourceBuffer, mSourceBufferLength); } SetStatus(FontFaceLoadStatus::Loading); DoLoad(); }
NTSTATUS WINAPI PNP_AddDevice(DRIVER_OBJECT *driver, DEVICE_OBJECT *PDO) { DEVICE_OBJECT *device = NULL; NTSTATUS status; minidriver *minidriver; HID_DEVICE_ATTRIBUTES attr; BASE_DEVICE_EXTENSION *ext = NULL; HID_DESCRIPTOR descriptor; BYTE *reportDescriptor; INT i; WCHAR *PDO_id; WCHAR *id_ptr; status = get_device_id(PDO, BusQueryInstanceID, &PDO_id); if (status != STATUS_SUCCESS) { ERR("Failed to get PDO id(%x)\n",status); return status; } TRACE("PDO add device(%p:%s)\n", PDO, debugstr_w(PDO_id)); minidriver = find_minidriver(driver); status = HID_CreateDevice(PDO, &minidriver->minidriver, &device); if (status != STATUS_SUCCESS) { ERR("Failed to create HID object (%x)\n",status); HeapFree(GetProcessHeap(), 0, PDO_id); return status; } ext = device->DeviceExtension; InitializeListHead(&ext->irp_queue); TRACE("Created device %p\n",device); status = minidriver->AddDevice(minidriver->minidriver.DriverObject, device); if (status != STATUS_SUCCESS) { ERR("Minidriver AddDevice failed (%x)\n",status); HeapFree(GetProcessHeap(), 0, PDO_id); HID_DeleteDevice(&minidriver->minidriver, device); return status; } status = call_minidriver(IOCTL_HID_GET_DEVICE_ATTRIBUTES, device, NULL, 0, &attr, sizeof(attr)); if (status != STATUS_SUCCESS) { ERR("Minidriver failed to get Attributes(%x)\n",status); HID_DeleteDevice(&minidriver->minidriver, device); HeapFree(GetProcessHeap(), 0, PDO_id); return status; } ext->information.VendorID = attr.VendorID; ext->information.ProductID = attr.ProductID; ext->information.VersionNumber = attr.VersionNumber; ext->information.Polled = minidriver->minidriver.DevicesArePolled; status = call_minidriver(IOCTL_HID_GET_DEVICE_DESCRIPTOR, device, NULL, 0, &descriptor, sizeof(descriptor)); if (status != STATUS_SUCCESS) { ERR("Cannot get Device Descriptor(%x)\n",status); HID_DeleteDevice(&minidriver->minidriver, device); HeapFree(GetProcessHeap(), 0, PDO_id); return status; } for (i = 0; i < descriptor.bNumDescriptors; i++) if (descriptor.DescriptorList[i].bReportType == HID_REPORT_DESCRIPTOR_TYPE) break; if (i >= descriptor.bNumDescriptors) { ERR("No Report Descriptor found in reply\n"); HID_DeleteDevice(&minidriver->minidriver, device); HeapFree(GetProcessHeap(), 0, PDO_id); return status; } reportDescriptor = HeapAlloc(GetProcessHeap(), 0, descriptor.DescriptorList[i].wReportLength); status = call_minidriver(IOCTL_HID_GET_REPORT_DESCRIPTOR, device, NULL, 0, reportDescriptor, descriptor.DescriptorList[i].wReportLength); if (status != STATUS_SUCCESS) { ERR("Cannot get Report Descriptor(%x)\n",status); HID_DeleteDevice(&minidriver->minidriver, device); HeapFree(GetProcessHeap(), 0, reportDescriptor); HeapFree(GetProcessHeap(), 0, PDO_id); return status; } ext->preparseData = ParseDescriptor(reportDescriptor, descriptor.DescriptorList[0].wReportLength); HeapFree(GetProcessHeap(), 0, reportDescriptor); if (!ext->preparseData) { ERR("Cannot parse Report Descriptor\n"); HID_DeleteDevice(&minidriver->minidriver, device); HeapFree(GetProcessHeap(), 0, PDO_id); return STATUS_NOT_SUPPORTED; } ext->information.DescriptorSize = ext->preparseData->dwSize; lstrcpyW(ext->instance_id, device_enumeratorW); strcatW(ext->instance_id, separator_W); /* Skip the original enumerator */ id_ptr = strchrW(PDO_id, '\\'); id_ptr++; strcatW(ext->instance_id, id_ptr); HeapFree(GetProcessHeap(), 0, PDO_id); sprintfW(ext->device_id, device_deviceid_fmtW, device_enumeratorW, ext->information.VendorID, ext->information.ProductID); HID_LinkDevice(device); ext->poll_interval = DEFAULT_POLL_INTERVAL; ext->ring_buffer = RingBuffer_Create(sizeof(HID_XFER_PACKET) + ext->preparseData->caps.InputReportByteLength); HID_StartDeviceThread(device); return STATUS_SUCCESS; }