type stringclasses 5
values | content stringlengths 9 163k |
|---|---|
functions | void __rb_rotate_right(struct AMCDict *dict, struct AMCDictNode *node)
{
struct AMCDictNode *prevLeft = node->left;
struct AMCDictNode *prevLeftRight = node->left->right;
_DEBUG("Rotate right %s", node->key);
if (_rb_node_is_root(node))
{
dict->children = prevLeft;
node->parent = prevLeft;
node->left = p... |
functions | void __rb_check_insert(struct AMCDict *dict, struct AMCDictNode *node)
{
struct AMCDictNode *uncleNode = node->parent ? _rb_brother_node(node->parent) : NULL;
if (_rb_node_is_root(node)) // root node. This is impossible because it is done previously
{
_DEBUG("MARK (%s) case 1", node->key);
_SET_BLACK(nod... |
functions | AMCDictErrno_st _rb_insert(struct AMCDict *dict, const char *key, void *value, BOOL replaceWhenConflict, BOOL shouldFree, BOOL *isDuplicated)
{
struct AMCDictNode *node = dict->children;
struct AMCDictNode *newNode = NULL;
AMCDictErrno_st error = {0, 0} |
functions | AMCDictErrno_st _rb_delete_leaf(struct AMCDict *dict, struct AMCDictNode *node, BOOL freeObject)
{
AMCDictErrno_st error = {0, 0} |
functions | void _rb_read_node_status(const struct AMCDictNode *node, BOOL *hasChild, BOOL *hasTwoChild, BOOL *hasLeftChild, BOOL *hasRightChild)
{
if (node->left)
{
if (node->right)
{
*hasChild = TRUE;
*hasTwoChild = TRUE;
*hasLeftChild = TRUE;
*hasRightChild = TRUE;
} |
functions | void __rb_delete_node_and_reconnect_with(struct AMCDict *dict, struct AMCDictNode *nodeToDel, struct AMCDictNode *nodeToReplace)
{
if (_rb_node_is_root(nodeToDel))
{
dict->count --;
dict->children = nodeToReplace;
nodeToReplace->parent = NULL;
} |
functions | void __rb_check_delete_node_case_6(struct AMCDict *dict, struct AMCDictNode *node)
{
struct AMCDictNode *sibling = _rb_brother_node(node->parent);
sibling->color = node->parent->color;
_SET_BLACK(node->parent);
if (node == node->parent->left) {
_SET_BLACK(sibling->right);
__rb_rotate_left(dict, node->parent);... |
functions | void __rb_check_delete_node_case_5(struct AMCDict *dict, struct AMCDictNode *node)
{
struct AMCDictNode *sibling = _rb_brother_node(node->parent);
BOOL sblLeftIsBlack = (sibling->left) ? _IS_BLACK(sibling->left) : TRUE;
BOOL sblRightIsBlack = (sibling->right) ? _IS_BLACK(sibling->right) : TRUE;
if (_IS_RED(sibling... |
functions | void __rb_check_delete_node_case_4(struct AMCDict *dict, struct AMCDictNode *node)
{
struct AMCDictNode *sibling = _rb_brother_node(node->parent);
BOOL sblLeftIsBlack = (sibling->left) ? _IS_BLACK(sibling->left) : TRUE;
BOOL sblRightIsBlack = (sibling->right) ? _IS_BLACK(sibling->right) : TRUE;
if (_IS_RED(node->p... |
functions | void __rb_check_delete_node_case_3(struct AMCDict *dict, struct AMCDictNode *node)
{
struct AMCDictNode *sibling = _rb_brother_node(node->parent);
BOOL sblLeftIsBlack = (sibling->left) ? _IS_BLACK(sibling->left) : TRUE;
BOOL sblRightIsBlack = (sibling->right) ? _IS_BLACK(sibling->right) : TRUE;
if (_IS_BLACK(node-... |
functions | void __rb_check_delete_node_case_2(struct AMCDict *dict, struct AMCDictNode *node)
{
struct AMCDictNode *sibling = _rb_brother_node(node);
if (_IS_RED(sibling))
{_DEBUG("DEL: case 2");
_SET_RED(node->parent);
_SET_BLACK(sibling);
if (node == node->parent->left) {
__rb_rotate_left(dict, node->parent);
... |
functions | void __rb_check_delete_node_case_1(struct AMCDict *dict, struct AMCDictNode *node)
{
/* let's operate with diferent cases */
if (_rb_node_is_root(node))
{_DEBUG("DEL: case 1");
return;
} |
functions | AMCDictErrno_st _rb_delete_node(struct AMCDict *dict, struct AMCDictNode *node, BOOL freeObject)
{
AMCDictErrno_st error = {0, 0} |
functions | else if (nodeHasTwoChildren)
{_DEBUG("DEL: node %s has 2 children", node->key);
struct AMCDictNode *smallestRightChild = _rb_find_min_leaf(node->right);
/* replace with smallest node */
strcpy(node->key, smallestRightChild->key);
node->value = smallestRightChild->value;
/* start operation with the smallest... |
functions | AMCDictErrno_st _rb_delete_node_in_dict(struct AMCDict *dict, const char *key, BOOL freeObject)
{
AMCDictErrno_st error = {0, 0} |
functions | void __rb_dump_tabs(unsigned long tabCount, FILE *file)
{
unsigned long tmp;
for (tmp = 0; tmp < tabCount; tmp++)
{
fprintf(file, "\t");
} |
functions | void _rb_dump_node(const struct AMCDictNode *node, unsigned long tabCount, FILE *file)
{
/* self */
__rb_dump_tabs(tabCount, file);
if (_IS_BLACK(node)) {
fprintf(file, "\033[0;43mNode\033[0m %p [%p] [%s]\n", node, node->value, node->key);
} |
functions | void _rb_dump_dictionary(struct AMCDict *dict, FILE *file)
{
if (NULL == dict->children)
{
fprintf(file, "AMCDictionary %p, count: 0\n", dict);
return;
} |
functions | int _check_and_init_amc_dictionary()
{
if (NULL == g_node_mem_pool) {
g_node_mem_pool = AMCMemPool_Create(sizeof(struct AMCDictNode), g_item_init_size, g_item_inc_size, TRUE);
} |
functions | AMCDictErrno_st _free_node_and_its_children(struct AMCDictNode *node, BOOL freeObjects)
{
/* free children */
if (node->left) {
_free_node_and_its_children(node->left, freeObjects);
} |
functions | AMCDictErrno_st AMCDictionary_GlobalConfig(ssize_t initDictCount, ssize_t growDictCount, ssize_t initItemCount, ssize_t growItemCount)
{
AMCDictErrno_st ret = {0, 0} |
functions | AMCDictErrno_st AMCDictionary_Free(AMCDictionary_st *dict, BOOL freeObjects)
{
if (NULL == dict) {
return _make_error(AMC_DICT_INVALID_PARAMETER);
} |
functions | size_t AMCDictionary_Count(const AMCDictionary_st *dict)
{
if (NULL == dict) {
return 0;
} |
functions | AMCDictErrno_st AMCDictionary_SetObject(AMCDictionary_st *dict, void *object, const char *key, BOOL freeOldObject, BOOL *pOverwritten)
{
AMCDictErrno_st error = {0, 0} |
functions | AMCDictErrno_st AMCDictionary_AddObject(AMCDictionary_st *dict, void *object, const char *key)
{
AMCDictErrno_st error = {0, 0} |
functions | AMCDictErrno_st AMCDictionary_UpdateObject(AMCDictionary_st *dict, void *object, const char *key, BOOL freeOldObject)
{
AMCDictErrno_st error = {0, 0} |
functions | AMCDictErrno_st AMCDictionary_RemoveObject(AMCDictionary_st *dict, const char *key, BOOL freeObject)
{
AMCDictErrno_st error = {0, 0} |
functions | void AMCDictionary_DumpStatus(AMCDictionary_st *dict, FILE *file)
{
if (NULL == dict) {
return;
} |
includes |
#include <logging/log.h> |
includes |
#include <device.h> |
includes | #include <drivers/emul.h> |
includes | #include <drivers/cros_kb_raw.h> |
includes | #include <keyboard_raw.h> |
defines |
#define DT_DRV_COMPAT cros_ec_kb_raw_emul |
defines |
#define KB_RAW_EMUL(n) \ |
structs | struct kb_raw_emul_data {
int active_column;
int *matrix;
}; |
structs | struct kb_raw_emul_cfg {
/** Label of the I2C device being emulated */
const char *dev_label;
/** Pointer to run-time data */
struct kb_raw_emul_data *data;
/** Number of emulated keyboard rows. */
int rows;
/** Number of emulated keyboard columns. */
int cols;
}; |
functions | int kb_raw_emul_init(const struct device *dev)
{
const struct kb_raw_emul_cfg *cfg = dev->config;
struct kb_raw_emul_data *data = dev->data;
memset(data->matrix, 0, sizeof(int) * cfg->cols);
return 0;
} |
functions | int emul_kb_raw_init(const struct device *dev)
{
ARG_UNUSED(dev);
return 0;
} |
functions | int emul_kb_raw_enable_interrupt(const struct device *dev, int enable)
{
ARG_UNUSED(dev);
ARG_UNUSED(enable);
return 0;
} |
functions | int emul_kb_raw_read_rows(const struct device *dev)
{
struct kb_raw_emul_data *data = dev->data;
if (data->active_column == KEYBOARD_COLUMN_ALL)
return 0;
if (data->active_column == KEYBOARD_COLUMN_NONE)
return 0;
return data->matrix[data->active_column];
} |
functions | int emul_kb_raw_drive_column(const struct device *dev, int col)
{
const struct kb_raw_emul_cfg *cfg = dev->config;
struct kb_raw_emul_data *data = dev->data;
if (col >= cfg->cols)
return -EINVAL;
data->active_column = col;
return 0;
} |
functions | int emul_kb_raw_set_kbstate(const struct device *dev, uint8_t row, uint8_t col,
int pressed)
{
const struct kb_raw_emul_cfg *cfg = dev->config;
struct kb_raw_emul_data *data = dev->data;
if (col >= cfg->cols || row >= cfg->rows)
return -EINVAL;
if (pressed)
data->matrix[col] |= 1 << row;
else
data->m... |
includes |
#include <stdarg.h> |
includes | #include <wchar.h> |
defines |
#define ENV_VARIABLE "ADD"
|
defines | #define GETENV getenv
|
defines | #define GETENV getenv
|
functions | void badVaSinkB(char * data, ...)
{
{
char dest[100] = "";
va_list args;
va_start(args, data);
/* POTENTIAL FLAW: Do not specify the format allowing a possible format string vulnerability */
vsnprintf(dest, 100-1, data, args);
va_end(args);
printLine(... |
functions | void CWE134_Uncontrolled_Format_String__char_environment_w32_vsnprintf_07_bad()
{
char * data;
char dataBuffer[100] = "";
data = dataBuffer;
if(staticFive==5)
{
{
/* Append input from an environment variable to data */
size_t dataLen = strlen(data);
... |
functions | void goodB2G1VaSinkG(char * data, ...)
{
{
char dest[100] = "";
va_list args;
va_start(args, data);
/* FIX: Specify the format disallowing a format string vulnerability */
vsnprintf(dest, 100-1, "%s", args);
va_end(args);
printLine(dest);
} |
functions | void goodB2G1()
{
char * data;
char dataBuffer[100] = "";
data = dataBuffer;
if(staticFive==5)
{
{
/* Append input from an environment variable to data */
size_t dataLen = strlen(data);
char * environment = GETENV(ENV_VARIABLE);
/* I... |
functions | void goodB2G2VaSinkG(char * data, ...)
{
{
char dest[100] = "";
va_list args;
va_start(args, data);
/* FIX: Specify the format disallowing a format string vulnerability */
vsnprintf(dest, 100-1, "%s", args);
va_end(args);
printLine(dest);
} |
functions | void goodB2G2()
{
char * data;
char dataBuffer[100] = "";
data = dataBuffer;
if(staticFive==5)
{
{
/* Append input from an environment variable to data */
size_t dataLen = strlen(data);
char * environment = GETENV(ENV_VARIABLE);
/* I... |
functions | void goodG2B1VaSinkB(char * data, ...)
{
{
char dest[100] = "";
va_list args;
va_start(args, data);
/* POTENTIAL FLAW: Do not specify the format allowing a possible format string vulnerability */
vsnprintf(dest, 100-1, data, args);
va_end(args);
print... |
functions | void goodG2B1()
{
char * data;
char dataBuffer[100] = "";
data = dataBuffer;
if(staticFive!=5)
{
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
printLine("Benign, fixed string");
} |
functions | void goodG2B2VaSinkB(char * data, ...)
{
{
char dest[100] = "";
va_list args;
va_start(args, data);
/* POTENTIAL FLAW: Do not specify the format allowing a possible format string vulnerability */
vsnprintf(dest, 100-1, data, args);
va_end(args);
print... |
functions | void goodG2B2()
{
char * data;
char dataBuffer[100] = "";
data = dataBuffer;
if(staticFive==5)
{
/* FIX: Use a fixed string that does not contain a format specifier */
strcpy(data, "fixedstringtest");
} |
functions | void CWE134_Uncontrolled_Format_String__char_environment_w32_vsnprintf_07_good()
{
goodG2B1();
goodG2B2();
goodB2G1();
goodB2G2();
} |
main | int main(int argc, char * argv[])
{
/* seed randomness */
srand( (unsigned)time(NULL) );
#ifndef OMITGOOD
printLine("Calling good()...");
CWE134_Uncontrolled_Format_String__char_environment_w32_vsnprintf_07_good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
pri... |
includes | #include <ctype.h> |
defines | #define UTNAMLEN 64 |
defines | #define UTLINLEN 64 |
defines |
#define ONLINE 01 |
defines | #define OFFLINE 02 |
defines | #define CHANGED 04 |
defines | #define STMASK 07 |
defines | #define ANNOUNCE 010 |
defines | #define CLEARED 020 |
structs | struct who {
struct who *who_next;
struct who *who_prev;
char who_name[UTNAMLEN + 1];
char who_new[UTNAMLEN + 1];
char who_tty[UTLINLEN + 1];
#ifdef UTHOSTLEN
char who_host[UTHOSTLEN + 1];
#endif /* UTHOSTLEN */
time_t who_time;
int who_status;
}; |
functions | void
initwatch(void)
{
whohead.who_next = &whotail;
whotail.who_prev = &whohead;
stlast = 1;
#ifdef WHODEBUG
debugwholist(NULL, NULL);
#endif /* WHODEBUG */
} |
functions | void
resetwatch(void)
{
watch_period = 0;
stlast = 0;
} |
functions | void
watch_login(int force)
{
int comp = -1, alldone;
int firsttime = stlast == 1;
#if defined(HAVE_GETUTENT) || defined(HAVE_GETUTXENT)
struct utmp *uptr;
#else
int utmpfd;
#endif
struct utmp utmp;
struct who *wp, *wpnew;
struct varent *v;
Char **vp = NULL;
time_t t, inter... |
functions | DEAD_PROCESS
if (utmp.ut_type == DEAD_PROCESS) {
wp->who_time = utmp.ut_time;
wp->who_status = OFFLINE;
} |
functions | void
debugwholist(struct who *new, struct who *wp)
{
struct who *a;
a = whohead.who_next;
while (a->who_next != NULL) {
xprintf("%s/%s -> ", a->who_name, a->who_tty);
a = a->who_next;
} |
functions | void
print_who(struct who *wp)
{
#ifdef UTHOSTLEN
Char *cp = str2short(CGETS(26, 7, "%n has %a %l from %m."));
#else
Char *cp = str2short(CGETS(26, 8, "%n has %a %l."));
#endif /* UTHOSTLEN */
struct varent *vp = adrof(STRwho);
Char *str;
if (vp && vp->vec && vp->vec[0])
cp = vp->vec[0];
... |
functions | size_t
utmphostsize(void)
{
return UTHOSTLEN;
} |
functions | void
add_to_who_list(char *name, char *mach_nm)
{
struct who *wp, *wpnew;
int comp = -1;
wp = whohead.who_next;
while (wp->who_next && (comp = strncmp(wp->who_tty,mach_nm,UTLINLEN)) < 0)
wp = wp->who_next;/* find that tty! */
if (wp->who_next && comp == 0) { /* found the tty... */
if (*name ==... |
includes | #include <linux/module.h> |
includes | #include <linux/string.h> |
includes | #include <linux/cryptohash.h> |
includes | #include <linux/delay.h> |
includes | #include <linux/in6.h> |
includes | #include <linux/syscalls.h> |
includes |
#include <asm/checksum.h> |
includes | #include <asm/io.h> |
includes | #include <asm/system.h> |
includes | #include <asm/uaccess.h> |
defines | #define EXPORT_CRC_ALIAS(sym) __CRC_SYMBOL(sym, "") |
defines |
#define EXPORT_SYMBOL_ALIAS(sym,orig) \ |
functions | void CWE843_Type_Confusion__char_53d_badSink(void * data)
{
/* POTENTIAL FLAW: Attempt to access data as an int */
printIntLine(*((int*)data));
} |
functions | void CWE843_Type_Confusion__char_53d_goodG2BSink(void * data)
{
/* POTENTIAL FLAW: Attempt to access data as an int */
printIntLine(*((int*)data));
} |
includes | #include <sys/queue.h> |
includes | #include <sys/ioctl.h> |
includes | #include <limits.h> |
includes | #include <unistd.h> |
includes | #include <assert.h> |
defines |
#define MAX(a, b) ((a)>(b)?(a):(b)) |
defines | #define MIN(a, b) ((a)<(b)?(a):(b)) |
functions | int
mtcp_is_connected(mtcp_manager_t mtcp, tcp_stream *cur_stream)
{
if (!cur_stream) {
TRACE_API("Stream does not exist\n");
return FALSE;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.