unique_id
int64 13
189k
| target
int64 0
1
| code
stringlengths 20
241k
| __index_level_0__
int64 0
18.9k
|
---|---|---|---|
57,188 | 0 | int nfs4_proc_fs_locations(struct rpc_clnt *client, struct inode *dir,
const struct qstr *name,
struct nfs4_fs_locations *fs_locations,
struct page *page)
{
struct nfs4_exception exception = { };
int err;
do {
err = _nfs4_proc_fs_locations(client, dir, name,
fs_locations, page);
trace_nfs4_get_fs_locations(dir, name, err);
err = nfs4_handle_exception(NFS_SERVER(dir), err,
&exception);
} while (exception.retry);
return err;
}
| 18,700 |
107,368 | 0 | gfx::Rect FindBarController::GetLocationForFindbarView(
gfx::Rect view_location,
const gfx::Rect& dialog_bounds,
const gfx::Rect& avoid_overlapping_rect) {
if (base::i18n::IsRTL()) {
int boundary = dialog_bounds.width() - view_location.width();
view_location.set_x(std::min(view_location.x(), boundary));
} else {
view_location.set_x(std::max(view_location.x(), dialog_bounds.x()));
}
gfx::Rect new_pos = view_location;
if (!avoid_overlapping_rect.IsEmpty() &&
avoid_overlapping_rect.Intersects(new_pos)) {
if (base::i18n::IsRTL()) {
new_pos.set_x(avoid_overlapping_rect.x() +
avoid_overlapping_rect.width() +
(2 * kMinFindWndDistanceFromSelection));
if (new_pos.x() + new_pos.width() > dialog_bounds.width())
new_pos = view_location; // Reset.
} else {
new_pos.set_x(avoid_overlapping_rect.x() - new_pos.width() -
kMinFindWndDistanceFromSelection);
if (new_pos.x() < 0)
new_pos = view_location; // Reset.
}
}
return new_pos;
}
| 18,701 |
97,502 | 0 | bool FrameLoader::shouldReloadToHandleUnreachableURL(DocumentLoader* docLoader)
{
KURL unreachableURL = docLoader->unreachableURL();
if (unreachableURL.isEmpty())
return false;
if (!isBackForwardLoadType(policyChecker()->loadType()))
return false;
DocumentLoader* compareDocumentLoader = 0;
if (policyChecker()->delegateIsDecidingNavigationPolicy() || policyChecker()->delegateIsHandlingUnimplementablePolicy())
compareDocumentLoader = m_policyDocumentLoader.get();
else if (m_delegateIsHandlingProvisionalLoadError)
compareDocumentLoader = m_provisionalDocumentLoader.get();
return compareDocumentLoader && unreachableURL == compareDocumentLoader->request().url();
}
| 18,702 |
64,316 | 0 | static const char *set_serverpath(cmd_parms *cmd, void *dummy,
const char *arg)
{
const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE);
if (err != NULL) {
return err;
}
cmd->server->path = arg;
cmd->server->pathlen = (int)strlen(arg);
return NULL;
}
| 18,703 |
122,366 | 0 | bool HTMLInputElement::setupDateTimeChooserParameters(DateTimeChooserParameters& parameters)
{
if (!document().view())
return false;
parameters.type = type();
parameters.minimum = minimum();
parameters.maximum = maximum();
parameters.required = isRequired();
if (!RuntimeEnabledFeatures::langAttributeAwareFormControlUIEnabled())
parameters.locale = defaultLanguage();
else {
AtomicString computedLocale = computeInheritedLanguage();
parameters.locale = computedLocale.isEmpty() ? defaultLanguage() : computedLocale;
}
StepRange stepRange = createStepRange(RejectAny);
if (stepRange.hasStep()) {
parameters.step = stepRange.step().toDouble();
parameters.stepBase = stepRange.stepBase().toDouble();
} else {
parameters.step = 1.0;
parameters.stepBase = 0;
}
parameters.anchorRectInRootView = document().view()->contentsToRootView(pixelSnappedBoundingBox());
parameters.currentValue = value();
parameters.doubleValue = m_inputType->valueAsDouble();
parameters.isAnchorElementRTL = computedStyle()->direction() == RTL;
if (RuntimeEnabledFeatures::dataListElementEnabled()) {
if (HTMLDataListElement* dataList = this->dataList()) {
RefPtr<HTMLCollection> options = dataList->options();
for (unsigned i = 0; HTMLOptionElement* option = toHTMLOptionElement(options->item(i)); ++i) {
if (!isValidValue(option->value()))
continue;
DateTimeSuggestion suggestion;
suggestion.value = m_inputType->parseToNumber(option->value(), Decimal::nan()).toDouble();
if (std::isnan(suggestion.value))
continue;
suggestion.localizedValue = localizeValue(option->value());
suggestion.label = option->value() == option->label() ? String() : option->label();
parameters.suggestions.append(suggestion);
}
}
}
return true;
}
| 18,704 |
131,786 | 0 | static void testInterfaceEmptyMethodOptionalLongArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
ExceptionState exceptionState(ExceptionState::ExecutionContext, "testInterfaceEmptyMethodOptionalLongArg", "TestObjectPython", info.Holder(), info.GetIsolate());
TestObjectPython* imp = V8TestObjectPython::toNative(info.Holder());
if (UNLIKELY(info.Length() <= 0)) {
v8SetReturnValue(info, imp->testInterfaceEmptyMethodOptionalLongArg());
return;
}
V8TRYCATCH_EXCEPTION_VOID(int, optionalLongArg, toInt32(info[0], exceptionState), exceptionState);
v8SetReturnValue(info, imp->testInterfaceEmptyMethodOptionalLongArg(optionalLongArg));
}
| 18,705 |
171,213 | 0 | status_t MediaPlayerService::Client::setRetransmitEndpoint(
const struct sockaddr_in* endpoint) {
if (NULL != endpoint) {
uint32_t a = ntohl(endpoint->sin_addr.s_addr);
uint16_t p = ntohs(endpoint->sin_port);
ALOGV("[%d] setRetransmitEndpoint(%u.%u.%u.%u:%hu)", mConnId,
(a >> 24), (a >> 16) & 0xFF, (a >> 8) & 0xFF, (a & 0xFF), p);
} else {
ALOGV("[%d] setRetransmitEndpoint = <none>", mConnId);
}
sp<MediaPlayerBase> p = getPlayer();
if (p != 0) return INVALID_OPERATION;
if (NULL != endpoint) {
mRetransmitEndpoint = *endpoint;
mRetransmitEndpointValid = true;
} else {
mRetransmitEndpointValid = false;
}
return NO_ERROR;
}
| 18,706 |
144,972 | 0 | void RenderWidgetHostViewAura::SetBackgroundColor(SkColor color) {
UpdateBackgroundColorFromRenderer(color);
DCHECK(SkColorGetA(color) == SK_AlphaOPAQUE ||
SkColorGetA(color) == SK_AlphaTRANSPARENT);
host_->SetBackgroundOpaque(SkColorGetA(color) == SK_AlphaOPAQUE);
}
| 18,707 |
88,197 | 0 | XML_MemMalloc(XML_Parser parser, size_t size) {
if (parser == NULL)
return NULL;
return MALLOC(parser, size);
}
| 18,708 |
144,991 | 0 | bool RenderWidgetHostViewAura::TransformPointToLocalCoordSpace(
const gfx::Point& point,
const cc::SurfaceId& original_surface,
gfx::Point* transformed_point) {
gfx::Point point_in_pixels =
gfx::ConvertPointToPixel(device_scale_factor_, point);
if (delegated_frame_host_ &&
!delegated_frame_host_->TransformPointToLocalCoordSpace(
point_in_pixels, original_surface, transformed_point))
return false;
*transformed_point =
gfx::ConvertPointToDIP(device_scale_factor_, *transformed_point);
return true;
}
| 18,709 |
113,084 | 0 | void DownloadItemImpl::OffThreadCancel(DownloadFileManager* file_manager) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
request_handle_->CancelRequest();
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
base::Bind(&DownloadFileManager::CancelDownload,
file_manager, download_id_));
}
| 18,710 |
75,392 | 0 | static int opfdivr(RAsm *a, ut8 *data, const Opcode *op) {
int l = 0;
switch (op->operands_count) {
case 1:
if ( op->operands[0].type & OT_MEMORY ) {
if ( op->operands[0].type & OT_DWORD ) {
data[l++] = 0xd8;
data[l++] = 0x38 | op->operands[0].regs[0];
} else if ( op->operands[0].type & OT_QWORD ) {
data[l++] = 0xdc;
data[l++] = 0x38 | op->operands[0].regs[0];
} else {
return -1;
}
} else {
return -1;
}
break;
case 2:
if ( op->operands[0].type & OT_FPUREG & ~OT_REGALL && op->operands[0].reg == 0 &&
op->operands[1].type & OT_FPUREG & ~OT_REGALL ) {
data[l++] = 0xd8;
data[l++] = 0xf8 | op->operands[1].reg;
} else if ( op->operands[0].type & OT_FPUREG & ~OT_REGALL &&
op->operands[1].type & OT_FPUREG & ~OT_REGALL && op->operands[1].reg == 0 ) {
data[l++] = 0xdc;
data[l++] = 0xf0 | op->operands[0].reg;
} else {
return -1;
}
break;
default:
return -1;
}
return l;
}
| 18,711 |
31,572 | 0 | sctp_disposition_t sctp_sf_cookie_echoed_prm_shutdown(
struct net *net,
const struct sctp_endpoint *ep,
const struct sctp_association *asoc,
const sctp_subtype_t type,
void *arg, sctp_cmd_seq_t *commands)
{
/* There is a single T1 timer, so we should be able to use
* common function with the COOKIE-WAIT state.
*/
return sctp_sf_cookie_wait_prm_shutdown(net, ep, asoc, type, arg, commands);
}
| 18,712 |
130,348 | 0 | void HTMLFormControlElement::dispatchBlurEvent(Element* newFocusedElement, WebFocusType type, InputDeviceCapabilities* sourceCapabilities)
{
if (type != WebFocusTypePage)
m_wasFocusedByMouse = false;
HTMLElement::dispatchBlurEvent(newFocusedElement, type, sourceCapabilities);
hideVisibleValidationMessage();
}
| 18,713 |
99,159 | 0 | void InlineFlowBox::placeBoxesInBlockDirection(int top, int maxHeight, int maxAscent, bool strictMode, int& lineTop, int& lineBottom, bool& setLineTop,
int& lineTopIncludingMargins, int& lineBottomIncludingMargins, bool& hasAnnotationsBefore, bool& hasAnnotationsAfter, FontBaseline baselineType)
{
if (isRootInlineBox())
setLogicalTop(top + maxAscent - baselinePosition(baselineType)); // Place our root box.
for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
if (curr->renderer()->isPositioned())
continue; // Positioned placeholders don't affect calculations.
bool isInlineFlow = curr->isInlineFlowBox();
if (isInlineFlow)
static_cast<InlineFlowBox*>(curr)->placeBoxesInBlockDirection(top, maxHeight, maxAscent, strictMode, lineTop, lineBottom, setLineTop,
lineTopIncludingMargins, lineBottomIncludingMargins, hasAnnotationsBefore, hasAnnotationsAfter, baselineType);
bool childAffectsTopBottomPos = true;
if (curr->verticalAlign() == TOP)
curr->setLogicalTop(top);
else if (curr->verticalAlign() == BOTTOM)
curr->setLogicalTop(top + maxHeight - curr->lineHeight());
else {
if ((isInlineFlow && !static_cast<InlineFlowBox*>(curr)->hasTextChildren()) && !curr->boxModelObject()->hasInlineDirectionBordersOrPadding() && !strictMode)
childAffectsTopBottomPos = false;
int posAdjust = maxAscent - curr->baselinePosition(baselineType);
curr->setLogicalTop(curr->logicalTop() + top + posAdjust);
}
int newLogicalTop = curr->logicalTop();
int newLogicalTopIncludingMargins = newLogicalTop;
int boxHeight = curr->logicalHeight();
int boxHeightIncludingMargins = boxHeight;
if (curr->isText() || curr->isInlineFlowBox()) {
const FontMetrics& fontMetrics = curr->renderer()->style(m_firstLine)->fontMetrics();
newLogicalTop += curr->baselinePosition(baselineType) - fontMetrics.ascent(baselineType);
if (curr->isInlineFlowBox()) {
RenderBoxModelObject* boxObject = toRenderBoxModelObject(curr->renderer());
newLogicalTop -= boxObject->style(m_firstLine)->isHorizontalWritingMode() ? boxObject->borderTop() + boxObject->paddingTop() :
boxObject->borderRight() + boxObject->paddingRight();
}
newLogicalTopIncludingMargins = newLogicalTop;
} else if (!curr->renderer()->isBR()) {
RenderBox* box = toRenderBox(curr->renderer());
newLogicalTopIncludingMargins = newLogicalTop;
int overSideMargin = curr->isHorizontal() ? box->marginTop() : box->marginRight();
int underSideMargin = curr->isHorizontal() ? box->marginBottom() : box->marginLeft();
newLogicalTop += overSideMargin;
boxHeightIncludingMargins += overSideMargin + underSideMargin;
}
curr->setLogicalTop(newLogicalTop);
if (childAffectsTopBottomPos) {
if (curr->renderer()->isRubyRun()) {
if (!renderer()->style()->isFlippedLinesWritingMode())
hasAnnotationsBefore = true;
else
hasAnnotationsAfter = true;
RenderRubyRun* rubyRun = static_cast<RenderRubyRun*>(curr->renderer());
if (RenderRubyBase* rubyBase = rubyRun->rubyBase()) {
int bottomRubyBaseLeading = (curr->logicalHeight() - rubyBase->logicalBottom()) + rubyBase->logicalHeight() - (rubyBase->lastRootBox() ? rubyBase->lastRootBox()->lineBottom() : 0);
int topRubyBaseLeading = rubyBase->logicalTop() + (rubyBase->firstRootBox() ? rubyBase->firstRootBox()->lineTop() : 0);
newLogicalTop += !renderer()->style()->isFlippedLinesWritingMode() ? topRubyBaseLeading : bottomRubyBaseLeading;
boxHeight -= (topRubyBaseLeading + bottomRubyBaseLeading);
}
}
if (curr->isInlineTextBox()) {
TextEmphasisPosition emphasisMarkPosition;
if (static_cast<InlineTextBox*>(curr)->getEmphasisMarkPosition(curr->renderer()->style(m_firstLine), emphasisMarkPosition)) {
bool emphasisMarkIsOver = emphasisMarkPosition == TextEmphasisPositionOver;
if (emphasisMarkIsOver != curr->renderer()->style(m_firstLine)->isFlippedLinesWritingMode())
hasAnnotationsBefore = true;
else
hasAnnotationsAfter = true;
}
}
if (!setLineTop) {
setLineTop = true;
lineTop = newLogicalTop;
lineTopIncludingMargins = min(lineTop, newLogicalTopIncludingMargins);
} else {
lineTop = min(lineTop, newLogicalTop);
lineTopIncludingMargins = min(lineTop, min(lineTopIncludingMargins, newLogicalTopIncludingMargins));
}
lineBottom = max(lineBottom, newLogicalTop + boxHeight);
lineBottomIncludingMargins = max(lineBottom, max(lineBottomIncludingMargins, newLogicalTopIncludingMargins + boxHeightIncludingMargins));
}
}
if (isRootInlineBox()) {
const FontMetrics& fontMetrics = renderer()->style(m_firstLine)->fontMetrics();
setLogicalTop(logicalTop() + baselinePosition(baselineType) - fontMetrics.ascent(baselineType));
if (hasTextChildren() || strictMode) {
if (!setLineTop) {
setLineTop = true;
lineTop = logicalTop();
lineTopIncludingMargins = lineTop;
} else {
lineTop = min(lineTop, logicalTop());
lineTopIncludingMargins = min(lineTop, lineTopIncludingMargins);
}
lineBottom = max(lineBottom, logicalTop() + logicalHeight());
lineBottomIncludingMargins = max(lineBottom, lineBottomIncludingMargins);
}
if (renderer()->style()->isFlippedLinesWritingMode())
flipLinesInBlockDirection(lineTopIncludingMargins, lineBottomIncludingMargins);
}
}
| 18,714 |
154,394 | 0 | static void WriteAlphaData(void* pixels,
uint32_t row_count,
uint32_t channel_count,
uint32_t alpha_channel_index,
uint32_t unpadded_row_size,
uint32_t padded_row_size,
pixel_data_type alpha_value) {
DCHECK_GT(channel_count, 0U);
DCHECK_EQ(unpadded_row_size % sizeof(pixel_data_type), 0U);
uint32_t unpadded_row_size_in_elements =
unpadded_row_size / sizeof(pixel_data_type);
DCHECK_EQ(padded_row_size % sizeof(pixel_data_type), 0U);
uint32_t padded_row_size_in_elements =
padded_row_size / sizeof(pixel_data_type);
pixel_data_type* dst =
static_cast<pixel_data_type*>(pixels) + alpha_channel_index;
for (uint32_t yy = 0; yy < row_count; ++yy) {
pixel_data_type* end = dst + unpadded_row_size_in_elements;
for (pixel_data_type* d = dst; d < end; d += channel_count) {
*d = alpha_value;
}
dst += padded_row_size_in_elements;
}
}
| 18,715 |
47,481 | 0 | static void add_session_id(struct cryp_ctx *ctx)
{
/*
* We never want 0 to be a valid value, since this is the default value
* for the software context.
*/
if (unlikely(atomic_inc_and_test(&session_id)))
atomic_inc(&session_id);
ctx->session_id = atomic_read(&session_id);
}
| 18,716 |
103,445 | 0 | ExtensionIdSet ExtensionService::GetAppIds() const {
ExtensionIdSet result;
for (ExtensionList::const_iterator it = extensions_.begin();
it != extensions_.end(); ++it) {
if ((*it)->is_app() && (*it)->location() != Extension::COMPONENT)
result.insert((*it)->id());
}
return result;
}
| 18,717 |
101,527 | 0 | bool PrintMsg_Print_Params_IsEqual(
const PrintMsg_PrintPages_Params& oldParams,
const PrintMsg_PrintPages_Params& newParams) {
return PageLayoutIsEqual(oldParams, newParams) &&
oldParams.params.max_shrink == newParams.params.max_shrink &&
oldParams.params.min_shrink == newParams.params.min_shrink &&
oldParams.params.selection_only == newParams.params.selection_only &&
oldParams.params.supports_alpha_blend ==
newParams.params.supports_alpha_blend &&
oldParams.pages.size() == newParams.pages.size() &&
oldParams.params.display_header_footer ==
newParams.params.display_header_footer &&
oldParams.params.date == newParams.params.date &&
oldParams.params.title == newParams.params.title &&
oldParams.params.url == newParams.params.url &&
std::equal(oldParams.pages.begin(), oldParams.pages.end(),
newParams.pages.begin());
}
| 18,718 |
24,408 | 0 | struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
struct ctl_table_header *prev)
{
struct ctl_table_root *root;
struct list_head *header_list;
struct ctl_table_header *head;
struct list_head *tmp;
spin_lock(&sysctl_lock);
if (prev) {
head = prev;
tmp = &prev->ctl_entry;
unuse_table(prev);
goto next;
}
tmp = &root_table_header.ctl_entry;
for (;;) {
head = list_entry(tmp, struct ctl_table_header, ctl_entry);
if (!use_table(head))
goto next;
spin_unlock(&sysctl_lock);
return head;
next:
root = head->root;
tmp = tmp->next;
header_list = lookup_header_list(root, namespaces);
if (tmp != header_list)
continue;
do {
root = list_entry(root->root_list.next,
struct ctl_table_root, root_list);
if (root == &sysctl_table_root)
goto out;
header_list = lookup_header_list(root, namespaces);
} while (list_empty(header_list));
tmp = header_list->next;
}
out:
spin_unlock(&sysctl_lock);
return NULL;
}
| 18,719 |
84,600 | 0 | begin_table(int border, int spacing, int padding, int vspace)
{
struct table *t;
int mincell = minimum_cellspacing(border);
int rcellspacing;
int mincell_pixels = round(mincell * pixel_per_char);
int ppc = round(pixel_per_char);
t = newTable();
t->row = t->col = -1;
t->maxcol = -1;
t->maxrow = -1;
t->border_mode = border;
t->flag = 0;
if (border == BORDER_NOWIN)
t->flag |= TBL_EXPAND_OK;
rcellspacing = spacing + 2 * padding;
switch (border) {
case BORDER_THIN:
case BORDER_THICK:
case BORDER_NOWIN:
t->cellpadding = padding - (mincell_pixels - 4) / 2;
break;
case BORDER_NONE:
t->cellpadding = rcellspacing - mincell_pixels;
}
if (t->cellpadding >= ppc)
t->cellpadding /= ppc;
else if (t->cellpadding > 0)
t->cellpadding = 1;
else
t->cellpadding = 0;
switch (border) {
case BORDER_THIN:
case BORDER_THICK:
case BORDER_NOWIN:
t->cellspacing = 2 * t->cellpadding + mincell;
break;
case BORDER_NONE:
t->cellspacing = t->cellpadding + mincell;
}
if (border == BORDER_NONE) {
if (rcellspacing / 2 + vspace <= 1)
t->vspace = 0;
else
t->vspace = 1;
}
else {
if (vspace < ppc)
t->vspace = 0;
else
t->vspace = 1;
}
if (border == BORDER_NONE) {
if (rcellspacing <= THR_PADDING)
t->vcellpadding = 0;
else
t->vcellpadding = 1;
}
else {
if (padding < 2 * ppc - 2)
t->vcellpadding = 0;
else
t->vcellpadding = 1;
}
return t;
}
| 18,720 |
95,580 | 0 | void Con_MessageMode_f( void ) {
chat_playerNum = -1;
chat_team = qfalse;
Field_Clear( &chatField );
chatField.widthInChars = 30;
Key_SetCatcher( Key_GetCatcher( ) ^ KEYCATCH_MESSAGE );
}
| 18,721 |
102,805 | 0 | double ExecutableAllocator::memoryPressureMultiplier(size_t addedMemoryUsage)
{
MetaAllocator::Statistics statistics = allocator->currentStatistics();
ASSERT(statistics.bytesAllocated <= statistics.bytesReserved);
size_t bytesAllocated = statistics.bytesAllocated + addedMemoryUsage;
if (bytesAllocated >= statistics.bytesReserved)
bytesAllocated = statistics.bytesReserved;
double result = 1.0;
size_t divisor = statistics.bytesReserved - bytesAllocated;
if (divisor)
result = static_cast<double>(statistics.bytesReserved) / divisor;
if (result < 1.0)
result = 1.0;
return result;
}
| 18,722 |
145,428 | 0 | void OnDataReceivedFromPeer(const char* data, size_t data_len) {
DCHECK(delegate_);
delegate_->OnPacketDataReceived(data, data_len);
}
| 18,723 |
21,896 | 0 | void drm_mode_destroy(struct drm_device *dev, struct drm_display_mode *mode)
{
drm_mode_object_put(dev, &mode->base);
kfree(mode);
}
| 18,724 |
133,047 | 0 | void RenderWidgetHostViewAura::UnlockResources() {
DCHECK(frame_provider_);
delegated_frame_evictor_->UnlockFrame();
}
| 18,725 |
167,435 | 0 | void SVGStyleElement::DispatchPendingEvent() {
DispatchEvent(Event::Create(EventTypeNames::error));
}
| 18,726 |
183,595 | 1 | void WebPluginDelegateImpl::SendJavaScriptStream(const GURL& url,
const std::string& result,
bool success,
bool notify_needed,
intptr_t notify_data) {
instance()->SendJavaScriptStream(url, result, success, notify_needed,
notify_data);
}
| 18,727 |
4,006 | 0 | void FileOutStream::printf(const char *format, ...)
{
va_list argptr;
va_start (argptr, format);
vfprintf(f, format, argptr);
va_end (argptr);
}
| 18,728 |
61,898 | 0 | static unsigned int readuint(FILE * f, int bigendian)
{
unsigned char c1, c2, c3, c4;
if (!fread(&c1, 1, 1, f)) {
fprintf(stderr,
"\nError: fread return a number of element different from the expected.\n");
return 0;
}
if (!fread(&c2, 1, 1, f)) {
fprintf(stderr,
"\nError: fread return a number of element different from the expected.\n");
return 0;
}
if (!fread(&c3, 1, 1, f)) {
fprintf(stderr,
"\nError: fread return a number of element different from the expected.\n");
return 0;
}
if (!fread(&c4, 1, 1, f)) {
fprintf(stderr,
"\nError: fread return a number of element different from the expected.\n");
return 0;
}
if (bigendian) {
return (unsigned int)(c1 << 24) + (unsigned int)(c2 << 16) + (unsigned int)(
c3 << 8) + c4;
} else {
return (unsigned int)(c4 << 24) + (unsigned int)(c3 << 16) + (unsigned int)(
c2 << 8) + c1;
}
}
| 18,729 |
187,842 | 1 | const CuePoint* Cues::GetLast() const {
if (m_cue_points == NULL)
return NULL;
if (m_count <= 0)
return NULL;
#if 0
LoadCuePoint(); //init cues
const size_t count = m_count + m_preload_count;
if (count == 0) //weird
return NULL;
const size_t index = count - 1;
CuePoint* const* const pp = m_cue_points;
assert(pp);
CuePoint* const pCP = pp[index];
assert(pCP);
pCP->Load(m_pSegment->m_pReader);
assert(pCP->GetTimeCode() >= 0);
#else
const long index = m_count - 1;
CuePoint* const* const pp = m_cue_points;
assert(pp);
CuePoint* const pCP = pp[index];
assert(pCP);
assert(pCP->GetTimeCode() >= 0);
#endif
return pCP;
}
| 18,730 |
78,186 | 0 | authentic_get_challenge(struct sc_card *card, unsigned char *rnd, size_t len)
{
/* 'GET CHALLENGE' returns always 24 bytes */
unsigned char rbuf[0x18];
size_t out_len;
int r;
LOG_FUNC_CALLED(card->ctx);
r = iso_ops->get_challenge(card, rbuf, sizeof rbuf);
LOG_TEST_RET(card->ctx, r, "GET CHALLENGE cmd failed");
if (len < (size_t) r) {
out_len = len;
} else {
out_len = (size_t) r;
}
memcpy(rnd, rbuf, out_len);
LOG_FUNC_RETURN(card->ctx, out_len);
}
| 18,731 |
106,075 | 0 | void JSTestObjConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject)
{
Base::finishCreation(exec->globalData());
ASSERT(inherits(&s_info));
putDirect(exec->globalData(), exec->propertyNames().prototype, JSTestObjPrototype::self(exec, globalObject), DontDelete | ReadOnly);
putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(1), ReadOnly | DontDelete | DontEnum);
}
| 18,732 |
184,672 | 1 | string16 ExtensionGlobalError::GenerateMessageSection(
const ExtensionIdSet* extensions,
int template_message_id) {
CHECK(extensions);
CHECK(template_message_id);
string16 message;
for (ExtensionIdSet::const_iterator iter = extensions->begin();
iter != extensions->end(); ++iter) {
const Extension* e = extension_service_->GetExtensionById(*iter, true);
message += l10n_util::GetStringFUTF16(
template_message_id,
string16(ASCIIToUTF16(e->name())),
l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME));
}
return message;
}
| 18,733 |
187,866 | 1 | long AudioTrack::Parse(Segment* pSegment, const Info& info,
long long element_start, long long element_size,
AudioTrack*& pResult) {
if (pResult)
return -1;
if (info.type != Track::kAudio)
return -1;
IMkvReader* const pReader = pSegment->m_pReader;
const Settings& s = info.settings;
assert(s.start >= 0);
assert(s.size >= 0);
long long pos = s.start;
assert(pos >= 0);
const long long stop = pos + s.size;
double rate = 8000.0; // MKV default
long long channels = 1;
long long bit_depth = 0;
while (pos < stop) {
long long id, size;
long status = ParseElementHeader(pReader, pos, stop, id, size);
if (status < 0) // error
return status;
if (id == 0x35) { // Sample Rate
status = UnserializeFloat(pReader, pos, size, rate);
if (status < 0)
return status;
if (rate <= 0)
return E_FILE_FORMAT_INVALID;
} else if (id == 0x1F) { // Channel Count
channels = UnserializeUInt(pReader, pos, size);
if (channels <= 0)
return E_FILE_FORMAT_INVALID;
} else if (id == 0x2264) { // Bit Depth
bit_depth = UnserializeUInt(pReader, pos, size);
if (bit_depth <= 0)
return E_FILE_FORMAT_INVALID;
}
pos += size; // consume payload
assert(pos <= stop);
}
assert(pos == stop);
AudioTrack* const pTrack =
new (std::nothrow) AudioTrack(pSegment, element_start, element_size);
if (pTrack == NULL)
return -1; // generic error
const int status = info.Copy(pTrack->m_info);
if (status) {
delete pTrack;
return status;
}
pTrack->m_rate = rate;
pTrack->m_channels = channels;
pTrack->m_bitDepth = bit_depth;
pResult = pTrack;
return 0; // success
}
| 18,734 |
78,816 | 0 | static int sc_pkcs15emu_sc_hsm_read_tokeninfo (sc_pkcs15_card_t * p15card)
{
sc_card_t *card = p15card->card;
int r;
u8 efbin[512];
size_t len;
LOG_FUNC_CALLED(card->ctx);
/* Read token info */
len = sizeof efbin;
r = read_file(p15card, (u8 *) "\x2F\x03", efbin, &len, 1);
LOG_TEST_RET(card->ctx, r, "Skipping optional EF.TokenInfo");
r = sc_pkcs15_parse_tokeninfo(card->ctx, p15card->tokeninfo, efbin, len);
LOG_TEST_RET(card->ctx, r, "Skipping optional EF.TokenInfo");
LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
}
| 18,735 |
51,995 | 0 | SpoolssStartPagePrinter_r(tvbuff_t *tvb, int offset,
packet_info *pinfo, proto_tree *tree,
dcerpc_info *di, guint8 *drep)
{
/* Parse packet */
offset = dissect_doserror(
tvb, offset, pinfo, tree, di, drep, hf_rc, NULL);
return offset;
}
| 18,736 |
3,094 | 0 | static int iccalternatespace(i_ctx_t * i_ctx_p, ref *space, ref **r, int *CIESubst)
{
int components, code = 0;
ref *tempref, ICCdict;
if (!r_is_array(space))
return_error(gs_error_typecheck);
/* Validate parameters, check we have enough operands */
if (r_size(space) != 2)
return_error(gs_error_rangecheck);
code = array_get(imemory, space, 1, &ICCdict);
if (code < 0)
return code;
code = dict_find_string(&ICCdict, "N", &tempref);
if (code < 0)
return code;
if (code == 0)
return gs_note_error(gs_error_undefined);
components = tempref->value.intval;
code = dict_find_string(&ICCdict, "Alternate", &tempref);
if (code > 0 && !r_has_type(tempref, t_null)) {
*r = tempref;
} else {
switch (components) {
case 1:
code = name_enter_string(imemory, "DeviceGray", *r);
break;
case 3:
code = name_enter_string(imemory, "DeviceRGB", *r);
break;
case 4:
code = name_enter_string(imemory, "DeviceCMYK", *r);
break;
default:
return_error(gs_error_rangecheck);
}
}
*CIESubst = 1;
return code;
}
| 18,737 |
165,714 | 0 | void FileReaderLoader::OnComplete(int32_t status, uint64_t data_length) {
DEFINE_THREAD_SAFE_STATIC_LOCAL(SparseHistogram,
file_reader_loader_read_errors_histogram,
("Storage.Blob.FileReaderLoader.ReadError"));
if (status != net::OK) {
net_error_ = status;
file_reader_loader_read_errors_histogram.Sample(std::max(0, -net_error_));
Failed(status == net::ERR_FILE_NOT_FOUND ? FileErrorCode::kNotFoundErr
: FileErrorCode::kNotReadableErr,
FailureType::kBackendReadError);
return;
}
if (data_length != total_bytes_) {
Failed(FileErrorCode::kNotReadableErr, FailureType::kReadSizesIncorrect);
return;
}
received_on_complete_ = true;
if (received_all_data_)
OnFinishLoading();
}
| 18,738 |
154,288 | 0 | error::Error GLES2DecoderImpl::HandleTexSubImage2D(
uint32_t immediate_data_size, const volatile void* cmd_data) {
const char* func_name = "glTexSubImage2D";
const volatile gles2::cmds::TexSubImage2D& c =
*static_cast<const volatile gles2::cmds::TexSubImage2D*>(cmd_data);
TRACE_EVENT2("gpu", "GLES2DecoderImpl::HandleTexSubImage2D",
"width", c.width, "height", c.height);
GLboolean internal = static_cast<GLboolean>(c.internal);
if (internal == GL_TRUE && texture_state_.tex_image_failed)
return error::kNoError;
GLenum target = static_cast<GLenum>(c.target);
GLint level = static_cast<GLint>(c.level);
GLint xoffset = static_cast<GLint>(c.xoffset);
GLint yoffset = static_cast<GLint>(c.yoffset);
GLsizei width = static_cast<GLsizei>(c.width);
GLsizei height = static_cast<GLsizei>(c.height);
GLenum format = static_cast<GLenum>(c.format);
GLenum type = static_cast<GLenum>(c.type);
uint32_t pixels_shm_id = static_cast<uint32_t>(c.pixels_shm_id);
uint32_t pixels_shm_offset = static_cast<uint32_t>(c.pixels_shm_offset);
if (width < 0 || height < 0) {
LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, func_name, "dimensions < 0");
return error::kNoError;
}
PixelStoreParams params;
Buffer* buffer = state_.bound_pixel_unpack_buffer.get();
if (buffer) {
if (pixels_shm_id)
return error::kInvalidArguments;
if (buffer->GetMappedRange()) {
LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name,
"pixel unpack buffer should not be mapped to client memory");
return error::kNoError;
}
params = state_.GetUnpackParams(ContextState::k2D);
} else {
if (!pixels_shm_id && pixels_shm_offset)
return error::kInvalidArguments;
params.alignment = state_.unpack_alignment;
}
uint32_t pixels_size;
uint32_t skip_size;
uint32_t padding;
if (!GLES2Util::ComputeImageDataSizesES3(width, height, 1,
format, type,
params,
&pixels_size,
nullptr,
nullptr,
&skip_size,
&padding)) {
return error::kOutOfBounds;
}
DCHECK_EQ(0u, skip_size);
const void* pixels;
if (pixels_shm_id) {
pixels = GetSharedMemoryAs<const void*>(
pixels_shm_id, pixels_shm_offset, pixels_size);
if (!pixels)
return error::kOutOfBounds;
} else {
DCHECK(buffer || !pixels_shm_offset);
pixels = reinterpret_cast<const void*>(pixels_shm_offset);
}
TextureManager::DoTexSubImageArguments args = {
target, level, xoffset, yoffset, 0, width, height, 1,
format, type, pixels, pixels_size, padding,
TextureManager::DoTexSubImageArguments::kTexSubImage2D};
texture_manager()->ValidateAndDoTexSubImage(
this, &texture_state_, &state_, error_state_.get(), &framebuffer_state_,
func_name, args);
ExitCommandProcessingEarly();
return error::kNoError;
}
| 18,739 |
135,723 | 0 | void InputMethodController::Clear() {
has_composition_ = false;
if (composition_range_) {
composition_range_->setStart(&GetDocument(), 0);
composition_range_->collapse(true);
}
GetDocument().Markers().RemoveMarkersOfTypes(DocumentMarker::kComposition);
}
| 18,740 |
154,417 | 0 | base::WeakPtr<DecoderContext> GLES2DecoderPassthroughImpl::AsWeakPtr() {
return weak_ptr_factory_.GetWeakPtr();
}
| 18,741 |
50,389 | 0 | posix_acl_valid(struct user_namespace *user_ns, const struct posix_acl *acl)
{
const struct posix_acl_entry *pa, *pe;
int state = ACL_USER_OBJ;
int needs_mask = 0;
FOREACH_ACL_ENTRY(pa, acl, pe) {
if (pa->e_perm & ~(ACL_READ|ACL_WRITE|ACL_EXECUTE))
return -EINVAL;
switch (pa->e_tag) {
case ACL_USER_OBJ:
if (state == ACL_USER_OBJ) {
state = ACL_USER;
break;
}
return -EINVAL;
case ACL_USER:
if (state != ACL_USER)
return -EINVAL;
if (!kuid_has_mapping(user_ns, pa->e_uid))
return -EINVAL;
needs_mask = 1;
break;
case ACL_GROUP_OBJ:
if (state == ACL_USER) {
state = ACL_GROUP;
break;
}
return -EINVAL;
case ACL_GROUP:
if (state != ACL_GROUP)
return -EINVAL;
if (!kgid_has_mapping(user_ns, pa->e_gid))
return -EINVAL;
needs_mask = 1;
break;
case ACL_MASK:
if (state != ACL_GROUP)
return -EINVAL;
state = ACL_OTHER;
break;
case ACL_OTHER:
if (state == ACL_OTHER ||
(state == ACL_GROUP && !needs_mask)) {
state = 0;
break;
}
return -EINVAL;
default:
return -EINVAL;
}
}
if (state == 0)
return 0;
return -EINVAL;
}
| 18,742 |
3,119 | 0 | static int rgbbasecolor(i_ctx_t * i_ctx_p, ref *space, int base, int *stage, int *cont, int *stack_depth)
{
os_ptr op = osp;
float RGB[3], CMYK[4], Gray, UCR, BG;
int i;
const gs_color_space * pcs = gs_currentcolorspace(igs);
if (pcs->id == cs_DeviceGray_id) {
/* UGLY hack. Its possible for the graphics library to change the
* colour space to DeviceGray (setcachedevice), but this does not
* change the PostScript space. It can't, because the graphics library
* doesn't know about the PostScript objects. If we get a current*
* operation before the space has been restored, the colour space in
* the graphics library and the PostScript stored space won't match.
* If that happens then we need to pretend the PS colour space was
* DeviceGray
*/
return(graybasecolor(i_ctx_p, space, base, stage, cont, stack_depth));
}
switch (*stage) {
case 0:
*cont = 0;
check_op(3);
op -= 2;
for (i=0;i<3;i++) {
if (!r_has_type(op, t_integer)) {
if (r_has_type(op, t_real)) {
RGB[i] = op->value.realval;
} else
return_error(gs_error_typecheck);
} else
RGB[i] = (float)op->value.intval;
if (RGB[i] < 0 || RGB[i] > 1)
return_error(gs_error_rangecheck);
op++;
}
op = osp;
switch (base) {
case 0:
pop(2);
op = osp;
/* If R == G == B, then this is gray, so just use it. Avoids
* rounding errors.
*/
if (RGB[0] == RGB[1] && RGB[1] == RGB[2])
Gray = RGB[0];
else
Gray = (0.3 * RGB[0]) + (0.59 * RGB[1]) + (0.11 * RGB[2]);
make_real(op, Gray);
return 0;
break;
case 1:
rgb2hsb((float *)&RGB);
make_real(&op[-2], RGB[0]);
make_real(&op[-1], RGB[1]);
make_real(op, RGB[2]);
return 0;
break;
case 2:
make_real(&op[-2], RGB[0]);
make_real(&op[-1], RGB[1]);
make_real(op, RGB[2]);
return 0;
break;
case 3:
*stage = 1;
*cont = 1;
for (i=0;i<3;i++)
CMYK[i] = 1 - RGB[i];
if (CMYK[0] < CMYK[1]) {
if (CMYK[0] < CMYK[2])
CMYK[3] = CMYK[0];
else
CMYK[3] = CMYK[2];
} else {
if (CMYK[1] < CMYK[2])
CMYK[3] = CMYK[1];
else
CMYK[3] = CMYK[2];
}
check_estack(1);
push(2);
op = osp - 4;
for (i=0;i<4;i++) {
make_real(op, CMYK[i]);
op++;
}
make_real(op, CMYK[3]);
esp++;
*esp = istate->undercolor_removal;
return o_push_estack;
break;
default:
return_error(gs_error_undefined);
break;
}
break;
case 1:
(*stage)++;
*cont = 1;
check_estack(1);
check_op(5);
op -= 4;
for (i=0;i<4;i++) {
if (!r_has_type(op, t_integer)) {
if (r_has_type(op, t_real)) {
CMYK[i] = op->value.realval;
} else
return_error(gs_error_typecheck);
} else
CMYK[i] = (float)op->value.intval;
op++;
}
if (!r_has_type(op, t_integer)) {
if (r_has_type(op, t_real)) {
UCR = op->value.realval;
} else
return_error(gs_error_typecheck);
} else
UCR = (float)op->value.intval;
for (i=0;i<3;i++) {
CMYK[i] = CMYK[i] - UCR;
if (CMYK[i] < 0)
CMYK[i] = 0;
if (CMYK[i] > 1)
CMYK[i] = 1.0;
}
op -= 4;
for (i=0;i<4;i++) {
make_real(op, CMYK[i]);
op++;
}
make_real(op, CMYK[3]);
esp++;
*esp = istate->black_generation;
return o_push_estack;
break;
case 2:
*stage = 0;
*cont = 0;
check_op(5);
if (!r_has_type(op, t_integer)) {
if (r_has_type(op, t_real)) {
BG = op->value.realval;
} else
return_error(gs_error_typecheck);
} else
BG = (float)op->value.intval;
pop(1);
op = osp;
if (BG < 0)
BG = 0;
if (BG > 1)
BG = 1;
make_real(op, BG);
break;
}
return 0;
}
| 18,743 |
120,907 | 0 | explicit FactoryForExtensions(const ProfileIOData* profile_io_data)
: profile_io_data_(profile_io_data) {}
| 18,744 |
67,305 | 0 | struct dentry *d_hash_and_lookup(struct dentry *dir, struct qstr *name)
{
/*
* Check for a fs-specific hash function. Note that we must
* calculate the standard hash first, as the d_op->d_hash()
* routine may choose to leave the hash value unchanged.
*/
name->hash = full_name_hash(dir, name->name, name->len);
if (dir->d_flags & DCACHE_OP_HASH) {
int err = dir->d_op->d_hash(dir, name);
if (unlikely(err < 0))
return ERR_PTR(err);
}
return d_lookup(dir, name);
}
| 18,745 |
6,493 | 0 | struct timeval *dtls1_get_timeout(SSL *s, struct timeval *timeleft)
{
struct timeval timenow;
/* If no timeout is set, just return NULL */
if (s->d1->next_timeout.tv_sec == 0 && s->d1->next_timeout.tv_usec == 0) {
return NULL;
}
/* Get current time */
get_current_time(&timenow);
/* If timer already expired, set remaining time to 0 */
if (s->d1->next_timeout.tv_sec < timenow.tv_sec ||
(s->d1->next_timeout.tv_sec == timenow.tv_sec &&
s->d1->next_timeout.tv_usec <= timenow.tv_usec)) {
memset(timeleft, 0, sizeof(struct timeval));
return timeleft;
}
/* Calculate time left until timer expires */
memcpy(timeleft, &(s->d1->next_timeout), sizeof(struct timeval));
timeleft->tv_sec -= timenow.tv_sec;
timeleft->tv_usec -= timenow.tv_usec;
if (timeleft->tv_usec < 0) {
timeleft->tv_sec--;
timeleft->tv_usec += 1000000;
}
/*
* If remaining time is less than 15 ms, set it to 0 to prevent issues
* because of small devergences with socket timeouts.
*/
if (timeleft->tv_sec == 0 && timeleft->tv_usec < 15000) {
memset(timeleft, 0, sizeof(struct timeval));
}
return timeleft;
}
| 18,746 |
151,932 | 0 | void RenderFrameHostImpl::EnterBackForwardCache() {
DCHECK(IsBackForwardCacheEnabled());
DCHECK(!is_in_back_forward_cache_);
is_in_back_forward_cache_ = true;
for (auto& child : children_)
child->current_frame_host()->EnterBackForwardCache();
}
| 18,747 |
132,680 | 0 | void BlinkTestRunner::SetGeofencingMockProvider(bool service_available) {
content::SetGeofencingMockProvider(service_available);
}
| 18,748 |
121,844 | 0 | ImageLoader::~ImageLoader()
{
if (m_image)
m_image->removeClient(this);
ASSERT(m_hasPendingBeforeLoadEvent || !beforeLoadEventSender().hasPendingEvents(this));
if (m_hasPendingBeforeLoadEvent)
beforeLoadEventSender().cancelEvent(this);
ASSERT(m_hasPendingLoadEvent || !loadEventSender().hasPendingEvents(this));
if (m_hasPendingLoadEvent)
loadEventSender().cancelEvent(this);
ASSERT(m_hasPendingErrorEvent || !errorEventSender().hasPendingEvents(this));
if (m_hasPendingErrorEvent)
errorEventSender().cancelEvent(this);
if (m_elementIsProtected)
m_element->deref();
}
| 18,749 |
95,188 | 0 | static void cmd_xmeid(const char *tag, const char *id)
{
mboxevent_set_client_id(id);
prot_printf(imapd_out, "%s OK %s\r\n", tag,
error_message(IMAP_OK_COMPLETED));
}
| 18,750 |
123,380 | 0 | void RenderWidgetHostViewGuest::InitAsChild(
gfx::NativeView parent_view) {
NOTIMPLEMENTED();
}
| 18,751 |
133,260 | 0 | void set_name(const char* name) { name_ = name; }
| 18,752 |
65,240 | 0 | check_gss_callback_principal(struct nfs_client *clp, struct svc_rqst *rqstp)
{
char *p = rqstp->rq_cred.cr_principal;
if (rqstp->rq_authop->flavour != RPC_AUTH_GSS)
return 1;
/* No RPC_AUTH_GSS on NFSv4.1 back channel yet */
if (clp->cl_minorversion != 0)
return 0;
/*
* It might just be a normal user principal, in which case
* userspace won't bother to tell us the name at all.
*/
if (p == NULL)
return 0;
/*
* Did we get the acceptor from userland during the SETCLIENID
* negotiation?
*/
if (clp->cl_acceptor)
return !strcmp(p, clp->cl_acceptor);
/*
* Otherwise try to verify it using the cl_hostname. Note that this
* doesn't work if a non-canonical hostname was used in the devname.
*/
/* Expect a GSS_C_NT_HOSTBASED_NAME like "nfs@serverhostname" */
if (memcmp(p, "nfs@", 4) != 0)
return 0;
p += 4;
if (strcmp(p, clp->cl_hostname) != 0)
return 0;
return 1;
}
| 18,753 |
154,694 | 0 | error::Error GLES2DecoderPassthroughImpl::DoGetProgramInfoLog(
GLuint program,
std::string* infolog) {
CheckErrorCallbackState();
GLint info_log_len = 0;
api()->glGetProgramivFn(GetProgramServiceID(program, resources_),
GL_INFO_LOG_LENGTH, &info_log_len);
if (CheckErrorCallbackState()) {
return error::kNoError;
}
std::vector<char> buffer(info_log_len, 0);
GLsizei length = 0;
api()->glGetProgramInfoLogFn(GetProgramServiceID(program, resources_),
info_log_len, &length, buffer.data());
DCHECK(length <= info_log_len);
*infolog = length > 0 ? std::string(buffer.data(), length) : std::string();
return error::kNoError;
}
| 18,754 |
50,851 | 0 | isofile_free_all_entries(struct iso9660 *iso9660)
{
struct isofile *file, *file_next;
file = iso9660->all_file_list.first;
while (file != NULL) {
file_next = file->allnext;
isofile_free(file);
file = file_next;
}
}
| 18,755 |
8,377 | 0 | static void mptsas_process_scsi_task_mgmt(MPTSASState *s, MPIMsgSCSITaskMgmt *req)
{
MPIMsgSCSITaskMgmtReply reply;
MPIMsgSCSITaskMgmtReply *reply_async;
int status, count;
SCSIDevice *sdev;
SCSIRequest *r, *next;
BusChild *kid;
mptsas_fix_scsi_task_mgmt_endianness(req);
QEMU_BUILD_BUG_ON(MPTSAS_MAX_REQUEST_SIZE < sizeof(*req));
QEMU_BUILD_BUG_ON(sizeof(s->doorbell_msg) < sizeof(*req));
QEMU_BUILD_BUG_ON(sizeof(s->doorbell_reply) < sizeof(reply));
memset(&reply, 0, sizeof(reply));
reply.TargetID = req->TargetID;
reply.Bus = req->Bus;
reply.MsgLength = sizeof(reply) / 4;
reply.Function = req->Function;
reply.TaskType = req->TaskType;
reply.MsgContext = req->MsgContext;
switch (req->TaskType) {
case MPI_SCSITASKMGMT_TASKTYPE_ABORT_TASK:
case MPI_SCSITASKMGMT_TASKTYPE_QUERY_TASK:
status = mptsas_scsi_device_find(s, req->Bus, req->TargetID,
req->LUN, &sdev);
if (status) {
reply.IOCStatus = status;
goto out;
}
if (sdev->lun != req->LUN[1]) {
reply.ResponseCode = MPI_SCSITASKMGMT_RSP_TM_INVALID_LUN;
goto out;
}
QTAILQ_FOREACH_SAFE(r, &sdev->requests, next, next) {
MPTSASRequest *cmd_req = r->hba_private;
if (cmd_req && cmd_req->scsi_io.MsgContext == req->TaskMsgContext) {
break;
}
}
if (r) {
/*
* Assert that the request has not been completed yet, we
* check for it in the loop above.
*/
assert(r->hba_private);
if (req->TaskType == MPI_SCSITASKMGMT_TASKTYPE_QUERY_TASK) {
/* "If the specified command is present in the task set, then
* return a service response set to FUNCTION SUCCEEDED".
*/
reply.ResponseCode = MPI_SCSITASKMGMT_RSP_TM_SUCCEEDED;
} else {
MPTSASCancelNotifier *notifier;
reply_async = g_memdup(&reply, sizeof(MPIMsgSCSITaskMgmtReply));
reply_async->IOCLogInfo = INT_MAX;
count = 1;
notifier = g_new(MPTSASCancelNotifier, 1);
notifier->s = s;
notifier->reply = reply_async;
notifier->notifier.notify = mptsas_cancel_notify;
scsi_req_cancel_async(r, ¬ifier->notifier);
goto reply_maybe_async;
}
}
break;
case MPI_SCSITASKMGMT_TASKTYPE_ABRT_TASK_SET:
case MPI_SCSITASKMGMT_TASKTYPE_CLEAR_TASK_SET:
status = mptsas_scsi_device_find(s, req->Bus, req->TargetID,
req->LUN, &sdev);
if (status) {
reply.IOCStatus = status;
goto out;
}
if (sdev->lun != req->LUN[1]) {
reply.ResponseCode = MPI_SCSITASKMGMT_RSP_TM_INVALID_LUN;
goto out;
}
reply_async = g_memdup(&reply, sizeof(MPIMsgSCSITaskMgmtReply));
reply_async->IOCLogInfo = INT_MAX;
count = 0;
QTAILQ_FOREACH_SAFE(r, &sdev->requests, next, next) {
if (r->hba_private) {
MPTSASCancelNotifier *notifier;
count++;
notifier = g_new(MPTSASCancelNotifier, 1);
notifier->s = s;
notifier->reply = reply_async;
notifier->notifier.notify = mptsas_cancel_notify;
scsi_req_cancel_async(r, ¬ifier->notifier);
}
}
reply_maybe_async:
if (reply_async->TerminationCount < count) {
reply_async->IOCLogInfo = count;
return;
}
g_free(reply_async);
reply.TerminationCount = count;
break;
case MPI_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET:
status = mptsas_scsi_device_find(s, req->Bus, req->TargetID,
req->LUN, &sdev);
if (status) {
reply.IOCStatus = status;
goto out;
}
if (sdev->lun != req->LUN[1]) {
reply.ResponseCode = MPI_SCSITASKMGMT_RSP_TM_INVALID_LUN;
goto out;
}
qdev_reset_all(&sdev->qdev);
break;
case MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET:
if (req->Bus != 0) {
reply.IOCStatus = MPI_IOCSTATUS_SCSI_INVALID_BUS;
goto out;
}
if (req->TargetID > s->max_devices) {
reply.IOCStatus = MPI_IOCSTATUS_SCSI_INVALID_TARGETID;
goto out;
}
QTAILQ_FOREACH(kid, &s->bus.qbus.children, sibling) {
sdev = SCSI_DEVICE(kid->child);
if (sdev->channel == 0 && sdev->id == req->TargetID) {
qdev_reset_all(kid->child);
}
}
break;
case MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS:
qbus_reset_all(&s->bus.qbus);
break;
default:
reply.ResponseCode = MPI_SCSITASKMGMT_RSP_TM_NOT_SUPPORTED;
break;
}
out:
mptsas_fix_scsi_task_mgmt_reply_endianness(&reply);
mptsas_post_reply(s, (MPIDefaultReply *)&reply);
}
| 18,756 |
184,298 | 1 | NaClProcessHost::NaClProcessHost(const GURL& manifest_url, bool off_the_record)
: manifest_url_(manifest_url),
#if defined(OS_WIN)
process_launched_by_broker_(false),
#elif defined(OS_LINUX)
wait_for_nacl_gdb_(false),
#endif
reply_msg_(NULL),
#if defined(OS_WIN)
debug_exception_handler_requested_(false),
#endif
internal_(new NaClInternal()),
ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
enable_exception_handling_(false),
off_the_record_(off_the_record) {
process_.reset(content::BrowserChildProcessHost::Create(
content::PROCESS_TYPE_NACL_LOADER, this));
// Set the display name so the user knows what plugin the process is running.
// We aren't on the UI thread so getting the pref locale for language
// formatting isn't possible, so IDN will be lost, but this is probably OK
// for this use case.
process_->SetName(net::FormatUrl(manifest_url_, std::string()));
// We allow untrusted hardware exception handling to be enabled via
// an env var for consistency with the standalone build of NaCl.
if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableNaClExceptionHandling) ||
getenv("NACL_UNTRUSTED_EXCEPTION_HANDLING") != NULL) {
enable_exception_handling_ = true;
}
enable_ipc_proxy_ = CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableNaClIPCProxy);
}
| 18,757 |
155,177 | 0 | void OmniboxViewViews::Update() {
if (model()->ResetDisplayTexts()) {
RevertAll();
if (model()->has_focus()) {
SelectAllForUserGesture();
}
} else {
EmphasizeURLComponents();
}
}
| 18,758 |
130,446 | 0 | ThreadWatcher::~ThreadWatcher() {}
| 18,759 |
148,795 | 0 | void InterstitialPageImpl::OnDomOperationResponse(
RenderFrameHostImpl* source,
const std::string& json_string) {
std::string json = json_string;
NotificationService::current()->Notify(NOTIFICATION_DOM_OPERATION_RESPONSE,
Source<WebContents>(web_contents()),
Details<std::string>(&json));
if (!enabled())
return;
delegate_->CommandReceived(json_string);
}
| 18,760 |
46,805 | 0 | static bool __init sparc64_has_sha256_opcode(void)
{
unsigned long cfr;
if (!(sparc64_elf_hwcap & HWCAP_SPARC_CRYPTO))
return false;
__asm__ __volatile__("rd %%asr26, %0" : "=r" (cfr));
if (!(cfr & CFR_SHA256))
return false;
return true;
}
| 18,761 |
119,673 | 0 | static bool shouldAddBorderPaddingMargin(RenderObject* child, bool &checkSide)
{
if (!child || (child->isText() && !toRenderText(child)->textLength()))
return true;
checkSide = false;
return checkSide;
}
| 18,762 |
154,408 | 0 | scoped_refptr<TextureRef> texture_ref() { return texture_ref_; }
| 18,763 |
91,038 | 0 | void CWebServer::GetJSonPage(WebEmSession & session, const request& req, reply & rep)
{
Json::Value root;
root["status"] = "ERR";
std::string rtype = request::findValue(&req, "type");
if (rtype == "command")
{
std::string cparam = request::findValue(&req, "param");
if (cparam.empty())
{
cparam = request::findValue(&req, "dparam");
if (cparam.empty())
{
goto exitjson;
}
}
if (cparam == "dologout")
{
session.forcelogin = true;
root["status"] = "OK";
root["title"] = "Logout";
goto exitjson;
}
_log.Debug(DEBUG_WEBSERVER, "WEBS GetJSon :%s :%s ", cparam.c_str(), req.uri.c_str());
HandleCommand(cparam, session, req, root);
} //(rtype=="command")
else {
HandleRType(rtype, session, req, root);
}
exitjson:
std::string jcallback = request::findValue(&req, "jsoncallback");
if (jcallback.size() == 0) {
reply::set_content(&rep, root.toStyledString());
return;
}
reply::set_content(&rep, "var data=" + root.toStyledString() + '\n' + jcallback + "(data);");
}
| 18,764 |
19,040 | 0 | static void tcp_v4_reqsk_destructor(struct request_sock *req)
{
kfree(inet_rsk(req)->opt);
}
| 18,765 |
156,506 | 0 | SQLiteDatabase::SQLiteDatabase()
: db_(nullptr),
page_size_(-1),
transaction_in_progress_(false),
opening_thread_(0),
open_error_(SQLITE_ERROR),
open_error_message_(),
last_changes_count_(0) {
}
| 18,766 |
83,362 | 0 | static int ssl_parse_server_hello( mbedtls_ssl_context *ssl )
{
int ret, i;
size_t n;
size_t ext_len;
unsigned char *buf, *ext;
unsigned char comp;
#if defined(MBEDTLS_ZLIB_SUPPORT)
int accept_comp;
#endif
#if defined(MBEDTLS_SSL_RENEGOTIATION)
int renegotiation_info_seen = 0;
#endif
int handshake_failure = 0;
const mbedtls_ssl_ciphersuite_t *suite_info;
MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse server hello" ) );
buf = ssl->in_msg;
if( ( ret = mbedtls_ssl_read_record( ssl ) ) != 0 )
{
/* No alert on a read error. */
MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_read_record", ret );
return( ret );
}
if( ssl->in_msgtype != MBEDTLS_SSL_MSG_HANDSHAKE )
{
#if defined(MBEDTLS_SSL_RENEGOTIATION)
if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS )
{
ssl->renego_records_seen++;
if( ssl->conf->renego_max_records >= 0 &&
ssl->renego_records_seen > ssl->conf->renego_max_records )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "renegotiation requested, "
"but not honored by server" ) );
return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE );
}
MBEDTLS_SSL_DEBUG_MSG( 1, ( "non-handshake message during renego" ) );
ssl->keep_current_message = 1;
return( MBEDTLS_ERR_SSL_WAITING_SERVER_HELLO_RENEGO );
}
#endif /* MBEDTLS_SSL_RENEGOTIATION */
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) );
mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
MBEDTLS_SSL_ALERT_MSG_UNEXPECTED_MESSAGE );
return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE );
}
#if defined(MBEDTLS_SSL_PROTO_DTLS)
if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM )
{
if( buf[0] == MBEDTLS_SSL_HS_HELLO_VERIFY_REQUEST )
{
MBEDTLS_SSL_DEBUG_MSG( 2, ( "received hello verify request" ) );
MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse server hello" ) );
return( ssl_parse_hello_verify_request( ssl ) );
}
else
{
/* We made it through the verification process */
mbedtls_free( ssl->handshake->verify_cookie );
ssl->handshake->verify_cookie = NULL;
ssl->handshake->verify_cookie_len = 0;
}
}
#endif /* MBEDTLS_SSL_PROTO_DTLS */
if( ssl->in_hslen < 38 + mbedtls_ssl_hs_hdr_len( ssl ) ||
buf[0] != MBEDTLS_SSL_HS_SERVER_HELLO )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) );
mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO );
}
/*
* 0 . 1 server_version
* 2 . 33 random (maybe including 4 bytes of Unix time)
* 34 . 34 session_id length = n
* 35 . 34+n session_id
* 35+n . 36+n cipher_suite
* 37+n . 37+n compression_method
*
* 38+n . 39+n extensions length (optional)
* 40+n . .. extensions
*/
buf += mbedtls_ssl_hs_hdr_len( ssl );
MBEDTLS_SSL_DEBUG_BUF( 3, "server hello, version", buf + 0, 2 );
mbedtls_ssl_read_version( &ssl->major_ver, &ssl->minor_ver,
ssl->conf->transport, buf + 0 );
if( ssl->major_ver < ssl->conf->min_major_ver ||
ssl->minor_ver < ssl->conf->min_minor_ver ||
ssl->major_ver > ssl->conf->max_major_ver ||
ssl->minor_ver > ssl->conf->max_minor_ver )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "server version out of bounds - "
" min: [%d:%d], server: [%d:%d], max: [%d:%d]",
ssl->conf->min_major_ver, ssl->conf->min_minor_ver,
ssl->major_ver, ssl->minor_ver,
ssl->conf->max_major_ver, ssl->conf->max_minor_ver ) );
mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
MBEDTLS_SSL_ALERT_MSG_PROTOCOL_VERSION );
return( MBEDTLS_ERR_SSL_BAD_HS_PROTOCOL_VERSION );
}
MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, current time: %lu",
( (uint32_t) buf[2] << 24 ) |
( (uint32_t) buf[3] << 16 ) |
( (uint32_t) buf[4] << 8 ) |
( (uint32_t) buf[5] ) ) );
memcpy( ssl->handshake->randbytes + 32, buf + 2, 32 );
n = buf[34];
MBEDTLS_SSL_DEBUG_BUF( 3, "server hello, random bytes", buf + 2, 32 );
if( n > 32 )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) );
mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO );
}
if( ssl->in_hslen > mbedtls_ssl_hs_hdr_len( ssl ) + 39 + n )
{
ext_len = ( ( buf[38 + n] << 8 )
| ( buf[39 + n] ) );
if( ( ext_len > 0 && ext_len < 4 ) ||
ssl->in_hslen != mbedtls_ssl_hs_hdr_len( ssl ) + 40 + n + ext_len )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) );
mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO );
}
}
else if( ssl->in_hslen == mbedtls_ssl_hs_hdr_len( ssl ) + 38 + n )
{
ext_len = 0;
}
else
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) );
mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO );
}
/* ciphersuite (used later) */
i = ( buf[35 + n] << 8 ) | buf[36 + n];
/*
* Read and check compression
*/
comp = buf[37 + n];
#if defined(MBEDTLS_ZLIB_SUPPORT)
/* See comments in ssl_write_client_hello() */
#if defined(MBEDTLS_SSL_PROTO_DTLS)
if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM )
accept_comp = 0;
else
#endif
accept_comp = 1;
if( comp != MBEDTLS_SSL_COMPRESS_NULL &&
( comp != MBEDTLS_SSL_COMPRESS_DEFLATE || accept_comp == 0 ) )
#else /* MBEDTLS_ZLIB_SUPPORT */
if( comp != MBEDTLS_SSL_COMPRESS_NULL )
#endif/* MBEDTLS_ZLIB_SUPPORT */
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "server hello, bad compression: %d", comp ) );
mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER );
return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE );
}
/*
* Initialize update checksum functions
*/
ssl->transform_negotiate->ciphersuite_info = mbedtls_ssl_ciphersuite_from_id( i );
if( ssl->transform_negotiate->ciphersuite_info == NULL )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "ciphersuite info for %04x not found", i ) );
mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
MBEDTLS_SSL_ALERT_MSG_INTERNAL_ERROR );
return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA );
}
mbedtls_ssl_optimize_checksum( ssl, ssl->transform_negotiate->ciphersuite_info );
MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, session id len.: %d", n ) );
MBEDTLS_SSL_DEBUG_BUF( 3, "server hello, session id", buf + 35, n );
/*
* Check if the session can be resumed
*/
if( ssl->handshake->resume == 0 || n == 0 ||
#if defined(MBEDTLS_SSL_RENEGOTIATION)
ssl->renego_status != MBEDTLS_SSL_INITIAL_HANDSHAKE ||
#endif
ssl->session_negotiate->ciphersuite != i ||
ssl->session_negotiate->compression != comp ||
ssl->session_negotiate->id_len != n ||
memcmp( ssl->session_negotiate->id, buf + 35, n ) != 0 )
{
ssl->state++;
ssl->handshake->resume = 0;
#if defined(MBEDTLS_HAVE_TIME)
ssl->session_negotiate->start = mbedtls_time( NULL );
#endif
ssl->session_negotiate->ciphersuite = i;
ssl->session_negotiate->compression = comp;
ssl->session_negotiate->id_len = n;
memcpy( ssl->session_negotiate->id, buf + 35, n );
}
else
{
ssl->state = MBEDTLS_SSL_SERVER_CHANGE_CIPHER_SPEC;
if( ( ret = mbedtls_ssl_derive_keys( ssl ) ) != 0 )
{
MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_derive_keys", ret );
mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
MBEDTLS_SSL_ALERT_MSG_INTERNAL_ERROR );
return( ret );
}
}
MBEDTLS_SSL_DEBUG_MSG( 3, ( "%s session has been resumed",
ssl->handshake->resume ? "a" : "no" ) );
MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, chosen ciphersuite: %04x", i ) );
MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, compress alg.: %d", buf[37 + n] ) );
suite_info = mbedtls_ssl_ciphersuite_from_id( ssl->session_negotiate->ciphersuite );
if( suite_info == NULL
#if defined(MBEDTLS_ARC4_C)
|| ( ssl->conf->arc4_disabled &&
suite_info->cipher == MBEDTLS_CIPHER_ARC4_128 )
#endif
)
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) );
mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO );
}
MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, chosen ciphersuite: %s", suite_info->name ) );
i = 0;
while( 1 )
{
if( ssl->conf->ciphersuite_list[ssl->minor_ver][i] == 0 )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) );
mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO );
}
if( ssl->conf->ciphersuite_list[ssl->minor_ver][i++] ==
ssl->session_negotiate->ciphersuite )
{
break;
}
}
if( comp != MBEDTLS_SSL_COMPRESS_NULL
#if defined(MBEDTLS_ZLIB_SUPPORT)
&& comp != MBEDTLS_SSL_COMPRESS_DEFLATE
#endif
)
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) );
mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO );
}
ssl->session_negotiate->compression = comp;
ext = buf + 40 + n;
MBEDTLS_SSL_DEBUG_MSG( 2, ( "server hello, total extension length: %d", ext_len ) );
while( ext_len )
{
unsigned int ext_id = ( ( ext[0] << 8 )
| ( ext[1] ) );
unsigned int ext_size = ( ( ext[2] << 8 )
| ( ext[3] ) );
if( ext_size + 4 > ext_len )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) );
mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO );
}
switch( ext_id )
{
case MBEDTLS_TLS_EXT_RENEGOTIATION_INFO:
MBEDTLS_SSL_DEBUG_MSG( 3, ( "found renegotiation extension" ) );
#if defined(MBEDTLS_SSL_RENEGOTIATION)
renegotiation_info_seen = 1;
#endif
if( ( ret = ssl_parse_renegotiation_info( ssl, ext + 4,
ext_size ) ) != 0 )
return( ret );
break;
#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
case MBEDTLS_TLS_EXT_MAX_FRAGMENT_LENGTH:
MBEDTLS_SSL_DEBUG_MSG( 3, ( "found max_fragment_length extension" ) );
if( ( ret = ssl_parse_max_fragment_length_ext( ssl,
ext + 4, ext_size ) ) != 0 )
{
return( ret );
}
break;
#endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */
#if defined(MBEDTLS_SSL_TRUNCATED_HMAC)
case MBEDTLS_TLS_EXT_TRUNCATED_HMAC:
MBEDTLS_SSL_DEBUG_MSG( 3, ( "found truncated_hmac extension" ) );
if( ( ret = ssl_parse_truncated_hmac_ext( ssl,
ext + 4, ext_size ) ) != 0 )
{
return( ret );
}
break;
#endif /* MBEDTLS_SSL_TRUNCATED_HMAC */
#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC)
case MBEDTLS_TLS_EXT_ENCRYPT_THEN_MAC:
MBEDTLS_SSL_DEBUG_MSG( 3, ( "found encrypt_then_mac extension" ) );
if( ( ret = ssl_parse_encrypt_then_mac_ext( ssl,
ext + 4, ext_size ) ) != 0 )
{
return( ret );
}
break;
#endif /* MBEDTLS_SSL_ENCRYPT_THEN_MAC */
#if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET)
case MBEDTLS_TLS_EXT_EXTENDED_MASTER_SECRET:
MBEDTLS_SSL_DEBUG_MSG( 3, ( "found extended_master_secret extension" ) );
if( ( ret = ssl_parse_extended_ms_ext( ssl,
ext + 4, ext_size ) ) != 0 )
{
return( ret );
}
break;
#endif /* MBEDTLS_SSL_EXTENDED_MASTER_SECRET */
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
case MBEDTLS_TLS_EXT_SESSION_TICKET:
MBEDTLS_SSL_DEBUG_MSG( 3, ( "found session_ticket extension" ) );
if( ( ret = ssl_parse_session_ticket_ext( ssl,
ext + 4, ext_size ) ) != 0 )
{
return( ret );
}
break;
#endif /* MBEDTLS_SSL_SESSION_TICKETS */
#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) || \
defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
case MBEDTLS_TLS_EXT_SUPPORTED_POINT_FORMATS:
MBEDTLS_SSL_DEBUG_MSG( 3, ( "found supported_point_formats extension" ) );
if( ( ret = ssl_parse_supported_point_formats_ext( ssl,
ext + 4, ext_size ) ) != 0 )
{
return( ret );
}
break;
#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C ||
MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */
#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
case MBEDTLS_TLS_EXT_ECJPAKE_KKPP:
MBEDTLS_SSL_DEBUG_MSG( 3, ( "found ecjpake_kkpp extension" ) );
if( ( ret = ssl_parse_ecjpake_kkpp( ssl,
ext + 4, ext_size ) ) != 0 )
{
return( ret );
}
break;
#endif /* MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */
#if defined(MBEDTLS_SSL_ALPN)
case MBEDTLS_TLS_EXT_ALPN:
MBEDTLS_SSL_DEBUG_MSG( 3, ( "found alpn extension" ) );
if( ( ret = ssl_parse_alpn_ext( ssl, ext + 4, ext_size ) ) != 0 )
return( ret );
break;
#endif /* MBEDTLS_SSL_ALPN */
default:
MBEDTLS_SSL_DEBUG_MSG( 3, ( "unknown extension found: %d (ignoring)",
ext_id ) );
}
ext_len -= 4 + ext_size;
ext += 4 + ext_size;
if( ext_len > 0 && ext_len < 4 )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO );
}
}
/*
* Renegotiation security checks
*/
if( ssl->secure_renegotiation == MBEDTLS_SSL_LEGACY_RENEGOTIATION &&
ssl->conf->allow_legacy_renegotiation == MBEDTLS_SSL_LEGACY_BREAK_HANDSHAKE )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "legacy renegotiation, breaking off handshake" ) );
handshake_failure = 1;
}
#if defined(MBEDTLS_SSL_RENEGOTIATION)
else if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS &&
ssl->secure_renegotiation == MBEDTLS_SSL_SECURE_RENEGOTIATION &&
renegotiation_info_seen == 0 )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "renegotiation_info extension missing (secure)" ) );
handshake_failure = 1;
}
else if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS &&
ssl->secure_renegotiation == MBEDTLS_SSL_LEGACY_RENEGOTIATION &&
ssl->conf->allow_legacy_renegotiation == MBEDTLS_SSL_LEGACY_NO_RENEGOTIATION )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "legacy renegotiation not allowed" ) );
handshake_failure = 1;
}
else if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS &&
ssl->secure_renegotiation == MBEDTLS_SSL_LEGACY_RENEGOTIATION &&
renegotiation_info_seen == 1 )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "renegotiation_info extension present (legacy)" ) );
handshake_failure = 1;
}
#endif /* MBEDTLS_SSL_RENEGOTIATION */
if( handshake_failure == 1 )
{
mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO );
}
MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse server hello" ) );
return( 0 );
}
| 18,767 |
20,600 | 0 | int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu,
struct kvm_sregs *sregs)
{
return -EINVAL;
}
| 18,768 |
72,839 | 0 | static void jpc_com_destroyparms(jpc_ms_t *ms)
{
jpc_com_t *com = &ms->parms.com;
if (com->data) {
jas_free(com->data);
}
}
| 18,769 |
175,043 | 0 | status_t MPEG4Extractor::readMetaData() {
if (mInitCheck != NO_INIT) {
return mInitCheck;
}
off64_t offset = 0;
status_t err;
while (true) {
err = parseChunk(&offset, 0);
if (err == OK) {
continue;
}
uint32_t hdr[2];
if (mDataSource->readAt(offset, hdr, 8) < 8) {
break;
}
uint32_t chunk_type = ntohl(hdr[1]);
if (chunk_type == FOURCC('s', 'i', 'd', 'x')) {
continue;
} else if (chunk_type == FOURCC('m', 'o', 'o', 'f')) {
mMoofOffset = offset;
}
break;
}
if (mInitCheck == OK) {
if (mHasVideo) {
mFileMetaData->setCString(
kKeyMIMEType, MEDIA_MIMETYPE_CONTAINER_MPEG4);
} else {
mFileMetaData->setCString(kKeyMIMEType, "audio/mp4");
}
mInitCheck = OK;
} else {
mInitCheck = err;
}
CHECK_NE(err, (status_t)NO_INIT);
int psshsize = 0;
for (size_t i = 0; i < mPssh.size(); i++) {
psshsize += 20 + mPssh[i].datalen;
}
if (psshsize) {
char *buf = (char*)malloc(psshsize);
char *ptr = buf;
for (size_t i = 0; i < mPssh.size(); i++) {
memcpy(ptr, mPssh[i].uuid, 20); // uuid + length
memcpy(ptr + 20, mPssh[i].data, mPssh[i].datalen);
ptr += (20 + mPssh[i].datalen);
}
mFileMetaData->setData(kKeyPssh, 'pssh', buf, psshsize);
free(buf);
}
return mInitCheck;
}
| 18,770 |
22,205 | 0 | static int rose_info_show(struct seq_file *seq, void *v)
{
char buf[11], rsbuf[11];
if (v == SEQ_START_TOKEN)
seq_puts(seq,
"dest_addr dest_call src_addr src_call dev lci neigh st vs vr va t t1 t2 t3 hb idle Snd-Q Rcv-Q inode\n");
else {
struct sock *s = sk_entry(v);
struct rose_sock *rose = rose_sk(s);
const char *devname, *callsign;
const struct net_device *dev = rose->device;
if (!dev)
devname = "???";
else
devname = dev->name;
seq_printf(seq, "%-10s %-9s ",
rose2asc(rsbuf, &rose->dest_addr),
ax2asc(buf, &rose->dest_call));
if (ax25cmp(&rose->source_call, &null_ax25_address) == 0)
callsign = "??????-?";
else
callsign = ax2asc(buf, &rose->source_call);
seq_printf(seq,
"%-10s %-9s %-5s %3.3X %05d %d %d %d %d %3lu %3lu %3lu %3lu %3lu %3lu/%03lu %5d %5d %ld\n",
rose2asc(rsbuf, &rose->source_addr),
callsign,
devname,
rose->lci & 0x0FFF,
(rose->neighbour) ? rose->neighbour->number : 0,
rose->state,
rose->vs,
rose->vr,
rose->va,
ax25_display_timer(&rose->timer) / HZ,
rose->t1 / HZ,
rose->t2 / HZ,
rose->t3 / HZ,
rose->hb / HZ,
ax25_display_timer(&rose->idletimer) / (60 * HZ),
rose->idle / (60 * HZ),
sk_wmem_alloc_get(s),
sk_rmem_alloc_get(s),
s->sk_socket ? SOCK_INODE(s->sk_socket)->i_ino : 0L);
}
return 0;
}
| 18,771 |
93,219 | 0 | finish_input_ppm(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
{
/* no work */
}
| 18,772 |
115,845 | 0 | void NavigationController::LoadEntry(NavigationEntry* entry) {
ChildProcessSecurityPolicy *policy =
ChildProcessSecurityPolicy::GetInstance();
if (policy->IsDisabledScheme(entry->url().scheme()) ||
policy->IsDisabledScheme(entry->virtual_url().scheme())) {
VLOG(1) << "URL not loaded because the scheme is blocked by policy: "
<< entry->url();
delete entry;
return;
}
DiscardNonCommittedEntriesInternal();
pending_entry_ = entry;
content::NotificationService::current()->Notify(
content::NOTIFICATION_NAV_ENTRY_PENDING,
content::Source<NavigationController>(this),
content::Details<NavigationEntry>(entry));
NavigateToPendingEntry(NO_RELOAD);
}
| 18,773 |
81,684 | 0 | get_response(struct mg_connection *conn, char *ebuf, size_t ebuf_len, int *err)
{
const char *cl;
if (!get_message(conn, ebuf, ebuf_len, err)) {
return 0;
}
if (parse_http_response(conn->buf, conn->buf_size, &conn->response_info)
<= 0) {
mg_snprintf(conn,
NULL, /* No truncation check for ebuf */
ebuf,
ebuf_len,
"%s",
"Bad response");
*err = 400;
return 0;
}
/* Message is a valid response */
/* Do we know the content length? */
if ((cl = get_header(conn->response_info.http_headers,
conn->response_info.num_headers,
"Content-Length")) != NULL) {
/* Request/response has content length set */
char *endptr = NULL;
conn->content_len = strtoll(cl, &endptr, 10);
if (endptr == cl) {
mg_snprintf(conn,
NULL, /* No truncation check for ebuf */
ebuf,
ebuf_len,
"%s",
"Bad request");
*err = 411;
return 0;
}
/* Publish the content length back to the response info. */
conn->response_info.content_length = conn->content_len;
/* TODO: check if it is still used in response_info */
conn->request_info.content_length = conn->content_len;
} else if ((cl = get_header(conn->response_info.http_headers,
conn->response_info.num_headers,
"Transfer-Encoding")) != NULL
&& !mg_strcasecmp(cl, "chunked")) {
conn->is_chunked = 1;
conn->content_len = -1; /* unknown content length */
} else {
conn->content_len = -1; /* unknown content length */
}
conn->connection_type = CONNECTION_TYPE_RESPONSE; /* Valid response */
return 1;
}
| 18,774 |
114,153 | 0 | int TestOpenFile(std::wstring path, bool for_write) {
wchar_t path_expanded[MAX_PATH + 1] = {0};
DWORD size = ::ExpandEnvironmentStrings(path.c_str(), path_expanded,
MAX_PATH);
if (!size)
return sandbox::SBOX_TEST_FAILED_TO_EXECUTE_COMMAND;
HANDLE file;
file = ::CreateFile(path_expanded,
for_write ? GENERIC_READ | GENERIC_WRITE : GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
NULL, // No security attributes.
OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS,
NULL); // No template.
if (INVALID_HANDLE_VALUE != file) {
::CloseHandle(file);
return sandbox::SBOX_TEST_SUCCEEDED;
} else {
if (ERROR_ACCESS_DENIED == ::GetLastError()) {
return sandbox::SBOX_TEST_DENIED;
} else {
return sandbox::SBOX_TEST_FAILED_TO_EXECUTE_COMMAND;
}
}
}
| 18,775 |
147,909 | 0 | static void TestInterfaceEmptyAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info) {
v8::Local<v8::Object> holder = info.Holder();
TestObject* impl = V8TestObject::ToImpl(holder);
V8SetReturnValueFast(info, WTF::GetPtr(impl->testInterfaceEmptyAttribute()), impl);
}
| 18,776 |
175,150 | 0 | void NuPlayer::GenericSource::cancelPollBuffering() {
++mPollBufferingGeneration;
}
| 18,777 |
145,975 | 0 | void ResizeDesktop(int width_delta) {
gfx::Size size =
display::Screen::GetScreen()
->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow())
.size();
size.Enlarge(0, width_delta);
UpdateDisplay(size.ToString());
}
| 18,778 |
81,522 | 0 | void tracing_snapshot_alloc(void)
{
/* Give warning */
tracing_snapshot();
}
| 18,779 |
154,625 | 0 | error::Error GLES2DecoderPassthroughImpl::DoDeleteTextures(
GLsizei n,
const volatile GLuint* textures) {
if (n < 0) {
InsertError(GL_INVALID_VALUE, "n cannot be negative.");
return error::kNoError;
}
std::vector<GLuint> non_mailbox_client_ids;
for (GLsizei ii = 0; ii < n; ++ii) {
GLuint client_id = textures[ii];
scoped_refptr<TexturePassthrough> texture = nullptr;
if (!resources_->texture_object_map.GetServiceID(client_id, &texture) ||
texture == nullptr) {
non_mailbox_client_ids.push_back(client_id);
} else {
resources_->texture_id_map.RemoveClientID(client_id);
resources_->texture_object_map.RemoveClientID(client_id);
resources_->texture_shared_image_map.erase(client_id);
UpdateTextureBinding(texture->target(), client_id, nullptr);
}
group_->passthrough_discardable_manager()->DeleteTexture(client_id,
group_.get());
}
return DeleteHelper(
non_mailbox_client_ids.size(), non_mailbox_client_ids.data(),
&resources_->texture_id_map, [this](GLsizei n, GLuint* textures) {
api()->glDeleteTexturesFn(n, textures);
});
}
| 18,780 |
27,542 | 0 | static struct inotify_inode_mark *inotify_idr_find_locked(struct fsnotify_group *group,
int wd)
{
struct idr *idr = &group->inotify_data.idr;
spinlock_t *idr_lock = &group->inotify_data.idr_lock;
struct inotify_inode_mark *i_mark;
assert_spin_locked(idr_lock);
i_mark = idr_find(idr, wd);
if (i_mark) {
struct fsnotify_mark *fsn_mark = &i_mark->fsn_mark;
fsnotify_get_mark(fsn_mark);
/* One ref for being in the idr, one ref we just took */
BUG_ON(atomic_read(&fsn_mark->refcnt) < 2);
}
return i_mark;
}
| 18,781 |
12,822 | 0 | void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x)
{
BUF_MEM *b = NULL;
const unsigned char *p;
void *ret = NULL;
int len;
len = asn1_d2i_read_bio(in, &b);
if (len < 0)
goto err;
p = (const unsigned char *)b->data;
ret = ASN1_item_d2i(x, &p, len, it);
err:
BUF_MEM_free(b);
return (ret);
}
| 18,782 |
12,763 | 0 | int ssl3_accept(SSL *s)
{
BUF_MEM *buf;
unsigned long alg_k, Time = (unsigned long)time(NULL);
void (*cb) (const SSL *ssl, int type, int val) = NULL;
int ret = -1;
int new_state, state, skip = 0;
RAND_add(&Time, sizeof(Time), 0);
ERR_clear_error();
clear_sys_error();
if (s->info_callback != NULL)
cb = s->info_callback;
else if (s->ctx->info_callback != NULL)
cb = s->ctx->info_callback;
/* init things to blank */
s->in_handshake++;
if (!SSL_in_init(s) || SSL_in_before(s))
SSL_clear(s);
if (s->cert == NULL) {
SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_NO_CERTIFICATE_SET);
return (-1);
}
#ifndef OPENSSL_NO_HEARTBEATS
/*
* If we're awaiting a HeartbeatResponse, pretend we already got and
* don't await it anymore, because Heartbeats don't make sense during
* handshakes anyway.
*/
if (s->tlsext_hb_pending) {
s->tlsext_hb_pending = 0;
s->tlsext_hb_seq++;
}
#endif
for (;;) {
state = s->state;
switch (s->state) {
case SSL_ST_RENEGOTIATE:
s->renegotiate = 1;
/* s->state=SSL_ST_ACCEPT; */
case SSL_ST_BEFORE:
case SSL_ST_ACCEPT:
case SSL_ST_BEFORE | SSL_ST_ACCEPT:
case SSL_ST_OK | SSL_ST_ACCEPT:
s->server = 1;
if (cb != NULL)
cb(s, SSL_CB_HANDSHAKE_START, 1);
if ((s->version >> 8) != 3) {
SSLerr(SSL_F_SSL3_ACCEPT, ERR_R_INTERNAL_ERROR);
s->state = SSL_ST_ERR;
return -1;
}
s->type = SSL_ST_ACCEPT;
if (s->init_buf == NULL) {
if ((buf = BUF_MEM_new()) == NULL) {
ret = -1;
s->state = SSL_ST_ERR;
goto end;
}
if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) {
BUF_MEM_free(buf);
ret = -1;
s->state = SSL_ST_ERR;
goto end;
}
s->init_buf = buf;
}
if (!ssl3_setup_buffers(s)) {
ret = -1;
s->state = SSL_ST_ERR;
goto end;
}
s->init_num = 0;
s->s3->flags &= ~TLS1_FLAGS_SKIP_CERT_VERIFY;
s->s3->flags &= ~SSL3_FLAGS_CCS_OK;
/*
* Should have been reset by ssl3_get_finished, too.
*/
s->s3->change_cipher_spec = 0;
if (s->state != SSL_ST_RENEGOTIATE) {
/*
* Ok, we now need to push on a buffering BIO so that the
* output is sent in a way that TCP likes :-)
*/
if (!ssl_init_wbio_buffer(s, 1)) {
ret = -1;
s->state = SSL_ST_ERR;
goto end;
}
ssl3_init_finished_mac(s);
s->state = SSL3_ST_SR_CLNT_HELLO_A;
s->ctx->stats.sess_accept++;
} else if (!s->s3->send_connection_binding &&
!(s->options &
SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)) {
/*
* Server attempting to renegotiate with client that doesn't
* support secure renegotiation.
*/
SSLerr(SSL_F_SSL3_ACCEPT,
SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED);
ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE);
ret = -1;
s->state = SSL_ST_ERR;
goto end;
} else {
/*
* s->state == SSL_ST_RENEGOTIATE, we will just send a
* HelloRequest
*/
s->ctx->stats.sess_accept_renegotiate++;
s->state = SSL3_ST_SW_HELLO_REQ_A;
}
break;
case SSL3_ST_SW_HELLO_REQ_A:
case SSL3_ST_SW_HELLO_REQ_B:
s->shutdown = 0;
ret = ssl3_send_hello_request(s);
if (ret <= 0)
goto end;
s->s3->tmp.next_state = SSL3_ST_SW_HELLO_REQ_C;
s->state = SSL3_ST_SW_FLUSH;
s->init_num = 0;
ssl3_init_finished_mac(s);
break;
case SSL3_ST_SW_HELLO_REQ_C:
s->state = SSL_ST_OK;
break;
case SSL3_ST_SR_CLNT_HELLO_A:
case SSL3_ST_SR_CLNT_HELLO_B:
case SSL3_ST_SR_CLNT_HELLO_C:
s->shutdown = 0;
ret = ssl3_get_client_hello(s);
if (ret <= 0)
goto end;
#ifndef OPENSSL_NO_SRP
s->state = SSL3_ST_SR_CLNT_HELLO_D;
case SSL3_ST_SR_CLNT_HELLO_D:
{
int al;
if ((ret = ssl_check_srp_ext_ClientHello(s, &al)) < 0) {
/*
* callback indicates firther work to be done
*/
s->rwstate = SSL_X509_LOOKUP;
goto end;
}
if (ret != SSL_ERROR_NONE) {
ssl3_send_alert(s, SSL3_AL_FATAL, al);
/*
* This is not really an error but the only means to for
* a client to detect whether srp is supported.
*/
if (al != TLS1_AD_UNKNOWN_PSK_IDENTITY)
SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_CLIENTHELLO_TLSEXT);
ret = -1;
s->state = SSL_ST_ERR;
goto end;
}
}
#endif
s->renegotiate = 2;
s->state = SSL3_ST_SW_SRVR_HELLO_A;
s->init_num = 0;
break;
case SSL3_ST_SW_SRVR_HELLO_A:
case SSL3_ST_SW_SRVR_HELLO_B:
ret = ssl3_send_server_hello(s);
if (ret <= 0)
goto end;
#ifndef OPENSSL_NO_TLSEXT
if (s->hit) {
if (s->tlsext_ticket_expected)
s->state = SSL3_ST_SW_SESSION_TICKET_A;
else
s->state = SSL3_ST_SW_CHANGE_A;
}
#else
if (s->hit)
s->state = SSL3_ST_SW_CHANGE_A;
#endif
else
s->state = SSL3_ST_SW_CERT_A;
s->init_num = 0;
break;
case SSL3_ST_SW_CERT_A:
case SSL3_ST_SW_CERT_B:
/* Check if it is anon DH or anon ECDH, */
/* normal PSK or KRB5 or SRP */
if (!
(s->s3->tmp.
new_cipher->algorithm_auth & (SSL_aNULL | SSL_aKRB5 |
SSL_aSRP))
&& !(s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) {
ret = ssl3_send_server_certificate(s);
if (ret <= 0)
goto end;
#ifndef OPENSSL_NO_TLSEXT
if (s->tlsext_status_expected)
s->state = SSL3_ST_SW_CERT_STATUS_A;
else
s->state = SSL3_ST_SW_KEY_EXCH_A;
} else {
skip = 1;
s->state = SSL3_ST_SW_KEY_EXCH_A;
}
#else
} else
skip = 1;
s->state = SSL3_ST_SW_KEY_EXCH_A;
#endif
s->init_num = 0;
break;
case SSL3_ST_SW_KEY_EXCH_A:
case SSL3_ST_SW_KEY_EXCH_B:
alg_k = s->s3->tmp.new_cipher->algorithm_mkey;
/*
* clear this, it may get reset by
* send_server_key_exchange
*/
s->s3->tmp.use_rsa_tmp = 0;
/*
* only send if a DH key exchange, fortezza or RSA but we have a
* sign only certificate PSK: may send PSK identity hints For
* ECC ciphersuites, we send a serverKeyExchange message only if
* the cipher suite is either ECDH-anon or ECDHE. In other cases,
* the server certificate contains the server's public key for
* key exchange.
*/
if (0
/*
* PSK: send ServerKeyExchange if PSK identity hint if
* provided
*/
#ifndef OPENSSL_NO_PSK
|| ((alg_k & SSL_kPSK) && s->ctx->psk_identity_hint)
#endif
#ifndef OPENSSL_NO_SRP
/* SRP: send ServerKeyExchange */
|| (alg_k & SSL_kSRP)
#endif
|| (alg_k & SSL_kEDH)
|| (alg_k & SSL_kEECDH)
|| ((alg_k & SSL_kRSA)
&& (s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL
|| (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher)
&& EVP_PKEY_size(s->cert->pkeys
[SSL_PKEY_RSA_ENC].privatekey) *
8 > SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)
)
)
)
) {
ret = ssl3_send_server_key_exchange(s);
if (ret <= 0)
goto end;
} else
skip = 1;
s->state = SSL3_ST_SW_CERT_REQ_A;
s->init_num = 0;
break;
case SSL3_ST_SW_CERT_REQ_A:
case SSL3_ST_SW_CERT_REQ_B:
if ( /* don't request cert unless asked for it: */
!(s->verify_mode & SSL_VERIFY_PEER) ||
/*
* if SSL_VERIFY_CLIENT_ONCE is set, don't request cert
* during re-negotiation:
*/
((s->session->peer != NULL) &&
(s->verify_mode & SSL_VERIFY_CLIENT_ONCE)) ||
/*
* never request cert in anonymous ciphersuites (see
* section "Certificate request" in SSL 3 drafts and in
* RFC 2246):
*/
((s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL) &&
/*
* ... except when the application insists on
* verification (against the specs, but s3_clnt.c accepts
* this for SSL 3)
*/
!(s->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)) ||
/*
* never request cert in Kerberos ciphersuites
*/
(s->s3->tmp.new_cipher->algorithm_auth & SSL_aKRB5) ||
/* don't request certificate for SRP auth */
(s->s3->tmp.new_cipher->algorithm_auth & SSL_aSRP)
/*
* With normal PSK Certificates and Certificate Requests
* are omitted
*/
|| (s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) {
/* no cert request */
skip = 1;
s->s3->tmp.cert_request = 0;
s->state = SSL3_ST_SW_SRVR_DONE_A;
if (s->s3->handshake_buffer) {
if (!ssl3_digest_cached_records(s)) {
s->state = SSL_ST_ERR;
return -1;
}
}
} else {
s->s3->tmp.cert_request = 1;
ret = ssl3_send_certificate_request(s);
if (ret <= 0)
goto end;
#ifndef NETSCAPE_HANG_BUG
s->state = SSL3_ST_SW_SRVR_DONE_A;
#else
s->state = SSL3_ST_SW_FLUSH;
s->s3->tmp.next_state = SSL3_ST_SR_CERT_A;
#endif
s->init_num = 0;
}
break;
case SSL3_ST_SW_SRVR_DONE_A:
case SSL3_ST_SW_SRVR_DONE_B:
ret = ssl3_send_server_done(s);
if (ret <= 0)
goto end;
s->s3->tmp.next_state = SSL3_ST_SR_CERT_A;
s->state = SSL3_ST_SW_FLUSH;
s->init_num = 0;
break;
case SSL3_ST_SW_FLUSH:
/*
* This code originally checked to see if any data was pending
* using BIO_CTRL_INFO and then flushed. This caused problems as
* documented in PR#1939. The proposed fix doesn't completely
* resolve this issue as buggy implementations of
* BIO_CTRL_PENDING still exist. So instead we just flush
* unconditionally.
*/
s->rwstate = SSL_WRITING;
if (BIO_flush(s->wbio) <= 0) {
ret = -1;
goto end;
}
s->rwstate = SSL_NOTHING;
s->state = s->s3->tmp.next_state;
break;
case SSL3_ST_SR_CERT_A:
case SSL3_ST_SR_CERT_B:
if (s->s3->tmp.cert_request) {
ret = ssl3_get_client_certificate(s);
if (ret <= 0)
goto end;
}
s->init_num = 0;
s->state = SSL3_ST_SR_KEY_EXCH_A;
break;
case SSL3_ST_SR_KEY_EXCH_A:
case SSL3_ST_SR_KEY_EXCH_B:
ret = ssl3_get_client_key_exchange(s);
if (ret <= 0)
goto end;
if (ret == 2) {
/*
* For the ECDH ciphersuites when the client sends its ECDH
* pub key in a certificate, the CertificateVerify message is
* not sent. Also for GOST ciphersuites when the client uses
* its key from the certificate for key exchange.
*/
#if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG)
s->state = SSL3_ST_SR_FINISHED_A;
#else
if (s->s3->next_proto_neg_seen)
s->state = SSL3_ST_SR_NEXT_PROTO_A;
else
s->state = SSL3_ST_SR_FINISHED_A;
#endif
s->init_num = 0;
} else if (SSL_USE_SIGALGS(s)) {
s->state = SSL3_ST_SR_CERT_VRFY_A;
s->init_num = 0;
if (!s->session->peer)
break;
/*
* For sigalgs freeze the handshake buffer at this point and
* digest cached records.
*/
if (!s->s3->handshake_buffer) {
SSLerr(SSL_F_SSL3_ACCEPT, ERR_R_INTERNAL_ERROR);
s->state = SSL_ST_ERR;
return -1;
}
s->s3->flags |= TLS1_FLAGS_KEEP_HANDSHAKE;
if (!ssl3_digest_cached_records(s)) {
s->state = SSL_ST_ERR;
return -1;
}
} else {
int offset = 0;
int dgst_num;
s->state = SSL3_ST_SR_CERT_VRFY_A;
s->init_num = 0;
/*
* We need to get hashes here so if there is a client cert,
* it can be verified FIXME - digest processing for
* CertificateVerify should be generalized. But it is next
* step
*/
if (s->s3->handshake_buffer) {
if (!ssl3_digest_cached_records(s)) {
s->state = SSL_ST_ERR;
return -1;
}
}
for (dgst_num = 0; dgst_num < SSL_MAX_DIGEST; dgst_num++)
if (s->s3->handshake_dgst[dgst_num]) {
int dgst_size;
s->method->ssl3_enc->cert_verify_mac(s,
EVP_MD_CTX_type
(s->
s3->handshake_dgst
[dgst_num]),
&(s->s3->
tmp.cert_verify_md
[offset]));
dgst_size =
EVP_MD_CTX_size(s->s3->handshake_dgst[dgst_num]);
if (dgst_size < 0) {
s->state = SSL_ST_ERR;
ret = -1;
goto end;
}
offset += dgst_size;
}
}
break;
case SSL3_ST_SR_CERT_VRFY_A:
case SSL3_ST_SR_CERT_VRFY_B:
ret = ssl3_get_cert_verify(s);
if (ret <= 0)
goto end;
#if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG)
s->state = SSL3_ST_SR_FINISHED_A;
#else
if (s->s3->next_proto_neg_seen)
s->state = SSL3_ST_SR_NEXT_PROTO_A;
else
s->state = SSL3_ST_SR_FINISHED_A;
#endif
s->init_num = 0;
break;
#if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG)
case SSL3_ST_SR_NEXT_PROTO_A:
case SSL3_ST_SR_NEXT_PROTO_B:
/*
* Enable CCS for NPN. Receiving a CCS clears the flag, so make
* sure not to re-enable it to ban duplicates. This *should* be the
* first time we have received one - but we check anyway to be
* cautious.
* s->s3->change_cipher_spec is set when a CCS is
* processed in s3_pkt.c, and remains set until
* the client's Finished message is read.
*/
if (!s->s3->change_cipher_spec)
s->s3->flags |= SSL3_FLAGS_CCS_OK;
ret = ssl3_get_next_proto(s);
if (ret <= 0)
goto end;
s->init_num = 0;
s->state = SSL3_ST_SR_FINISHED_A;
break;
#endif
case SSL3_ST_SR_FINISHED_A:
case SSL3_ST_SR_FINISHED_B:
/*
* Enable CCS for handshakes without NPN. In NPN the CCS flag has
* already been set. Receiving a CCS clears the flag, so make
* sure not to re-enable it to ban duplicates.
* s->s3->change_cipher_spec is set when a CCS is
* processed in s3_pkt.c, and remains set until
* the client's Finished message is read.
*/
if (!s->s3->change_cipher_spec)
s->s3->flags |= SSL3_FLAGS_CCS_OK;
ret = ssl3_get_finished(s, SSL3_ST_SR_FINISHED_A,
SSL3_ST_SR_FINISHED_B);
if (ret <= 0)
goto end;
if (s->hit)
s->state = SSL_ST_OK;
#ifndef OPENSSL_NO_TLSEXT
else if (s->tlsext_ticket_expected)
s->state = SSL3_ST_SW_SESSION_TICKET_A;
#endif
else
s->state = SSL3_ST_SW_CHANGE_A;
s->init_num = 0;
break;
#ifndef OPENSSL_NO_TLSEXT
case SSL3_ST_SW_SESSION_TICKET_A:
case SSL3_ST_SW_SESSION_TICKET_B:
ret = ssl3_send_newsession_ticket(s);
if (ret <= 0)
goto end;
s->state = SSL3_ST_SW_CHANGE_A;
s->init_num = 0;
break;
case SSL3_ST_SW_CERT_STATUS_A:
case SSL3_ST_SW_CERT_STATUS_B:
ret = ssl3_send_cert_status(s);
if (ret <= 0)
goto end;
s->state = SSL3_ST_SW_KEY_EXCH_A;
s->init_num = 0;
break;
#endif
case SSL3_ST_SW_CHANGE_A:
case SSL3_ST_SW_CHANGE_B:
s->session->cipher = s->s3->tmp.new_cipher;
if (!s->method->ssl3_enc->setup_key_block(s)) {
ret = -1;
s->state = SSL_ST_ERR;
goto end;
}
ret = ssl3_send_change_cipher_spec(s,
SSL3_ST_SW_CHANGE_A,
SSL3_ST_SW_CHANGE_B);
if (ret <= 0)
goto end;
s->state = SSL3_ST_SW_FINISHED_A;
s->init_num = 0;
if (!s->method->ssl3_enc->change_cipher_state(s,
SSL3_CHANGE_CIPHER_SERVER_WRITE))
{
ret = -1;
s->state = SSL_ST_ERR;
goto end;
}
break;
case SSL3_ST_SW_FINISHED_A:
case SSL3_ST_SW_FINISHED_B:
ret = ssl3_send_finished(s,
SSL3_ST_SW_FINISHED_A,
SSL3_ST_SW_FINISHED_B,
s->method->
ssl3_enc->server_finished_label,
s->method->
ssl3_enc->server_finished_label_len);
if (ret <= 0)
goto end;
s->state = SSL3_ST_SW_FLUSH;
if (s->hit) {
#if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG)
s->s3->tmp.next_state = SSL3_ST_SR_FINISHED_A;
#else
if (s->s3->next_proto_neg_seen) {
s->s3->tmp.next_state = SSL3_ST_SR_NEXT_PROTO_A;
} else
s->s3->tmp.next_state = SSL3_ST_SR_FINISHED_A;
#endif
} else
s->s3->tmp.next_state = SSL_ST_OK;
s->init_num = 0;
break;
case SSL_ST_OK:
/* clean a few things up */
ssl3_cleanup_key_block(s);
BUF_MEM_free(s->init_buf);
s->init_buf = NULL;
/* remove buffering on output */
ssl_free_wbio_buffer(s);
s->init_num = 0;
if (s->renegotiate == 2) { /* skipped if we just sent a
* HelloRequest */
s->renegotiate = 0;
s->new_session = 0;
ssl_update_cache(s, SSL_SESS_CACHE_SERVER);
s->ctx->stats.sess_accept_good++;
/* s->server=1; */
s->handshake_func = ssl3_accept;
if (cb != NULL)
cb(s, SSL_CB_HANDSHAKE_DONE, 1);
}
ret = 1;
goto end;
/* break; */
case SSL_ST_ERR:
default:
SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_UNKNOWN_STATE);
ret = -1;
goto end;
/* break; */
}
if (!s->s3->tmp.reuse_message && !skip) {
if (s->debug) {
if ((ret = BIO_flush(s->wbio)) <= 0)
goto end;
}
if ((cb != NULL) && (s->state != state)) {
new_state = s->state;
s->state = state;
cb(s, SSL_CB_ACCEPT_LOOP, 1);
s->state = new_state;
}
}
skip = 0;
}
| 18,783 |
149,520 | 0 | void LoadingDataCollector::RecordResourceLoadComplete(
const NavigationID& navigation_id,
const content::mojom::ResourceLoadInfo& resource_load_info) {
auto nav_it = inflight_navigations_.find(navigation_id);
if (nav_it == inflight_navigations_.end())
return;
if (!ShouldRecordResourceLoad(navigation_id, resource_load_info))
return;
auto& page_request_summary = *nav_it->second;
page_request_summary.UpdateOrAddToOrigins(resource_load_info);
}
| 18,784 |
84,524 | 0 | numTab(int n)
{
TabBuffer *tab;
int i;
if (n == 0)
return CurrentTab;
if (n == 1)
return FirstTab;
if (nTab <= 1)
return NULL;
for (tab = FirstTab, i = 1; tab && i < n; tab = tab->nextTab, i++) ;
return tab;
}
| 18,785 |
174,193 | 0 | status_t Camera3Device::addDummyStreamLocked() {
ATRACE_CALL();
status_t res;
if (mDummyStreamId != NO_STREAM) {
SET_ERR_L("%s: Camera %d: A dummy stream already exists!",
__FUNCTION__, mId);
return INVALID_OPERATION;
}
ALOGV("%s: Camera %d: Adding a dummy stream", __FUNCTION__, mId);
sp<Camera3OutputStreamInterface> dummyStream =
new Camera3DummyStream(mNextStreamId);
res = mOutputStreams.add(mNextStreamId, dummyStream);
if (res < 0) {
SET_ERR_L("Can't add dummy stream to set: %s (%d)", strerror(-res), res);
return res;
}
mDummyStreamId = mNextStreamId;
mNextStreamId++;
return OK;
}
| 18,786 |
171,805 | 0 | bt_status_t btif_hh_execute_service(BOOLEAN b_enable)
{
if (b_enable)
{
/* Enable and register with BTA-HH */
BTA_HhEnable(BTUI_HH_SECURITY, bte_hh_evt);
}
else {
/* Disable HH */
BTA_HhDisable();
}
return BT_STATUS_SUCCESS;
}
| 18,787 |
76,217 | 0 | int cdrom_get_media_event(struct cdrom_device_info *cdi,
struct media_event_desc *med)
{
struct packet_command cgc;
unsigned char buffer[8];
struct event_header *eh = (struct event_header *)buffer;
init_cdrom_command(&cgc, buffer, sizeof(buffer), CGC_DATA_READ);
cgc.cmd[0] = GPCMD_GET_EVENT_STATUS_NOTIFICATION;
cgc.cmd[1] = 1; /* IMMED */
cgc.cmd[4] = 1 << 4; /* media event */
cgc.cmd[8] = sizeof(buffer);
cgc.quiet = 1;
if (cdi->ops->generic_packet(cdi, &cgc))
return 1;
if (be16_to_cpu(eh->data_len) < sizeof(*med))
return 1;
if (eh->nea || eh->notification_class != 0x4)
return 1;
memcpy(med, &buffer[sizeof(*eh)], sizeof(*med));
return 0;
}
| 18,788 |
22,159 | 0 | long do_fork(unsigned long clone_flags,
unsigned long stack_start,
struct pt_regs *regs,
unsigned long stack_size,
int __user *parent_tidptr,
int __user *child_tidptr)
{
struct task_struct *p;
int trace = 0;
long nr;
/*
* We hope to recycle these flags after 2.6.26
*/
if (unlikely(clone_flags & CLONE_STOPPED)) {
static int __read_mostly count = 100;
if (count > 0 && printk_ratelimit()) {
char comm[TASK_COMM_LEN];
count--;
printk(KERN_INFO "fork(): process `%s' used deprecated "
"clone flags 0x%lx\n",
get_task_comm(comm, current),
clone_flags & CLONE_STOPPED);
}
}
/*
* When called from kernel_thread, don't do user tracing stuff.
*/
if (likely(user_mode(regs)))
trace = tracehook_prepare_clone(clone_flags);
p = copy_process(clone_flags, stack_start, regs, stack_size,
child_tidptr, NULL, trace);
/*
* Do this prior waking up the new thread - the thread pointer
* might get invalid after that point, if the thread exits quickly.
*/
if (!IS_ERR(p)) {
struct completion vfork;
trace_sched_process_fork(current, p);
nr = task_pid_vnr(p);
if (clone_flags & CLONE_PARENT_SETTID)
put_user(nr, parent_tidptr);
if (clone_flags & CLONE_VFORK) {
p->vfork_done = &vfork;
init_completion(&vfork);
}
tracehook_report_clone(trace, regs, clone_flags, nr, p);
/*
* We set PF_STARTING at creation in case tracing wants to
* use this to distinguish a fully live task from one that
* hasn't gotten to tracehook_report_clone() yet. Now we
* clear it and set the child going.
*/
p->flags &= ~PF_STARTING;
if (unlikely(clone_flags & CLONE_STOPPED)) {
/*
* We'll start up with an immediate SIGSTOP.
*/
sigaddset(&p->pending.signal, SIGSTOP);
set_tsk_thread_flag(p, TIF_SIGPENDING);
__set_task_state(p, TASK_STOPPED);
} else {
wake_up_new_task(p, clone_flags);
}
tracehook_report_clone_complete(trace, regs,
clone_flags, nr, p);
if (clone_flags & CLONE_VFORK) {
freezer_do_not_count();
wait_for_completion(&vfork);
freezer_count();
tracehook_report_vfork_done(p, nr);
}
} else {
nr = PTR_ERR(p);
}
return nr;
}
| 18,789 |
84,221 | 0 | selRead(const char *fname)
{
FILE *fp;
SEL *sel;
PROCNAME("selRead");
if (!fname)
return (SEL *)ERROR_PTR("fname not defined", procName, NULL);
if ((fp = fopenReadStream(fname)) == NULL)
return (SEL *)ERROR_PTR("stream not opened", procName, NULL);
if ((sel = selReadStream(fp)) == NULL) {
fclose(fp);
return (SEL *)ERROR_PTR("sela not returned", procName, NULL);
}
fclose(fp);
return sel;
}
| 18,790 |
178,356 | 1 | static int ne2000_buffer_full(NE2000State *s)
{
int avail, index, boundary;
index = s->curpag << 8;
boundary = s->boundary << 8;
if (index < boundary)
return 1;
return 0;
}
| 18,791 |
166,652 | 0 | ImageBitmap* WebGLRenderingContextBase::TransferToImageBitmapBase(
ScriptState* script_state) {
WebFeature feature = WebFeature::kOffscreenCanvasTransferToImageBitmapWebGL;
UseCounter::Count(ExecutionContext::From(script_state), feature);
if (!GetDrawingBuffer())
return nullptr;
std::unique_ptr<viz::SingleReleaseCallback> image_release_callback;
scoped_refptr<StaticBitmapImage> image =
GetDrawingBuffer()->TransferToStaticBitmapImage(&image_release_callback);
GetDrawingBuffer()->SwapPreviousFrameCallback(
std::move(image_release_callback));
return ImageBitmap::Create(image);
}
| 18,792 |
113,593 | 0 | bool AccessibilityUIElement::isMultiSelectable() const
{
return checkElementState(m_element, ATK_STATE_MULTISELECTABLE);
}
| 18,793 |
113,164 | 0 | void set_focus_cycler(internal::FocusCycler* focus_cycler) {
focus_cycler_ = focus_cycler;
}
| 18,794 |
36,183 | 0 | static struct mount *alloc_vfsmnt(const char *name)
{
struct mount *mnt = kmem_cache_zalloc(mnt_cache, GFP_KERNEL);
if (mnt) {
int err;
err = mnt_alloc_id(mnt);
if (err)
goto out_free_cache;
if (name) {
mnt->mnt_devname = kstrdup(name, GFP_KERNEL);
if (!mnt->mnt_devname)
goto out_free_id;
}
#ifdef CONFIG_SMP
mnt->mnt_pcp = alloc_percpu(struct mnt_pcp);
if (!mnt->mnt_pcp)
goto out_free_devname;
this_cpu_add(mnt->mnt_pcp->mnt_count, 1);
#else
mnt->mnt_count = 1;
mnt->mnt_writers = 0;
#endif
INIT_HLIST_NODE(&mnt->mnt_hash);
INIT_LIST_HEAD(&mnt->mnt_child);
INIT_LIST_HEAD(&mnt->mnt_mounts);
INIT_LIST_HEAD(&mnt->mnt_list);
INIT_LIST_HEAD(&mnt->mnt_expire);
INIT_LIST_HEAD(&mnt->mnt_share);
INIT_LIST_HEAD(&mnt->mnt_slave_list);
INIT_LIST_HEAD(&mnt->mnt_slave);
#ifdef CONFIG_FSNOTIFY
INIT_HLIST_HEAD(&mnt->mnt_fsnotify_marks);
#endif
}
return mnt;
#ifdef CONFIG_SMP
out_free_devname:
kfree(mnt->mnt_devname);
#endif
out_free_id:
mnt_free_id(mnt);
out_free_cache:
kmem_cache_free(mnt_cache, mnt);
return NULL;
}
| 18,795 |
57,476 | 0 | static unsigned long blocks_for_truncate(struct inode *inode)
{
ext4_lblk_t needed;
needed = inode->i_blocks >> (inode->i_sb->s_blocksize_bits - 9);
/* Give ourselves just enough room to cope with inodes in which
* i_blocks is corrupt: we've seen disk corruptions in the past
* which resulted in random data in an inode which looked enough
* like a regular file for ext4 to try to delete it. Things
* will go a bit crazy if that happens, but at least we should
* try not to panic the whole kernel. */
if (needed < 2)
needed = 2;
/* But we need to bound the transaction so we don't overflow the
* journal. */
if (needed > EXT4_MAX_TRANS_DATA)
needed = EXT4_MAX_TRANS_DATA;
return EXT4_DATA_TRANS_BLOCKS(inode->i_sb) + needed;
}
| 18,796 |
131,707 | 0 | static void serializedScriptValueMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
TestObjectPythonV8Internal::serializedScriptValueMethodMethod(info);
TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
}
| 18,797 |
187,608 | 1 | write_png(const char **name, FILE *fp, int color_type, int bit_depth,
volatile png_fixed_point gamma, chunk_insert * volatile insert,
unsigned int filters, unsigned int *colors)
{
png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
name, makepng_error, makepng_warning);
volatile png_infop info_ptr = NULL;
volatile png_bytep row = NULL;
if (png_ptr == NULL)
{
fprintf(stderr, "makepng: OOM allocating write structure\n");
return 1;
}
if (setjmp(png_jmpbuf(png_ptr)))
{
png_structp nv_ptr = png_ptr;
png_infop nv_info = info_ptr;
png_ptr = NULL;
info_ptr = NULL;
png_destroy_write_struct(&nv_ptr, &nv_info);
if (row != NULL) free(row);
return 1;
}
/* Allow benign errors so that we can write PNGs with errors */
png_set_benign_errors(png_ptr, 1/*allowed*/);
png_init_io(png_ptr, fp);
info_ptr = png_create_info_struct(png_ptr);
if (info_ptr == NULL)
png_error(png_ptr, "OOM allocating info structure");
{
unsigned int size = image_size_of_type(color_type, bit_depth, colors);
png_fixed_point real_gamma = 45455; /* For sRGB */
png_byte gamma_table[256];
double conv;
/* This function uses the libpng values used on read to carry extra
* information about the gamma:
*/
if (gamma == PNG_GAMMA_MAC_18)
gamma = 65909;
else if (gamma > 0 && gamma < 1000)
gamma = PNG_FP_1;
if (gamma > 0)
real_gamma = gamma;
{
unsigned int i;
if (real_gamma == 45455) for (i=0; i<256; ++i)
{
gamma_table[i] = (png_byte)i;
conv = 1.;
}
else
{
/* Convert 'i' from sRGB (45455) to real_gamma, this makes
* the images look the same regardless of the gAMA chunk.
*/
conv = real_gamma;
conv /= 45455;
gamma_table[0] = 0;
for (i=1; i<255; ++i)
gamma_table[i] = (png_byte)floor(pow(i/255.,conv) * 255 + .5);
gamma_table[255] = 255;
}
}
png_set_IHDR(png_ptr, info_ptr, size, size, bit_depth, color_type,
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
if (color_type & PNG_COLOR_MASK_PALETTE)
{
int npalette;
png_color palette[256];
png_byte trans[256];
npalette = generate_palette(palette, trans, bit_depth, gamma_table,
colors);
png_set_PLTE(png_ptr, info_ptr, palette, npalette);
png_set_tRNS(png_ptr, info_ptr, trans, npalette-1,
NULL/*transparent color*/);
/* Reset gamma_table to prevent the image rows being changed */
for (npalette=0; npalette<256; ++npalette)
gamma_table[npalette] = (png_byte)npalette;
}
if (gamma == PNG_DEFAULT_sRGB)
png_set_sRGB(png_ptr, info_ptr, PNG_sRGB_INTENT_ABSOLUTE);
else if (gamma > 0) /* Else don't set color space information */
{
png_set_gAMA_fixed(png_ptr, info_ptr, real_gamma);
/* Just use the sRGB values here. */
png_set_cHRM_fixed(png_ptr, info_ptr,
/* color x y */
/* white */ 31270, 32900,
/* red */ 64000, 33000,
/* green */ 30000, 60000,
/* blue */ 15000, 6000
);
}
/* Insert extra information. */
while (insert != NULL)
{
insert->insert(png_ptr, info_ptr, insert->nparams, insert->parameters);
insert = insert->next;
}
/* Write the file header. */
png_write_info(png_ptr, info_ptr);
/* Restrict the filters */
png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, filters);
{
int passes = png_set_interlace_handling(png_ptr);
int pass;
png_size_t rowbytes = png_get_rowbytes(png_ptr, info_ptr);
row = malloc(rowbytes);
if (row == NULL)
png_error(png_ptr, "OOM allocating row buffer");
for (pass = 0; pass < passes; ++pass)
{
unsigned int y;
for (y=0; y<size; ++y)
{
generate_row(row, rowbytes, y, color_type, bit_depth,
gamma_table, conv, colors);
png_write_row(png_ptr, row);
}
}
}
}
/* Finish writing the file. */
png_write_end(png_ptr, info_ptr);
{
png_structp nv_ptr = png_ptr;
png_infop nv_info = info_ptr;
png_ptr = NULL;
info_ptr = NULL;
png_destroy_write_struct(&nv_ptr, &nv_info);
}
free(row);
return 0;
}
| 18,798 |
50,253 | 0 | void __sock_tx_timestamp(const struct sock *sk, __u8 *tx_flags)
{
u8 flags = *tx_flags;
if (sk->sk_tsflags & SOF_TIMESTAMPING_TX_HARDWARE)
flags |= SKBTX_HW_TSTAMP;
if (sk->sk_tsflags & SOF_TIMESTAMPING_TX_SOFTWARE)
flags |= SKBTX_SW_TSTAMP;
if (sk->sk_tsflags & SOF_TIMESTAMPING_TX_SCHED)
flags |= SKBTX_SCHED_TSTAMP;
if (sk->sk_tsflags & SOF_TIMESTAMPING_TX_ACK)
flags |= SKBTX_ACK_TSTAMP;
*tx_flags = flags;
}
| 18,799 |
Subsets and Splits