type
stringclasses
5 values
content
stringlengths
9
163k
includes
#include <winsock2.h>
includes
#include <windows.h>
includes
#include <direct.h>
includes
#include <sys/types.h>
includes
#include <sys/socket.h>
includes
#include <netinet/in.h>
includes
#include <arpa/inet.h>
includes
#include <unistd.h>
defines
#define CLOSE_SOCKET closesocket
defines
#define INVALID_SOCKET -1
defines
#define SOCKET_ERROR -1
defines
#define CLOSE_SOCKET close
defines
#define SOCKET int
defines
#define TCP_PORT 27015
defines
#define IP_ADDRESS "127.0.0.1"
defines
#define CHAR_ARRAY_SIZE (3 * sizeof(data) + 2)
functions
void CWE191_Integer_Underflow__int_connect_socket_sub_07_bad() { int data; /* Initialize data */ data = 0; if(staticFive==5) { { #ifdef _WIN32 WSADATA wsaData; int wsaDataInit = 0; #endif int recvResult; struct sockaddr_in service;...
functions
_WIN32 if (wsaDataInit) { WSACleanup(); }
functions
void goodB2G1() { int data; /* Initialize data */ data = 0; if(staticFive==5) { { #ifdef _WIN32 WSADATA wsaData; int wsaDataInit = 0; #endif int recvResult; struct sockaddr_in service; SOCKET connectSocket = INVALID_SO...
functions
_WIN32 if (wsaDataInit) { WSACleanup(); }
functions
void goodB2G2() { int data; /* Initialize data */ data = 0; if(staticFive==5) { { #ifdef _WIN32 WSADATA wsaData; int wsaDataInit = 0; #endif int recvResult; struct sockaddr_in service; SOCKET connectSocket = INVALID_SO...
functions
_WIN32 if (wsaDataInit) { WSACleanup(); }
functions
void goodG2B1() { int data; /* Initialize data */ data = 0; if(staticFive!=5) { /* INCIDENTAL: CWE 561 Dead Code, the code below will never run */ printLine("Benign, fixed string"); }
functions
void goodG2B2() { int data; /* Initialize data */ data = 0; if(staticFive==5) { /* FIX: Use a small, non-zero value that will not cause an integer underflow in the sinks */ data = -2; }
functions
void CWE191_Integer_Underflow__int_connect_socket_sub_07_good() { goodB2G1(); goodB2G2(); goodG2B1(); goodG2B2(); }
main
int main(int argc, char * argv[]) { /* seed randomness */ srand( (unsigned)time(NULL) ); #ifndef OMITGOOD printLine("Calling good()..."); CWE191_Integer_Underflow__int_connect_socket_sub_07_good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling b...
includes
#include <errno.h>
functions
VALUE kernel_spec_call_proc(VALUE arg_array) { VALUE arg = rb_ary_pop(arg_array); VALUE proc = rb_ary_pop(arg_array); return rb_funcall(proc, rb_intern("call"), 1, arg); }
functions
VALUE kernel_spec_rb_block_given_p(VALUE self) { return rb_block_given_p() ? Qtrue : Qfalse; }
functions
VALUE kernel_spec_rb_need_block(VALUE self) { rb_need_block(); return Qnil; }
functions
VALUE kernel_spec_rb_block_proc(VALUE self) { return rb_block_proc(); }
functions
VALUE block_call_inject(VALUE yield_value, VALUE data2) { // yield_value yields the first block argument VALUE elem = yield_value; VALUE elem_incr = INT2FIX(FIX2INT(elem) + 1); return elem_incr; }
functions
VALUE kernel_spec_rb_block_call(VALUE self, VALUE ary) { return rb_block_call(ary, rb_intern("map"), 0, NULL, block_call_inject, Qnil); }
functions
VALUE block_call_inject_multi_arg(VALUE yield_value, VALUE data2, int argc, VALUE argv[]) { // yield_value yields the first block argument VALUE sum = yield_value; VALUE elem = argv[1]; return INT2FIX(FIX2INT(sum) + FIX2INT(elem)); }
functions
VALUE kernel_spec_rb_block_call_multi_arg(VALUE self, VALUE ary) { VALUE method_args[1]; method_args[0] = INT2FIX(0); return rb_block_call(ary, rb_intern("inject"), 1, method_args, block_call_inject_multi_arg, Qnil); }
functions
VALUE kernel_spec_rb_block_call_no_func(VALUE self, VALUE ary) { return rb_block_call(ary, rb_intern("map"), 0, NULL, NULL, Qnil); }
functions
VALUE kernel_spec_rb_ensure(VALUE self, VALUE main_proc, VALUE arg, VALUE ensure_proc, VALUE arg2) { VALUE main_array, ensure_array; main_array = rb_ary_new(); rb_ary_push(main_array, main_proc); rb_ary_push(main_array, arg); ensure_array = rb_ary_new(); rb_ary_push(ensure_arra...
functions
VALUE kernel_spec_call_proc_with_catch(VALUE arg, VALUE data) { return rb_funcall(data, rb_intern("call"), 0); }
functions
VALUE kernel_spec_rb_catch(VALUE self, VALUE sym, VALUE main_proc) { return rb_catch(StringValuePtr(sym), kernel_spec_call_proc_with_catch, main_proc); }
functions
VALUE kernel_spec_call_proc_with_catch_obj(VALUE arg, VALUE data) { return rb_funcall(data, rb_intern("call"), 0); }
functions
VALUE kernel_spec_rb_catch_obj(VALUE self, VALUE obj, VALUE main_proc) { return rb_catch_obj(obj, kernel_spec_call_proc_with_catch, main_proc); }
functions
VALUE kernel_spec_rb_eval_string(VALUE self, VALUE str) { return rb_eval_string(RSTRING_PTR(str)); }
functions
VALUE kernel_spec_rb_raise(VALUE self, VALUE hash) { rb_hash_aset(hash, ID2SYM(rb_intern("stage")), ID2SYM(rb_intern("before"))); rb_raise(rb_eTypeError, "Wrong argument type %s (expected %s)", "Integer", "String"); rb_hash_aset(hash, ID2SYM(rb_intern("stage")), ID2SYM(rb_intern("after"))); return Qnil; }
functions
VALUE kernel_spec_rb_throw(VALUE self, VALUE result) { rb_throw("foo", result); return ID2SYM(rb_intern("rb_throw_failed")); }
functions
VALUE kernel_spec_rb_throw_obj(VALUE self, VALUE obj, VALUE result) { rb_throw_obj(obj, result); return ID2SYM(rb_intern("rb_throw_failed")); }
functions
VALUE kernel_spec_call_proc_with_raised_exc(VALUE arg_array, VALUE raised_exc) { VALUE argv[2]; int argc; VALUE arg = rb_ary_pop(arg_array); VALUE proc = rb_ary_pop(arg_array); argv[0] = arg; argv[1] = raised_exc; argc = 2; return rb_funcall2(proc, rb_intern("call"), argc, argv); }
functions
VALUE kernel_spec_rb_rescue(VALUE self, VALUE main_proc, VALUE arg, VALUE raise_proc, VALUE arg2) { VALUE main_array, raise_array; main_array = rb_ary_new(); rb_ary_push(main_array, main_proc); rb_ary_push(main_array, arg); raise_array = rb_ary_new(); rb_ary_push(raise_array, r...
functions
VALUE kernel_spec_rb_rescue2(int argc, VALUE *args, VALUE self) { VALUE main_array, raise_array; main_array = rb_ary_new(); rb_ary_push(main_array, args[0]); rb_ary_push(main_array, args[1]); raise_array = rb_ary_new(); rb_ary_push(raise_array, args[2]); rb_ary_push(raise_array, args[3]); return rb_r...
functions
VALUE kernel_spec_rb_sys_fail(VALUE self, VALUE msg) { errno = 1; if(msg == Qnil) { rb_sys_fail(0); }
functions
VALUE kernel_spec_rb_warn(VALUE self, VALUE msg) { rb_warn("%s", StringValuePtr(msg)); return Qnil; }
functions
VALUE kernel_spec_rb_yield(VALUE self, VALUE obj) { return rb_yield(obj); }
functions
VALUE kernel_spec_rb_yield_splat(VALUE self, VALUE ary) { return rb_yield_splat(ary); }
functions
VALUE kernel_spec_rb_yield_values(VALUE self, VALUE obj1, VALUE obj2) { return rb_yield_values(2, obj1, obj2); }
functions
VALUE do_rec(VALUE obj, VALUE arg, int is_rec) { if(is_rec) { return obj; }
functions
else if(arg == Qtrue) { return rb_exec_recursive(do_rec, obj, Qnil); }
functions
VALUE kernel_spec_rb_exec_recursive(VALUE self, VALUE obj) { return rb_exec_recursive(do_rec, obj, Qtrue); }
functions
void write_io(VALUE io) { rb_funcall(io, rb_intern("write"), 1, rb_str_new2("e")); }
functions
VALUE kernel_spec_rb_set_end_proc(VALUE self, VALUE io) { rb_set_end_proc(write_io, io); return Qnil; }
functions
VALUE kernel_spec_rb_f_sprintf(VALUE self, VALUE ary) { return rb_f_sprintf((int)RARRAY_LEN(ary), RARRAY_PTR(ary)); }
functions
VALUE kernel_spec_rb_make_backtrace(VALUE self) { return rb_make_backtrace(); }
functions
void Init_kernel_spec() { VALUE cls; cls = rb_define_class("CApiKernelSpecs", rb_cObject); #ifdef HAVE_RB_BLOCK_GIVEN_P rb_define_method(cls, "rb_block_given_p", kernel_spec_rb_block_given_p, 0); #endif #ifdef HAVE_RB_NEED_BLOCK rb_define_method(cls, "rb_need_block", kernel_spec_rb_need_block, 0); #endif #if...
includes
#include <unistd.h>
includes
#include <string.h>
includes
#include <sys/types.h>
includes
#include <sys/stat.h>
includes
#include <sys/ioctl.h>
includes
#include <fcntl.h>
includes
#include <linux/ashmem.h>
includes
#include <cutils/ashmem.h>
defines
#define ASHMEM_DEVICE "/dev/ashmem"
functions
int ashmem_create_region(const char *name, size_t size) { int fd, ret; fd = open(ASHMEM_DEVICE, O_RDWR); if (fd < 0) return fd; if (name) { char buf[ASHMEM_NAME_LEN] = {0}
functions
int ashmem_set_prot_region(int fd, int prot) { return ioctl(fd, ASHMEM_SET_PROT_MASK, prot); }
functions
int ashmem_pin_region(int fd, size_t offset, size_t len) { struct ashmem_pin pin = { offset, len }
functions
int ashmem_unpin_region(int fd, size_t offset, size_t len) { struct ashmem_pin pin = { offset, len }
functions
int ashmem_get_size_region(int fd) { return ioctl(fd, ASHMEM_GET_SIZE, NULL); }
includes
#include <assert.h>
includes
#include <utils/code_utils.h>
includes
#include <openthread/platform/spi-slave.h>
includes
#include <hal/nrf_gpio.h>
includes
#include <nrfx.h>
includes
#include <nrfx_spis.h>
includes
#include <platform-nrf5.h>
functions
void spisEventHandler(nrfx_spis_evt_t const *aEvent, void *aContext) { OT_UNUSED_VARIABLE(aContext); switch (aEvent->evt_type) { case NRFX_SPIS_BUFFERS_SET_DONE: if (sRequestTransactionFlag) { // Host IRQ pin is active low. nrf_gpio_pin_clear(SPIS_PIN_HOST_IRQ); ...
functions
void nrf5SpiSlaveInit(void) { // Intentionally empty. }
functions
void nrf5SpiSlaveDeinit(void) { sOutputBuf = NULL; sOutputBufLen = 0; sInputBuf = NULL; sInputBufLen = 0; sRequestTransactionFlag = false; otPlatSpiSlaveDisable(); }
functions
void nrf5SpiSlaveProcess(void) { otEXPECT(sFurtherProcessingFlag == true); // Clear further processing flag. sFurtherProcessingFlag = false; // Perform any further processing if necessary. sProcessCallback(sContext); exit: return; }
functions
otError otPlatSpiSlaveEnable(otPlatSpiSlaveTransactionCompleteCallback aCompleteCallback, otPlatSpiSlaveTransactionProcessCallback aProcessCallback, void * aContext) { otError result = OT_ERROR_NONE; nrfx_er...
functions
void otPlatSpiSlaveDisable(void) { nrfx_spis_uninit(&sSpiSlaveInstance); }
functions
otError otPlatSpiSlavePrepareTransaction(uint8_t *aOutputBuf, uint16_t aOutputBufLen, uint8_t *aInputBuf, uint16_t aInputBufLen, bool aRequestTransactio...
includes
#include <linux/kernel.h>
includes
#include <linux/errno.h>
includes
#include <linux/smp.h>
includes
#include <asm/cacheflush.h>
functions
void platform_do_lowpower(unsigned int cpu) { flush_cache_all(); /* we put the platform to just WFI */ for (;;) { __asm__ __volatile__("dsb\n\t" "wfi\n\t" : : : "memory"); if (pen_release == cpu) { /* * OK, proper wakeup, we're done */ break; }
functions
int platform_cpu_kill(unsigned int cpu) { return 1; }
functions
void platform_cpu_die(unsigned int cpu) { /* directly enter low power state, skipping secure registers */ platform_do_lowpower(cpu); }
functions
int platform_cpu_disable(unsigned int cpu) { /* * we don't allow CPU 0 to be shutdown (it is still too special * e.g. clock tick interrupts) */ return cpu == 0 ? -EPERM : 0; }
defines
#define QSPI_STD_CMD_WRSR 0x01 /**< Write status register command*/
defines
#define QSPI_STD_CMD_RSTEN 0x66 /**< Reset enable command*/
defines
#define QSPI_STD_CMD_RST 0x99 /**< Reset command*/