idx
int64
func
string
target
int64
375,799
static void aer_log_del_err(PCIEAERLog *aer_log, PCIEAERErr *err) { assert(aer_log->log_num); *err = aer_log->log[0]; aer_log->log_num--; memmove(&aer_log->log[0], &aer_log->log[1], aer_log->log_num * sizeof *err); }
0
156,733
mono_image_register_token (MonoDynamicImage *assembly, guint32 token, MonoObject *obj) { MonoObject *prev = mono_g_hash_table_lookup (assembly->tokens, GUINT_TO_POINTER (token)); if (prev) { /* There could be multiple MethodInfo objects with the same token */ //g_assert (prev == obj); } else { mono_g_hash_table_insert (assembly->tokens, GUINT_TO_POINTER (token), obj); } }
0
93,297
static MagickBooleanType IsJ2K(const unsigned char *magick,const size_t length) { if (length < 4) return(MagickFalse); if (memcmp(magick,"\xff\x4f\xff\x51",4) == 0) return(MagickTrue); return(MagickFalse); }
0
344,017
rfbBool rfbProcessFileTransfer(rfbClientPtr cl, uint8_t contentType, uint8_t contentParam, uint32_t size, uint32_t length) { char *buffer=NULL, *p=NULL; int retval=0; char filename1[MAX_PATH]; char filename2[MAX_PATH]; char szFileTime[MAX_PATH]; struct stat statbuf; uint32_t sizeHtmp=0; int n=0; char timespec[64]; #ifdef LIBVNCSERVER_HAVE_LIBZ unsigned char compBuff[sz_rfbBlockSize]; unsigned long nRawBytes = sz_rfbBlockSize; int nRet = 0; #endif FILEXFER_ALLOWED_OR_CLOSE_AND_RETURN("", cl, FALSE); /* rfbLog("rfbProcessFileTransfer(%dtype, %dparam, %dsize, %dlen)\n", contentType, contentParam, size, length); */ switch (contentType) { case rfbDirContentRequest: switch (contentParam) { case rfbRDrivesList: /* Client requests the List of Local Drives */ /* rfbLog("rfbProcessFileTransfer() rfbDirContentRequest: rfbRDrivesList:\n"); */ /* Format when filled : "C:\<NULL>D:\<NULL>....Z:\<NULL><NULL> * * We replace the "\" char following the drive letter and ":" * with a char corresponding to the type of drive * We obtain something like "C:l<NULL>D:c<NULL>....Z:n\<NULL><NULL>" * Isn't it ugly ? * DRIVE_FIXED = 'l' (local?) * DRIVE_REMOVABLE = 'f' (floppy?) * DRIVE_CDROM = 'c' * DRIVE_REMOTE = 'n' */ /* in unix, there are no 'drives' (We could list mount points though) * We fake the root as a "C:" for the Winblows users */ filename2[0]='C'; filename2[1]=':'; filename2[2]='l'; filename2[3]=0; filename2[4]=0; retval = rfbSendFileTransferMessage(cl, rfbDirPacket, rfbADrivesList, 0, 5, filename2); if (buffer!=NULL) free(buffer); return retval; break; case rfbRDirContent: /* Client requests the content of a directory */ /* rfbLog("rfbProcessFileTransfer() rfbDirContentRequest: rfbRDirContent\n"); */ if ((buffer = rfbProcessFileTransferReadBuffer(cl, length))==NULL) return FALSE; retval = rfbSendDirContent(cl, length, buffer); if (buffer!=NULL) free(buffer); return retval; } break; case rfbDirPacket: rfbLog("rfbProcessFileTransfer() rfbDirPacket\n"); break; case rfbFileAcceptHeader: rfbLog("rfbProcessFileTransfer() rfbFileAcceptHeader\n"); break; case rfbCommandReturn: rfbLog("rfbProcessFileTransfer() rfbCommandReturn\n"); break; case rfbFileChecksums: /* Destination file already exists - the viewer sends the checksums */ rfbLog("rfbProcessFileTransfer() rfbFileChecksums\n"); break; case rfbFileTransferAccess: rfbLog("rfbProcessFileTransfer() rfbFileTransferAccess\n"); break; /* * sending from the server to the viewer */ case rfbFileTransferRequest: /* rfbLog("rfbProcessFileTransfer() rfbFileTransferRequest:\n"); */ /* add some space to the end of the buffer as we will be adding a timespec to it */ if ((buffer = rfbProcessFileTransferReadBuffer(cl, length))==NULL) return FALSE; /* The client requests a File */ rfbFilenameTranslate2UNIX(cl, buffer, filename1); cl->fileTransfer.fd=open(filename1, O_RDONLY, 0744); /* */ if (DB) rfbLog("rfbProcessFileTransfer() rfbFileTransferRequest(\"%s\"->\"%s\") Open: %s fd=%d\n", buffer, filename1, (cl->fileTransfer.fd==-1?"Failed":"Success"), cl->fileTransfer.fd); if (cl->fileTransfer.fd!=-1) { if (fstat(cl->fileTransfer.fd, &statbuf)!=0) { close(cl->fileTransfer.fd); cl->fileTransfer.fd=-1; } else { /* Add the File Time Stamp to the filename */ strftime(timespec, sizeof(timespec), "%m/%d/%Y %H:%M",gmtime(&statbuf.st_ctime)); buffer=realloc(buffer, length + strlen(timespec) + 2); /* comma, and Null term */ if (buffer==NULL) { rfbLog("rfbProcessFileTransfer() rfbFileTransferRequest: Failed to malloc %d bytes\n", length + strlen(timespec) + 2); return FALSE; } strcat(buffer,","); strcat(buffer, timespec); length = strlen(buffer); if (DB) rfbLog("rfbProcessFileTransfer() buffer is now: \"%s\"\n", buffer); } } /* The viewer supports compression if size==1 */ cl->fileTransfer.compressionEnabled = (size==1); /* rfbLog("rfbProcessFileTransfer() rfbFileTransferRequest(\"%s\"->\"%s\")%s\n", buffer, filename1, (size==1?" <Compression Enabled>":"")); */ /* File Size in bytes, 0xFFFFFFFF (-1) means error */ retval = rfbSendFileTransferMessage(cl, rfbFileHeader, 0, (cl->fileTransfer.fd==-1 ? -1 : statbuf.st_size), length, buffer); if (cl->fileTransfer.fd==-1) { if (buffer!=NULL) free(buffer); return retval; } /* setup filetransfer stuff */ cl->fileTransfer.fileSize = statbuf.st_size; cl->fileTransfer.numPackets = statbuf.st_size / sz_rfbBlockSize; cl->fileTransfer.receiving = 0; cl->fileTransfer.sending = 0; /* set when we receive a rfbFileHeader: */ /* TODO: finish 64-bit file size support */ sizeHtmp = 0; if (rfbWriteExact(cl, (char *)&sizeHtmp, 4) < 0) { rfbLogPerror("rfbProcessFileTransfer: write"); rfbCloseClient(cl); if (buffer!=NULL) free(buffer); return FALSE; } break; case rfbFileHeader: /* Destination file (viewer side) is ready for reception (size > 0) or not (size = -1) */ if (size==-1) { rfbLog("rfbProcessFileTransfer() rfbFileHeader (error, aborting)\n"); close(cl->fileTransfer.fd); cl->fileTransfer.fd=-1; return TRUE; } /* rfbLog("rfbProcessFileTransfer() rfbFileHeader (%d bytes of a file)\n", size); */ /* Starts the transfer! */ cl->fileTransfer.sending=1; return rfbSendFileTransferChunk(cl); break; /* * sending from the viewer to the server */ case rfbFileTransferOffer: /* client is sending a file to us */ /* buffer contains full path name (plus FileTime) */ /* size contains size of the file */ /* rfbLog("rfbProcessFileTransfer() rfbFileTransferOffer:\n"); */ if ((buffer = rfbProcessFileTransferReadBuffer(cl, length))==NULL) return FALSE; /* Parse the FileTime */ p = strrchr(buffer, ','); if (p!=NULL) { *p = '\0'; strcpy(szFileTime, p+1); } else szFileTime[0]=0; /* Need to read in sizeHtmp */ if ((n = rfbReadExact(cl, (char *)&sizeHtmp, 4)) <= 0) { if (n != 0) rfbLogPerror("rfbProcessFileTransfer: read sizeHtmp"); rfbCloseClient(cl); /* NOTE: don't forget to free(buffer) if you return early! */ if (buffer!=NULL) free(buffer); return FALSE; } sizeHtmp = Swap32IfLE(sizeHtmp); rfbFilenameTranslate2UNIX(cl, buffer, filename1); /* If the file exists... We can send a rfbFileChecksums back to the client before we send an rfbFileAcceptHeader */ /* TODO: Delta Transfer */ cl->fileTransfer.fd=open(filename1, O_CREAT|O_WRONLY|O_TRUNC, 0744); if (DB) rfbLog("rfbProcessFileTransfer() rfbFileTransferOffer(\"%s\"->\"%s\") %s %s fd=%d\n", buffer, filename1, (cl->fileTransfer.fd==-1?"Failed":"Success"), (cl->fileTransfer.fd==-1?strerror(errno):""), cl->fileTransfer.fd); /* */ /* File Size in bytes, 0xFFFFFFFF (-1) means error */ retval = rfbSendFileTransferMessage(cl, rfbFileAcceptHeader, 0, (cl->fileTransfer.fd==-1 ? -1 : 0), length, buffer); if (cl->fileTransfer.fd==-1) { free(buffer); return retval; } /* setup filetransfer stuff */ cl->fileTransfer.fileSize = size; cl->fileTransfer.numPackets = size / sz_rfbBlockSize; cl->fileTransfer.receiving = 1; cl->fileTransfer.sending = 0; break; case rfbFilePacket: /* rfbLog("rfbProcessFileTransfer() rfbFilePacket:\n"); */ if ((buffer = rfbProcessFileTransferReadBuffer(cl, length))==NULL) return FALSE; if (cl->fileTransfer.fd!=-1) { /* buffer contains the contents of the file */ if (size==0) retval=write(cl->fileTransfer.fd, buffer, length); else { #ifdef LIBVNCSERVER_HAVE_LIBZ /* compressed packet */ nRet = uncompress(compBuff,&nRawBytes,(const unsigned char*)buffer, length); retval=write(cl->fileTransfer.fd, compBuff, nRawBytes); #else /* Write the file out as received... */ retval=write(cl->fileTransfer.fd, buffer, length); #endif } if (retval==-1) { close(cl->fileTransfer.fd); cl->fileTransfer.fd=-1; cl->fileTransfer.sending = 0; cl->fileTransfer.receiving = 0; } } break; case rfbEndOfFile: if (DB) rfbLog("rfbProcessFileTransfer() rfbEndOfFile\n"); /* */ if (cl->fileTransfer.fd!=-1) close(cl->fileTransfer.fd); cl->fileTransfer.fd=-1; cl->fileTransfer.sending = 0; cl->fileTransfer.receiving = 0; break; case rfbAbortFileTransfer: if (DB) rfbLog("rfbProcessFileTransfer() rfbAbortFileTransfer\n"); /* */ if (cl->fileTransfer.fd!=-1) { close(cl->fileTransfer.fd); cl->fileTransfer.fd=-1; cl->fileTransfer.sending = 0; cl->fileTransfer.receiving = 0; } else { /* We use this message for FileTransfer rights (<=RC18 versions) * The client asks for FileTransfer permission */ if (contentParam == 0) { rfbLog("rfbProcessFileTransfer() File Transfer Permission DENIED! (Client Version <=RC18)\n"); /* Old method for FileTransfer handshake perimssion (<=RC18) (Deny it)*/ return rfbSendFileTransferMessage(cl, rfbAbortFileTransfer, 0, -1, 0, ""); } /* New method is allowed */ if (cl->screen->getFileTransferPermission!=NULL) { if (cl->screen->getFileTransferPermission(cl)==TRUE) { rfbLog("rfbProcessFileTransfer() File Transfer Permission Granted!\n"); return rfbSendFileTransferMessage(cl, rfbFileTransferAccess, 0, 1 , 0, ""); /* Permit */ } else { rfbLog("rfbProcessFileTransfer() File Transfer Permission DENIED!\n"); return rfbSendFileTransferMessage(cl, rfbFileTransferAccess, 0, -1 , 0, ""); /* Deny */ } } else { if (cl->screen->permitFileTransfer) { rfbLog("rfbProcessFileTransfer() File Transfer Permission Granted!\n"); return rfbSendFileTransferMessage(cl, rfbFileTransferAccess, 0, 1 , 0, ""); /* Permit */ } else { rfbLog("rfbProcessFileTransfer() File Transfer Permission DENIED by default!\n"); return rfbSendFileTransferMessage(cl, rfbFileTransferAccess, 0, -1 , 0, ""); /* DEFAULT: DENY (for security) */ } } } break; case rfbCommand: /* rfbLog("rfbProcessFileTransfer() rfbCommand:\n"); */ if ((buffer = rfbProcessFileTransferReadBuffer(cl, length))==NULL) return FALSE; switch (contentParam) { case rfbCDirCreate: /* Client requests the creation of a directory */ rfbFilenameTranslate2UNIX(cl, buffer, filename1); retval = mkdir(filename1, 0755); if (DB) rfbLog("rfbProcessFileTransfer() rfbCommand: rfbCDirCreate(\"%s\"->\"%s\") %s\n", buffer, filename1, (retval==-1?"Failed":"Success")); /* */ retval = rfbSendFileTransferMessage(cl, rfbCommandReturn, rfbADirCreate, retval, length, buffer); if (buffer!=NULL) free(buffer); return retval; case rfbCFileDelete: /* Client requests the deletion of a file */ rfbFilenameTranslate2UNIX(cl, buffer, filename1); if (stat(filename1,&statbuf)==0) { if (S_ISDIR(statbuf.st_mode)) retval = rmdir(filename1); else retval = unlink(filename1); } else retval=-1; retval = rfbSendFileTransferMessage(cl, rfbCommandReturn, rfbAFileDelete, retval, length, buffer); if (buffer!=NULL) free(buffer); return retval; case rfbCFileRename: /* Client requests the Renaming of a file/directory */ p = strrchr(buffer, '*'); if (p != NULL) { /* Split into 2 filenames ('*' is a seperator) */ *p = '\0'; rfbFilenameTranslate2UNIX(cl, buffer, filename1); rfbFilenameTranslate2UNIX(cl, p+1, filename2); retval = rename(filename1,filename2); if (DB) rfbLog("rfbProcessFileTransfer() rfbCommand: rfbCFileRename(\"%s\"->\"%s\" -->> \"%s\"->\"%s\") %s\n", buffer, filename1, p+1, filename2, (retval==-1?"Failed":"Success")); /* */ /* Restore the buffer so the reply is good */ *p = '*'; retval = rfbSendFileTransferMessage(cl, rfbCommandReturn, rfbAFileRename, retval, length, buffer); if (buffer!=NULL) free(buffer); return retval; } break; } break; } /* NOTE: don't forget to free(buffer) if you return early! */ if (buffer!=NULL) free(buffer); return TRUE; }
1
344,806
xps_parse_gradient_stops(xps_document *doc, char *base_uri, fz_xml *node, struct stop *stops, int maxcount) { fz_colorspace *colorspace; float sample[8]; float rgb[3]; int before, after; int count; int i; /* We may have to insert 2 extra stops when postprocessing */ maxcount -= 2; count = 0; while (node && count < maxcount) { if (!strcmp(fz_xml_tag(node), "GradientStop")) { char *offset = fz_xml_att(node, "Offset"); char *color = fz_xml_att(node, "Color"); if (offset && color) { stops[count].offset = fz_atof(offset); stops[count].index = count; xps_parse_color(doc, base_uri, color, &colorspace, sample); fz_convert_color(doc->ctx, fz_device_rgb(doc->ctx), rgb, colorspace, sample + 1); stops[count].r = rgb[0]; stops[count].g = rgb[1]; stops[count].b = rgb[2]; stops[count].a = sample[0]; count ++; } } node = fz_xml_next(node); } if (count == 0) { fz_warn(doc->ctx, "gradient brush has no gradient stops"); stops[0].offset = 0; stops[0].r = 0; stops[0].g = 0; stops[0].b = 0; stops[0].a = 1; stops[1].offset = 1; stops[1].r = 1; stops[1].g = 1; stops[1].b = 1; stops[1].a = 1; return 2; } if (count == maxcount) fz_warn(doc->ctx, "gradient brush exceeded maximum number of gradient stops"); /* Postprocess to make sure the range of offsets is 0.0 to 1.0 */ qsort(stops, count, sizeof(struct stop), cmp_stop); before = -1; after = -1; for (i = 0; i < count; i++) { if (stops[i].offset < 0) before = i; if (stops[i].offset > 1) { after = i; break; } } /* Remove all stops < 0 except the largest one */ if (before > 0) { memmove(stops, stops + before, (count - before) * sizeof(struct stop)); count -= before; } /* Remove all stops > 1 except the smallest one */ if (after >= 0) count = after + 1; /* Expand single stop to 0 .. 1 */ if (count == 1) { stops[1] = stops[0]; stops[0].offset = 0; stops[1].offset = 1; return 2; } /* First stop < 0 -- interpolate value to 0 */ if (stops[0].offset < 0) { float d = -stops[0].offset / (stops[1].offset - stops[0].offset); stops[0].offset = 0; stops[0].r = lerp(stops[0].r, stops[1].r, d); stops[0].g = lerp(stops[0].g, stops[1].g, d); stops[0].b = lerp(stops[0].b, stops[1].b, d); stops[0].a = lerp(stops[0].a, stops[1].a, d); } /* Last stop > 1 -- interpolate value to 1 */ if (stops[count-1].offset > 1) { float d = (1 - stops[count-2].offset) / (stops[count-1].offset - stops[count-2].offset); stops[count-1].offset = 1; stops[count-1].r = lerp(stops[count-2].r, stops[count-1].r, d); stops[count-1].g = lerp(stops[count-2].g, stops[count-1].g, d); stops[count-1].b = lerp(stops[count-2].b, stops[count-1].b, d); stops[count-1].a = lerp(stops[count-2].a, stops[count-1].a, d); } /* First stop > 0 -- insert a duplicate at 0 */ if (stops[0].offset > 0) { memmove(stops + 1, stops, count * sizeof(struct stop)); stops[0] = stops[1]; stops[0].offset = 0; count++; } /* Last stop < 1 -- insert a duplicate at 1 */ if (stops[count-1].offset < 1) { stops[count] = stops[count-1]; stops[count].offset = 1; count++; } return count; }
1
316,581
static MagickBooleanType WriteJNGImage(const ImageInfo *image_info,Image *image) { MagickBooleanType logging, status; MngInfo *mng_info; /* Open image file. */ assert(image_info != (const ImageInfo *) NULL); assert(image_info->signature == MagickSignature); assert(image != (Image *) NULL); assert(image->signature == MagickSignature); (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); logging=LogMagickEvent(CoderEvent,GetMagickModule(),"Enter WriteJNGImage()"); status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception); if (status == MagickFalse) return(status); if ((image->columns > 65535UL) || (image->rows > 65535UL)) ThrowWriterException(ImageError,"WidthOrHeightExceedsLimit"); /* Allocate a MngInfo structure. */ mng_info=(MngInfo *) AcquireMagickMemory(sizeof(MngInfo)); if (mng_info == (MngInfo *) NULL) ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed"); /* Initialize members of the MngInfo structure. */ (void) ResetMagickMemory(mng_info,0,sizeof(MngInfo)); mng_info->image=image; (void) WriteBlob(image,8,(const unsigned char *) "\213JNG\r\n\032\n"); status=WriteOneJNGImage(mng_info,image_info,image); mng_info=MngInfoFreeStruct(mng_info); (void) CloseBlob(image); (void) CatchImageException(image); if (logging != MagickFalse) (void) LogMagickEvent(CoderEvent,GetMagickModule(), " exit WriteJNGImage()"); return(status); }
0
222,903
void Document::processViewport(const String& features, ViewportArguments::Type origin) { ASSERT(!features.isNull()); if (origin < m_viewportArguments.type) return; m_viewportArguments = ViewportArguments(origin); processArguments(features, (void*)&m_viewportArguments, &setViewportFeature); updateViewportArguments(); }
0
496,521
moreLeft(T D) : T(D) {}
0
458,487
flow_compose_l7(struct dp_packet *p, const void *l7, size_t l7_len) { if (l7_len) { if (l7) { dp_packet_put(p, l7, l7_len); } else { uint8_t *payload = dp_packet_put_uninit(p, l7_len); for (size_t i = 0; i < l7_len; i++) { payload[i] = i; } } } }
0
383,324
ecdsa_qbits_from_Q (unsigned int qbits) { if ((qbits%8) > 3) { log_error (_("ECDSA public key is expected to be in SEC encoding " "multiple of 8 bits\n")); return 0; } qbits -= qbits%8; qbits /= 2; return qbits; }
0
400,964
static int audit_null_notify(MYSQL_THD thd, mysql_event_class_t event_class, const void *event) { char buffer[2000]= { 0, }; int buffer_data= 0; unsigned long event_subclass= (unsigned long)*(int *)event; const char *order_str= (const char *)THDVAR(thd, event_order_check); int event_order_started= (int)THDVAR(thd, event_order_started); int exact_check= (int)THDVAR(thd, event_order_check_exact); LEX_CSTRING event_name= event_to_str(event_class, event_subclass); LEX_CSTRING event_token= get_token(&order_str); LEX_CSTRING event_data= get_token(&order_str); LEX_CSTRING event_command= get_token(&order_str); my_bool consume_event= TRUE; /* prone to races, oh well */ number_of_calls++; if (event_class == MYSQL_AUDIT_GENERAL_CLASS) { const struct mysql_event_general *event_general= (const struct mysql_event_general *)event; switch (event_general->event_subclass) { case MYSQL_AUDIT_GENERAL_LOG: number_of_calls_general_log++; break; case MYSQL_AUDIT_GENERAL_ERROR: number_of_calls_general_error++; break; case MYSQL_AUDIT_GENERAL_RESULT: number_of_calls_general_result++; break; case MYSQL_AUDIT_GENERAL_STATUS: number_of_calls_general_status++; break; default: break; } } else if (event_class == MYSQL_AUDIT_CONNECTION_CLASS) { const struct mysql_event_connection *event_connection= (const struct mysql_event_connection *) event; switch (event_connection->event_subclass) { case MYSQL_AUDIT_CONNECTION_CONNECT: number_of_calls_connection_connect++; break; case MYSQL_AUDIT_CONNECTION_DISCONNECT: number_of_calls_connection_disconnect++; break; case MYSQL_AUDIT_CONNECTION_CHANGE_USER: number_of_calls_connection_change_user++; break; case MYSQL_AUDIT_CONNECTION_PRE_AUTHENTICATE: number_of_calls_connection_pre_authenticate++; break; default: break; } } else if (event_class == MYSQL_AUDIT_PARSE_CLASS) { const struct mysql_event_parse *event_parse = (const struct mysql_event_parse *)event; switch (event_parse->event_subclass) { case MYSQL_AUDIT_PARSE_PREPARSE: number_of_calls_parse_preparse++; break; case MYSQL_AUDIT_PARSE_POSTPARSE: number_of_calls_parse_postparse++; break; default: break; } } /** Currently events not active. else if (event_class == MYSQL_AUDIT_AUTHORIZATION_CLASS) { const struct mysql_event_authorization *event_grant = (const struct mysql_event_authorization *)event; buffer_data= sprintf(buffer, "db=\"%s\" table=\"%s\" object=\"%s\" " "requested=\"0x%08x\" granted=\"0x%08x\"", event_grant->database.str ? event_grant->database.str : "<NULL>", event_grant->table.str ? event_grant->table.str : "<NULL>", event_grant->object.str ? event_grant->object.str : "<NULL>", event_grant->requested_privilege, event_grant->granted_privilege); switch (event_grant->event_subclass) { case MYSQL_AUDIT_AUTHORIZATION_USER: number_of_calls_authorization_user++; break; case MYSQL_AUDIT_AUTHORIZATION_DB: number_of_calls_authorization_db++; break; case MYSQL_AUDIT_AUTHORIZATION_TABLE: number_of_calls_authorization_table++; break; case MYSQL_AUDIT_AUTHORIZATION_COLUMN: number_of_calls_authorization_column++; break; case MYSQL_AUDIT_AUTHORIZATION_PROCEDURE: number_of_calls_authorization_procedure++; break; case MYSQL_AUDIT_AUTHORIZATION_PROXY: number_of_calls_authorization_proxy++; break; default: break; } } */ else if (event_class == MYSQL_AUDIT_SERVER_STARTUP_CLASS) { /* const struct mysql_event_server_startup *event_startup= (const struct mysql_event_server_startup *) event; */ number_of_calls_server_startup++; } else if (event_class == MYSQL_AUDIT_SERVER_SHUTDOWN_CLASS) { /* const struct mysql_event_server_shutdown *event_startup= (const struct mysql_event_server_shutdown *) event; */ number_of_calls_server_shutdown++; } else if (event_class == MYSQL_AUDIT_COMMAND_CLASS) { const struct mysql_event_command *event_command= (const struct mysql_event_command *)event; buffer_data= sprintf(buffer, "command_id=\"%d\"", event_command->command_id); switch (event_command->event_subclass) { case MYSQL_AUDIT_COMMAND_START: number_of_calls_command_start++; break; case MYSQL_AUDIT_COMMAND_END: number_of_calls_command_end++; break; default: break; } } else if (event_class == MYSQL_AUDIT_QUERY_CLASS) { const struct mysql_event_query *event_query= (const struct mysql_event_query *)event; buffer_data= sprintf(buffer, "sql_command_id=\"%d\"", (int) event_query->sql_command_id); switch (event_query->event_subclass) { case MYSQL_AUDIT_QUERY_START: number_of_calls_query_start++; break; case MYSQL_AUDIT_QUERY_NESTED_START: number_of_calls_query_nested_start++; break; case MYSQL_AUDIT_QUERY_STATUS_END: number_of_calls_query_status_end++; break; case MYSQL_AUDIT_QUERY_NESTED_STATUS_END: number_of_calls_query_nested_status_end++; break; default: break; } } else if (event_class == MYSQL_AUDIT_TABLE_ACCESS_CLASS) { const struct mysql_event_table_access *event_table= (const struct mysql_event_table_access *)event; buffer_data= sprintf(buffer, "db=\"%s\" table=\"%s\"", event_table->table_database.str, event_table->table_name.str); switch (event_table->event_subclass) { case MYSQL_AUDIT_TABLE_ACCESS_INSERT: number_of_calls_table_access_insert++; break; case MYSQL_AUDIT_TABLE_ACCESS_DELETE: number_of_calls_table_access_delete++; break; case MYSQL_AUDIT_TABLE_ACCESS_UPDATE: number_of_calls_table_access_update++; break; case MYSQL_AUDIT_TABLE_ACCESS_READ: number_of_calls_table_access_read++; break; default: break; } } else if (event_class == MYSQL_AUDIT_GLOBAL_VARIABLE_CLASS) { const struct mysql_event_global_variable *event_gvar = (const struct mysql_event_global_variable *)event; /* Copy the variable content into the buffer. We do not guarantee that the variable value will fit into buffer. The buffer should be large enough to be used for the test purposes. */ buffer_data= sprintf(buffer, "name=\"%.*s\"", MY_MIN((int) event_gvar->variable_name.length, (int) (sizeof(buffer) - 8)), event_gvar->variable_name.str); buffer_data+= sprintf(buffer + buffer_data, " value=\"%.*s\"", MY_MIN((int) event_gvar->variable_value.length, (int) (sizeof(buffer) - 16)), event_gvar->variable_value.str); buffer[buffer_data]= '\0'; switch (event_gvar->event_subclass) { case MYSQL_AUDIT_GLOBAL_VARIABLE_GET: number_of_calls_global_variable_get++; break; case MYSQL_AUDIT_GLOBAL_VARIABLE_SET: number_of_calls_global_variable_set++; break; default: break; } } process_event_record(thd, event_name, buffer, buffer_data); if (my_charset_latin1.coll->strnncoll(&my_charset_latin1, (const uchar *)event_name.str, event_name.length, (const uchar *)event_token.str, event_token.length, 0)) { /* Clear event command. */ event_command.str= NULL; event_command.length= 0; if (exact_check == 1 && event_order_started == 1) { if (!(event_class == MYSQL_AUDIT_GENERAL_CLASS && event_subclass == MYSQL_AUDIT_GENERAL_ERROR)) { strxnmov(buffer, sizeof(buffer), event_name.str, " instead of ", event_token.str, NullS); my_message(ER_AUDIT_API_ABORT, buffer, MYF(0)); } THDVAR(thd, event_order_started)= 0; THDVAR(thd, event_order_check)= 0; return 1; } } else { LEX_CSTRING ignore= { C_STRING_WITH_LEN("<IGNORE>") }; /* When we are not in the event order check, check if the specified data corresponds to the actual event data. */ if (my_charset_latin1.coll->strnncoll(&my_charset_latin1, (const uchar *)event_data.str, event_data.length, (const uchar *) ignore.str, ignore.length, 0) && my_charset_latin1.coll->strnncoll(&my_charset_latin1, (const uchar *) event_data.str, event_data.length, (const uchar *)buffer, (size_t)buffer_data, 0)) { if (exact_check == 1 && event_order_started == 1) { char invalid_data_buffer[sizeof(buffer)]= { 0, }; LEX_CSTRING status= { C_STRING_WITH_LEN("EVENT-ORDER-INVALID-DATA") }; LEX_CSTRING order_cstr; lex_cstring_set(&order_cstr, (const char *)THDVAR(thd, event_order_check)); memmove((char *)order_cstr.str, (void *)status.str, status.length + 1); strxnmov(invalid_data_buffer, sizeof(invalid_data_buffer), "Invalid data for '", event_name.str, "' -> ", buffer, NullS); my_message(ER_AUDIT_API_ABORT, invalid_data_buffer, MYF(0)); THDVAR(thd, event_order_started)= 0; THDVAR(thd, event_order_check)= (char *)order_cstr.str; return 1; } /* Clear event command. */ event_command.str= NULL; event_command.length= 0; } else { LEX_CSTRING order_cstr; ulong consume= THDVAR(thd, event_order_check_consume_ignore_count); lex_cstring_set(&order_cstr, (const char *)THDVAR(thd, event_order_check)); THDVAR(thd, event_order_started)= 1; if (consume) { /* Do not consume event this time. Just decrease value and wait until the next event is matched. */ THDVAR(thd, event_order_check_consume_ignore_count)= consume - 1; consume_event= FALSE; } else { /* Consume matched event. */ memmove((char*)order_cstr.str, (void*)order_str, order_cstr.length - (order_str - order_cstr.str) + 1); /* Count new length. */ lex_cstring_set(&order_cstr, order_cstr.str); if (order_cstr.length == 0) { LEX_CSTRING status = { C_STRING_WITH_LEN("EVENT-ORDER-OK") }; memmove((char *)order_cstr.str, (void *)status.str, status.length + 1); /* event_order_started contains message. Do not verify it. */ THDVAR(thd, event_order_started)= 0; } } } } return process_command(thd, event_command, consume_event); }
0
485,245
safi2str (safi_t safi) { if (safi == SAFI_UNICAST) return "SAFI_UNICAST"; else if (safi == SAFI_MULTICAST) return "SAFI_MULTICAST"; else if (safi == SAFI_MPLS_VPN || safi == BGP_SAFI_VPNV4) return "SAFI_MPLS_VPN"; else return "Unknown SAFI"; }
0
107,670
//! Load image from a PANDORE-5 file \newinstance. static CImg<T> get_load_pandore(const char *const filename) { return CImg<T>().load_pandore(filename);
0
277,380
void AutomationProvider::OnChannelConnected(int pid) { is_connected_ = true; LOG(INFO) << "Testing channel connected, sending hello message"; channel_->Send(new AutomationMsg_Hello(GetProtocolVersion())); if (initial_loads_complete_) Send(new AutomationMsg_InitialLoadsComplete()); }
0
244,866
int ff_h263_decode_picture_header(MpegEncContext *s) { int format, width, height, i, ret; uint32_t startcode; align_get_bits(&s->gb); startcode= get_bits(&s->gb, 22-8); for(i= get_bits_left(&s->gb); i>24; i-=8) { startcode = ((startcode << 8) | get_bits(&s->gb, 8)) & 0x003FFFFF; if(startcode == 0x20) break; } if (startcode != 0x20) { av_log(s->avctx, AV_LOG_ERROR, "Bad picture start code\n"); return -1; } /* temporal reference */ i = get_bits(&s->gb, 8); /* picture timestamp */ if( (s->picture_number&~0xFF)+i < s->picture_number) i+= 256; s->picture_number= (s->picture_number&~0xFF) + i; /* PTYPE starts here */ if (get_bits1(&s->gb) != 1) { /* marker */ av_log(s->avctx, AV_LOG_ERROR, "Bad marker\n"); return -1; } if (get_bits1(&s->gb) != 0) { av_log(s->avctx, AV_LOG_ERROR, "Bad H263 id\n"); return -1; /* h263 id */ } skip_bits1(&s->gb); /* split screen off */ skip_bits1(&s->gb); /* camera off */ skip_bits1(&s->gb); /* freeze picture release off */ format = get_bits(&s->gb, 3); /* 0 forbidden 1 sub-QCIF 10 QCIF 7 extended PTYPE (PLUSPTYPE) */ if (format != 7 && format != 6) { s->h263_plus = 0; /* H.263v1 */ /* H.263v1 */ width = ff_h263_format[format][0]; height = ff_h263_format[format][1]; s->pict_type = AV_PICTURE_TYPE_I + get_bits1(&s->gb); s->h263_long_vectors = get_bits1(&s->gb); if (get_bits1(&s->gb) != 0) { av_log(s->avctx, AV_LOG_ERROR, "H263 SAC not supported\n"); return -1; /* SAC: off */ } s->obmc= get_bits1(&s->gb); /* Advanced prediction mode */ s->unrestricted_mv = s->h263_long_vectors || s->obmc; s->pb_frame = get_bits1(&s->gb); s->chroma_qscale= s->qscale = get_bits(&s->gb, 5); skip_bits1(&s->gb); /* Continuous Presence Multipoint mode: off */ s->width = width; s->height = height; s->avctx->sample_aspect_ratio= (AVRational){12,11}; s->avctx->framerate = (AVRational){ 30000, 1001 }; } else { int ufep; /* H.263v2 */ s->h263_plus = 1; ufep = get_bits(&s->gb, 3); /* Update Full Extended PTYPE */ /* ufep other than 0 and 1 are reserved */ if (ufep == 1) { /* OPPTYPE */ format = get_bits(&s->gb, 3); ff_dlog(s->avctx, "ufep=1, format: %d\n", format); s->custom_pcf= get_bits1(&s->gb); s->umvplus = get_bits1(&s->gb); /* Unrestricted Motion Vector */ if (get_bits1(&s->gb) != 0) { av_log(s->avctx, AV_LOG_ERROR, "Syntax-based Arithmetic Coding (SAC) not supported\n"); } s->obmc= get_bits1(&s->gb); /* Advanced prediction mode */ s->h263_aic = get_bits1(&s->gb); /* Advanced Intra Coding (AIC) */ s->loop_filter= get_bits1(&s->gb); s->unrestricted_mv = s->umvplus || s->obmc || s->loop_filter; s->h263_slice_structured= get_bits1(&s->gb); if (get_bits1(&s->gb) != 0) { av_log(s->avctx, AV_LOG_ERROR, "Reference Picture Selection not supported\n"); } if (get_bits1(&s->gb) != 0) { av_log(s->avctx, AV_LOG_ERROR, "Independent Segment Decoding not supported\n"); } s->alt_inter_vlc= get_bits1(&s->gb); s->modified_quant= get_bits1(&s->gb); if(s->modified_quant) s->chroma_qscale_table= ff_h263_chroma_qscale_table; skip_bits(&s->gb, 1); /* Prevent start code emulation */ skip_bits(&s->gb, 3); /* Reserved */ } else if (ufep != 0) { av_log(s->avctx, AV_LOG_ERROR, "Bad UFEP type (%d)\n", ufep); return -1; } /* MPPTYPE */ s->pict_type = get_bits(&s->gb, 3); switch(s->pict_type){ case 0: s->pict_type= AV_PICTURE_TYPE_I;break; case 1: s->pict_type= AV_PICTURE_TYPE_P;break; case 2: s->pict_type= AV_PICTURE_TYPE_P;s->pb_frame = 3;break; case 3: s->pict_type= AV_PICTURE_TYPE_B;break; case 7: s->pict_type= AV_PICTURE_TYPE_I;break; //ZYGO default: return -1; } skip_bits(&s->gb, 2); s->no_rounding = get_bits1(&s->gb); skip_bits(&s->gb, 4); /* Get the picture dimensions */ if (ufep) { if (format == 6) { /* Custom Picture Format (CPFMT) */ s->aspect_ratio_info = get_bits(&s->gb, 4); ff_dlog(s->avctx, "aspect: %d\n", s->aspect_ratio_info); /* aspect ratios: 0 - forbidden 1 - 1:1 2 - 12:11 (CIF 4:3) 3 - 10:11 (525-type 4:3) 4 - 16:11 (CIF 16:9) 5 - 40:33 (525-type 16:9) 6-14 - reserved */ width = (get_bits(&s->gb, 9) + 1) * 4; skip_bits1(&s->gb); height = get_bits(&s->gb, 9) * 4; ff_dlog(s->avctx, "\nH.263+ Custom picture: %dx%d\n",width,height); if (s->aspect_ratio_info == FF_ASPECT_EXTENDED) { /* aspected dimensions */ s->avctx->sample_aspect_ratio.num= get_bits(&s->gb, 8); s->avctx->sample_aspect_ratio.den= get_bits(&s->gb, 8); }else{ s->avctx->sample_aspect_ratio= ff_h263_pixel_aspect[s->aspect_ratio_info]; } } else { width = ff_h263_format[format][0]; height = ff_h263_format[format][1]; s->avctx->sample_aspect_ratio= (AVRational){12,11}; } if ((width == 0) || (height == 0)) return -1; s->width = width; s->height = height; if(s->custom_pcf){ int gcd; s->avctx->framerate.num = 1800000; s->avctx->framerate.den = 1000 + get_bits1(&s->gb); s->avctx->framerate.den *= get_bits(&s->gb, 7); if(s->avctx->framerate.den == 0){ av_log(s, AV_LOG_ERROR, "zero framerate\n"); return -1; } gcd= av_gcd(s->avctx->framerate.den, s->avctx->framerate.num); s->avctx->framerate.den /= gcd; s->avctx->framerate.num /= gcd; }else{ s->avctx->framerate = (AVRational){ 30000, 1001 }; } } if(s->custom_pcf){ skip_bits(&s->gb, 2); //extended Temporal reference } if (ufep) { if (s->umvplus) { if(get_bits1(&s->gb)==0) /* Unlimited Unrestricted Motion Vectors Indicator (UUI) */ skip_bits1(&s->gb); } if(s->h263_slice_structured){ if (get_bits1(&s->gb) != 0) { av_log(s->avctx, AV_LOG_ERROR, "rectangular slices not supported\n"); } if (get_bits1(&s->gb) != 0) { av_log(s->avctx, AV_LOG_ERROR, "unordered slices not supported\n"); } } } s->qscale = get_bits(&s->gb, 5); } if ((ret = av_image_check_size(s->width, s->height, 0, s)) < 0) return ret; s->mb_width = (s->width + 15) / 16; s->mb_height = (s->height + 15) / 16; s->mb_num = s->mb_width * s->mb_height; skip_bits(&s->gb, 3); /* Temporal reference for B-pictures */ if (s->custom_pcf) skip_bits(&s->gb, 2); //extended Temporal reference skip_bits(&s->gb, 2); /* Quantization information for B-pictures */ }
0
239,768
free_realm_contexts(krb5_context context, pkinit_kdc_context *realm_contexts) { int i; if (realm_contexts == NULL) return; for (i = 0; realm_contexts[i] != NULL; i++) pkinit_server_plugin_fini_realm(context, realm_contexts[i]); pkiDebug("%s: freeing context at %p\n", __FUNCTION__, realm_contexts); free(realm_contexts); }
0
354,270
static int sqlite_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len, pdo_stmt_t *stmt, zval *driver_options TSRMLS_DC) { pdo_sqlite_db_handle *H = (pdo_sqlite_db_handle *)dbh->driver_data; pdo_sqlite_stmt *S = ecalloc(1, sizeof(pdo_sqlite_stmt)); int i; const char *tail; S->H = H; stmt->driver_data = S; stmt->methods = &sqlite_stmt_methods; stmt->supports_placeholders = PDO_PLACEHOLDER_POSITIONAL|PDO_PLACEHOLDER_NAMED; if (PDO_CURSOR_FWDONLY != pdo_attr_lval(driver_options, PDO_ATTR_CURSOR, PDO_CURSOR_FWDONLY TSRMLS_CC)) { H->einfo.errcode = SQLITE_ERROR; pdo_sqlite_error(dbh); return 0; } i = sqlite3_prepare(H->db, sql, sql_len, &S->stmt, &tail); if (i == SQLITE_OK) { return 1; } pdo_sqlite_error(dbh); return 0; }
0
164,729
XML_SetParamEntityParsing(XML_Parser parser, enum XML_ParamEntityParsing peParsing) { if (parser == NULL) return 0; /* block after XML_Parse()/XML_ParseBuffer() has been called */ if (parser->m_parsingStatus.parsing == XML_PARSING || parser->m_parsingStatus.parsing == XML_SUSPENDED) return 0; #ifdef XML_DTD parser->m_paramEntityParsing = peParsing; return 1; #else return peParsing == XML_PARAM_ENTITY_PARSING_NEVER; #endif }
0
246,572
static void _php_curl_close(zend_resource *rsrc) { php_curl *ch = (php_curl *) rsrc->ptr; _php_curl_close_ex(ch); }
0
346,394
static size_t php_bz2iop_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC) { struct php_bz2_stream_data_t *self = (struct php_bz2_stream_data_t *) stream->abstract; return BZ2_bzwrite(self->bz_file, (char*)buf, count); }
1
11,661
void NaClProcessHost::OnProcessLaunched() { FilePath irt_path; const char* irt_path_var = getenv("NACL_IRT_LIBRARY"); if (irt_path_var != NULL) { FilePath::StringType string(irt_path_var, irt_path_var + strlen(irt_path_var)); irt_path = FilePath(string); } else { FilePath plugin_dir; if (!PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &plugin_dir)) { LOG(ERROR) << "Failed to locate the plugins directory"; delete this; return; } irt_path = plugin_dir.Append(GetIrtLibraryFilename()); } base::FileUtilProxy::CreateOrOpenCallback* callback = callback_factory_.NewCallback(&NaClProcessHost::OpenIrtFileDone); if (!base::FileUtilProxy::CreateOrOpen( BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), irt_path, base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ, callback)) { delete callback; delete this; } }
1
187,912
String8::String8(const char32_t* o, size_t len) : mString(allocFromUTF32(o, len)) { }
0
315,678
void GLES2Implementation::BindBufferRangeHelper(GLenum target, GLuint index, GLuint buffer_id, GLintptr offset, GLsizeiptr size) { if (UpdateIndexedBufferState(target, index, buffer_id, "glBindBufferRange")) { GetIdHandler(SharedIdNamespaces::kBuffers) ->MarkAsUsedForBind(this, target, index, buffer_id, offset, size, &GLES2Implementation::BindBufferRangeStub); } }
0
45,156
best_effort_strncat_from_utf16le(struct archive_string *as, const void *_p, size_t bytes, struct archive_string_conv *sc) { return (best_effort_strncat_from_utf16(as, _p, bytes, sc, 0)); }
0
116,784
static void derive_crypt_complete(struct crypto_async_request *req, int rc) { struct fscrypt_completion_result *ecr = req->data; if (rc == -EINPROGRESS) return; ecr->res = rc; complete(&ecr->completion); }
0
289,262
long jas_stream_length ( jas_stream_t * stream ) { long oldpos ; long pos ; if ( ( oldpos = jas_stream_tell ( stream ) ) < 0 ) { return - 1 ; } if ( jas_stream_seek ( stream , 0 , SEEK_END ) < 0 ) { return - 1 ; } if ( ( pos = jas_stream_tell ( stream ) ) < 0 ) { return - 1 ; } if ( jas_stream_seek ( stream , oldpos , SEEK_SET ) < 0 ) { return - 1 ; } return pos ; }
0
54,373
QPDF::getWarnings() { std::vector<QPDFExc> result = this->m->warnings; this->m->warnings.clear(); return result; }
0
340,558
static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) { MOVContext *mov = s->priv_data; MOVStreamContext *sc; AVIndexEntry *sample; AVStream *st = NULL; int ret; mov->fc = s; retry: sample = mov_find_next_sample(s, &st); if (!sample) { mov->found_mdat = 0; if (!mov->next_root_atom) return AVERROR_EOF; avio_seek(s->pb, mov->next_root_atom, SEEK_SET); mov->next_root_atom = 0; if (mov_read_default(mov, s->pb, (MOVAtom){ AV_RL32("root"), INT64_MAX }) < 0 || url_feof(s->pb)) return AVERROR_EOF; av_dlog(s, "read fragments, offset 0x%"PRIx64"\n", avio_tell(s->pb)); goto retry; sc = st->priv_data; /* must be done just before reading, to avoid infinite loop on sample */ sc->current_sample++; if (st->discard != AVDISCARD_ALL) { if (avio_seek(sc->pb, sample->pos, SEEK_SET) != sample->pos) { av_log(mov->fc, AV_LOG_ERROR, "stream %d, offset 0x%"PRIx64": partial file\n", sc->ffindex, sample->pos); return AVERROR_INVALIDDATA; ret = av_get_packet(sc->pb, pkt, sample->size); if (ret < 0) return ret; if (sc->has_palette) { uint8_t *pal; pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, AVPALETTE_SIZE); if (!pal) { av_log(mov->fc, AV_LOG_ERROR, "Cannot append palette to packet\n"); } else { memcpy(pal, sc->palette, AVPALETTE_SIZE); sc->has_palette = 0; #if CONFIG_DV_DEMUXER if (mov->dv_demux && sc->dv_audio_container) { avpriv_dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size, pkt->pos); av_free(pkt->data); pkt->size = 0; ret = avpriv_dv_get_packet(mov->dv_demux, pkt); if (ret < 0) return ret; #endif pkt->stream_index = sc->ffindex; pkt->dts = sample->timestamp; if (sc->ctts_data && sc->ctts_index < sc->ctts_count) { pkt->pts = pkt->dts + sc->dts_shift + sc->ctts_data[sc->ctts_index].duration; /* update ctts context */ sc->ctts_sample++; if (sc->ctts_index < sc->ctts_count && sc->ctts_data[sc->ctts_index].count == sc->ctts_sample) { sc->ctts_index++; sc->ctts_sample = 0; if (sc->wrong_dts) pkt->dts = AV_NOPTS_VALUE; } else { int64_t next_dts = (sc->current_sample < st->nb_index_entries) ? st->index_entries[sc->current_sample].timestamp : st->duration; pkt->duration = next_dts - pkt->dts; pkt->pts = pkt->dts; if (st->discard == AVDISCARD_ALL) goto retry; pkt->flags |= sample->flags & AVINDEX_KEYFRAME ? AV_PKT_FLAG_KEY : 0; pkt->pos = sample->pos; av_dlog(s, "stream %d, pts %"PRId64", dts %"PRId64", pos 0x%"PRIx64", duration %d\n", pkt->stream_index, pkt->pts, pkt->dts, pkt->pos, pkt->duration); return 0;
1
281,297
bool Extension::LoadManifestVersion(string16* error) { if (manifest_->value()->HasKey(keys::kManifestVersion)) { int manifest_version = 1; if (!manifest_->GetInteger(keys::kManifestVersion, &manifest_version) || manifest_version < 1) { *error = ASCIIToUTF16(errors::kInvalidManifestVersion); return false; } } manifest_version_ = manifest_->GetManifestVersion(); if (creation_flags_ & REQUIRE_MODERN_MANIFEST_VERSION && manifest_version_ < kModernManifestVersion && !CommandLine::ForCurrentProcess()->HasSwitch( switches::kAllowLegacyExtensionManifests)) { *error = ErrorUtils::FormatErrorMessageUTF16( errors::kInvalidManifestVersionOld, base::IntToString(kModernManifestVersion)); return false; } return true; }
0
104,983
rdpsnd_queue_init(void) { queue_pending = queue_lo = queue_hi = 0; }
0
21,447
static void balloon_page(void *addr, int deflate) { #if defined(__linux__) if (!kvm_enabled() || kvm_has_sync_mmu()) madvise(addr, TARGET_PAGE_SIZE, deflate ? MADV_WILLNEED : MADV_DONTNEED); #endif }
1
370,351
int http_wait_for_request(struct session *s, struct buffer *req, int an_bit) { /* * We will parse the partial (or complete) lines. * We will check the request syntax, and also join multi-line * headers. An index of all the lines will be elaborated while * parsing. * * For the parsing, we use a 28 states FSM. * * Here is the information we currently have : * req->data + msg->som = beginning of request * req->data + msg->eoh = end of processed headers / start of current one * msg->eol = end of current header or line (LF or CRLF) * req->lr = first non-visited byte * req->r = end of data * * At end of parsing, we may perform a capture of the error (if any), and * we will set a few fields (msg->sol, txn->meth, sn->flags/SN_REDIRECTABLE). * We also check for monitor-uri, logging, HTTP/0.9 to 1.0 conversion, and * finally headers capture. */ int cur_idx; int use_close_only; struct http_txn *txn = &s->txn; struct http_msg *msg = &txn->req; struct hdr_ctx ctx; DPRINTF(stderr,"[%u] %s: session=%p b=%p, exp(r,w)=%u,%u bf=%08x bl=%d analysers=%02x\n", now_ms, __FUNCTION__, s, req, req->rex, req->wex, req->flags, req->l, req->analysers); /* we're speaking HTTP here, so let's speak HTTP to the client */ s->srv_error = http_return_srv_error; /* There's a protected area at the end of the buffer for rewriting * purposes. We don't want to start to parse the request if the * protected area is affected, because we may have to move processed * data later, which is much more complicated. */ if (req->l && msg->msg_state < HTTP_MSG_ERROR) { if ((txn->flags & TX_NOT_FIRST) && unlikely((req->flags & BF_FULL) || req->r < req->lr || req->r > req->data + req->size - global.tune.maxrewrite)) { if (req->send_max) { if (req->flags & (BF_SHUTW|BF_SHUTW_NOW|BF_WRITE_ERROR|BF_WRITE_TIMEOUT)) goto failed_keep_alive; /* some data has still not left the buffer, wake us once that's done */ buffer_dont_connect(req); req->flags |= BF_READ_DONTWAIT; /* try to get back here ASAP */ return 0; } if (req->l <= req->size - global.tune.maxrewrite) http_buffer_heavy_realign(req, msg); } /* Note that we have the same problem with the response ; we * may want to send a redirect, error or anything which requires * some spare space. So we'll ensure that we have at least * maxrewrite bytes available in the response buffer before * processing that one. This will only affect pipelined * keep-alive requests. */ if ((txn->flags & TX_NOT_FIRST) && unlikely((s->rep->flags & BF_FULL) || s->rep->r < s->rep->lr || s->rep->r > s->rep->data + s->rep->size - global.tune.maxrewrite)) { if (s->rep->send_max) { if (s->rep->flags & (BF_SHUTW|BF_SHUTW_NOW|BF_WRITE_ERROR|BF_WRITE_TIMEOUT)) goto failed_keep_alive; /* don't let a connection request be initiated */ buffer_dont_connect(req); s->rep->flags &= ~BF_EXPECT_MORE; /* speed up sending a previous response */ return 0; } } if (likely(req->lr < req->r)) http_msg_analyzer(req, msg, &txn->hdr_idx); } /* 1: we might have to print this header in debug mode */ if (unlikely((global.mode & MODE_DEBUG) && (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE)) && msg->sol && (msg->msg_state >= HTTP_MSG_BODY || msg->msg_state == HTTP_MSG_ERROR))) { char *eol, *sol; sol = req->data + msg->som; eol = sol + msg->sl.rq.l; debug_hdr("clireq", s, sol, eol); sol += hdr_idx_first_pos(&txn->hdr_idx); cur_idx = hdr_idx_first_idx(&txn->hdr_idx); while (cur_idx) { eol = sol + txn->hdr_idx.v[cur_idx].len; debug_hdr("clihdr", s, sol, eol); sol = eol + txn->hdr_idx.v[cur_idx].cr + 1; cur_idx = txn->hdr_idx.v[cur_idx].next; } } /* * Now we quickly check if we have found a full valid request. * If not so, we check the FD and buffer states before leaving. * A full request is indicated by the fact that we have seen * the double LF/CRLF, so the state is >= HTTP_MSG_BODY. Invalid * requests are checked first. When waiting for a second request * on a keep-alive session, if we encounter and error, close, t/o, * we note the error in the session flags but don't set any state. * Since the error will be noted there, it will not be counted by * process_session() as a frontend error. */ if (unlikely(msg->msg_state < HTTP_MSG_BODY)) { /* * First, let's catch bad requests. */ if (unlikely(msg->msg_state == HTTP_MSG_ERROR)) { proxy_inc_fe_req_ctr(s->fe); goto return_bad_req; } /* 1: Since we are in header mode, if there's no space * left for headers, we won't be able to free more * later, so the session will never terminate. We * must terminate it now. */ if (unlikely(req->flags & BF_FULL)) { /* FIXME: check if URI is set and return Status * 414 Request URI too long instead. */ proxy_inc_fe_req_ctr(s->fe); if (msg->err_pos < 0) msg->err_pos = req->l; goto return_bad_req; } /* 2: have we encountered a read error ? */ else if (req->flags & BF_READ_ERROR) { if (!(s->flags & SN_ERR_MASK)) s->flags |= SN_ERR_CLICL; if (txn->flags & TX_WAIT_NEXT_RQ) goto failed_keep_alive; /* we cannot return any message on error */ if (msg->err_pos >= 0) http_capture_bad_message(&s->fe->invalid_req, s, req, msg, msg->msg_state, s->fe); txn->status = 400; stream_int_retnclose(req->prod, NULL); msg->msg_state = HTTP_MSG_ERROR; req->analysers = 0; proxy_inc_fe_req_ctr(s->fe); s->fe->counters.failed_req++; if (s->listener->counters) s->listener->counters->failed_req++; if (!(s->flags & SN_FINST_MASK)) s->flags |= SN_FINST_R; return 0; } /* 3: has the read timeout expired ? */ else if (req->flags & BF_READ_TIMEOUT || tick_is_expired(req->analyse_exp, now_ms)) { if (!(s->flags & SN_ERR_MASK)) s->flags |= SN_ERR_CLITO; if (txn->flags & TX_WAIT_NEXT_RQ) goto failed_keep_alive; /* read timeout : give up with an error message. */ if (msg->err_pos >= 0) http_capture_bad_message(&s->fe->invalid_req, s, req, msg, msg->msg_state, s->fe); txn->status = 408; stream_int_retnclose(req->prod, error_message(s, HTTP_ERR_408)); msg->msg_state = HTTP_MSG_ERROR; req->analysers = 0; proxy_inc_fe_req_ctr(s->fe); s->fe->counters.failed_req++; if (s->listener->counters) s->listener->counters->failed_req++; if (!(s->flags & SN_FINST_MASK)) s->flags |= SN_FINST_R; return 0; } /* 4: have we encountered a close ? */ else if (req->flags & BF_SHUTR) { if (!(s->flags & SN_ERR_MASK)) s->flags |= SN_ERR_CLICL; if (txn->flags & TX_WAIT_NEXT_RQ) goto failed_keep_alive; if (msg->err_pos >= 0) http_capture_bad_message(&s->fe->invalid_req, s, req, msg, msg->msg_state, s->fe); txn->status = 400; stream_int_retnclose(req->prod, error_message(s, HTTP_ERR_400)); msg->msg_state = HTTP_MSG_ERROR; req->analysers = 0; proxy_inc_fe_req_ctr(s->fe); s->fe->counters.failed_req++; if (s->listener->counters) s->listener->counters->failed_req++; if (!(s->flags & SN_FINST_MASK)) s->flags |= SN_FINST_R; return 0; } buffer_dont_connect(req); req->flags |= BF_READ_DONTWAIT; /* try to get back here ASAP */ s->rep->flags &= ~BF_EXPECT_MORE; /* speed up sending a previous response */ #ifdef TCP_QUICKACK if (s->listener->options & LI_O_NOQUICKACK) { /* We need more data, we have to re-enable quick-ack in case we * previously disabled it, otherwise we might cause the client * to delay next data. */ setsockopt(s->si[0].fd, IPPROTO_TCP, TCP_QUICKACK, &one, sizeof(one)); } #endif if ((msg->msg_state != HTTP_MSG_RQBEFORE) && (txn->flags & TX_WAIT_NEXT_RQ)) { /* If the client starts to talk, let's fall back to * request timeout processing. */ txn->flags &= ~TX_WAIT_NEXT_RQ; req->analyse_exp = TICK_ETERNITY; } /* just set the request timeout once at the beginning of the request */ if (!tick_isset(req->analyse_exp)) { if ((msg->msg_state == HTTP_MSG_RQBEFORE) && (txn->flags & TX_WAIT_NEXT_RQ) && tick_isset(s->be->timeout.httpka)) req->analyse_exp = tick_add(now_ms, s->be->timeout.httpka); else req->analyse_exp = tick_add_ifset(now_ms, s->be->timeout.httpreq); } /* we're not ready yet */ return 0; failed_keep_alive: /* Here we process low-level errors for keep-alive requests. In * short, if the request is not the first one and it experiences * a timeout, read error or shutdown, we just silently close so * that the client can try again. */ txn->status = 0; msg->msg_state = HTTP_MSG_RQBEFORE; req->analysers = 0; s->logs.logwait = 0; s->rep->flags &= ~BF_EXPECT_MORE; /* speed up sending a previous response */ stream_int_retnclose(req->prod, NULL); return 0; } /* OK now we have a complete HTTP request with indexed headers. Let's * complete the request parsing by setting a few fields we will need * later. At this point, we have the last CRLF at req->data + msg->eoh. * If the request is in HTTP/0.9 form, the rule is still true, and eoh * points to the CRLF of the request line. req->lr points to the first * byte after the last LF. msg->sov points to the first * byte of data. msg->eol cannot be trusted because it may have been * left uninitialized (for instance in the absence of headers). */ proxy_inc_fe_req_ctr(s->fe); /* one more valid request for this FE */ if (txn->flags & TX_WAIT_NEXT_RQ) { /* kill the pending keep-alive timeout */ txn->flags &= ~TX_WAIT_NEXT_RQ; req->analyse_exp = TICK_ETERNITY; } /* Maybe we found in invalid header name while we were configured not * to block on that, so we have to capture it now. */ if (unlikely(msg->err_pos >= 0)) http_capture_bad_message(&s->fe->invalid_req, s, req, msg, msg->msg_state, s->fe); /* * 1: identify the method */ txn->meth = find_http_meth(msg->sol, msg->sl.rq.m_l); /* we can make use of server redirect on GET and HEAD */ if (txn->meth == HTTP_METH_GET || txn->meth == HTTP_METH_HEAD) s->flags |= SN_REDIRECTABLE; /* * 2: check if the URI matches the monitor_uri. * We have to do this for every request which gets in, because * the monitor-uri is defined by the frontend. */ if (unlikely((s->fe->monitor_uri_len != 0) && (s->fe->monitor_uri_len == msg->sl.rq.u_l) && !memcmp(msg->sol + msg->sl.rq.u, s->fe->monitor_uri, s->fe->monitor_uri_len))) { /* * We have found the monitor URI */ struct acl_cond *cond; s->flags |= SN_MONITOR; /* Check if we want to fail this monitor request or not */ list_for_each_entry(cond, &s->fe->mon_fail_cond, list) { int ret = acl_exec_cond(cond, s->fe, s, txn, ACL_DIR_REQ); ret = acl_pass(ret); if (cond->pol == ACL_COND_UNLESS) ret = !ret; if (ret) { /* we fail this request, let's return 503 service unavail */ txn->status = 503; stream_int_retnclose(req->prod, error_message(s, HTTP_ERR_503)); goto return_prx_cond; } } /* nothing to fail, let's reply normaly */ txn->status = 200; stream_int_retnclose(req->prod, error_message(s, HTTP_ERR_200)); goto return_prx_cond; } /* * 3: Maybe we have to copy the original REQURI for the logs ? * Note: we cannot log anymore if the request has been * classified as invalid. */ if (unlikely(s->logs.logwait & LW_REQ)) { /* we have a complete HTTP request that we must log */ if ((txn->uri = pool_alloc2(pool2_requri)) != NULL) { int urilen = msg->sl.rq.l; if (urilen >= REQURI_LEN) urilen = REQURI_LEN - 1; memcpy(txn->uri, &req->data[msg->som], urilen); txn->uri[urilen] = 0; if (!(s->logs.logwait &= ~LW_REQ)) s->do_log(s); } else { Alert("HTTP logging : out of memory.\n"); } } /* 4. We may have to convert HTTP/0.9 requests to HTTP/1.0 */ if (unlikely(msg->sl.rq.v_l == 0) && !http_upgrade_v09_to_v10(req, msg, txn)) goto return_bad_req; /* ... and check if the request is HTTP/1.1 or above */ if ((msg->sl.rq.v_l == 8) && ((msg->sol[msg->sl.rq.v + 5] > '1') || ((msg->sol[msg->sl.rq.v + 5] == '1') && (msg->sol[msg->sl.rq.v + 7] >= '1')))) txn->flags |= TX_REQ_VER_11; /* "connection" has not been parsed yet */ txn->flags &= ~(TX_HDR_CONN_PRS | TX_HDR_CONN_CLO | TX_HDR_CONN_KAL); /* if the frontend has "option http-use-proxy-header", we'll check if * we have what looks like a proxied connection instead of a connection, * and in this case set the TX_USE_PX_CONN flag to use Proxy-connection. * Note that this is *not* RFC-compliant, however browsers and proxies * happen to do that despite being non-standard :-( * We consider that a request not beginning with either '/' or '*' is * a proxied connection, which covers both "scheme://location" and * CONNECT ip:port. */ if ((s->fe->options2 & PR_O2_USE_PXHDR) && msg->sol[msg->sl.rq.u] != '/' && msg->sol[msg->sl.rq.u] != '*') txn->flags |= TX_USE_PX_CONN; /* transfer length unknown*/ txn->flags &= ~TX_REQ_XFER_LEN; /* 5: we may need to capture headers */ if (unlikely((s->logs.logwait & LW_REQHDR) && txn->req.cap)) capture_headers(msg->sol, &txn->hdr_idx, txn->req.cap, s->fe->req_cap); /* 6: determine the transfer-length. * According to RFC2616 #4.4, amended by the HTTPbis working group, * the presence of a message-body in a REQUEST and its transfer length * must be determined that way (in order of precedence) : * 1. The presence of a message-body in a request is signaled by the * inclusion of a Content-Length or Transfer-Encoding header field * in the request's header fields. When a request message contains * both a message-body of non-zero length and a method that does * not define any semantics for that request message-body, then an * origin server SHOULD either ignore the message-body or respond * with an appropriate error message (e.g., 413). A proxy or * gateway, when presented the same request, SHOULD either forward * the request inbound with the message- body or ignore the * message-body when determining a response. * * 2. If a Transfer-Encoding header field (Section 9.7) is present * and the "chunked" transfer-coding (Section 6.2) is used, the * transfer-length is defined by the use of this transfer-coding. * If a Transfer-Encoding header field is present and the "chunked" * transfer-coding is not present, the transfer-length is defined * by the sender closing the connection. * * 3. If a Content-Length header field is present, its decimal value in * OCTETs represents both the entity-length and the transfer-length. * If a message is received with both a Transfer-Encoding header * field and a Content-Length header field, the latter MUST be ignored. * * 4. By the server closing the connection. (Closing the connection * cannot be used to indicate the end of a request body, since that * would leave no possibility for the server to send back a response.) * * Whenever a transfer-coding is applied to a message-body, the set of * transfer-codings MUST include "chunked", unless the message indicates * it is terminated by closing the connection. When the "chunked" * transfer-coding is used, it MUST be the last transfer-coding applied * to the message-body. */ use_close_only = 0; ctx.idx = 0; /* set TE_CHNK and XFER_LEN only if "chunked" is seen last */ while ((txn->flags & TX_REQ_VER_11) && http_find_header2("Transfer-Encoding", 17, msg->sol, &txn->hdr_idx, &ctx)) { if (ctx.vlen == 7 && strncasecmp(ctx.line + ctx.val, "chunked", 7) == 0) txn->flags |= (TX_REQ_TE_CHNK | TX_REQ_XFER_LEN); else if (txn->flags & TX_REQ_TE_CHNK) { /* bad transfer-encoding (chunked followed by something else) */ use_close_only = 1; txn->flags &= ~(TX_REQ_TE_CHNK | TX_REQ_XFER_LEN); break; } } ctx.idx = 0; while (!(txn->flags & TX_REQ_TE_CHNK) && !use_close_only && http_find_header2("Content-Length", 14, msg->sol, &txn->hdr_idx, &ctx)) { signed long long cl; if (!ctx.vlen) { msg->err_pos = ctx.line + ctx.val - req->data; goto return_bad_req; } if (strl2llrc(ctx.line + ctx.val, ctx.vlen, &cl)) { msg->err_pos = ctx.line + ctx.val - req->data; goto return_bad_req; /* parse failure */ } if (cl < 0) { msg->err_pos = ctx.line + ctx.val - req->data; goto return_bad_req; } if ((txn->flags & TX_REQ_CNT_LEN) && (msg->chunk_len != cl)) { msg->err_pos = ctx.line + ctx.val - req->data; goto return_bad_req; /* already specified, was different */ } txn->flags |= TX_REQ_CNT_LEN | TX_REQ_XFER_LEN; msg->body_len = msg->chunk_len = cl; } /* bodyless requests have a known length */ if (!use_close_only) txn->flags |= TX_REQ_XFER_LEN; /* end of job, return OK */ req->analysers &= ~an_bit; req->analyse_exp = TICK_ETERNITY; return 1; return_bad_req: /* We centralize bad requests processing here */ if (unlikely(msg->msg_state == HTTP_MSG_ERROR) || msg->err_pos >= 0) { /* we detected a parsing error. We want to archive this request * in the dedicated proxy area for later troubleshooting. */ http_capture_bad_message(&s->fe->invalid_req, s, req, msg, msg->msg_state, s->fe); } txn->req.msg_state = HTTP_MSG_ERROR; txn->status = 400; stream_int_retnclose(req->prod, error_message(s, HTTP_ERR_400)); s->fe->counters.failed_req++; if (s->listener->counters) s->listener->counters->failed_req++; return_prx_cond: if (!(s->flags & SN_ERR_MASK)) s->flags |= SN_ERR_PRXCOND; if (!(s->flags & SN_FINST_MASK)) s->flags |= SN_FINST_R; req->analysers = 0; req->analyse_exp = TICK_ETERNITY; return 0; }
0
353,757
static int dump_tablespaces(char* ts_where) { MYSQL_ROW row; MYSQL_RES *tableres; char buf[FN_REFLEN]; DYNAMIC_STRING sqlbuf; int first= 0; /* The following are used for parsing the EXTRA field */ char extra_format[]= "UNDO_BUFFER_SIZE="; char *ubs; char *endsemi; DBUG_ENTER("dump_tablespaces"); /* Try to turn off semi-join optimization (if that fails, this is a pre-optimizer_switch server, and the old query plan is ok for us. */ mysql_query(mysql, "set optimizer_switch='semijoin=off'"); init_dynamic_string_checked(&sqlbuf, "SELECT LOGFILE_GROUP_NAME," " FILE_NAME," " TOTAL_EXTENTS," " INITIAL_SIZE," " ENGINE," " EXTRA" " FROM INFORMATION_SCHEMA.FILES" " WHERE FILE_TYPE = 'UNDO LOG'" " AND FILE_NAME IS NOT NULL", 256, 1024); if(ts_where) { dynstr_append_checked(&sqlbuf, " AND LOGFILE_GROUP_NAME IN (" "SELECT DISTINCT LOGFILE_GROUP_NAME" " FROM INFORMATION_SCHEMA.FILES" " WHERE FILE_TYPE = 'DATAFILE'" ); dynstr_append_checked(&sqlbuf, ts_where); dynstr_append_checked(&sqlbuf, ")"); } dynstr_append_checked(&sqlbuf, " GROUP BY LOGFILE_GROUP_NAME, FILE_NAME" ", ENGINE" " ORDER BY LOGFILE_GROUP_NAME"); if (mysql_query(mysql, sqlbuf.str) || !(tableres = mysql_store_result(mysql))) { dynstr_free(&sqlbuf); if (mysql_errno(mysql) == ER_BAD_TABLE_ERROR || mysql_errno(mysql) == ER_BAD_DB_ERROR || mysql_errno(mysql) == ER_UNKNOWN_TABLE) { fprintf(md_result_file, "\n--\n-- Not dumping tablespaces as no INFORMATION_SCHEMA.FILES" " table on this server\n--\n"); check_io(md_result_file); DBUG_RETURN(0); } fprintf(stderr, "%s: Error: '%s' when trying to dump tablespaces\n", my_progname_short, mysql_error(mysql)); DBUG_RETURN(1); } buf[0]= 0; while ((row= mysql_fetch_row(tableres))) { if (strcmp(buf, row[0]) != 0) first= 1; if (first) { print_comment(md_result_file, 0, "\n--\n-- Logfile group: %s\n--\n", row[0]); fprintf(md_result_file, "\nCREATE"); } else { fprintf(md_result_file, "\nALTER"); } fprintf(md_result_file, " LOGFILE GROUP %s\n" " ADD UNDOFILE '%s'\n", row[0], row[1]); if (first) { ubs= strstr(row[5],extra_format); if(!ubs) break; ubs+= strlen(extra_format); endsemi= strstr(ubs,";"); if(endsemi) endsemi[0]= '\0'; fprintf(md_result_file, " UNDO_BUFFER_SIZE %s\n", ubs); } fprintf(md_result_file, " INITIAL_SIZE %s\n" " ENGINE=%s;\n", row[3], row[4]); check_io(md_result_file); if (first) { first= 0; strxmov(buf, row[0], NullS); } } dynstr_free(&sqlbuf); mysql_free_result(tableres); init_dynamic_string_checked(&sqlbuf, "SELECT DISTINCT TABLESPACE_NAME," " FILE_NAME," " LOGFILE_GROUP_NAME," " EXTENT_SIZE," " INITIAL_SIZE," " ENGINE" " FROM INFORMATION_SCHEMA.FILES" " WHERE FILE_TYPE = 'DATAFILE'", 256, 1024); if(ts_where) dynstr_append_checked(&sqlbuf, ts_where); dynstr_append_checked(&sqlbuf, " ORDER BY TABLESPACE_NAME, LOGFILE_GROUP_NAME"); if (mysql_query_with_error_report(mysql, &tableres, sqlbuf.str)) { dynstr_free(&sqlbuf); DBUG_RETURN(1); } buf[0]= 0; while ((row= mysql_fetch_row(tableres))) { if (strcmp(buf, row[0]) != 0) first= 1; if (first) { print_comment(md_result_file, 0, "\n--\n-- Tablespace: %s\n--\n", row[0]); fprintf(md_result_file, "\nCREATE"); } else { fprintf(md_result_file, "\nALTER"); } fprintf(md_result_file, " TABLESPACE %s\n" " ADD DATAFILE '%s'\n", row[0], row[1]); if (first) { fprintf(md_result_file, " USE LOGFILE GROUP %s\n" " EXTENT_SIZE %s\n", row[2], row[3]); } fprintf(md_result_file, " INITIAL_SIZE %s\n" " ENGINE=%s;\n", row[4], row[5]); check_io(md_result_file); if (first) { first= 0; strxmov(buf, row[0], NullS); } } mysql_free_result(tableres); dynstr_free(&sqlbuf); mysql_query(mysql, "set optimizer_switch=default"); DBUG_RETURN(0); }
1
57,333
int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, __u64 start, __u64 len) { ext4_lblk_t start_blk; int error = 0; /* fallback to generic here if not in extents fmt */ if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) return generic_block_fiemap(inode, fieinfo, start, len, ext4_get_block); if (fiemap_check_flags(fieinfo, EXT4_FIEMAP_FLAGS)) return -EBADR; if (fieinfo->fi_flags & FIEMAP_FLAG_XATTR) { error = ext4_xattr_fiemap(inode, fieinfo); } else { ext4_lblk_t len_blks; __u64 last_blk; start_blk = start >> inode->i_sb->s_blocksize_bits; last_blk = (start + len - 1) >> inode->i_sb->s_blocksize_bits; if (last_blk >= EXT_MAX_BLOCK) last_blk = EXT_MAX_BLOCK-1; len_blks = ((ext4_lblk_t) last_blk) - start_blk + 1; /* * Walk the extent tree gathering extent information. * ext4_ext_fiemap_cb will push extents back to user. */ error = ext4_ext_walk_space(inode, start_blk, len_blks, ext4_ext_fiemap_cb, fieinfo); } return error; }
0
236,749
void RenderWidgetHostViewAura::OnInputMethodChanged() { if (!host_) return; if (GetInputMethod()) host_->SetInputMethodActive(GetInputMethod()->IsActive()); }
0
334,847
static void mv88w8618_audio_write(void *opaque, target_phys_addr_t offset, uint64_t value, unsigned size) { mv88w8618_audio_state *s = opaque; switch (offset) { case MP_AUDIO_PLAYBACK_MODE: if (value & MP_AUDIO_PLAYBACK_EN && !(s->playback_mode & MP_AUDIO_PLAYBACK_EN)) { s->status = 0; s->last_free = 0; s->play_pos = 0; } s->playback_mode = value; mv88w8618_audio_clock_update(s); break; case MP_AUDIO_CLOCK_DIV: s->clock_div = value; s->last_free = 0; s->play_pos = 0; mv88w8618_audio_clock_update(s); break; case MP_AUDIO_IRQ_STATUS: s->status &= ~value; break; case MP_AUDIO_IRQ_ENABLE: s->irq_enable = value; if (s->status & s->irq_enable) { qemu_irq_raise(s->irq); } break; case MP_AUDIO_TX_START_LO: s->phys_buf = (s->phys_buf & 0xFFFF0000) | (value & 0xFFFF); s->target_buffer = s->phys_buf; s->play_pos = 0; s->last_free = 0; break; case MP_AUDIO_TX_THRESHOLD: s->threshold = (value + 1) * 4; break; case MP_AUDIO_TX_START_HI: s->phys_buf = (s->phys_buf & 0xFFFF) | (value << 16); s->target_buffer = s->phys_buf; s->play_pos = 0; s->last_free = 0; break; } }
0
512,909
CairoImageOutputDev::~CairoImageOutputDev() { int i; for (i = 0; i < numImages; i++) delete images[i]; gfree (images); }
0
324,146
static inline int svq3_decode_block(GetBitContext *gb, DCTELEM *block, int index, const int type) { static const uint8_t *const scan_patterns[4] = { luma_dc_zigzag_scan, zigzag_scan, svq3_scan, chroma_dc_scan }; int run, level, sign, vlc, limit; const int intra = (3 * type) >> 2; const uint8_t *const scan = scan_patterns[type]; for (limit = (16 >> intra); index < 16; index = limit, limit += 8) { for (; (vlc = svq3_get_ue_golomb(gb)) != 0; index++) { if (vlc == INVALID_VLC) return -1; sign = (vlc & 0x1) - 1; vlc = (vlc + 1) >> 1; if (type == 3) { if (vlc < 3) { run = 0; level = vlc; } else if (vlc < 4) { run = 1; level = 1; } else { run = (vlc & 0x3); level = ((vlc + 9) >> 2) - run; } } else { if (vlc < 16) { run = svq3_dct_tables[intra][vlc].run; level = svq3_dct_tables[intra][vlc].level; } else if (intra) { run = (vlc & 0x7); level = (vlc >> 3) + ((run == 0) ? 8 : ((run < 2) ? 2 : ((run < 5) ? 0 : -1))); } else { run = (vlc & 0xF); level = (vlc >> 4) + ((run == 0) ? 4 : ((run < 3) ? 2 : ((run < 10) ? 1 : 0))); } } if ((index += run) >= limit) return -1; block[scan[index]] = (level ^ sign) - sign; } if (type != 2) { break; } } return 0; }
0
235,931
bool GetTabFunction::RunImpl() { int tab_id; EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &tab_id)); TabStripModel* tab_strip = NULL; TabContents* contents = NULL; int tab_index = -1; if (!GetTabById(tab_id, profile(), include_incognito(), NULL, &tab_strip, &contents, &tab_index, &error_)) return false; result_.reset(ExtensionTabUtil::CreateTabValue(contents, tab_strip, tab_index)); return true; }
0
280,550
ExportTIFF_Date ( const SXMPMeta & xmp, const char * xmpNS, const char * xmpProp, TIFF_Manager * tiff, XMP_Uns16 mainID ) { XMP_Uns8 mainIFD = kTIFF_ExifIFD; XMP_Uns16 fracID=0; switch ( mainID ) { case kTIFF_DateTime : mainIFD = kTIFF_PrimaryIFD; fracID = kTIFF_SubSecTime; break; case kTIFF_DateTimeOriginal : fracID = kTIFF_SubSecTimeOriginal; break; case kTIFF_DateTimeDigitized : fracID = kTIFF_SubSecTimeDigitized; break; } try { // Don't let errors with one stop the others. std::string xmpStr; bool foundXMP = xmp.GetProperty ( xmpNS, xmpProp, &xmpStr, 0 ); if ( ! foundXMP ) { tiff->DeleteTag ( mainIFD, mainID ); tiff->DeleteTag ( kTIFF_ExifIFD, fracID ); // ! The subseconds are always in the Exif IFD. return; } XMP_DateTime xmpBin; SXMPUtils::ConvertToDate ( xmpStr.c_str(), &xmpBin ); char buffer[24]; snprintf ( buffer, sizeof(buffer), "%04d:%02d:%02d %02d:%02d:%02d", // AUDIT: Use of sizeof(buffer) is safe. xmpBin.year, xmpBin.month, xmpBin.day, xmpBin.hour, xmpBin.minute, xmpBin.second ); size_t xmpLen = xmpStr.size(); if ( xmpLen < 18 ) { buffer[17] = buffer[18] = ' '; if ( xmpLen < 15 ) { buffer[14] = buffer[15] = ' '; if ( xmpLen < 12 ) { buffer[11] = buffer[12] = ' '; if ( xmpLen < 9 ) { buffer[8] = buffer[9] = ' '; if ( xmpLen < 6 ) { buffer[5] = buffer[6] = ' '; if ( xmpLen < 1 ) { buffer[0] = buffer[1] = buffer[2] = buffer[3] = ' '; } } } } } } tiff->SetTag_ASCII ( mainIFD, mainID, buffer ); if ( xmpBin.nanoSecond == 0 ) { tiff->DeleteTag ( kTIFF_ExifIFD, fracID ); } else { snprintf ( buffer, sizeof(buffer), "%09d", xmpBin.nanoSecond ); // AUDIT: Use of sizeof(buffer) is safe. for ( size_t i = strlen(buffer)-1; i > 0; --i ) { if ( buffer[i] != '0' ) break; buffer[i] = 0; // Strip trailing zero digits. } tiff->SetTag_ASCII ( kTIFF_ExifIFD, fracID, buffer ); // ! The subseconds are always in the Exif IFD. } } catch ( ... ) { } } // ExportTIFF_Date
0
301,961
check_entry(const struct ip6t_entry *e) { const struct xt_entry_target *t; if (!ip6_checkentry(&e->ipv6)) return -EINVAL; if (e->target_offset + sizeof(struct xt_entry_target) > e->next_offset) return -EINVAL; t = ip6t_get_target_c(e); if (e->target_offset + t->u.target_size > e->next_offset) return -EINVAL; return 0; }
0
518,341
longlong Item_cache_temporal::val_time_packed() { DBUG_ASSERT(fixed == 1); if (Item_cache_temporal::field_type() != MYSQL_TYPE_TIME) return Item::val_time_packed(); // DATETIME-to-TIME conversion needed if ((!value_cached && !cache_value()) || null_value) { null_value= TRUE; return 0; } return value; }
0
296,156
AP_DECLARE(const char*) ap_get_server_protocol(server_rec* s) { core_server_config *conf = ap_get_core_module_config(s->module_config); return conf->protocol; }
0
439,535
skb_flow_dissect_tunnel_info(const struct sk_buff *skb, struct flow_dissector *flow_dissector, void *target_container) { struct ip_tunnel_info *info; struct ip_tunnel_key *key; /* A quick check to see if there might be something to do. */ if (!dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_ENC_KEYID) && !dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_ENC_IPV4_ADDRS) && !dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_ENC_IPV6_ADDRS) && !dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_ENC_CONTROL) && !dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_ENC_PORTS) && !dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_ENC_IP) && !dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_ENC_OPTS)) return; info = skb_tunnel_info(skb); if (!info) return; key = &info->key; switch (ip_tunnel_info_af(info)) { case AF_INET: skb_flow_dissect_set_enc_addr_type(FLOW_DISSECTOR_KEY_IPV4_ADDRS, flow_dissector, target_container); if (dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_ENC_IPV4_ADDRS)) { struct flow_dissector_key_ipv4_addrs *ipv4; ipv4 = skb_flow_dissector_target(flow_dissector, FLOW_DISSECTOR_KEY_ENC_IPV4_ADDRS, target_container); ipv4->src = key->u.ipv4.src; ipv4->dst = key->u.ipv4.dst; } break; case AF_INET6: skb_flow_dissect_set_enc_addr_type(FLOW_DISSECTOR_KEY_IPV6_ADDRS, flow_dissector, target_container); if (dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_ENC_IPV6_ADDRS)) { struct flow_dissector_key_ipv6_addrs *ipv6; ipv6 = skb_flow_dissector_target(flow_dissector, FLOW_DISSECTOR_KEY_ENC_IPV6_ADDRS, target_container); ipv6->src = key->u.ipv6.src; ipv6->dst = key->u.ipv6.dst; } break; } if (dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_ENC_KEYID)) { struct flow_dissector_key_keyid *keyid; keyid = skb_flow_dissector_target(flow_dissector, FLOW_DISSECTOR_KEY_ENC_KEYID, target_container); keyid->keyid = tunnel_id_to_key32(key->tun_id); } if (dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_ENC_PORTS)) { struct flow_dissector_key_ports *tp; tp = skb_flow_dissector_target(flow_dissector, FLOW_DISSECTOR_KEY_ENC_PORTS, target_container); tp->src = key->tp_src; tp->dst = key->tp_dst; } if (dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_ENC_IP)) { struct flow_dissector_key_ip *ip; ip = skb_flow_dissector_target(flow_dissector, FLOW_DISSECTOR_KEY_ENC_IP, target_container); ip->tos = key->tos; ip->ttl = key->ttl; } if (dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_ENC_OPTS)) { struct flow_dissector_key_enc_opts *enc_opt; enc_opt = skb_flow_dissector_target(flow_dissector, FLOW_DISSECTOR_KEY_ENC_OPTS, target_container); if (info->options_len) { enc_opt->len = info->options_len; ip_tunnel_info_opts_get(enc_opt->data, info); enc_opt->dst_opt_type = info->key.tun_flags & TUNNEL_OPTIONS_PRESENT; } } }
0
450,896
bool is_nonempty() const { return (len > 0); }
0
277,449
issuer_key_hash (ksba_cert_t cert, unsigned char *sha1_buffer) { gpg_error_t err; const unsigned char *ptr; size_t length, dummy; err = _ksba_cert_get_public_key_ptr (cert, &ptr, &length); if (!err) { err = _ksba_hash_buffer (NULL, ptr, length, 20, sha1_buffer, &dummy); if (!err && dummy != 20) err = gpg_error (GPG_ERR_BUG); } return err; }
0
164,589
RTCPeerConnectionHandler::RemoveTrackUnifiedPlan( blink::WebRTCRtpSender* web_sender) { DCHECK(task_runner_->RunsTasksInCurrentSequence()); DCHECK_EQ(configuration_.sdp_semantics, webrtc::SdpSemantics::kUnifiedPlan); auto it = FindSender(web_sender->Id()); if (it == rtp_senders_.end()) return webrtc::RTCError(webrtc::RTCErrorType::INVALID_PARAMETER); const auto& sender = *it; auto webrtc_sender = sender->state().webrtc_sender(); TransceiverStateSurfacer transceiver_state_surfacer(task_runner_, signaling_thread()); bool result; RunSynchronousClosureOnSignalingThread( base::BindRepeating( &RTCPeerConnectionHandler::RemoveTrackUnifiedPlanOnSignalingThread, base::Unretained(this), base::RetainedRef(webrtc_sender), base::Unretained(&transceiver_state_surfacer), base::Unretained(&result)), "RemoveTrackUnifiedPlanOnSignalingThread"); DCHECK(transceiver_state_surfacer.is_initialized()); if (!result) { transceiver_state_surfacer.ObtainStates(); return webrtc::RTCError(webrtc::RTCErrorType::INTERNAL_ERROR); } auto transceiver_states = transceiver_state_surfacer.ObtainStates(); DCHECK_EQ(transceiver_states.size(), 1u); auto transceiver_state = std::move(transceiver_states[0]); auto transceiver = CreateOrUpdateTransceiver(std::move(transceiver_state)); if (peer_connection_tracker_) { size_t transceiver_index = GetTransceiverIndex(*transceiver); peer_connection_tracker_->TrackModifyTransceiver( this, PeerConnectionTracker::TransceiverUpdatedReason::kRemoveTrack, *transceiver.get(), transceiver_index); } std::unique_ptr<blink::WebRTCRtpTransceiver> web_transceiver = std::move(transceiver); return web_transceiver; }
0
106,415
void put_transaction(struct btrfs_transaction *transaction) { WARN_ON(atomic_read(&transaction->use_count) == 0); if (atomic_dec_and_test(&transaction->use_count)) { BUG_ON(!list_empty(&transaction->list)); WARN_ON(transaction->delayed_refs.root.rb_node); memset(transaction, 0, sizeof(*transaction)); kmem_cache_free(btrfs_transaction_cachep, transaction); } }
0
113,160
njs_array_handler_reduce(njs_vm_t *vm, njs_iterator_args_t *args, njs_value_t *entry, int64_t n) { njs_int_t ret; njs_value_t arguments[5]; if (njs_is_valid(entry)) { if (!njs_is_valid(args->argument)) { *(args->argument) = *entry; return NJS_OK; } /* GC: array elt, array */ njs_set_undefined(&arguments[0]); arguments[1] = *args->argument; arguments[2] = *entry; njs_set_number(&arguments[3], n); arguments[4] = *args->value; ret = njs_function_apply(vm, args->function, arguments, 5, args->argument); if (njs_slow_path(ret != NJS_OK)) { return ret; } } return NJS_OK; }
0
480,484
gif_initialise_frame_extensions(gif_animation *gif, const int frame) { const unsigned char *gif_data, *gif_end; ssize_t gif_bytes; ssize_t block_size; /* Get our buffer position etc. */ gif_data = (const unsigned char *)(gif->gif_data + gif->buffer_position); gif_end = (const unsigned char *)(gif->gif_data + gif->buffer_size); /* Initialise the extensions */ while (gif_data < gif_end && gif_data[0] == GIF_EXTENSION_INTRODUCER) { ++gif_data; if ((gif_bytes = (gif_end - gif_data)) < 1) { return GIF_INSUFFICIENT_FRAME_DATA; } /* Switch on extension label */ switch (gif_data[0]) { case GIF_EXTENSION_GRAPHIC_CONTROL: /* 6-byte Graphic Control Extension is: * * +0 CHAR Graphic Control Label * +1 CHAR Block Size * +2 CHAR __Packed Fields__ * 3BITS Reserved * 3BITS Disposal Method * 1BIT User Input Flag * 1BIT Transparent Color Flag * +3 SHORT Delay Time * +5 CHAR Transparent Color Index */ if (gif_bytes < 6) { return GIF_INSUFFICIENT_FRAME_DATA; } gif->frames[frame].frame_delay = gif_data[3] | (gif_data[4] << 8); if (gif_data[2] & GIF_TRANSPARENCY_MASK) { gif->frames[frame].transparency = true; gif->frames[frame].transparency_index = gif_data[5]; } gif->frames[frame].disposal_method = ((gif_data[2] & GIF_DISPOSAL_MASK) >> 2); /* I have encountered documentation and GIFs in the * wild that use 0x04 to restore the previous frame, * rather than the officially documented 0x03. I * believe some (older?) software may even actually * export this way. We handle this as a type of * "quirks" mode. */ if (gif->frames[frame].disposal_method == GIF_FRAME_QUIRKS_RESTORE) { gif->frames[frame].disposal_method = GIF_FRAME_RESTORE; } gif_data += (2 + gif_data[1]); break; case GIF_EXTENSION_APPLICATION: /* 14-byte+ Application Extension is: * * +0 CHAR Application Extension Label * +1 CHAR Block Size * +2 8CHARS Application Identifier * +10 3CHARS Appl. Authentication Code * +13 1-256 Application Data (Data sub-blocks) */ if (gif_bytes < 17) { return GIF_INSUFFICIENT_FRAME_DATA; } if ((gif_data[1] == 0x0b) && (strncmp((const char *) gif_data + 2, "NETSCAPE2.0", 11) == 0) && (gif_data[13] == 0x03) && (gif_data[14] == 0x01)) { gif->loop_count = gif_data[15] | (gif_data[16] << 8); } gif_data += (2 + gif_data[1]); break; case GIF_EXTENSION_COMMENT: /* Move the pointer to the first data sub-block Skip 1 * byte for the extension label */ ++gif_data; break; default: /* Move the pointer to the first data sub-block Skip 2 * bytes for the extension label and size fields Skip * the extension size itself */ if (gif_bytes < 2) { return GIF_INSUFFICIENT_FRAME_DATA; } gif_data += (2 + gif_data[1]); } /* Repeatedly skip blocks until we get a zero block or run out * of data This data is ignored by this gif decoder */ gif_bytes = (gif_end - gif_data); block_size = 0; while (gif_data < gif_end && gif_data[0] != GIF_BLOCK_TERMINATOR) { block_size = gif_data[0] + 1; if ((gif_bytes -= block_size) < 0) { return GIF_INSUFFICIENT_FRAME_DATA; } gif_data += block_size; } ++gif_data; } /* Set buffer position and return */ gif->buffer_position = (gif_data - gif->gif_data); return GIF_OK; }
0
485,429
DEFUN (neighbor_default_originate_rmap, neighbor_default_originate_rmap_cmd, NEIGHBOR_CMD2 "default-originate route-map WORD", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Originate default route to this neighbor\n" "Route-map to specify criteria to originate default\n" "route-map name\n") { return peer_default_originate_set_vty (vty, argv[0], bgp_node_afi (vty), bgp_node_safi (vty), argv[1], 1); }
0
496,952
static void set_run_features(ASS_Shaper *shaper, GlyphInfo *info) { // enable vertical substitutions for @font runs if (info->font->desc.vertical) shaper->features[VERT].value = shaper->features[VKNA].value = 1; else shaper->features[VERT].value = shaper->features[VKNA].value = 0; // disable ligatures if horizontal spacing is non-standard if (info->hspacing) shaper->features[LIGA].value = shaper->features[CLIG].value = 0; else shaper->features[LIGA].value = shaper->features[CLIG].value = 1; }
0
484,764
static int snd_ctl_dev_disconnect(struct snd_device *device) { struct snd_card *card = device->device_data; struct snd_ctl_file *ctl; struct snd_ctl_layer_ops *lops; unsigned long flags; read_lock_irqsave(&card->ctl_files_rwlock, flags); list_for_each_entry(ctl, &card->ctl_files, list) { wake_up(&ctl->change_sleep); snd_kill_fasync(ctl->fasync, SIGIO, POLL_ERR); } read_unlock_irqrestore(&card->ctl_files_rwlock, flags); down_read(&card->controls_rwsem); down_read(&snd_ctl_layer_rwsem); for (lops = snd_ctl_layer; lops; lops = lops->next) lops->ldisconnect(card); up_read(&snd_ctl_layer_rwsem); up_read(&card->controls_rwsem); return snd_unregister_device(&card->ctl_dev); }
0
41,184
do_string_sub( char_u *str, char_u *pat, char_u *sub, typval_T *expr, char_u *flags) { int sublen; regmatch_T regmatch; int i; int do_all; char_u *tail; char_u *end; garray_T ga; char_u *ret; char_u *save_cpo; char_u *zero_width = NULL; // Make 'cpoptions' empty, so that the 'l' flag doesn't work here save_cpo = p_cpo; p_cpo = empty_option; ga_init2(&ga, 1, 200); do_all = (flags[0] == 'g'); regmatch.rm_ic = p_ic; regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING); if (regmatch.regprog != NULL) { tail = str; end = str + STRLEN(str); while (vim_regexec_nl(&regmatch, str, (colnr_T)(tail - str))) { // Skip empty match except for first match. if (regmatch.startp[0] == regmatch.endp[0]) { if (zero_width == regmatch.startp[0]) { // avoid getting stuck on a match with an empty string i = mb_ptr2len(tail); mch_memmove((char_u *)ga.ga_data + ga.ga_len, tail, (size_t)i); ga.ga_len += i; tail += i; continue; } zero_width = regmatch.startp[0]; } /* * Get some space for a temporary buffer to do the substitution * into. It will contain: * - The text up to where the match is. * - The substituted text. * - The text after the match. */ sublen = vim_regsub(&regmatch, sub, expr, tail, FALSE, TRUE, FALSE); if (ga_grow(&ga, (int)((end - tail) + sublen - (regmatch.endp[0] - regmatch.startp[0]))) == FAIL) { ga_clear(&ga); break; } // copy the text up to where the match is i = (int)(regmatch.startp[0] - tail); mch_memmove((char_u *)ga.ga_data + ga.ga_len, tail, (size_t)i); // add the substituted text (void)vim_regsub(&regmatch, sub, expr, (char_u *)ga.ga_data + ga.ga_len + i, TRUE, TRUE, FALSE); ga.ga_len += i + sublen - 1; tail = regmatch.endp[0]; if (*tail == NUL) break; if (!do_all) break; } if (ga.ga_data != NULL) STRCPY((char *)ga.ga_data + ga.ga_len, tail); vim_regfree(regmatch.regprog); } ret = vim_strsave(ga.ga_data == NULL ? str : (char_u *)ga.ga_data); ga_clear(&ga); if (p_cpo == empty_option) p_cpo = save_cpo; else { // Darn, evaluating {sub} expression or {expr} changed the value. // If it's still empty it was changed and restored, need to restore in // the complicated way. if (*p_cpo == NUL) set_option_value((char_u *)"cpo", 0L, save_cpo, 0); free_string_option(save_cpo); } return ret; }
0
523,759
int BN_is_negative(const BIGNUM *a) { return (a->neg != 0); }
0
223,342
void WebContentsAndroid::OpenURL(JNIEnv* env,
0
466,400
void ConnectionManagerImpl::doDeferredStreamDestroy(ActiveStream& stream) { if (stream.max_stream_duration_timer_) { stream.max_stream_duration_timer_->disableTimer(); stream.max_stream_duration_timer_ = nullptr; } if (stream.stream_idle_timer_ != nullptr) { stream.stream_idle_timer_->disableTimer(); stream.stream_idle_timer_ = nullptr; } stream.filter_manager_.disarmRequestTimeout(); if (stream.request_header_timer_ != nullptr) { stream.request_header_timer_->disableTimer(); stream.request_header_timer_ = nullptr; } stream.completeRequest(); stream.filter_manager_.onStreamComplete(); stream.filter_manager_.log(); stream.filter_manager_.destroyFilters(); read_callbacks_->connection().dispatcher().deferredDelete(stream.removeFromList(streams_)); if (connection_idle_timer_ && streams_.empty()) { connection_idle_timer_->enableTimer(config_.idleTimeout().value()); } }
0
270,732
static void dwc3_ep_inc_enq(struct dwc3_ep *dep) { dwc3_ep_inc_trb(&dep->trb_enqueue); }
0
473,054
k_rational_p(VALUE x) { return f_kind_of_p(x, rb_cRational); }
0
292,251
idtab_lookup(int version) { if (version < 1 || version > 2) fatal("internal error, bad protocol version %d", version); return &idtable[version]; }
0
428,311
static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it, gfp_t gfp_mask) { return __tcp_transmit_skb(sk, skb, clone_it, gfp_mask, tcp_sk(sk)->rcv_nxt); }
0
307,706
static void mem_cgroup_charge_statistics(struct mem_cgroup *memcg, bool file, int nr_pages) { preempt_disable(); if (file) __this_cpu_add(memcg->stat->count[MEM_CGROUP_STAT_CACHE], nr_pages); else __this_cpu_add(memcg->stat->count[MEM_CGROUP_STAT_RSS], nr_pages); /* pagein of a big page is an event. So, ignore page size */ if (nr_pages > 0) __this_cpu_inc(memcg->stat->events[MEM_CGROUP_EVENTS_PGPGIN]); else { __this_cpu_inc(memcg->stat->events[MEM_CGROUP_EVENTS_PGPGOUT]); nr_pages = -nr_pages; /* for event */ } __this_cpu_add(memcg->stat->events[MEM_CGROUP_EVENTS_COUNT], nr_pages); preempt_enable(); }
0
487,964
SampleEncrypter(AP4_CbcStreamCipher* stream_cipher, const AP4_UI08* iv): m_StreamCipher(stream_cipher) { AP4_CopyMemory(m_IV, iv, 16); }
0
44,629
void credssp_free(rdpCredssp* credssp) { if (credssp != NULL) { if (credssp->table) credssp->table->DeleteSecurityContext(&credssp->context); sspi_SecBufferFree(&credssp->PublicKey); sspi_SecBufferFree(&credssp->ts_credentials); free(credssp->ServicePrincipalName); free(credssp->identity.User); free(credssp->identity.Domain); free(credssp->identity.Password); free(credssp); } }
0
228,096
void TabStripModel::SelectPreviousTab() { SelectRelativeTab(false); }
0
160,192
session_start_process (const gchar **argv, const gchar **env) { CockpitTransport *transport = NULL; CockpitPipe *pipe = NULL; GError *error = NULL; ChildData child; gboolean ret; GPid pid = 0; int fds[2]; g_debug ("spawning %s", argv[0]); /* The main stdin/stdout for the socket ... both are read/writable */ if (socketpair (PF_LOCAL, SOCK_STREAM, 0, fds) < 0) { g_warning ("couldn't create loopback socket: %s", g_strerror (errno)); return NULL; } child.io = fds[0]; ret = g_spawn_async_with_pipes (NULL, (gchar **)argv, (gchar **)env, G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_LEAVE_DESCRIPTORS_OPEN, session_child_setup, &child, &pid, NULL, NULL, NULL, &error); close (fds[0]); if (!ret) { g_message ("couldn't launch cockpit session: %s: %s", argv[0], error->message); g_error_free (error); close (fds[1]); return NULL; } pipe = g_object_new (COCKPIT_TYPE_PIPE, "in-fd", fds[1], "out-fd", fds[1], "pid", pid, "name", argv[0], NULL); transport = cockpit_pipe_transport_new (pipe); g_object_unref (pipe); return transport; }
0
139,178
void Magick::Image::affineTransform(const DrawableAffine &affine_) { AffineMatrix _affine; MagickCore::Image *newImage; _affine.sx=affine_.sx(); _affine.sy=affine_.sy(); _affine.rx=affine_.rx(); _affine.ry=affine_.ry(); _affine.tx=affine_.tx(); _affine.ty=affine_.ty(); GetPPException; newImage=AffineTransformImage(constImage(),&_affine,exceptionInfo); replaceImage(newImage); ThrowImageException; }
0
162,608
void CommandBufferProxyImpl::CreateGpuFence(uint32_t gpu_fence_id, ClientGpuFence source) { CheckLock(); base::AutoLock lock(last_state_lock_); if (last_state_.error != gpu::error::kNoError) { DLOG(ERROR) << "got error=" << last_state_.error; return; } gfx::GpuFence* gpu_fence = gfx::GpuFence::FromClientGpuFence(source); gfx::GpuFenceHandle handle = gfx::CloneHandleForIPC(gpu_fence->GetGpuFenceHandle()); Send(new GpuCommandBufferMsg_CreateGpuFenceFromHandle(route_id_, gpu_fence_id, handle)); }
0
325,080
static int do_pcie_aer_inject_error(Monitor *mon, const QDict *qdict, QObject **ret_data) { const char *id = qdict_get_str(qdict, "id"); const char *error_name; uint32_t error_status; bool correctable; PCIDevice *dev; PCIEAERErr err; int ret; ret = pci_qdev_find_device(id, &dev); if (ret < 0) { monitor_printf(mon, "id or pci device path is invalid or device not " "found. %s\n", id); return ret; } if (!pci_is_express(dev)) { monitor_printf(mon, "the device doesn't support pci express. %s\n", id); return -ENOSYS; } error_name = qdict_get_str(qdict, "error_status"); if (pcie_aer_parse_error_string(error_name, &error_status, &correctable)) { char *e = NULL; error_status = strtoul(error_name, &e, 0); correctable = qdict_get_try_bool(qdict, "correctable", false); if (!e || *e != '\0') { monitor_printf(mon, "invalid error status value. \"%s\"", error_name); return -EINVAL; } } err.status = error_status; err.source_id = pci_requester_id(dev); err.flags = 0; if (correctable) { err.flags |= PCIE_AER_ERR_IS_CORRECTABLE; } if (qdict_get_try_bool(qdict, "advisory_non_fatal", false)) { err.flags |= PCIE_AER_ERR_MAYBE_ADVISORY; } if (qdict_haskey(qdict, "header0")) { err.flags |= PCIE_AER_ERR_HEADER_VALID; } if (qdict_haskey(qdict, "prefix0")) { err.flags |= PCIE_AER_ERR_TLP_PREFIX_PRESENT; } err.header[0] = qdict_get_try_int(qdict, "header0", 0); err.header[1] = qdict_get_try_int(qdict, "header1", 0); err.header[2] = qdict_get_try_int(qdict, "header2", 0); err.header[3] = qdict_get_try_int(qdict, "header3", 0); err.prefix[0] = qdict_get_try_int(qdict, "prefix0", 0); err.prefix[1] = qdict_get_try_int(qdict, "prefix1", 0); err.prefix[2] = qdict_get_try_int(qdict, "prefix2", 0); err.prefix[3] = qdict_get_try_int(qdict, "prefix3", 0); ret = pcie_aer_inject_error(dev, &err); *ret_data = qobject_from_jsonf("{'id': %s, " "'root_bus': %s, 'bus': %d, 'devfn': %d, " "'ret': %d}", id, pci_root_bus_path(dev), pci_bus_num(dev->bus), dev->devfn, ret); assert(*ret_data); return 0; }
1
119,596
static int ptrace_set_breakpoint_addr(struct task_struct *tsk, int nr, unsigned long addr) { struct perf_event *bp; struct thread_struct *t = &tsk->thread; struct perf_event_attr attr; int err = 0; if (ptrace_get_breakpoints(tsk) < 0) return -ESRCH; if (!t->ptrace_bps[nr]) { ptrace_breakpoint_init(&attr); /* * Put stub len and type to register (reserve) an inactive but * correct bp */ attr.bp_addr = addr; attr.bp_len = HW_BREAKPOINT_LEN_1; attr.bp_type = HW_BREAKPOINT_W; attr.disabled = 1; bp = register_user_hw_breakpoint(&attr, ptrace_triggered, tsk); /* * CHECKME: the previous code returned -EIO if the addr wasn't * a valid task virtual addr. The new one will return -EINVAL in * this case. * -EINVAL may be what we want for in-kernel breakpoints users, * but -EIO looks better for ptrace, since we refuse a register * writing for the user. And anyway this is the previous * behaviour. */ if (IS_ERR(bp)) { err = PTR_ERR(bp); goto put; } t->ptrace_bps[nr] = bp; } else { bp = t->ptrace_bps[nr]; attr = bp->attr; attr.bp_addr = addr; err = modify_user_hw_breakpoint(bp, &attr); } put: ptrace_put_breakpoints(tsk); return err; }
0
30,228
int ssl3_get_finished ( SSL * s , int a , int b ) { int al , i , ok ; long n ; unsigned char * p ; # ifdef OPENSSL_NO_NEXTPROTONEG # endif n = s -> method -> ssl_get_message ( s , a , b , SSL3_MT_FINISHED , 64 , & ok ) ; if ( ! ok ) return ( ( int ) n ) ; if ( ! s -> s3 -> change_cipher_spec ) { al = SSL_AD_UNEXPECTED_MESSAGE ; SSLerr ( SSL_F_SSL3_GET_FINISHED , SSL_R_GOT_A_FIN_BEFORE_A_CCS ) ; goto f_err ; } s -> s3 -> change_cipher_spec = 0 ; p = ( unsigned char * ) s -> init_msg ; i = s -> s3 -> tmp . peer_finish_md_len ; if ( i != n ) { al = SSL_AD_DECODE_ERROR ; SSLerr ( SSL_F_SSL3_GET_FINISHED , SSL_R_BAD_DIGEST_LENGTH ) ; goto f_err ; } if ( CRYPTO_memcmp ( p , s -> s3 -> tmp . peer_finish_md , i ) != 0 ) { al = SSL_AD_DECRYPT_ERROR ; SSLerr ( SSL_F_SSL3_GET_FINISHED , SSL_R_DIGEST_CHECK_FAILED ) ; goto f_err ; } if ( s -> type == SSL_ST_ACCEPT ) { OPENSSL_assert ( i <= EVP_MAX_MD_SIZE ) ; memcpy ( s -> s3 -> previous_client_finished , s -> s3 -> tmp . peer_finish_md , i ) ; s -> s3 -> previous_client_finished_len = i ; } else { OPENSSL_assert ( i <= EVP_MAX_MD_SIZE ) ; memcpy ( s -> s3 -> previous_server_finished , s -> s3 -> tmp . peer_finish_md , i ) ; s -> s3 -> previous_server_finished_len = i ; } return ( 1 ) ; f_err : ssl3_send_alert ( s , SSL3_AL_FATAL , al ) ; return ( 0 ) ; }
0
378,203
static int selinux_msg_queue_msgrcv(struct msg_queue *msq, struct msg_msg *msg, struct task_struct *target, long type, int mode) { struct ipc_security_struct *isec; struct msg_security_struct *msec; struct common_audit_data ad; struct selinux_audit_data sad = {0,}; u32 sid = task_sid(target); int rc; isec = msq->q_perm.security; msec = msg->security; COMMON_AUDIT_DATA_INIT(&ad, IPC); ad.selinux_audit_data = &sad; ad.u.ipc_id = msq->q_perm.key; rc = avc_has_perm(sid, isec->sid, SECCLASS_MSGQ, MSGQ__READ, &ad); if (!rc) rc = avc_has_perm(sid, msec->sid, SECCLASS_MSG, MSG__RECEIVE, &ad); return rc; }
0
180,610
bool StartupBrowserCreator::Start(const base::CommandLine& cmd_line, const base::FilePath& cur_dir, Profile* last_used_profile, const Profiles& last_opened_profiles) { TRACE_EVENT0("startup", "StartupBrowserCreator::Start"); SCOPED_UMA_HISTOGRAM_TIMER("Startup.StartupBrowserCreator_Start"); return ProcessCmdLineImpl(cmd_line, cur_dir, true, last_used_profile, last_opened_profiles); }
0
42,209
enum econn_state ecall_state(const struct ecall *ecall) { if (!ecall) return ECONN_IDLE; if (ecall->econn) { return econn_current_state(ecall->econn); } else { return ECONN_IDLE; } }
0
121,320
static void t1_start_eexec(void) { int i; if (is_included(fm_cur)) { get_length1(); save_offset(); } if (!t1_pfa) t1_check_block_len(false); for (t1_line_ptr = t1_line_array, i = 0; i < 4; i++) { edecrypt((byte)t1_getbyte()); *t1_line_ptr++ = 0; } t1_eexec_encrypt = true; if (is_included(fm_cur)) t1_putline(); /* to put the first four bytes */ }
0
83,963
DecimalQuantity& DecimalQuantity::setToDecNum(const DecNum& decnum, UErrorCode& status) { setBcdToZero(); flags = 0; _setToDecNum(decnum, status); return *this; }
0
491,750
parser_set_continues_to_current_position (parser_context_t *context_p, /**< context */ parser_branch_node_t *current_p) /**< branch list */ { while (current_p != NULL) { if (current_p->branch.offset & CBC_HIGHEST_BIT_MASK) { parser_set_branch_to_current_position (context_p, &current_p->branch); } current_p = current_p->next_p; } } /* parser_set_continues_to_current_position */
0
54,955
init_etherarray(netdissect_options *ndo) { register const struct etherlist *el; register struct enamemem *tp; #ifdef USE_ETHER_NTOHOST char name[256]; #else register struct pcap_etherent *ep; register FILE *fp; /* Suck in entire ethers file */ fp = fopen(PCAP_ETHERS_FILE, "r"); if (fp != NULL) { while ((ep = pcap_next_etherent(fp)) != NULL) { tp = lookup_emem(ndo, ep->addr); tp->e_name = strdup(ep->name); if (tp->e_name == NULL) (*ndo->ndo_error)(ndo, "init_etherarray: strdup(ep->addr)"); } (void)fclose(fp); } #endif /* Hardwire some ethernet names */ for (el = etherlist; el->name != NULL; ++el) { tp = lookup_emem(ndo, el->addr); /* Don't override existing name */ if (tp->e_name != NULL) continue; #ifdef USE_ETHER_NTOHOST /* * Use YP/NIS version of name if available. */ if (ether_ntohost(name, (const struct ether_addr *)el->addr) == 0) { tp->e_name = strdup(name); if (tp->e_name == NULL) (*ndo->ndo_error)(ndo, "init_etherarray: strdup(name)"); continue; } #endif tp->e_name = el->name; } }
0
174,460
void ShelfLayoutManager::SetDockedMagnifierHeight(int height) { docked_magnifier_height_ = height; LayoutShelf(); }
0
393,109
xmlSchemaAnnotDump(FILE * output, xmlSchemaAnnotPtr annot) { xmlChar *content; if (annot == NULL) return; content = xmlNodeGetContent(annot->content); if (content != NULL) { fprintf(output, " Annot: %s\n", content); xmlFree(content); } else fprintf(output, " Annot: empty\n"); }
0
431,641
bool AuthorizationSession::isAuthenticated() { return _authenticatedUsers.begin() != _authenticatedUsers.end(); }
0
188,609
void CoordinatorImpl::FinalizeGlobalMemoryDumpIfAllManagersReplied() { TRACE_EVENT0(base::trace_event::MemoryDumpManager::kTraceCategory, "GlobalMemoryDump.Computation"); DCHECK(!queued_memory_dump_requests_.empty()); QueuedRequest* request = &queued_memory_dump_requests_.front(); if (!request->dump_in_progress || request->pending_responses.size() > 0) return; QueuedRequestDispatcher::Finalize(request, tracing_observer_.get()); queued_memory_dump_requests_.pop_front(); request = nullptr; if (!queued_memory_dump_requests_.empty()) { base::SequencedTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(&CoordinatorImpl::PerformNextQueuedGlobalMemoryDump, base::Unretained(this))); } }
0
189,978
bool tap() const { return tap_; }
0
170,687
void PaletteTray::ClickedOutsideBubble() { HidePalette(); }
0
209,941
void ExtensionOptionsGuest::DidNavigateMainFrame( const content::LoadCommittedDetails& details, const content::FrameNavigateParams& params) { if (attached()) { auto guest_zoom_controller = ui_zoom::ZoomController::FromWebContents(web_contents()); guest_zoom_controller->SetZoomMode( ui_zoom::ZoomController::ZOOM_MODE_ISOLATED); SetGuestZoomLevelToMatchEmbedder(); if (!url::IsSameOriginWith(params.url, options_page_)) { bad_message::ReceivedBadMessage(web_contents()->GetRenderProcessHost(), bad_message::EOG_BAD_ORIGIN); } } }
0
423,493
dns_zone_getchecknames(dns_zone_t *zone) { REQUIRE(DNS_ZONE_VALID(zone)); return (zone->check_names); }
0
4,656
static void tcp_cwnd_reduction(struct sock *sk, const int prior_unsacked, int fast_rexmit, int flag) { struct tcp_sock *tp = tcp_sk(sk); int sndcnt = 0; int delta = tp->snd_ssthresh - tcp_packets_in_flight(tp); int newly_acked_sacked = prior_unsacked - (tp->packets_out - tp->sacked_out); tp->prr_delivered += newly_acked_sacked; if (delta < 0) { u64 dividend = (u64)tp->snd_ssthresh * tp->prr_delivered + tp->prior_cwnd - 1; sndcnt = div_u64(dividend, tp->prior_cwnd) - tp->prr_out; } else if ((flag & FLAG_RETRANS_DATA_ACKED) && !(flag & FLAG_LOST_RETRANS)) { sndcnt = min_t(int, delta, max_t(int, tp->prr_delivered - tp->prr_out, newly_acked_sacked) + 1); } else { sndcnt = min(delta, newly_acked_sacked); } sndcnt = max(sndcnt, (fast_rexmit ? 1 : 0)); tp->snd_cwnd = tcp_packets_in_flight(tp) + sndcnt; }
1
273,831
Lock_AF_UNIX(const char *unixSocketDir, const char *unixSocketPath) { /* no lock file for abstract sockets */ if (unixSocketPath[0] == '@') return STATUS_OK; /* * Grab an interlock file associated with the socket file. * * Note: there are two reasons for using a socket lock file, rather than * trying to interlock directly on the socket itself. First, it's a lot * more portable, and second, it lets us remove any pre-existing socket * file without race conditions. */ CreateSocketLockFile(unixSocketPath, true, unixSocketDir); /* * Once we have the interlock, we can safely delete any pre-existing * socket file to avoid failure at bind() time. */ (void) unlink(unixSocketPath); /* * Remember socket file pathnames for later maintenance. */ sock_paths = lappend(sock_paths, pstrdup(unixSocketPath)); return STATUS_OK; }
0
71,932
size_t ConnectionImpl::dispatchSlice(const char* slice, size_t len) { ssize_t rc = http_parser_execute(&parser_, &settings_, slice, len); if (HTTP_PARSER_ERRNO(&parser_) != HPE_OK && HTTP_PARSER_ERRNO(&parser_) != HPE_PAUSED) { sendProtocolError(); throw CodecProtocolException("http/1.1 protocol error: " + std::string(http_errno_name(HTTP_PARSER_ERRNO(&parser_)))); } return rc; }
0
10,068
pixel_copy(png_bytep toBuffer, png_uint_32 toIndex, png_const_bytep fromBuffer, png_uint_32 fromIndex, unsigned int pixelSize) { /* Assume we can multiply by 'size' without overflow because we are * just working in a single buffer. */ toIndex *= pixelSize; fromIndex *= pixelSize; if (pixelSize < 8) /* Sub-byte */ { /* Mask to select the location of the copied pixel: */ unsigned int destMask = ((1U<<pixelSize)-1) << (8-pixelSize-(toIndex&7)); /* The following read the entire pixels and clears the extra: */ unsigned int destByte = toBuffer[toIndex >> 3] & ~destMask; unsigned int sourceByte = fromBuffer[fromIndex >> 3]; /* Don't rely on << or >> supporting '0' here, just in case: */ fromIndex &= 7; if (fromIndex > 0) sourceByte <<= fromIndex; if ((toIndex & 7) > 0) sourceByte >>= toIndex & 7; toBuffer[toIndex >> 3] = (png_byte)(destByte | (sourceByte & destMask)); } else /* One or more bytes */ memmove(toBuffer+(toIndex>>3), fromBuffer+(fromIndex>>3), pixelSize>>3); }
1
73,757
pq_discardbytes(size_t len) { size_t amount; Assert(PqCommReadingMsg); while (len > 0) { while (PqRecvPointer >= PqRecvLength) { if (pq_recvbuf()) /* If nothing in buffer, then recv some */ return EOF; /* Failed to recv data */ } amount = PqRecvLength - PqRecvPointer; if (amount > len) amount = len; PqRecvPointer += amount; len -= amount; } return 0; }
0
95,593
const Model* BuildModelWithOfflinePlanning(int number_of_tensors, const int32_t* metadata_buffer, NodeConnection* node_conn, int num_conns, int num_subgraph_inputs) { using flatbuffers::Offset; flatbuffers::FlatBufferBuilder* fb_builder = BuilderInstance(); ModelBuilder model_builder(fb_builder); const int op_id = model_builder.RegisterOp(BuiltinOperator_CUSTOM, "mock_custom", /* version= */ 0); for (int i = 0; i < number_of_tensors; ++i) { model_builder.AddTensor(TensorType_FLOAT32, {2, 2, 3}); } for (int i = 0; i < num_conns; ++i) { model_builder.AddNode(op_id, node_conn[i].input, node_conn[i].output); } model_builder.AddMetadata( "OfflineMemoryAllocation", metadata_buffer, number_of_tensors + tflite::testing::kOfflinePlannerHeaderSize); return model_builder.BuildModel( node_conn[0].input, node_conn[num_conns - 1].output, num_subgraph_inputs); }
0
267,771
template<typename t> static int _isosurface3d_index(const unsigned int edge, const CImg<t>& indices1, const CImg<t>& indices2, const unsigned int x, const unsigned int y, const unsigned int nx, const unsigned int ny) { switch (edge) { case 0 : return indices1(x,y,0); case 1 : return indices1(nx,y,1); case 2 : return indices1(x,ny,0); case 3 : return indices1(x,y,1); case 4 : return indices2(x,y,0); case 5 : return indices2(nx,y,1); case 6 : return indices2(x,ny,0); case 7 : return indices2(x,y,1); case 8 : return indices1(x,y,2); case 9 : return indices1(nx,y,2); case 10 : return indices1(nx,ny,2); case 11 : return indices1(x,ny,2); } return 0;
0
51,446
static void pdo_stmt_iter_move_forwards(zend_object_iterator *iter TSRMLS_DC) { struct php_pdo_iterator *I = (struct php_pdo_iterator*)iter->data; if (I->fetch_ahead) { zval_ptr_dtor(&I->fetch_ahead); I->fetch_ahead = NULL; } MAKE_STD_ZVAL(I->fetch_ahead); if (!do_fetch(I->stmt, TRUE, I->fetch_ahead, PDO_FETCH_USE_DEFAULT, PDO_FETCH_ORI_NEXT, 0, 0 TSRMLS_CC)) { pdo_stmt_t *stmt = I->stmt; /* for PDO_HANDLE_STMT_ERR() */ PDO_HANDLE_STMT_ERR(); I->key = (ulong)-1; FREE_ZVAL(I->fetch_ahead); I->fetch_ahead = NULL; return; } I->key++;
0
473,537
xfs_iunpin( struct xfs_inode *ip) { ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_ILOCK_SHARED)); trace_xfs_inode_unpin_nowait(ip, _RET_IP_); /* Give the log a push to start the unpinning I/O */ xfs_log_force_lsn(ip->i_mount, ip->i_itemp->ili_last_lsn, 0, NULL); }
0
109,312
l2tp_proxy_auth_type_print(netdissect_options *ndo, const u_char *dat, u_int length) { const uint16_t *ptr = (const uint16_t *)dat; if (length < 2) { ND_PRINT((ndo, "AVP too short")); return; } ND_PRINT((ndo, "%s", tok2str(l2tp_authentype2str, "AuthType-#%u", EXTRACT_16BITS(ptr)))); }
0
69,346
ipf_is_first_v6_frag(ovs_be16 ip6f_offlg) { if (!(ip6f_offlg & IP6F_OFF_MASK) && ip6f_offlg & IP6F_MORE_FRAG) { return true; } return false; }
0
229,267
virtual ~TileIndependenceTest() { delete fw_dec_; delete inv_dec_; }
0
425,106
static void mask2shift(uint32_t mask, int *right, int *left) { int rshift = 0, lshift = 0; if(!mask) { *right = *left = 0; return; } while(!(mask & 1)) { mask >>= 1; rshift++; } *right = rshift; while(mask & 1) { mask >>= 1; lshift++; } *left = 12 - lshift; }
0
456,788
static inline bool shuffle_freelist(struct kmem_cache *s, struct page *page) { return false; }
0