Datasets:
func stringlengths 12 2.67k | cwe stringclasses 7
values | __index_level_0__ int64 0 20k |
|---|---|---|
inline double stirling_approx_tail(double k) {
static double kTailValues[] = {0.0810614667953272, 0.0413406959554092,
0.0276779256849983, 0.02079067210376509,
0.0166446911898211, 0.0138761288230707,
0.011896709945891... | safe | 0 |
TEST(HeaderMapImplTest, IterateReverse) {
TestHeaderMapImpl headers;
headers.addCopy("hello", "world");
headers.addCopy("foo", "bar");
LowerCaseString world_key("world");
headers.setReferenceKey(world_key, "hello");
using MockCb = testing::MockFunction<void(const std::string&, const std::string&)>;
MockC... | safe | 1 |
inline static void _slurm_rpc_trigger_set(slurm_msg_t * msg)
{
int rc;
uid_t uid = g_slurm_auth_get_uid(msg->auth_cred,
slurmctld_config.auth_info);
gid_t gid = g_slurm_auth_get_gid(msg->auth_cred,
slurmctld_config.auth_info);
trigger_info_msg_t * trigger_ptr = (trigger_info_msg_t *) msg->data;
DEF_TI... | safe | 2 |
static void uvesafb_check_limits(struct fb_var_screeninfo *var,
struct fb_info *info)
{
const struct fb_videomode *mode;
struct uvesafb_par *par = info->par;
/*
* If pixclock is set to 0, then we're using default BIOS timings
* and thus don't have to perform any checks here.
*/
if (!var->pixclock)
return... | safe | 3 |
mesh_state_delete(struct module_qstate* qstate)
{
struct mesh_area* mesh;
struct mesh_state_ref* super, ref;
struct mesh_state* mstate;
if(!qstate)
return;
mstate = qstate->mesh_info;
mesh = mstate->s.env->mesh;
mesh_detach_subs(&mstate->s);
if(mstate->list_select == mesh_forever_list) {
mesh->num_forever_s... | safe | 4 |
void CLASS nikon_coolscan_load_raw()
{
if(!image)
throw LIBRAW_EXCEPTION_IO_CORRUPT;
int bypp = tiff_bps <= 8 ? 1 : 2;
int bufsize = width * 3 * bypp;
if (tiff_bps <= 8)
gamma_curve(1.0 / imgdata.params.coolscan_nef_gamma, 0., 1, 255);
else
gamma_curve(1.0/imgdata.params.coolscan_nef_gamma,0.,1,... | safe | 5 |
static int nl80211_msg_put_wmm_rules(struct sk_buff *msg,
const struct ieee80211_reg_rule *rule)
{
int j;
struct nlattr *nl_wmm_rules =
nla_nest_start_noflag(msg, NL80211_FREQUENCY_ATTR_WMM);
if (!nl_wmm_rules)
goto nla_put_failure;
for (j = 0; j < IEEE80211_NUM_ACS; j++) {
struct nlattr *nl_wmm_ru... | safe | 6 |
add_index_file(ParsedURL *pu, URLFile *uf)
{
char *p, *q;
TextList *index_file_list = NULL;
TextListItem *ti;
if (non_null(index_file))
index_file_list = make_domain_list(index_file);
if (index_file_list == NULL) {
uf->stream = NULL;
return;
}
for (ti = index_file_list->first; ti; ti = t... | safe | 7 |
static void __kvm_synchronize_tsc(struct kvm_vcpu *vcpu, u64 offset, u64 tsc,
u64 ns, bool matched)
{
struct kvm *kvm = vcpu->kvm;
lockdep_assert_held(&kvm->arch.tsc_write_lock);
/*
* We also track th most recent recorded KHZ, write and time to
* allow the matching interval to be extended at each write.
... | safe | 8 |
static void trace_packet(const struct sk_buff *skb,
unsigned int hook,
const struct net_device *in,
const struct net_device *out,
const char *tablename,
const struct xt_table_info *private,
const struct ipt_entry *e)
{
const void *table_base;
const struct ipt_entry *root;
const char *hookname... | safe | 9 |
static struct sk_buff *add_grhead(struct sk_buff *skb, struct ip_mc_list *pmc,
int type, struct igmpv3_grec **ppgr, unsigned int mtu)
{
struct net_device *dev = pmc->interface->dev;
struct igmpv3_report *pih;
struct igmpv3_grec *pgr;
if (!skb) {
skb = igmpv3_newpack(dev, mtu);
if (!skb)
return NULL;
}
pg... | safe | 10 |
TfLiteStatus Subgraph::UndoAllDelegates() {
// Return early if there is nothing to reset to.
if (pre_delegation_execution_plan_.empty()) return kTfLiteOk;
// First free all delegate nodes.
for (int execution_plan_index = 0;
execution_plan_index < execution_plan_.size(); ++execution_plan_index) {
int... | safe | 11 |
read_2007_section_appinfo (Bit_Chain *restrict dat, Dwg_Data *restrict dwg,
r2007_section *restrict sections_map,
r2007_page *restrict pages_map)
{
Bit_Chain old_dat, sec_dat = { 0 };
Bit_Chain *str_dat;
Dwg_AppInfo *_obj = &dwg->appinfo;
Dwg_Object *obj = N... | safe | 12 |
static int selinux_syslog(int type)
{
int rc;
switch (type) {
case SYSLOG_ACTION_READ_ALL: /* Read last kernel messages */
case SYSLOG_ACTION_SIZE_BUFFER: /* Return size of the log buffer */
rc = task_has_system(current, SYSTEM__SYSLOG_READ);
break;
case SYSLOG_ACTION_CONSOLE_OFF: /* Disable logging to consol... | safe | 13 |
int sas_smp_phy_control(struct domain_device *dev, int phy_id,
enum phy_func phy_func,
struct sas_phy_linkrates *rates)
{
u8 *pc_req;
u8 *pc_resp;
int res;
pc_req = alloc_smp_req(PC_REQ_SIZE);
if (!pc_req)
return -ENOMEM;
pc_resp = alloc_smp_resp(PC_RESP_SIZE);
if (!pc_resp) {
kfree(pc_req);
return... | safe | 14 |
OJPEGWriteStreamSof(TIFF* tif, void** mem, uint32* len)
{
OJPEGState* sp=(OJPEGState*)tif->tif_data;
uint8 m;
assert(OJPEG_BUFFER>=2+8+sp->samples_per_pixel_per_plane*3);
assert(255>=8+sp->samples_per_pixel_per_plane*3);
sp->out_buffer[0]=255;
sp->out_buffer[1]=sp->sof_marker_id;
/* Lf */
sp->out_buffer[2]=0;
... | safe | 15 |
struct Scsi_Host *iscsi_host_alloc(struct scsi_host_template *sht,
int dd_data_size, bool xmit_can_sleep)
{
struct Scsi_Host *shost;
struct iscsi_host *ihost;
shost = scsi_host_alloc(sht, sizeof(struct iscsi_host) + dd_data_size);
if (!shost)
return NULL;
ihost = shost_priv(shost);
if (xmit_can_sleep) ... | safe | 16 |
void lease_file_rewrite(void)
{
int index;
unsigned short eport, iport;
int proto;
char iaddr[32];
char desc[64];
char rhost[40];
unsigned int timestamp;
if (lease_file == NULL) return;
remove(lease_file);
for(index = 0; ; index++) {
if(get_redirect_rule_by_index(index, 0/*ifname*/, &eport, iaddr, sizeof(i... | safe | 17 |
void r_bin_mdmp_free(struct r_bin_mdmp_obj *obj) {
if (!obj) {
return;
}
r_list_free (obj->streams.ex_threads);
r_list_free (obj->streams.memories);
r_list_free (obj->streams.memories64.memories);
r_list_free (obj->streams.memory_infos);
r_list_free (obj->streams.modules);
r_list_free (obj->streams.operation... | safe | 18 |
GF_Err sdtp_box_read(GF_Box *s, GF_BitStream *bs)
{
GF_SampleDependencyTypeBox *ptr = (GF_SampleDependencyTypeBox*)s;
/*out-of-order sdtp, assume no padding at the end*/
if (!ptr->sampleCount) ptr->sampleCount = (u32) ptr->size;
else if (ptr->sampleCount > (u32) ptr->size) return GF_ISOM_INVALID_FILE;
ptr->samp... | safe | 19 |
get_keyblock_byfprint (KBNODE * ret_keyblock, const byte * fprint,
size_t fprint_len)
{
int rc;
if (fprint_len == 20 || fprint_len == 16)
{
struct getkey_ctx_s ctx;
memset (&ctx, 0, sizeof ctx);
ctx.not_allocated = 1;
ctx.kr_handle = keydb_new ();
ctx.nitems = 1;
c... | safe | 20 |
GF_Err gf_isom_read_null_terminated_string(GF_Box *s, GF_BitStream *bs, u64 size, char **out_str)
{
u32 len=10;
u32 i=0;
*out_str = gf_malloc(sizeof(char)*len);
while (1) {
ISOM_DECREASE_SIZE(s, 1 );
(*out_str)[i] = gf_bs_read_u8(bs);
if (!(*out_str)[i]) break;
i++;
if (i==len) {
len += 10;
*out_s... | safe | 21 |
void luaV_objlen (lua_State *L, StkId ra, const TValue *rb) {
const TValue *tm;
switch (ttypetag(rb)) {
case LUA_VTABLE: {
Table *h = hvalue(rb);
tm = fasttm(L, h->metatable, TM_LEN);
if (tm) break; /* metamethod? break switch to call it */
setivalue(s2v(ra), luaH_getn(h)); /* else pri... | safe | 22 |
bool detect_ramfs_rootfs(void)
{
FILE *f;
char *p, *p2;
char *line = NULL;
size_t len = 0;
int i;
f = fopen("/proc/self/mountinfo", "r");
if (!f)
return false;
while (getline(&line, &len, f) != -1) {
for (p = line, i = 0; p && i < 4; i++)
p = strchr(p + 1, ' ');
if (!p)
continue;
p2 = strchr(p +... | safe | 23 |
static int MP4_ReadBox_dref( stream_t *p_stream, MP4_Box_t *p_box )
{
MP4_READBOX_ENTER( MP4_Box_data_dref_t );
MP4_GETVERSIONFLAGS( p_box->data.p_dref );
MP4_GET4BYTES( p_box->data.p_dref->i_entry_count );
stream_Seek( p_stream, p_box->i_pos + mp4_box_headersize( p_box ) + 8 );
MP4_ReadBoxContai... | safe | 24 |
void iscsi_session_teardown(struct iscsi_cls_session *cls_session)
{
struct iscsi_session *session = cls_session->dd_data;
struct module *owner = cls_session->transport->owner;
struct Scsi_Host *shost = session->host;
iscsi_pool_free(&session->cmdpool);
iscsi_remove_session(cls_session);
kfree(session->passwor... | safe | 25 |
map_token (const value_valuestring *token_map, guint8 codepage, guint8 token) {
const value_string *vs;
const char *s;
if (token_map) { /* Found map */
if ((vs = val_to_valstr (codepage, token_map))) {
/* Found codepage map */
s = try_val_to_str (token, vs);
if (s) { /* Found valid token */
D... | safe | 26 |
void part_round_stats(struct request_queue *q, int cpu, struct hd_struct *part)
{
struct hd_struct *part2 = NULL;
unsigned long now = jiffies;
unsigned int inflight[2];
int stats = 0;
if (part->stamp != now)
stats |= 1;
if (part->partno) {
part2 = &part_to_disk(part)->part0;
if (part2->stamp != now)
st... | safe | 27 |
struct platform_device *platform_device_register_full(
const struct platform_device_info *pdevinfo)
{
int ret;
struct platform_device *pdev;
pdev = platform_device_alloc(pdevinfo->name, pdevinfo->id);
if (!pdev)
return ERR_PTR(-ENOMEM);
pdev->dev.parent = pdevinfo->parent;
pdev->dev.fwnode = pdevinfo->fwnod... | safe | 28 |
get_next_address(
address_node *addr
)
{
const char addr_prefix[] = "192.168.0.";
static int curr_addr_num = 1;
#define ADDR_LENGTH 16 + 1 /* room for 192.168.1.255 */
char addr_string[ADDR_LENGTH];
sockaddr_u *final_addr;
struct addrinfo *ptr;
int gai_err;
final_addr = emalloc(sizeof(*final_addr));
if (add... | safe | 29 |
static void tracing_start_tr(struct trace_array *tr)
{
struct ring_buffer *buffer;
unsigned long flags;
if (tracing_disabled)
return;
/* If global, we need to also start the max tracer */
if (tr->flags & TRACE_ARRAY_FL_GLOBAL)
return tracing_start();
raw_spin_lock_irqsave(&tr->start_lock, flags);
if (--t... | safe | 30 |
}
EXPORT_SYMBOL_GPL(iscsi_unblock_session);
static void __iscsi_block_session(struct work_struct *work)
{
struct iscsi_cls_session *session =
container_of(work, struct iscsi_cls_session,
block_work);
unsigned long flags;
ISCSI_DBG_TRANS_SESSION(session, "Blocking session\n");
spin_lock_irqsave(&sessio... | safe | 31 |
delete_nsec(dns_db_t *db, dns_dbversion_t *ver, dns_dbnode_t *node,
dns_name_t *name, dns_diff_t *diff)
{
dns_rdataset_t rdataset;
isc_result_t result;
dns_rdataset_init(&rdataset);
result = dns_db_findrdataset(db, node, ver, dns_rdatatype_nsec,
0, 0, &rdataset, NULL);
if (result == ISC_R_NOTFOUND)... | safe | 32 |
static bool checkreturn pb_dec_bytes(pb_istream_t *stream, const pb_field_t *field, void *dest)
{
uint32_t size;
size_t alloc_size;
pb_bytes_array_t *bdest;
if (!pb_decode_varint32(stream, &size))
return false;
alloc_size = PB_BYTES_ARRAY_T_ALLOCSIZE(size);
if (size > alloc_siz... | safe | 33 |
aac_type_find_scan_loas_frames_ep (GstTypeFind * tf, DataScanCtx * scan_ctx,
gint max_frames)
{
DataScanCtx c = *scan_ctx;
guint16 snc;
guint len;
gint count = 0;
do {
if (!data_scan_ctx_ensure_data (tf, &c, 5))
break;
/* EPAudioSyncStream */
len = ((c.data[2] & 0x0f) << 9) | (c.data[3... | safe | 34 |
_g_path_is_parent_of (const char *dirname,
const char *filename)
{
int dirname_l, filename_l, separator_position;
if ((dirname == NULL) || (filename == NULL))
return FALSE;
dirname_l = strlen (dirname);
filename_l = strlen (filename);
if ((dirname_l == filename_l + 1)
&& (dirname[dirname_l - 1] ... | safe | 35 |
string_append_listele(uschar * list, uschar sep, const uschar * ele)
{
uschar * new = NULL;
int sz = 0, off = 0;
uschar * sp;
if (list)
{
new = string_cat(new, &sz, &off, list, Ustrlen(list));
new = string_cat(new, &sz, &off, &sep, 1);
}
while((sp = Ustrchr(ele, sep)))
{
new = string_cat(new, &sz, &off, e... | safe | 36 |
xmlNewTextChild(xmlNodePtr parent, xmlNsPtr ns,
const xmlChar *name, const xmlChar *content) {
xmlNodePtr cur, prev;
if (parent == NULL) {
#ifdef DEBUG_TREE
xmlGenericError(xmlGenericErrorContext,
"xmlNewTextChild : parent == NULL\n");
#endif
return(NULL);
}
if (name == NULL) {
... | safe | 37 |
MODULE_ENTRY (fill_info) (GdkPixbufFormat *info)
{
static const GdkPixbufModulePattern signature[] = {
{ " \x1\x1", "x ", 100 },
{ " \x1\x9", "x ", 100 },
{ " \x2", "xz ", 99 }, /* only 99 since .CUR also matches this */
{ " \x3", "xz ", 100 },
{ " \xa", "xz ", 100 },
{ " \xb", "xz ", 100 },
{ NUL... | safe | 38 |
longlong Field::convert_decimal2longlong(const my_decimal *val,
bool unsigned_flag, int *err)
{
longlong i;
if (unsigned_flag)
{
if (val->sign())
{
set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1);
i= 0;
*err= 1;
}
else if (warn_if_overflow(my_de... | safe | 39 |
main(int argc, char *argv[])
{
oid objid[MAX_OID_LEN];
int objidlen = MAX_OID_LEN;
int count;
netsnmp_variable_list variable;
netsnmp_init_mib();
if (argc < 2)
print_subtree(stdout, tree_head, 0);
variable.type = ASN_INTEGER;
variable.val.inte... | safe | 40 |
int fpm_unix_resolve_socket_premissions(struct fpm_worker_pool_s *wp) /* {{{ */
{
struct fpm_worker_pool_config_s *c = wp->config;
/* uninitialized */
wp->socket_uid = -1;
wp->socket_gid = -1;
wp->socket_mode = 0660;
if (!c) {
return 0;
}
if (c->listen_owner && *c->listen_owner) {
struct passwd *pwd;
... | safe | 41 |
ex_tabs(exarg_T *eap UNUSED)
{
tabpage_T *tp;
win_T *wp;
int tabcount = 1;
msg_start();
msg_scroll = TRUE;
for (tp = first_tabpage; tp != NULL && !got_int; tp = tp->tp_next)
{
msg_putchar('\n');
vim_snprintf((char *)IObuff, IOSIZE, _("Tab page %d"), tabcount++);
msg_outtrans_attr(IObuff... | safe | 42 |
static __init void vmx_set_cpu_caps(void)
{
kvm_set_cpu_caps();
/* CPUID 0x1 */
if (nested)
kvm_cpu_cap_set(X86_FEATURE_VMX);
/* CPUID 0x7 */
if (kvm_mpx_supported())
kvm_cpu_cap_check_and_set(X86_FEATURE_MPX);
if (!cpu_has_vmx_invpcid())
kvm_cpu_cap_clear(X86_FEATURE_INVPCID);
if (vmx_pt_mode_is_host_gu... | safe | 43 |
list_terms()
{
int i;
char *line_buffer = gp_alloc(BUFSIZ, "list_terms");
int sort_idxs[TERMCOUNT];
/* sort terminal types alphabetically */
for( i = 0; i < TERMCOUNT; i++ )
sort_idxs[i] = i;
qsort( sort_idxs, TERMCOUNT, sizeof(int), termcomp );
/* now sort_idxs[] contains the sorted indic... | safe | 44 |
PHP_METHOD(HttpParams, offsetGet)
{
char *name_str;
int name_len;
zval **zparam, *zparams;
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name_str, &name_len)) {
return;
}
zparams = php_http_ztyp(IS_ARRAY, zend_read_property(php_http_params_class_entry, getThis(), ZEND_STRL("params"), 0... | safe | 45 |
void TCDeleteDeviceObject (PDEVICE_OBJECT DeviceObject, PEXTENSION Extension)
{
UNICODE_STRING Win32NameString;
NTSTATUS ntStatus;
Dump ("TCDeleteDeviceObject BEGIN\n");
if (Extension->bRootDevice)
{
RtlInitUnicodeString (&Win32NameString, (LPWSTR) DOS_ROOT_PREFIX);
ntStatus = IoDeleteSymbolicLink (&Win32Nam... | safe | 46 |
static int nfc_genl_disable_se(struct sk_buff *skb, struct genl_info *info)
{
struct nfc_dev *dev;
int rc;
u32 idx, se_idx;
if (!info->attrs[NFC_ATTR_DEVICE_INDEX] ||
!info->attrs[NFC_ATTR_SE_INDEX])
return -EINVAL;
idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
se_idx = nla_get_u32(info->attrs[N... | safe | 47 |
return err;
}
static int iscsi_logout_flashnode(struct iscsi_transport *transport,
struct iscsi_uevent *ev)
{
struct Scsi_Host *shost;
struct iscsi_bus_flash_session *fnode_sess;
struct iscsi_bus_flash_conn *fnode_conn;
struct device *dev;
uint32_t idx;
int err = 0;
if (!transport->logout_flashnode) {
... | safe | 48 |
struct file *do_file_open_root(struct dentry *dentry, struct vfsmount *mnt,
const char *name, const struct open_flags *op)
{
struct nameidata nd;
struct file *file;
struct filename *filename;
int flags = op->lookup_flags | LOOKUP_ROOT;
nd.root.mnt = mnt;
nd.root.dentry = dentry;
if (d_is_symlink(dentry) && o... | safe | 49 |
string_endswith(PyStringObject *self, PyObject *args)
{
Py_ssize_t start = 0;
Py_ssize_t end = PY_SSIZE_T_MAX;
PyObject *subobj;
int result;
if (!stringlib_parse_args_finds("endswith", args, &subobj, &start, &end))
return NULL;
if (PyTuple_Check(subobj)) {
Py_ssize_t i;
... | safe | 50 |
static void test_conditional_updates()
{
json_t *object, *other;
object = json_pack("{sisi}", "foo", 1, "bar", 2);
other = json_pack("{sisi}", "foo", 3, "baz", 4);
if(json_object_update_existing(object, other))
fail("json_object_update_existing failed");
if(json_object_size(object) != 2)
... | safe | 51 |
b64flush(bs, outp)
struct b64state *bs;
u_char *outp;
{
int outlen = 0;
if (bs->bs_offs == 8) {
*outp++ = base64[(bs->bs_bits >> 2) & 0x3F];
*outp++ = base64[(bs->bs_bits << 4) & 0x3F];
outlen = 2;
} else if (bs->bs_offs == 16) {
*outp++ = base64[(bs->bs_bits >> 10) & 0x3F];
*outp++ = base64[(bs->bs_bits ... | safe | 52 |
static void account_shadowed(struct kvm *kvm, struct kvm_mmu_page *sp)
{
struct kvm_memslots *slots;
struct kvm_memory_slot *slot;
gfn_t gfn;
kvm->arch.indirect_shadow_pages++;
gfn = sp->gfn;
slots = kvm_memslots_for_spte_role(kvm, sp->role);
slot = __gfn_to_memslot(slots, gfn);
/* the non-leaf shadow pages a... | safe | 53 |
decode_NXAST_RAW_LEARN2(const struct nx_action_learn2 *nal,
enum ofp_version ofp_version OVS_UNUSED,
const struct vl_mff_map *vl_mff_map,
uint64_t *tlv_bitmap, struct ofpbuf *ofpacts)
{
struct ofpbuf b = ofpbuf_const_initializer(nal, ntohs(nal-... | safe | 54 |
CMS_ContentInfo *CMS_encrypt(STACK_OF(X509) *certs, BIO *data,
const EVP_CIPHER *cipher, unsigned int flags)
{
CMS_ContentInfo *cms;
int i;
X509 *recip;
cms = CMS_EnvelopedData_create(cipher);
if (!cms)
goto merr;
for (i = 0; i < sk_X509_num(certs); i++)
{
recip = sk_X509_value(certs, i);
if (!CMS_ad... | safe | 55 |
flatpak_remote_state_lookup_cache (FlatpakRemoteState *self,
const char *ref,
guint64 *download_size,
guint64 *installed_size,
const char **met... | safe | 56 |
void jpc_qmfb_split_col(jpc_fix_t *a, int numrows, int stride,
int parity)
{
int bufsize = JPC_CEILDIVPOW2(numrows, 1);
jpc_fix_t splitbuf[QMFB_SPLITBUFSIZE];
jpc_fix_t *buf = splitbuf;
register jpc_fix_t *srcptr;
register jpc_fix_t *dstptr;
register int n;
register int m;
int hstartrow;
/* Get a buffer. *... | safe | 57 |
_PRIVATE_ int ldb_register_extended_match_rules(struct ldb_context *ldb)
{
struct ldb_extended_match_rule *bitmask_and;
struct ldb_extended_match_rule *bitmask_or;
struct ldb_extended_match_rule *always_false;
int ret;
/* Register bitmask-and match */
bitmask_and = talloc_zero(ldb, struct ldb_extended_match_rule... | safe | 58 |
void SSL_copy_session_id(SSL *t, const SSL *f)
{
CERT *tmp;
/* Do we need to to SSL locking? */
SSL_set_session(t, SSL_get_session(f));
/*
* what if we are setup as SSLv2 but want to talk SSLv3 or vice-versa
*/
if (t->method != f->method) {
t->method->ssl_free(t); /* cleanup curr... | safe | 59 |
cp_buffer_from_ref(THD *thd, TABLE *table, TABLE_REF *ref)
{
enum enum_check_fields save_count_cuted_fields= thd->count_cuted_fields;
thd->count_cuted_fields= CHECK_FIELD_IGNORE;
MY_BITMAP *old_map= dbug_tmp_use_all_columns(table, &table->write_set);
bool result= 0;
for (store_key **copy=ref->key_copy ; *cop... | safe | 60 |
int compat_sock_get_timestampns(struct sock *sk, struct timespec __user *userstamp)
{
struct compat_timespec __user *ctv;
int err;
struct timespec ts;
if (COMPAT_USE_64BIT_TIME)
return sock_get_timestampns (sk, userstamp);
ctv = (struct compat_timespec __user *) userstamp;
err = -ENOENT;
if (!sock_flag(sk, S... | safe | 61 |
ath6kl_usb_alloc_urb_from_pipe(struct ath6kl_usb_pipe *pipe)
{
struct ath6kl_urb_context *urb_context = NULL;
unsigned long flags;
/* bail if this pipe is not initialized */
if (!pipe->ar_usb)
return NULL;
spin_lock_irqsave(&pipe->ar_usb->cs_lock, flags);
if (!list_empty(&pipe->urb_list_head)) {
urb_context... | safe | 62 |
static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
{
int ret;
if (!ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN))
return -EPERM;
switch (cmd) {
case ARPT_SO_GET_INFO:
ret = get_info(sock_net(sk), user, len, 0);
break;
case ARPT_SO_GET_ENTRIES:
ret = get_entries(sock_net... | safe | 63 |
mysql_ssl_set(MYSQL *mysql __attribute__((unused)) ,
const char *key __attribute__((unused)),
const char *cert __attribute__((unused)),
const char *ca __attribute__((unused)),
const char *capath __attribute__((unused)),
const char *cipher __attribute__((unused)))
{
DBUG_ENTER("mysql... | safe | 64 |
static void fdctrl_handle_relative_seek_in(FDCtrl *fdctrl, int direction)
{
FDrive *cur_drv;
SET_CUR_DRV(fdctrl, fdctrl->fifo[1] & FD_DOR_SELMASK);
cur_drv = get_cur_drv(fdctrl);
if (fdctrl->fifo[2] + cur_drv->track >= cur_drv->max_track) {
fd_seek(cur_drv, cur_drv->head, cur_drv->max_track - 1... | safe | 65 |
mono_image_get_generic_param_info (MonoReflectionGenericParam *gparam, guint32 owner, MonoDynamicImage *assembly)
{
GenericParamTableEntry *entry;
/*
* The GenericParam table must be sorted according to the `owner' field.
* We need to do this sorting prior to writing the GenericParamConstraint
* table, since w... | safe | 66 |
TEST_P(DownstreamProtocolIntegrationTest, ManyRequestTrailersRejected) {
// Default header (and trailer) count limit is 100.
config_helper_.addConfigModifier(setEnableDownstreamTrailersHttp1());
config_helper_.addConfigModifier(setEnableUpstreamTrailersHttp1());
Http::TestRequestTrailerMapImpl request_trailers;... | safe | 67 |
static int sd_ioctl(struct block_device *bdev, fmode_t mode,
unsigned int cmd, unsigned long arg)
{
struct gendisk *disk = bdev->bd_disk;
struct scsi_disk *sdkp = scsi_disk(disk);
struct scsi_device *sdp = sdkp->device;
void __user *p = (void __user *)arg;
int error;
SCSI_LOG_IOCTL(1, sd_printk(KERN_IN... | safe | 68 |
PJ_DEF(unsigned) pjmedia_sdp_attr_remove_all(unsigned *count,
pjmedia_sdp_attr *attr_array[],
const char *name)
{
unsigned i, removed = 0;
pj_str_t attr_name;
PJ_ASSERT_RETURN(count && attr_array && name, PJ_EINVAL);
PJ_ASSERT_RETURN(*count <= PJMEDIA_MAX_SDP_ATTR, PJ_ETOOMANY);
... | safe | 69 |
static void aesni_gcm_dec_avx2(void *ctx, u8 *out,
const u8 *in, unsigned long ciphertext_len, u8 *iv,
u8 *hash_subkey, const u8 *aad, unsigned long aad_len,
u8 *auth_tag, unsigned long auth_tag_len)
{
struct crypto_aes_ctx *aes_ctx = (struct crypto_aes_ctx*)ctx;
if ((ciphertext_len < AVX_GEN2_OPTSIZE)... | safe | 70 |
static void xgmac_enet_realize(DeviceState *dev, Error **errp)
{
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
XgmacState *s = XGMAC(dev);
memory_region_init_io(&s->iomem, OBJECT(s), &enet_mem_ops, s,
"xgmac", 0x1000);
sysbus_init_mmio(sbd, &s->iomem);
sysbus_init_irq(sbd, &s->... | safe | 71 |
void FoFiTrueType::cvtCharStrings(char **encoding,
int *codeToGID,
FoFiOutputFunc outputFunc,
void *outputStream) {
char *name;
GooString *buf;
char buf2[16];
int i, k;
// always define '.notdef'
(*outputFunc)(outputStream, "/CharStrings 256 dict dup begin\n", 32);
(*outputFunc)(outputS... | safe | 72 |
static int mxf_read_track(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
{
MXFTrack *track = arg;
switch(tag) {
case 0x4801:
track->track_id = avio_rb32(pb);
break;
case 0x4804:
avio_read(pb, track->track_number, 4);
break;
case 0x4802:
... | safe | 73 |
int modbus_mask_write_register(modbus_t *ctx, int addr, uint16_t and_mask, uint16_t or_mask)
{
int rc;
int req_length;
/* The request length can not exceed _MIN_REQ_LENGTH - 2 and 4 bytes to
* store the masks. The ugly substraction is there to remove the 'nb' value
* (2 bytes) which is not used. *... | safe | 74 |
int orangefs_init_acl(struct inode *inode, struct inode *dir)
{
struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode);
struct posix_acl *default_acl, *acl;
umode_t mode = inode->i_mode;
int error = 0;
ClearModeFlag(orangefs_inode);
error = posix_acl_create(dir, &mode, &default_acl, &acl);
if (error)
re... | safe | 75 |
lys_is_disabled(const struct lys_node *node, int recursive)
{
FUN_IN;
int i;
if (!node) {
return NULL;
}
check:
if (node->nodetype != LYS_INPUT && node->nodetype != LYS_OUTPUT) {
/* input/output does not have if-feature, so skip them */
/* check local if-features */
... | safe | 76 |
static CURLMcode add_next_timeout(struct timeval now,
struct Curl_multi *multi,
struct Curl_easy *d)
{
struct timeval *tv = &d->state.expiretime;
struct curl_llist *list = d->state.timeoutlist;
struct curl_llist_element *e;
/* move over the ti... | safe | 77 |
static unsigned int xdr_shrink_pagelen(struct xdr_buf *buf, unsigned int len)
{
unsigned int shift, buflen = buf->len - buf->head->iov_len;
WARN_ON_ONCE(len > buf->page_len);
if (buf->head->iov_len >= buf->len || len > buflen)
buflen = len;
if (buf->page_len > buflen) {
buf->buflen -= buf->page_len - buflen;
... | safe | 78 |
cmsSEQ* CMSEXPORT cmsAllocProfileSequenceDescription(cmsContext ContextID, cmsUInt32Number n)
{
cmsSEQ* Seq;
cmsUInt32Number i;
if (n == 0) return NULL;
// In a absolutely arbitrary way, I hereby decide to allow a maxim of 255 profiles linked
// in a devicelink. It makes not sense anyway and may b... | safe | 79 |
static PHP_NAMED_FUNCTION(zif_zip_read)
{
zval *zip_dp;
zip_read_rsrc *zr_rsrc;
int ret;
zip_rsrc *rsrc_int;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &zip_dp) == FAILURE) {
return;
}
if ((rsrc_int = (zip_rsrc *)zend_fetch_resource(Z_RES_P(zip_dp), le_zip_dir_name, le_zip_dir)) == NULL) {
RETURN_FALS... | safe | 80 |
START_TEST(ratelimit_helpers)
{
struct ratelimit rl;
unsigned int i, j;
/* 10 attempts every 1000ms */
ratelimit_init(&rl, ms2us(1000), 10);
for (j = 0; j < 3; ++j) {
/* a burst of 9 attempts must succeed */
for (i = 0; i < 9; ++i) {
ck_assert_int_eq(ratelimit_test(&rl),
RATELIMIT_PASS);
}
/* t... | safe | 81 |
static int compat_getdrvstat(int drive, bool poll,
struct compat_floppy_drive_struct __user *arg)
{
struct compat_floppy_drive_struct v;
memset(&v, 0, sizeof(struct compat_floppy_drive_struct));
mutex_lock(&floppy_mutex);
if (poll) {
if (lock_fdc(drive))
goto Eintr;
if (poll_drive(true, FD_RAW_NEED_... | safe | 82 |
long posix_cpu_nsleep_restart(struct restart_block *restart_block)
{
clockid_t which_clock = restart_block->arg0;
struct timespec __user *rmtp;
struct timespec t;
struct itimerspec it;
int error;
rmtp = (struct timespec __user *) restart_block->arg1;
t.tv_sec = restart_block->arg2;
t.tv_nsec = restart_block->a... | safe | 83 |
uint32 CSoundFile::CalculateXParam(PATTERNINDEX pat, ROWINDEX row, CHANNELINDEX chn, bool *isExtended) const
{
if(isExtended != nullptr) *isExtended = false;
ROWINDEX maxCommands = 4;
const ModCommand *m = Patterns[pat].GetpModCommand(row, chn);
uint32 val = m->param;
switch(m->command)
{
case CMD_OFFSET:
// ... | safe | 84 |
PJ_DEF(char*) pjsip_rx_data_get_info(pjsip_rx_data *rdata)
{
char obj_name[PJ_MAX_OBJ_NAME];
PJ_ASSERT_RETURN(rdata->msg_info.msg, "INVALID MSG");
if (rdata->msg_info.info)
return rdata->msg_info.info;
pj_ansi_strcpy(obj_name, "rdata");
pj_ansi_snprintf(obj_name+5, sizeof(obj_name)-5, "%p", rdat... | safe | 85 |
static inline int user_regset_copyout_zero(unsigned int *pos,
unsigned int *count,
void **kbuf, void __user **ubuf,
const int start_pos,
const int end_pos)
{
if (*count == 0)
return 0;
BUG_ON(*pos < start_pos);
if (end_pos < 0 || *pos < end_pos) {
unsigned int copy = (end_pos < 0 ... | safe | 86 |
rb_str_buf_append(str, str2)
VALUE str, str2;
{
long capa, len;
rb_str_modify(str);
if (FL_TEST(str, STR_ASSOC)) {
FL_UNSET(str, STR_ASSOC);
capa = RSTRING(str)->aux.capa = RSTRING(str)->len;
}
else {
capa = RSTRING(str)->aux.capa;
}
len = RSTRING(str)->len+RSTRING(str2)->len;
if... | safe | 87 |
static int check_helper_mem_access(struct bpf_verifier_env *env, int regno,
int access_size, bool zero_size_allowed,
struct bpf_call_arg_meta *meta)
{
struct bpf_reg_state *regs = cur_regs(env), *reg = ®s[regno];
switch (reg->type) {
case PTR_TO_PACKET:
case PTR_TO_PACKET_META:
return check_pack... | safe | 88 |
static void *ffs_acquire_dev(const char *dev_name)
{
struct ffs_dev *ffs_dev;
ENTER();
ffs_dev_lock();
ffs_dev = _ffs_find_dev(dev_name);
if (!ffs_dev)
ffs_dev = ERR_PTR(-ENOENT);
else if (ffs_dev->mounted)
ffs_dev = ERR_PTR(-EBUSY);
else if (ffs_dev->ffs_acquire_dev_callback &&
ffs_dev->ffs_acquire_d... | safe | 89 |
static noinline int mmc_ioctl_cdrom_subchannel(struct cdrom_device_info *cdi,
void __user *arg)
{
int ret;
struct cdrom_subchnl q;
u_char requested, back;
if (copy_from_user(&q, (struct cdrom_subchnl __user *)arg, sizeof(q)))
return -EFAULT;
requested = q.cdsc_format;
if (!((requested == CDROM_MSF) ... | safe | 90 |
void AsyncConnection::DelayedDelivery::flush() {
stop_dispatch = true;
center->submit_to(
center->get_id(), [this] () mutable {
std::lock_guard<std::mutex> l(delay_lock);
while (!delay_queue.empty()) {
Message *m = delay_queue.front().second;
if (msgr->ms_can_fast_dispatch(m)) {
di... | safe | 91 |
void addrconf_dad_failure(struct inet6_ifaddr *ifp)
{
struct inet6_dev *idev = ifp->idev;
if (addrconf_dad_end(ifp)) {
in6_ifa_put(ifp);
return;
}
net_info_ratelimited("%s: IPv6 duplicate address %pI6c detected!\n",
ifp->idev->dev->name, &ifp->addr);
if (idev->cnf.accept_dad > 1 && !idev->cnf.disabl... | safe | 92 |
static int buffer_want_with_caps(const git_remote_head *head, transport_smart_caps *caps, git_buf *buf)
{
git_buf str = GIT_BUF_INIT;
char oid[GIT_OID_HEXSZ +1] = {0};
size_t len;
/* Prefer multi_ack_detailed */
if (caps->multi_ack_detailed)
git_buf_puts(&str, GIT_CAP_MULTI_ACK_DETAILED " ");
else if (caps->mu... | safe | 93 |
template<typename tp, typename tf, typename tc, typename to>
CImg<T>& draw_object3d(LibBoard::Board& board,
const float x0, const float y0, const float z0,
const CImg<tp>& vertices, const CImgList<tf>& primitives,
const CImgList<tc... | safe | 94 |
GF_Err gf_isom_update_sample(GF_ISOFile *movie, u32 trackNumber, u32 sampleNumber, GF_ISOSample *sample, Bool data_only)
{
GF_Err e;
GF_TrackBox *trak;
e = CanAccessMovie(movie, GF_ISOM_OPEN_EDIT);
if (e) return e;
trak = gf_isom_get_track_from_file(movie, trackNumber);
if (!trak) return GF_BAD_PARAM;
e = unp... | safe | 95 |
void fslib_duplicate(const char *full_path) {
assert(full_path);
struct stat s;
if (stat(full_path, &s) != 0 || s.st_uid != 0 || access(full_path, R_OK))
return;
char *dest_dir = build_dest_dir(full_path);
// don't copy it if the file is already there
char *ptr = strrchr(full_path, '/');
if (!ptr)
return;... | safe | 96 |
static int sdp_parse_fmtp_config_h264(AVFormatContext *s,
AVStream *stream,
PayloadContext *h264_data,
const char *attr, const char *value)
{
AVCodecParameters *par = stream->codecpar;
if (!strcmp(... | safe | 97 |
nf_tables_chain_type_lookup(struct net *net, const struct nlattr *nla,
u8 family, bool autoload)
{
const struct nft_chain_type *type;
type = __nf_tables_chain_type_lookup(nla, family);
if (type != NULL)
return type;
lockdep_nfnl_nft_mutex_not_held();
#ifdef CONFIG_MODULES
if (autoload) {
if (nft_reque... | safe | 98 |
parsecreateopres(netdissect_options *ndo,
const uint32_t *dp, int verbose)
{
int er;
if (!(dp = parsestatus(ndo, dp, &er)))
return (0);
if (er)
dp = parse_wcc_data(ndo, dp, verbose);
else {
ND_TCHECK(dp[0]);
if (!EXTRACT_32BITS(&dp[0]))
return (dp + 1);
dp++;
if (!(dp = parsefh(ndo,... | safe | 99 |
A minified, clean and annotated version of DiverseVul
Dataset Summary
This is a minified, clean and deduplicated version of the DiverseVul dataset.
We publish this version to help practionners in their code vulnerability detection research.
Data Structure & Overview
- Number of samples: 23847
- Features:
func(the C/C++ code)cwe(the CWE weakness, see table below) - Supported Programming Languages: C/C++
- Supported CWE Weaknesses:
Label Description CWE-119 Improper Restriction of Operations within the Bounds of a Memory Buffer CWE-125 Out-of-bounds Read CWE-20 Improper Input Validation CWE-416 Use After Free CWE-703 Improper Check or Handling of Exceptional Conditions CWE-787 Out-of-bounds Write safe Safe code
Cleaning & Preprocessing
The original dataset contains 18,945 vulnerable functions spanning 150 CWEs and 330,492 non-vulnerable functions extracted from 7,514 commits, according to the original paper.
We constructed the minified version through the following steps: We cleaned the original dataset by removing null values and removing deduplicates (keeping the first occurance only). We then randomly sampled 19271 'safe' functions that have between 50 and 595 tokens (tokenized using ModernBERT-base's tokenizer, special tokens excluded). The majority of function have between 200 and 595, a small fraction that have between 50 and 200 tokens were randomly added for the sake of diversification. The safe label's token distribution is as follows:
To construct the unsafe labels, we only kept the six most frequent CWE weaknesses (see table above).
We also noticed that the unsafe functions are very long (token wise): The average token length was around 1200 and the median token length was arround 512.
We built this dataset to use it for fine-tuning ModernBERT-base. For compute reasons, we decided to only keep functions that have less than 595 tokens, just like the safe label. In case you want different token lengths, we provide the github repository to re construct the dataset. The unsafe labels have the following token distribution:
Application
We publish this minified dataset to help researchers with low compute resources in their code vulnerability research projects.
This dataset was also used to fine tune ThreatDetect-C-Cpp.
More Details & Acknowledgements
You can find all the code on our Github Repository. We deeply thank the mainteners of the DiverseVul dataset.
- Downloads last month
- 26

