project
stringclasses 633
values | commit_id
stringlengths 7
81
| target
int64 0
1
| func
stringlengths 5
484k
| cwe
stringclasses 131
values | big_vul_idx
float64 0
189k
⌀ | idx
int64 0
522k
| hash
stringlengths 34
39
| size
float64 1
24k
⌀ | message
stringlengths 0
11.5k
⌀ | dataset
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_OptionsGet(Jsi_Interp *interp, Jsi_OptionSpec *specs, void *rec, const char *option, Jsi_Value** valuePtr, Jsi_Wide flags)
{
char *record = (char*)rec;
Jsi_OptionSpec *specPtr;
const char *cp = NULL, *cb = NULL;
if (option) {
cp = Jsi_Strchr(option, '.');
cb = Jsi_Strchr(option, '[');
}
if (cp && (!cb || cp<cb) ) {
Jsi_DString dStr;
int len = (cp-option);
Jsi_DSInit(&dStr);
cp = Jsi_DSAppendLen(&dStr, option, len);
specPtr = Jsi_OptionsFind(interp, specs, cp, flags);
Jsi_DSFree(&dStr);
if (!specPtr || !specPtr->data || specPtr->id != JSI_OPTION_CUSTOM || specPtr->custom != Jsi_Opt_SwitchSuboption)
return Jsi_LogError("unknown or bad sub-config option: %s", option);
cp = option+len+1;
return Jsi_OptionsGet(interp, (Jsi_OptionSpec *)(specPtr->data), (void*)(((char*)rec)+specPtr->offset), cp, valuePtr, flags);
}
if (cb && cb != option) {
char *ce = Jsi_Strchr(option, ']');
Jsi_Wide ul;
Jsi_DString dStr;
Jsi_DSInit(&dStr);
int len = 0;
if (ce && ce>cb) {
len = (ce-cb-1);
cp = Jsi_DSAppendLen(&dStr, cb+1, len);
}
if (len <= 0 || Jsi_GetWide(interp, cp, &ul, 0) != JSI_OK || ul<0)
return Jsi_LogError("bad sub-array option: %s", option);
len = (cb-option);
Jsi_DSSetLength(&dStr, 0);
cp = Jsi_DSAppendLen(&dStr, option, len);
specPtr = Jsi_OptionsFind(interp, specs, cp, flags);
Jsi_DSFree(&dStr);
if (!specPtr || !specPtr->init.OPT_CARRAY|| specPtr->id != JSI_OPTION_CUSTOM || specPtr->custom != Jsi_Opt_SwitchCArray) {
bail:
return Jsi_LogError("unknown or bad array option: %s", option);
}
cp = cb+1;
Jsi_OptionSpec *subSpec = specPtr->init.OPT_CARRAY;
int isize, size = specPtr->arrSize;
if (!subSpec || size<=0 || (isize=subSpec->size)<=0)
goto bail;
isize = isize/size;
uchar *s = (((uchar*)rec)+specPtr->offset + isize*ul);
if (ce[1] != '.' || !subSpec->data) {
if (Jsi_OptionsGet(interp, subSpec, (void*)s, subSpec->name, valuePtr, flags) != JSI_OK)
return JSI_ERROR;
} else {
if (Jsi_OptionsGet(interp, (Jsi_OptionSpec *)subSpec->data, (void*)s, ce+2, valuePtr, flags) != JSI_OK)
return JSI_ERROR;
}
return JSI_OK;
}
specPtr = Jsi_OptionsFind(interp, specs, option, flags);
if (specPtr == NULL || jsi_GetOption(interp, specPtr, record, option, valuePtr, flags) != JSI_OK) {
return JSI_ERROR;
}
return JSI_OK;
}
|
CWE-120
| null | 520,686 |
107587082289137259113700132634570133189
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void jsi_DumpOptionSpec(Jsi_Interp *interp, Jsi_Obj *nobj, Jsi_OptionSpec* spec, int addName)
{
if (addName)
Jsi_ObjInsert(interp, nobj, "name", Jsi_ValueNewStringKey(interp, spec->name),0);
if (spec->help) {
if (Jsi_Strchr(spec->help, '\n'))
Jsi_LogError("%s .help contains newline: %s", spec->name, spec->help);
Jsi_ObjInsert(interp, nobj, "help", Jsi_ValueNewStringKey(interp, spec->help),0);
}
if (spec->info)
Jsi_ObjInsert(interp, nobj, "info", Jsi_ValueNewStringKey(interp, spec->info),0);
Jsi_ObjInsert(interp, nobj, "type", Jsi_ValueNewStringKey(interp, jsi_OptionTypeStr(spec->id,0)),0);
Jsi_ObjInsert(interp, nobj, "cName", Jsi_ValueNewStringKey(interp, jsi_OptionTypeStr(spec->id,1)),0);
Jsi_ObjInsert(interp, nobj, "initOnly", Jsi_ValueNewBoolean(interp, (spec->flags & JSI_OPT_INIT_ONLY)!=0), 0);
Jsi_ObjInsert(interp, nobj, "readOnly", Jsi_ValueNewBoolean(interp, (spec->flags & JSI_OPT_READ_ONLY)!=0), 0);
Jsi_ObjInsert(interp, nobj, "required", Jsi_ValueNewBoolean(interp, (spec->flags & JSI_OPT_REQUIRED)!=0), 0);
Jsi_ObjInsert(interp, nobj, "noCase", Jsi_ValueNewBoolean(interp, (spec->flags & JSI_OPT_CUST_NOCASE)!=0), 0);
Jsi_ObjInsert(interp, nobj, "size", Jsi_ValueNewNumber(interp, (Jsi_Number)spec->size), 0);
if (spec->flags)
Jsi_ObjInsert(interp, nobj, "flags", Jsi_ValueNewNumber(interp, (Jsi_Number)spec->flags), 0);
if (spec->data) {
if (spec->id == JSI_OPTION_FUNC && spec->data)
Jsi_ObjInsert(interp, nobj, "args", Jsi_ValueNewStringDup(interp, (char*)spec->data), 0);
else if (spec->id == JSI_OPTION_CUSTOM && (spec->custom == Jsi_Opt_SwitchBitset ||
spec->custom == Jsi_Opt_SwitchEnum)) {
const char **list = jsi_OptGetEnumList(spec);
if (list)
Jsi_ObjInsert(interp, nobj, "data", Jsi_ValueNewArray(interp, list, -1), 0);
}
}
if (spec->id == JSI_OPTION_CUSTOM && spec->custom) {
Jsi_Obj *sobj = Jsi_ObjNewType(interp, JSI_OT_OBJECT);
Jsi_Value *cvalue = Jsi_ValueMakeObject(interp, NULL, sobj);
jsi_DumpCustomSpec(interp, sobj, spec);
Jsi_ObjInsert(interp, nobj, "customArg", cvalue,0);
Jsi_OptionSpec *os = spec;
while (os->id != JSI_OPTION_END) os++;
Jsi_ObjInsert(interp, nobj, "customArgHelp", Jsi_ValueNewStringKey(interp, (os->help?os->help:"")), 0);
}
}
|
CWE-120
| null | 520,687 |
224045276752987430150386626823974450450
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
bool Jsi_ValueIsNumber(Jsi_Interp *interp, Jsi_Value *pv)
{
return (pv->vt == JSI_VT_NUMBER || (pv->vt == JSI_VT_OBJECT && pv->d.obj->ot == JSI_OT_NUMBER));
}
|
CWE-120
| null | 520,688 |
88779509048985854121303846376822841031
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void insert_case4(Jsi_TreeEntry* n) {
Jsi_TreeEntry* g = grandparent(n);
if (n == n->parent->right && n->parent == g->left) {
rotate_left(n->parent);
n = n->left;
} else if (n == n->parent->left && n->parent == g->right) {
rotate_right(n->parent);
n = n->right;
}
insert_case5(n);
}
|
CWE-120
| null | 520,689 |
49343967830791905587457496583388995819
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
HashOneWordFind( Jsi_Hash *tablePtr, const void *key)
{
Jsi_HashEntry *hPtr;
size_t hindex;
hindex = RANDOM_INDEX(tablePtr, key);
/*
* Search all of the entries in the appropriate bucket.
*/
for (hPtr = tablePtr->buckets[hindex]; hPtr != NULL;
hPtr = hPtr->nextPtr) {
if (hPtr->key.oneWordValue == key) {
return hPtr;
}
}
return NULL;
}
|
CWE-120
| null | 520,690 |
224314914065663330718395258650972913071
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void jsiPop(Jsi_Interp* interp, int n) {
int t = n;
while (t > 0) {
Assert((interp->framePtr->Sp-t)>=0);
/* Jsi_Value *v = _jsi_STACKIDX(interp->framePtr->Sp-t);
if (v->refCnt>1) puts("OO");*/
jsiClearStack(interp,t);
--t;
}
interp->framePtr->Sp -= n;
}
|
CWE-120
| null | 520,691 |
108063894639696982433031360673181033420
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static bool mysqlObjEqual(void *data1, void *data2)
{
//SQLSIGASSERT(data1,DB);
//SQLSIGASSERT(data2,DB);
return (data1 == data2);
}
|
CWE-120
| null | 520,692 |
30099928845461971212787524390129138505
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC _StringTrimCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this, // TODO: UTF
Jsi_Value **ret, Jsi_Func *funcPtr, int ends)
{
const char *tstr = " \t\n\r", *vstr;
int vend, n, tlen = Jsi_Strlen(tstr), clen, bLen;
ChkString(_this, funcPtr, vstr, &clen, &bLen);
Jsi_Value *tchars = Jsi_ValueArrayIndex(interp, args, skip);
if (tchars) {
tstr = Jsi_ValueToString(interp, tchars, NULL);
tlen = Jsi_Strlen(tstr);
}
if (ends&1) {
while (*vstr) {
for (n=0; n<tlen; n++)
if (tstr[n] == *vstr) break;
if (n>=tlen) break;
vstr++;
clen--;
}
}
vend = clen-1;
if (ends&2) {
for (; vend>=0; vend--) {
for (n=0; n<tlen; n++)
if (tstr[n] == vstr[vend]) break;
if (n>=tlen) break;
}
}
Jsi_DString dStr;
Jsi_DSInit(&dStr);
Jsi_UtfSubstr(vstr, 0, vend+1, &dStr);
Jsi_ValueFromDS(interp, &dStr, ret);
return JSI_OK;
}
|
CWE-120
| null | 520,693 |
78634107935093792349980780456241678418
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static bool interpObjIsTrue(void *data)
{
InterpObj *fo = (InterpObj *)data;
SIGASSERT(fo,INTERPOBJ);
if (!fo->subinterp) return 0;
else return 1;
}
|
CWE-120
| null | 520,694 |
308807975067970553448703913860623891457
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC Jsi_HashConf(Jsi_Hash *hashPtr, Jsi_MapOpts *opts, bool set)
{
if (set)
hashPtr->opts = *opts;
else
*opts = hashPtr->opts;
return JSI_OK;
}
|
CWE-120
| null | 520,695 |
104889690838845485433886113186531988642
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_MapEntry* Jsi_MapEntryFind (Jsi_Map *mapPtr, const void *key){
SIGASSERT(mapPtr, MAP);
switch (mapPtr->typ) {
case JSI_MAP_HASH: return (Jsi_MapEntry*)Jsi_HashEntryFind(mapPtr->v.hash, key);
case JSI_MAP_TREE: return (Jsi_MapEntry*)Jsi_TreeEntryFind(mapPtr->v.tree, key);
case JSI_MAP_LIST:
return (Jsi_MapEntry*) (key == NULL? Jsi_ListGetFront(mapPtr->v.list) : Jsi_ListGetBack(mapPtr->v.list));
case JSI_MAP_NONE: break;
}
return NULL;
}
|
CWE-120
| null | 520,696 |
302821538166955149561312360222404069893
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_Number Jsi_NumberNaN(void)
{
return NAN;
}
|
CWE-120
| null | 520,697 |
178806395258816300556219999002277586404
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
int Jsi_ValueInstanceOf( Jsi_Interp *interp, Jsi_Value* v1, Jsi_Value* v2)
{
Jsi_Value *proto, *sproto;
if (v1->vt != JSI_VT_OBJECT || v2->vt != JSI_VT_OBJECT || v2->d.obj->ot != JSI_OT_FUNCTION)
return 0;
proto = Jsi_ValueObjLookup(interp, v2, "prototype", 0);
if (!proto)
return 0;
sproto = v1->d.obj->__proto__ ;
while (sproto) {
if (sproto == proto)
return 1;
if (sproto->vt != JSI_VT_OBJECT)
return 0;
sproto = sproto->d.obj->__proto__;
}
return 0;
}
|
CWE-120
| null | 520,698 |
233472906530654516235380354815559899594
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_with(jsi_Pstate *p, jsi_Pline *line, int withlen) { JSI_NEW_CODESLN(0,OP_WITH, withlen); }
|
CWE-120
| null | 520,699 |
222095692303537420017735006235427500100
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC MySqlReconnectCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr)
{
MySqlObj *jdb = _mysql_getDbHandle(interp, _this, funcPtr);
if (!jdb) return JSI_ERROR;
int oldMax = jdb->maxStmts;
jdb->maxStmts = 0;
mdbStmtLimit(jdb);
jdb->maxStmts = oldMax;
mysql_close(jdb->db);
jdb->db = mysql_init(NULL);
if (!mdbConnect(interp, jdb))
return Jsi_LogError("reconnect failed: %s", mysql_error(jdb->db));
return JSI_OK;
}
|
CWE-120
| null | 520,700 |
146675964204114063656719760981659031779
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_MapEntry* Jsi_MapSearchNext (Jsi_MapSearch *searchPtr){
switch (searchPtr->typ) {
case JSI_MAP_HASH: return (Jsi_MapEntry*)Jsi_HashSearchNext(&searchPtr->v.hash);
case JSI_MAP_TREE: return (Jsi_MapEntry*)Jsi_TreeSearchNext(&searchPtr->v.tree);
case JSI_MAP_LIST: return (Jsi_MapEntry*)Jsi_ListSearchNext(&searchPtr->v.list);
case JSI_MAP_NONE: break;
}
return NULL;
}
|
CWE-120
| null | 520,701 |
83994295791165970077672297434801278825
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC Jsi_DoneWebSocket(Jsi_Interp *interp)
{
Jsi_UserObjUnregister(interp, &websockobject);
Jsi_PkgProvide(interp, "WebSocket", -1, NULL);
return JSI_OK;
}
|
CWE-120
| null | 520,702 |
322064263668594277313775342847134147071
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC MySqlOnecolumnCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr)
{
Jsi_RC rc;
MySqlObj *jdb;
if (!(jdb = _mysql_getDbHandle(interp, _this, funcPtr))) return JSI_ERROR;
Jsi_Value *vSql = Jsi_ValueArrayIndex(interp, args, 0);
Jsi_DString dStr;
Jsi_DSInit(&dStr);
Jsi_DString sStr;
Jsi_DSInit(&sStr);
MyDbEvalContext sEval = {};
const char *zSql = Jsi_ValueGetDString(interp, vSql, &dStr, 0);
sEval.nocache = jdb->queryOpts.nocache;
if (mdbEvalInit(interp, &sEval, jdb, zSql, &sStr, 0, 0) != JSI_OK)
return JSI_ERROR;
sEval.ret = *ret;
sEval.tocall = NULL;
int cnt = 0;
if( JSI_OK==(rc = mdbEvalStep(&sEval)) ) {
int nCol = sEval.prep->numCol;
if (nCol>0)
mdbEvalSetColumnValue(&sEval, 0, ret);
cnt++;
}
mdbEvalFinalize(&sEval);
if( rc==JSI_BREAK ) {
rc = JSI_OK;
}
Jsi_DSFree(&dStr);
return rc;
}
|
CWE-120
| null | 520,703 |
196881134008446896156376709761537857597
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC jsi_FuncArgsToString(Jsi_Interp *interp, Jsi_Func *f, Jsi_DString *dStr, int withTypes)
{
if (f->type == FC_NORMAL) {
int i;
for (i = 0; i < f->argnames->count; ++i) {
jsi_ArgValue *av = f->argnames->args+i;
if (i) Jsi_DSAppend(dStr, ", ", NULL);
Jsi_DSAppend(dStr, jsi_ScopeStrsGet(f->argnames, i), NULL);
if (withTypes && av) {
Jsi_DString tStr = {};
int atyp = av->type;
if (av->defValue)
atyp &= ~(av->defValue->vt==JSI_VT_NULL?JSI_TT_NULL:(1<<av->defValue->vt));
if (atyp) {
Jsi_DSAppend(dStr, ":", jsi_typeName(interp, atyp, &tStr), NULL);
}
Jsi_DSSetLength(&tStr, 0);
if (av->defValue)
Jsi_DSAppend(dStr, "=", Jsi_ValueGetDString(interp, av->defValue, &tStr, 1), NULL);
Jsi_DSFree(&tStr);
}
}
} else if (f->cmdSpec && f->cmdSpec->argStr)
Jsi_DSAppend(dStr, f->cmdSpec->argStr, NULL);
return JSI_OK;
}
|
CWE-120
| null | 520,704 |
256359802943509911584791283151345307867
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_HashEntry* Jsi_HashSet(Jsi_Hash *tbl, const void *key, void *value) {
Jsi_HashEntry *hPtr;
bool isNew;
hPtr = Jsi_HashEntryNew(tbl, key, &isNew);
if (!hPtr) return hPtr;
Jsi_HashValueSet(hPtr, value);
return hPtr;
}
|
CWE-120
| null | 520,705 |
295879529921080098665222662422170165183
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC FilesysCloseCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr)
{
UdfGet(udf, _this, funcPtr);
fileObjErase(udf);
Jsi_ValueMakeBool(interp, ret, 1);
return JSI_OK;
}
|
CWE-120
| null | 520,706 |
275498254783478090617960225687882612084
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC jsi_EnumToValue(Jsi_Interp *interp, Jsi_OptionSpec* spec, Jsi_Value **outValue, Jsi_DString *outStr, void *record, Jsi_Wide flags)
{
uint i = 0, j, esiz = 0;
int64_t n;
char *s = (char*)(((char*)record) + spec->offset);
const char **list = (const char**)spec->data;
Jsi_OptionSpec* es=NULL, *esp = NULL;
int fflags = (flags|spec->flags);
int uflag = (fflags&JSI_OPT_ENUM_UNSIGNED);
if (list && (fflags & JSI_OPT_ENUM_SPEC)) {
esp = es = (typeof(es))list;
while (es->id != JSI_OPTION_END) es++;
list = es->init.STRKEY;
esiz = es->size;
es = (typeof(es))spec->data;
}
if (!list)
return Jsi_LogError("custom enum spec did not set data: %s", spec->name);
if (outStr) {
if (uflag) {
switch (spec->size) {
case 1: n = *(uint8_t*)s; break;
case 2: n = *(uint16_t*)s; break;
case 4: n = *(uint32_t*)s; break;
case 8: n = *(uint64_t*)s; break;
default:
return Jsi_LogError("enum size %d must be 1, 2, 4, or 8: %s", spec->size, spec->name);
}
} else {
switch (spec->size) {
case 1: n = *(int8_t*)s; break;
case 2: n = *(int16_t*)s; break;
case 4: n = *(int32_t*)s; break;
case 8: n = *(int64_t*)s; break;
default:
return Jsi_LogError("enum size %d must be 1, 2, 4, or 8: %s", spec->size, spec->name);
}
}
if (spec->flags&JSI_OPT_FMT_NUMBER) {
Jsi_DSPrintf(outStr, "%" PRIu64, (uint64_t)n);
return JSI_OK;
}
if (es) {
for (j=0; j<esiz && list[j]; j++) {
if (n == esp[j].value) {
i = j;
break;
}
if (j>=esiz)
i = esiz;
}
} else
for (i=0; i<n && list[i]; i++) ; /* Look forward til n */
if (list[i])
Jsi_DSAppendLen(outStr, list[i], -1);
else if ((spec->flags&JSI_OPT_COERCE)) {
Jsi_DSPrintf(outStr, "%" PRIu64, (uint64_t)n);
return JSI_OK;
} else
return Jsi_LogError("enum has unknown value: %d", *s);
return JSI_OK;
}
#ifndef JSI_LITE_ONLY
Jsi_DString dStr;
Jsi_DSInit(&dStr);
Jsi_RC rc = jsi_EnumToValue(interp, spec, NULL, &dStr, record, flags);
if (rc == JSI_OK)
Jsi_ValueMakeStringKey(interp, outValue, Jsi_DSValue(&dStr));
Jsi_DSFree(&dStr);
return rc;
#endif
return JSI_ERROR;
}
|
CWE-120
| null | 520,707 |
249494249814199573946758302408826915827
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void* Jsi_Malloc(unsigned int size) {
void *v = malloc(size);
Assert(v);
return v;
}
|
CWE-120
| null | 520,708 |
331318363917289225919653350351311672374
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_vtype Jsi_ValueTypeGet(Jsi_Value *pv) { return pv->vt; }
|
CWE-120
| null | 520,709 |
183820768041082554843629835955380291302
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void jsi_PstatePop(jsi_Pstate *ps)
{
Jsi_Interp *interp = ps->interp;
if (interp->cur_scope <= 0) {
Jsi_LogBug("No more scope to pop");
return;
}
jsi_ScopeStrsFree(interp, interp->scopes[interp->cur_scope]);
interp->scopes[interp->cur_scope] = NULL;
interp->cur_scope--;
}
|
CWE-120
| null | 520,710 |
212621427229101047200040082880733040465
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC jsi_wsGetCmd(Jsi_Interp *interp, jsi_wsCmdObj *cmdPtr, jsi_wsPss* pss, struct lws *wsi,
const char *inPtr, Jsi_Value *cmd, Jsi_DString *tStr)
{
Jsi_RC jrc;
Jsi_Value *retStr = Jsi_ValueNew1(interp);
// 4 args: ws, id, url, query
Jsi_Value *vpargs, *vargs[10];
int n = 0;
if (cmdPtr->deleted) return JSI_ERROR;
vargs[n++] = Jsi_ValueNewObj(interp, cmdPtr->fobj);
vargs[n++] = Jsi_ValueNewNumber(interp, (Jsi_Number)(pss?pss->wid:0));
vargs[n++] = Jsi_ValueNewStringDup(interp, inPtr);
vargs[n++] = (pss->query?pss->query:Jsi_ValueNewArray(interp, NULL, 0));
vpargs = Jsi_ValueMakeObject(interp, NULL, Jsi_ObjNewArray(interp, vargs, n, 0));
Jsi_IncrRefCount(interp, vpargs);
jrc = Jsi_FunctionInvoke(interp, cmd, vpargs, &retStr, NULL);
Jsi_DecrRefCount(interp, vpargs);
if (Jsi_InterpGone(interp))
return JSI_ERROR;
Jsi_DString dStr = {};
const char *rstr = "";
if (jrc != JSI_OK)
rstr = "Error";
else if (Jsi_ValueIsFalse(interp, retStr)) {
rstr = "Access denied";
jrc = JSI_ERROR;
} else
rstr = Jsi_ValueString(interp, retStr, NULL);
if (rstr && tStr && Jsi_Strncmp(rstr, "!!!", 3)==0) {
Jsi_DSAppend(tStr, rstr+3, NULL);
jrc = JSI_CONTINUE;
} else if (rstr && tStr && Jsi_Strncmp(rstr, ">>>", 3)==0) {
Jsi_DSAppend(tStr, rstr+3, NULL);
jrc = JSI_SIGNAL;
} else if (rstr && rstr[0] != 0)
jsi_wsServeString(pss, wsi, rstr, jrc==JSI_OK?0:404, NULL, NULL);
else
jrc = JSI_BREAK;
Jsi_DecrRefCount(interp, retStr);
Jsi_DSFree(&dStr);
return jrc;
}
|
CWE-120
| null | 520,711 |
168128758702793980058255975748773511799
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
int jsi_FuncSigsMatch(jsi_Pstate *pstate, Jsi_Func *f1, Jsi_Func *f2)
{
// Skip where both functions have no types.
if (f1->retType==0 && f1->argnames->typeCnt==0 && f1->argnames->varargs==0 &&
f2->retType==0 && f2->argnames->typeCnt==0 && f2->argnames->varargs==0 &&
pstate->interp->typeCheck.all==0)
return 1;
if (f1->retType != f2->retType)
return 0;
if (f1->argnames->count != f2->argnames->count)
return 0;
if (f1->argnames->typeCnt != f2->argnames->typeCnt)
return 0;
if (f1->argnames->varargs != f2->argnames->varargs)
return 0;
int i;
for (i=0; i<f1->argnames->count; i++) {
Jsi_ScopeStrs *a1 = f1->argnames, *a2 = f2->argnames;
if (a1->args[i].type != a2->args[i].type)
return 0;
Jsi_Value *v1, *v2;
v1 = a1->args[i].defValue;
v2 = a2->args[i].defValue;
if (v1==NULL && v2 == NULL)
continue;
if (v1==NULL || v2 == NULL)
return 0;
if (v1->vt != v2->vt)
return 0;
if (Jsi_ValueCmp(pstate->interp, v1, v2, 0))
return 0;
}
return 1;
}
|
CWE-120
| null | 520,712 |
303403301484765013502159566739760211693
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC jsi_wswebsocketObjFree(Jsi_Interp *interp, void *data)
{
jsi_wsCmdObj *cmdPtr = (jsi_wsCmdObj*)data;
WSSIGASSERT(cmdPtr,OBJ);
cmdPtr->deleted = 1;
struct lws_context *ctx = cmdPtr->context;
if (ctx)
lws_context_destroy(ctx);
cmdPtr->context = NULL;
cmdPtr->_->activeCnt--;
jsi_wswebsocketObjErase(cmdPtr);
_JSI_MEMCLEAR(cmdPtr);
Jsi_Free(cmdPtr);
return JSI_OK;
}
|
CWE-120
| null | 520,713 |
216795485563691575405997967807340679889
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_debug(jsi_Pstate *p, jsi_Pline *line) { JSI_NEW_CODESLN(0,OP_DEBUG, 0); }
|
CWE-120
| null | 520,714 |
43820809765269226944974509493842508057
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC jsi_AliasInvoke(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr)
{
AliasCmd *ac = (AliasCmd *)funcPtr->cmdSpec->reserved[2];
Jsi_Interp *dinterp = ac->dinterp;
Jsi_Value *nargs = NULL;
int inc=0, argc = Jsi_ValueGetLength(interp, args);
if (!ac) {
Jsi_LogBug("BAD ALIAS INVOKE OF DELETED");
return JSI_ERROR;
}
SIGASSERT(ac,ALIASCMD);
bool isthrd = (interp != dinterp && interp->threadId != dinterp->threadId);
Jsi_Value *nrPtr = Jsi_ValueNew1(dinterp);
if (argc == 0 && ac->args)
nargs = ac->args;
else if (argc) {
if (dinterp == interp)
Jsi_ValueCopy(interp, nrPtr, args);
else if (Jsi_CleanValue(interp, dinterp, args, &nrPtr) != JSI_OK)
return JSI_ERROR;
if (ac->args && Jsi_ValueGetLength(dinterp, ac->args)) {
nargs = Jsi_ValueArrayConcat(dinterp, ac->args, nrPtr);
Jsi_IncrRefCount(dinterp, nargs);
inc=1;
} else {
nargs = nrPtr;
}
}
if (isthrd) {
/* Post to thread event in sub-interps queue. */
if (Jsi_MutexLock(interp, dinterp->QMutex) != JSI_OK)
return JSI_ERROR;
/* Is an async call. */
InterpStrEvent *se, *s = (InterpStrEvent *)Jsi_Calloc(1, sizeof(*s));
// TODO: is s->data inited?
Jsi_DSInit(&s->data);
Jsi_ValueGetDString(interp, nargs, &s->data, JSI_OUTPUT_JSON);
if (inc)
Jsi_DecrRefCount(dinterp, nargs);
Jsi_DecrRefCount(dinterp, nrPtr);
s->acfunc = ac->func;
Jsi_IncrRefCount(dinterp, ac->func);
se = dinterp->interpStrEvents;
if (!se)
dinterp->interpStrEvents = s;
else {
while (se->next)
se = se->next;
se->next = s;
}
Jsi_MutexUnlock(interp, dinterp->QMutex);
return JSI_OK;
}
if (dinterp != interp) {
if (interp->subOpts.mutexUnlock) Jsi_MutexUnlock(interp, interp->Mutex);
if (Jsi_MutexLock(interp, dinterp->Mutex) != JSI_OK) {
if (interp->subOpts.mutexUnlock) Jsi_MutexLock(interp, interp->Mutex);
return JSI_ERROR;
}
}
ac->refCount++;
Jsi_Value *srPtr, **srpPtr = ret;
if (dinterp != interp) {
srPtr = Jsi_ValueNew1(dinterp);
srpPtr = &srPtr;
}
Jsi_RC rc = Jsi_FunctionInvoke(dinterp, ac->func, nargs, srpPtr, NULL);
ac->refCount--;
if (inc)
Jsi_DecrRefCount(dinterp, nargs);
Jsi_DecrRefCount(dinterp, nrPtr);
if (dinterp != interp) {
Jsi_MutexUnlock(interp, dinterp->Mutex);
if (interp->subOpts.mutexUnlock && Jsi_MutexLock(interp, interp->Mutex) != JSI_OK) {
return JSI_ERROR;
}
}
if (dinterp != interp) {
Jsi_CleanValue(dinterp, interp, *srpPtr, ret);
Jsi_DecrRefCount(dinterp, srPtr);
if (rc != JSI_OK && dinterp->errMsgBuf[0] && interp != dinterp) {
Jsi_Strcpy(interp->errMsgBuf, dinterp->errMsgBuf);
interp->errLine = dinterp->errLine;
interp->errFile = dinterp->errFile;
dinterp->errMsgBuf[0] = 0;
}
}
return rc;
}
|
CWE-120
| null | 520,715 |
192121441612948196533725199873442074634
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_bxor() { JSI_NEW_CODES(0,OP_BXOR, 0); }
|
CWE-120
| null | 520,716 |
48017410114690901296274928695939997614
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_array(jsi_Pstate *p, jsi_Pline *line, int c) { JSI_NEW_CODESLN(0,OP_ARRAY, c); }
|
CWE-120
| null | 520,717 |
265280156598354042795898616142989748667
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static JSITHREADRET NewInterpThread(void* iPtr)
{
int rc = JSI_OK;
InterpObj *udf = (InterpObj *)iPtr;
Jsi_Interp *interp = udf->subinterp;
interp->threadId = Jsi_CurrentThread();
if (interp->scriptStr)
rc = Jsi_EvalString(interp, interp->scriptStr, 0);
else if (interp->scriptFile) {
if (!interp->debugOpts.debugCallback) // Debug will use Interp.source() instead.
Jsi_EvalFile(interp, interp->scriptFile, 0);
} else {
Jsi_LogBug("no eval");
}
if (rc != JSI_OK) {
Jsi_LogError("eval failure");
interp->threadErrCnt++;
if (Jsi_MutexLock(interp, interp->Mutex) != JSI_OK)
return NULL;
Jsi_MutexUnlock(interp, interp->Mutex);
}
interpObjErase(udf);
#ifndef __WIN32
/* TODO: should we wait/notify parent??? */
pthread_detach(pthread_self());
return NULL;
#endif
}
|
CWE-120
| null | 520,718 |
280574938477489993177222479600347606507
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_push_null() { JSI_NEW_CODES(0,OP_PUSHNULL, 0); }
|
CWE-120
| null | 520,719 |
87253631783036432360529112951962968527
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
int Jsi_HexStr(const uchar *data, int len, Jsi_DString *dStr, bool decode) {
int olen = (decode?(len/2+1):(len*2+1));
Jsi_DSSetLength(dStr, olen);
if (!decode)
return jsi_FromHexStr((const char*)data, (uchar*)Jsi_DSValue(dStr));
jsi_ToHexStr((const uchar*)data, len, Jsi_DSValue(dStr));
return olen-1;
}
|
CWE-120
| null | 520,720 |
19942785006678912970948251625217233716
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_ListEntry* Jsi_ListSearchFirst (Jsi_List *list, Jsi_ListSearch *searchPtr, int flags)
{
SIGASSERT(list, LIST);
searchPtr->flags = flags;
Jsi_ListEntry *lptr;
if (flags & JSI_LIST_REVERSE) {
lptr = Jsi_ListGetBack(list);
searchPtr->nextEntryPtr = (lptr?Jsi_ListEntryPrev(lptr):NULL);
} else {
lptr = Jsi_ListGetFront(list);
searchPtr->nextEntryPtr = (lptr?Jsi_ListEntryNext(lptr):NULL);
}
return lptr;
}
|
CWE-120
| null | 520,721 |
185135391703918899085046470433596785249
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_TreeEntry *Jsi_TreeSet(Jsi_Tree *treePtr, const void *key, void *value)
{
Jsi_TreeEntry *hPtr;
bool isNew;
hPtr = Jsi_TreeEntryNew(treePtr, key, &isNew);
if (!hPtr) return hPtr;
Jsi_TreeValueSet(hPtr, value);
return hPtr;
}
|
CWE-120
| null | 520,722 |
154884258813121566089819301824342399178
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void* Jsi_MapGet(Jsi_Map *mapPtr, const void *key, int flags){
SIGASSERT(mapPtr, MAP);
switch (mapPtr->typ) {
case JSI_MAP_HASH: return Jsi_HashGet(mapPtr->v.hash, (void*)key, flags);
case JSI_MAP_TREE: return Jsi_TreeGet(mapPtr->v.tree, (void*)key, flags);
case JSI_MAP_LIST: {
Jsi_ListEntry* lptr = (key == NULL? Jsi_ListGetFront(mapPtr->v.list) : Jsi_ListGetBack(mapPtr->v.list));
if (lptr)
return Jsi_ListValueGet(lptr);
break;
}
case JSI_MAP_NONE: break;
}
return NULL;
}
|
CWE-120
| null | 520,723 |
29786279578179819464936100312378085743
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void *Jsi_StackHead(Jsi_Stack *stack)
{
if (stack->len == 0)
return NULL;
return stack->vector[0];
}
|
CWE-120
| null | 520,724 |
128318166857522353879331450725190557797
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void *Jsi_CommandNewObj(Jsi_Interp *interp, const char *name, const char *arg1, const char *opts, const char *var) {
char buf[JSI_BUFSIZ];
if (arg1)
snprintf(buf, sizeof(buf), "%s%snew %s('%s', %s);", var?var:"", var?"=":"return ", name, arg1, opts?opts:"null");
else
snprintf(buf, sizeof(buf), "%s%snew %s(%s);", var?var:"", var?"=":"return ", name, opts?opts:"null");
int rc = Jsi_EvalString(interp, buf, 0);
if (rc != JSI_OK)
return NULL;
Jsi_Value *vObj = interp->retValue;
if (var)
vObj = Jsi_NameLookup(interp, var);
if (!vObj)
return NULL;
return Jsi_UserObjGetData(interp, vObj, NULL);
}
|
CWE-120
| null | 520,725 |
129493198116601033603899190849667147642
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_GetIndex( Jsi_Interp *interp, const char *str,
const char **tablePtr, const char *msg, int flags,
int *indexPtr)
{
const char *msg2 = "unknown ";
char **cp, *c;
int cond, index = -1, slen, i, dup = 0;
int exact = (flags & JSI_CMP_EXACT);
int nocase = (flags & JSI_CMP_NOCASE);
slen = Jsi_Strlen(str);
/* if (slen==0)
return Jsi_LogError("empty option %s %s", msg, str);*/
cp = (char**)tablePtr;
i = -1;
while (*cp != 0) {
i++;
c = *cp;
if (c[0] != str[0]) { cp++; continue; }
if (!nocase)
cond = (exact ? Jsi_Strcmp(c,str) : Jsi_Strncmp(c,str,slen));
else {
cond = (exact ? Jsi_Strncasecmp(c,str, -1) : Jsi_Strncasecmp(c,str,slen));
}
if (cond == 0) {
if (index<0) {
index = i;
} else {
dup = 1;
break;
}
}
cp++;
}
if (index >= 0 && dup == 0) {
*indexPtr = index;
return JSI_OK;
}
if (exact && (dup || index<=0)) {
if (interp != NULL) {
msg2 = (index>=0? "unknown ":"duplicate ");
}
goto err;
}
cp = (char**)tablePtr;
i = -1;
dup = 0;
index = -1;
while (*cp != 0) {
i++;
c = *cp;
if (c[0] == str[0] && Jsi_Strncmp(c,str, slen) == 0) {
if (index<0) {
index = i;
if (slen == (int)Jsi_Strlen(c))
break;
} else {
if (interp != NULL) {
msg2 = "ambiguous ";
}
goto err;
}
}
cp++;
}
if (index >= 0 && dup == 0) {
*indexPtr = index;
return JSI_OK;
}
err:
if (interp != NULL) {
Jsi_DString dStr = {};
Jsi_DSAppend(&dStr, msg2, msg, " \"", str, "\" not one of: ", NULL);
cp = (char**)tablePtr;
while (*cp != 0) {
c = *cp;
Jsi_DSAppend(&dStr, c, NULL);
Jsi_DSAppend(&dStr, " ", NULL);
cp++;
}
Jsi_LogError("%s", Jsi_DSValue(&dStr));
Jsi_DSFree(&dStr);
}
return JSI_ERROR;
}
|
CWE-120
| null | 520,726 |
72486164135469460398139385563900384054
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static bool jsi_wswebsocketObjEqual(void *data1, void *data2)
{
return (data1 == data2);
}
|
CWE-120
| null | 520,727 |
237828875600481346231059984519720112653
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OptionSpec * jsi_GetCachedOptionSpecs(Jsi_Interp *interp, const Jsi_OptionSpec *staticSpecs)
{
Jsi_OptionSpec *cachedSpecs;
Jsi_Hash *specCacheTablePtr;
Jsi_HashEntry *entryPtr;
bool isNew;
specCacheTablePtr = (Jsi_Hash*)Jsi_InterpGetData(interp, "jsi:OptionSpec", NULL);
if (specCacheTablePtr == NULL) {
specCacheTablePtr = Jsi_HashNew(interp, JSI_KEYS_ONEWORD, 0);
Jsi_InterpSetData(interp, "jsi:OptionSpec", specCacheTablePtr, jsi_DeleteSpecCacheTable);
}
entryPtr = Jsi_HashEntryNew(specCacheTablePtr, (char *) staticSpecs, &isNew);
if (isNew) {
unsigned int entrySpace = sizeof(Jsi_OptionSpec);
const Jsi_OptionSpec *staticSpecPtr;
for (staticSpecPtr=staticSpecs; staticSpecPtr->id>=JSI_OPTION_BOOL && staticSpecPtr->id!=JSI_OPTION_END; staticSpecPtr++)
entrySpace += sizeof(Jsi_OptionSpec);
assert(staticSpecPtr->id==JSI_OPTION_END);
cachedSpecs = (Jsi_OptionSpec *) Jsi_Malloc(entrySpace);
memcpy((void *) cachedSpecs, (void *) staticSpecs, entrySpace);
Jsi_HashValueSet(entryPtr, cachedSpecs);
} else {
cachedSpecs = (Jsi_OptionSpec *) Jsi_HashValueGet(entryPtr);
}
return cachedSpecs;
}
|
CWE-120
| null | 520,728 |
41496621898855642120739227979139996601
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_ScopeStrs *jsi_argInsert(jsi_Pstate *pstate, Jsi_ScopeStrs *a, const char *name, Jsi_Value *defValue, jsi_Pline *lPtr, bool prepend)
{
Jsi_Interp *interp = pstate->interp;
if (!a)
a = jsi_ScopeStrsNew();
pstate->args = a;
int atyp = pstate->argType;
if (defValue) {
int vt = defValue->vt;
if (vt == JSI_VT_NULL)
vt = JSI_TT_NULL;
else if (vt == JSI_VT_UNDEF && defValue->d.num==1)
vt = JSI_TT_VOID;
else if (vt == JSI_VT_OBJECT && defValue->d.obj->ot==JSI_OT_STRING)
vt = JSI_TT_STRING;
else
vt = (1<<defValue->vt);
atyp |= vt;
}
jsi_ScopeStrsPush(interp, a, name, atyp);
pstate->argType = 0;
a->args[a->count-1].defValue = defValue;
a->argCnt++;
if (prepend) {
jsi_ArgValue t;
int i, end = a->argCnt-1;
t = a->args[end];
for (i=end-1; i>=0; i--)
a->args[i+1]=a->args[i];
a->args[0] = t;
}
jsi_Pline *opl = interp->parseLine;
interp->parseLine = lPtr;
if (defValue) {
Jsi_IncrRefCount(interp, defValue);
if (a->firstDef==0)
a->firstDef = a->argCnt;
if (atyp)
jsi_ArgTypeCheck(interp, atyp, defValue, "default value", name, a->argCnt, NULL, 1);
} else {
if (a->firstDef && (interp->typeCheck.run || interp->typeCheck.all) )
Jsi_LogWarn("expected default value in argument list: \"%s\"", name);
}
interp->parseLine = opl;
return a;
}
|
CWE-120
| null | 520,729 |
172347059828712109012173377336043297323
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC Jsi_JSONParseFmt(Jsi_Interp *interp, Jsi_Value **ret, const char *fmt, ...)
{
va_list argList;
uint n;
char buf[JSI_BUFSIZ], *cp = buf;
Jsi_DString dStr = {};
va_start(argList, fmt);
n = vsnprintf(buf, sizeof(buf), fmt, argList);
if (n>JSI_MAX_ALLOC_BUF) {
Jsi_LogError("Jsi_JSONParseFmt error: rc = %d", n);
va_end(argList);
return JSI_ERROR;
}
if (n >= sizeof(buf)) {
uint m;
Jsi_DSSetLength(&dStr, n+1);
m = vsnprintf(Jsi_DSValue(&dStr), n+1, fmt, argList);
assert(m == n);
JSI_NOWARN(m);
cp = Jsi_DSValue(&dStr);
}
va_end(argList);
return Jsi_JSONParse(interp, cp, ret, 0);
}
|
CWE-120
| null | 520,730 |
305379873556510494874739185548935293092
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void Jsi_HashValueSet(Jsi_HashEntry *h, void *value)
{
h->clientData = value;
}
|
CWE-120
| null | 520,731 |
155668375390620474019966975186339126908
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void jsi_FuncObjFree(Jsi_FuncObj *fobj)
{
if (fobj->scope)
jsi_ScopeChainFree(fobj->interp, fobj->scope);
if (fobj->bindArgs)
Jsi_DecrRefCount(fobj->interp, fobj->bindArgs);
if (fobj->bindFunc)
Jsi_DecrRefCount(fobj->interp, fobj->bindFunc);
if (fobj->func)
jsi_FuncFree(fobj->interp, fobj->func);
_JSI_MEMCLEAR(fobj);
Jsi_Free(fobj);
}
|
CWE-120
| null | 520,732 |
127190722194891949742662843949045113209
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static bool mysqlObjIsTrue(void *data)
{
MySqlObj *jdb = (MySqlObj*)data;
SQLSIGASSERT(jdb,DB);
if (!jdb->db) return 0;
else return 1;
}
|
CWE-120
| null | 520,733 |
300242509487228196359814655536579683369
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC jsi_ValueToBitfield(Jsi_Interp *interp, Jsi_OptionSpec* spec, Jsi_Value *inValue,
const char *inStr, void *record, Jsi_Wide flags)
{
Jsi_csgset *bsget = spec->init.OPT_BITS;
Jsi_Interp *d = interp;
int idx = spec->idx;
uchar *data = (uchar*)record;
Jsi_Number num;
Jsi_OptionSpec* enumSpec = (typeof(enumSpec))spec->data;
if (!d || !bsget || idx<0)
return Jsi_LogBug("invalid bitfield");
if (enumSpec) {
struct numStruct { int64_t numVal; } nval = {};
Jsi_OptionSpec eSpec[] = {
JSI_OPT(CUSTOM, typeof(nval), numVal, .help=spec->help, .flags=JSI_OPT_ENUM_SPEC,
.custom=Jsi_Opt_SwitchEnum, .data=(void*)enumSpec, .info=0, .tname=spec->tname, .value=0, .bits=0, .boffset=8*sizeof(int64_t) ),
JSI_OPT_END(typeof(nval))
};
if (JSI_OK != jsi_ValueToEnum(interp, eSpec, inValue, inStr, (void*)&nval, flags))
return JSI_ERROR;
num = (Jsi_Number)nval.numVal;
} else if (inStr) {
if (Jsi_GetDouble(interp, inStr, &num) != JSI_OK)
return JSI_ERROR;
} else {
if (inValue && !Jsi_ValueIsNumber(interp, inValue))
return JSI_ERROR;
Jsi_ValueGetNumber(interp, inValue, &num);
}
int64_t inum = (int64_t)num;
return (*bsget)(interp, data, &inum, spec, idx, 1);
}
|
CWE-120
| null | 520,734 |
170071632619435322614116468949650975809
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void dbCollateNeeded(
void *cd,
sqlite3 *db,
int enc,
const char *zName
) {
int rc;
Jsi_Db *jdb = (Jsi_Db*)cd;
Jsi_Interp *interp = jdb->interp;
Jsi_Value *vpargs, *items[2], *ret;
items[0] = Jsi_ValueNewObj(interp, jdb->fobj);
items[1] = Jsi_ValueMakeStringDup(interp, NULL, zName);
vpargs = Jsi_ValueMakeObject(interp, NULL, Jsi_ObjNewArray(interp, items, 2, 0));
Jsi_IncrRefCount(interp, vpargs);
ret = Jsi_ValueNew1(interp);
rc = Jsi_FunctionInvoke(interp, jdb->onNeedCollate, vpargs,& ret, NULL);
Jsi_DecrRefCount(interp, vpargs);
Jsi_DecrRefCount(interp, ret);
if (rc != JSI_OK)
jdb->errCnt++;
}
|
CWE-120
| null | 520,735 |
201920606875048705664948700908178616458
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static int StringCompare(Jsi_Tree *treePtr, const void *key1, const void *key2)
{
return Jsi_DictionaryCompare((char*)key1, (char*)key2);
//return Jsi_Strcmp((char*)key1, (char*)key2);
}
|
CWE-120
| null | 520,736 |
162134873530058223013021806350458452208
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_TreeEntry *TreeArrayCreate(Jsi_Tree *treePtr, const void *key, bool *newPtr)
{
Jsi_TreeEntry *hPtr;
size_t size;
if ((hPtr = Jsi_TreeEntryFind(treePtr, key))) {
if (newPtr)
*newPtr = 0;
return hPtr;
}
if (newPtr)
*newPtr = 1;
size = sizeof(Jsi_TreeEntry) + treePtr->keyType; /*- sizeof(jsi_TreeKey);*/
hPtr = (Jsi_TreeEntry*)Jsi_Calloc(1,size);
SIGINIT(hPtr,TREEENTRY);
hPtr->typ = JSI_MAP_TREE;
hPtr->treePtr = treePtr;
hPtr->value = 0;
memcpy(hPtr->key.string, key, treePtr->keyType);
treePtr->numEntries++;
return hPtr;
}
|
CWE-120
| null | 520,737 |
317297493327921811689125727952380956819
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void jsi_InteractiveSignal(int sig){
if (jsi_interactiveInterp)
jsi_interactiveInterp->interrupted = 1;
}
|
CWE-120
| null | 520,738 |
273257028788140584615078000195727201802
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
int Jsi_Write(Jsi_Interp *interp, Jsi_Channel chan, const char *bufPtr, int slen) {
if (chan->fsPtr==0 || !chan->fsPtr->writeProc) return -1;
return chan->fsPtr->writeProc(chan, bufPtr, slen);
}
|
CWE-120
| null | 520,739 |
208040175484238232031020978556571187541
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_Interp *jsi_DoExit(Jsi_Interp *interp, int rc)
{
if (rc<0 || rc>127) rc = 127;
if (!interp || !interp->opts.no_exit) {
if (rc) {
Jsi_Flush(interp, jsi_Stdout);
Jsi_Flush(interp, jsi_Stderr);
}
exit(rc);
}
fprintf(stderr, "ignoring attempted exit: may cause a crash\n");
if (interp) interp->deleting = 1;
return NULL;
}
|
CWE-120
| null | 520,740 |
66534326861487986115605650974766264677
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_Interp* Jsi_Main(Jsi_InterpOpts *opts)
{
Jsi_RC rc = JSI_OK;
Jsi_Interp* interp = NULL;
int argc = 0, first = 1;
char **argv = NULL;
if (opts) {
interp = opts->interp;
argc = opts->argc;
argv = opts->argv;
}
if (!interp)
interp = Jsi_InterpNew(opts);
if (!interp)
return NULL;
Jsi_InterpOnDelete(interp, &jsi_InterpDelete, (void*)&jsi_InterpDelete);
argc -= interp->iskips;
argv += interp->iskips;
#ifndef NO_JAZ
/* Mount zip at end of executable */
Jsi_Value *v = Jsi_Executable(interp);
const char *exeFile = (v?Jsi_ValueString(interp, v, NULL):NULL);
int jsFound = 0;
if (v && (argc != 2 || Jsi_Strcmp(argv[1], "--nozvfs"))) {
rc = Jsi_EvalZip(interp, exeFile, JSI_ZVFS_DIR, &jsFound);
if (rc == JSI_OK) {
interp->selfZvfs = 1;
if (!jsFound) {
#if (JSI__FILESYS && JSI__ZVFS)
fprintf(stderr, "warning: no main.jsi or autoload.jsi\n");
#endif
}
if (jsi_deleted)
return jsi_DoExit(interp, jsi_exitCode);
else if (rc != 0) {
fprintf(stderr, "Error\n");
return jsi_DoExit(interp, 1);
}
}
}
#endif
const char *ext = NULL, *ai1, *iext = (argc<=1?NULL:Jsi_Strrchr(argv[1], '.'));
if (interp->selfZvfs && iext && Jsi_Strcmp(iext,".fossil")==0) {
rc = Jsi_EvalString(interp, "runModule('Archive');", JSI_EVAL_ISMAIN);
goto done;
}
Jsi_ShiftArgs(interp, NULL);
if (argc <= 1) {
if (interp->opts.no_interactive && !interp->interactive)
return interp;
rc = Jsi_Interactive(interp, JSI_OUTPUT_QUOTE|JSI_OUTPUT_NEWLINES);
goto done;
}
ai1 = argv[1];
if ((!Jsi_Strcmp(ai1, "-help") || !Jsi_Strcmp(ai1, "-h")) && argc<=3) {
if (argc>2) {
if (Jsi_PkgRequire(interp, "Help", 0)>=0) {
char tbuf[BUFSIZ];
snprintf(tbuf, sizeof(tbuf), "return runModule('Help', '%s'.trim().split(null));", argv[2]);
Jsi_RC rc = Jsi_EvalString(interp, tbuf, 0);
const char *hstr = Jsi_ValueToString(interp, interp->retValue, NULL);
if (rc == JSI_OK)
puts(hstr);
return jsi_DoExit(interp, 1);
}
}
dohelp:
puts("USAGE:\n jsish [PREFIX-OPTS] [COMMAND-OPTS|FILE] ...\n"
"\nPREFIX-OPTS:\n"
" --C FILE\tOption file of config options.\n"
" --F\t\tTrace all function calls and returns.\n"
" --I OPT:VAL\tInterp option: equivalent to Interp.conf({OPT:VAL}).\n"
" --L PATH\tSet safeMode to \"lockdown\" using PATH for safe(Read/Write)Dirs.\n"
" --T OPT\tTypecheck option: equivalent to \"use OPT\".\n"
" --U\t\tDisplay unittest output, minus pass/fail compare.\n"
" --V\t\tSame as --U, but adds file and line number to output.\n"
"\nCOMMAND-OPTS:\n"
" -a\t\tArchive: mount an archive (zip, sqlar or fossil repo) and run module.\n"
" -c\t\tCData: generate .c or JSON output from a .jsc description.\n"
" -d\t\tDebug: console script debugger.\n"
" -e CODE ...\tEvaluate javascript CODE.\n"
" -g\t\tGendeep: generate html output from markdeep source.\n"
" -h ?CMD?\tHelp: show help for jsish or its commands.\n"
" -m\t\tModule: utility create/manage/invoke a Module.\n"
" -s\t\tSafe: runs script in safe sub-interp.\n"
" -u\t\tUnitTest: test script file(s) or directories .js/.jsi files.\n"
" -w\t\tWget: web client to download file from url.\n"
" -v\t\tVersion: show version detail: add an arg to show only X.Y.Z\n"
" -z\t\tZip: append/manage zip files at end of executable.\n"
" -D\t\tDebugUI: web-gui script debugger.\n"
" -J\t\tJSpp: preprocess javascript for web.\n"
" -S\t\tSqliteUI: web-gui for sqlite database file.\n"
" -W\t\tWebsrv: web server to serve out content.\n"
"\nInterp options may also be set via the confFile.'\n"
);
return jsi_DoExit(interp, 1);
}
if (!Jsi_Strcmp(ai1, "-version"))
ai1 = "-v";
if (ai1[0] == '-') {
switch (ai1[1]) {
case 'a':
rc = Jsi_EvalString(interp, "runModule('Archive');", JSI_EVAL_ISMAIN);
break;
case 'c':
rc = Jsi_EvalString(interp, "runModule('Cdata');", JSI_EVAL_ISMAIN);
break;
case 'd':
interp->debugOpts.isDebugger = 1;
rc = Jsi_EvalString(interp, "runModule('Debug');", JSI_EVAL_ISMAIN);
break;
case 'D':
interp->debugOpts.isDebugger = 1;
rc = Jsi_EvalString(interp, "runModule('DebugUI');", JSI_EVAL_ISMAIN);
break;
case 'e':
if (argc < 3)
rc = Jsi_LogError("missing argument");
else {
rc = Jsi_EvalString(interp, argv[2], JSI_EVAL_ISMAIN|JSI_EVAL_NOSKIPBANG);
if (rc == JSI_OK && argc>3) {
first += 2;
Jsi_ShiftArgs(interp, NULL);
Jsi_ShiftArgs(interp, NULL);
goto dofile;
}
}
break;
case 'g':
rc = Jsi_EvalString(interp, "runModule('GenDeep');", JSI_EVAL_ISMAIN);
break;
case 'h':
goto dohelp;
case 'J':
rc = Jsi_EvalString(interp, "runModule('Jspp');", JSI_EVAL_ISMAIN);
break;
case 'm':
if (argc <= 2 || argv[2][0] == '-')
rc = Jsi_EvalString(interp, "runModule('Module');", JSI_EVAL_ISMAIN);
else {
Jsi_DString dStr = {}, eStr = {};
const char *cps, *cpe;
cps = Jsi_Strrchr(argv[2], '/');
if (cps) cps++; else cps = argv[2];
cpe = Jsi_Strrchr(cps, '.');
int len = (cpe?cpe-cps:(int)Jsi_Strlen(cps));
if (cpe)
Jsi_DSPrintf(&dStr, "source(\"%s\");", argv[2]);
else
Jsi_DSPrintf(&dStr, "require(\"%s\");", argv[2]);
Jsi_DSPrintf(&dStr, "puts(runModule(\"%.*s\",console.args.slice(1)));", len, cps);
rc = Jsi_EvalString(interp, Jsi_DSValue(&dStr), JSI_EVAL_NOSKIPBANG);
Jsi_DSFree(&dStr);
Jsi_DSFree(&eStr);
}
break;
case 's':
rc = Jsi_EvalString(interp, "runModule('Safe');", JSI_EVAL_ISMAIN);
break;
case 'S':
rc = Jsi_EvalString(interp, "runModule('SqliteUI');", JSI_EVAL_ISMAIN);
break;
case 'u':
rc = Jsi_EvalString(interp, "exit(runModule('UnitTest'));", JSI_EVAL_ISMAIN);
break;
case 'v': {
char str[200] = "\n";
Jsi_Value* fval = Jsi_ValueNewStringKey(interp, "/zvfs/lib/sourceid.txt");
if (!Jsi_Access(interp, fval, R_OK)) {
Jsi_Channel chan = Jsi_Open(interp, fval, "r");
if (chan)
Jsi_Read(interp, chan, str, sizeof(str));
}
if (argc>2)
printf("%u.%u.%u\n", JSI_VERSION_MAJOR, JSI_VERSION_MINOR, JSI_VERSION_RELEASE);
else
printf("%u.%u.%u %." JSI_VERFMT_LEN JSI_NUMGFMT " %s", JSI_VERSION_MAJOR, JSI_VERSION_MINOR, JSI_VERSION_RELEASE, Jsi_Version(), str);
return jsi_DoExit(interp, 1);
}
case 'w':
rc = Jsi_EvalString(interp, "runModule('Wget');", JSI_EVAL_ISMAIN);
break;
case 'W':
rc = Jsi_EvalString(interp, "runModule('Websrv');", JSI_EVAL_ISMAIN);
break;
case 'z':
rc = Jsi_EvalString(interp, "runModule('Zip');", JSI_EVAL_ISMAIN);
break;
default:
puts("usage: jsish [ --C FILE | --I OPT:VAL | --L PATH | --T OPT | --U | --V | --F ] | -e STRING |\n\t"
"| -a | -c | -d | -D | -h | -m | -s | -S | -u | -v | -w | -W | -z | FILE ...\nUse -help for long help.");
return jsi_DoExit(interp, 1);
}
} else {
dofile:
ext = Jsi_Strrchr(argv[first], '.');
/* Support running "main.jsi" from a zip file. */
if (ext && (Jsi_Strcmp(ext,".zip")==0 ||Jsi_Strcmp(ext,".jsz")==0 ) ) {
rc = Jsi_EvalZip(interp, argv[first], NULL, &jsFound);
if (rc<0) {
fprintf(stderr, "zip mount failed\n");
return jsi_DoExit(interp, 1);
}
if (!(jsFound&JSI_ZIP_MAIN)) {
fprintf(stderr, "main.jsi not found\n");
return jsi_DoExit(interp, 1);
}
} else if (ext && !Jsi_Strcmp(ext,".jsc")) {
Jsi_DString dStr = {};
Jsi_DSPrintf(&dStr, "console.args.unshift('%s'); runModule('CData');", argv[first]);
rc = Jsi_EvalString(interp, Jsi_DSValue(&dStr), JSI_EVAL_ISMAIN|JSI_EVAL_NOSKIPBANG);
Jsi_DSFree(&dStr);
} else {
if (argc>1) {
jsi_vf = Jsi_ValueNewStringKey(interp, argv[first]);
Jsi_IncrRefCount(interp, jsi_vf);
}
rc = Jsi_EvalFile(interp, jsi_vf, JSI_EVAL_ARGV0|JSI_EVAL_AUTOINDEX|JSI_EVAL_ISMAIN);
if (jsi_vf) {
Jsi_DecrRefCount(interp, jsi_vf);
jsi_vf = NULL;
}
}
}
if (jsi_deleted) //TODO: rationalize jsi_deleted, jsi_exitCode, etc
return jsi_DoExit(rc==JSI_EXIT?NULL:interp, jsi_exitCode);
if (rc == JSI_OK) {
/* Skip output from an ending semicolon which evaluates to undefined */
Jsi_Value *ret = Jsi_ReturnValue(interp);
if (!Jsi_ValueIsType(interp, ret, JSI_VT_UNDEF)) {
Jsi_DString dStr = {};
fputs(Jsi_ValueGetDString(interp, ret, &dStr, 0), stdout);
Jsi_DSFree(&dStr);
fputs("\n", stdout);
}
} else {
if (!interp->parent && !interp->isHelp)
fprintf(stderr, "ERROR: %s\n", interp->errMsgBuf);
return jsi_DoExit(interp, 1);
}
done:
if (rc == JSI_EXIT) {
if (opts)
opts->exitCode = jsi_exitCode;
return NULL;
}
if (jsi_deleted == 0 && interp->opts.auto_delete) {
Jsi_InterpDelete(interp);
return NULL;
}
return interp;
}
|
CWE-120
| null | 520,741 |
185370777007312442860469894292552259536
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC Jsi_ListConf(Jsi_List *listPtr, Jsi_MapOpts *opts, bool set)
{
if (set) {
listPtr->opts = *opts;
} else {
*opts = listPtr->opts;
}
return JSI_OK;
}
|
CWE-120
| null | 520,742 |
242013444343005449946834738207352994359
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void dbRollbackHandler(void *cd) {
Jsi_Db *jdb = (Jsi_Db*)cd;
Jsi_Interp *interp = jdb->interp;
Jsi_Value *vpargs, *items[2] = {}, *ret = Jsi_ValueNew1(interp);
items[0] = Jsi_ValueNewObj(interp, jdb->fobj);
vpargs = Jsi_ValueMakeObject(interp, NULL, Jsi_ObjNewArray(interp, items, 1, 0));
Jsi_IncrRefCount(interp, vpargs);
Jsi_FunctionInvoke(interp, jdb->onRollback, NULL, &ret, NULL);
Jsi_DecrRefCount(interp, vpargs);
Jsi_DecrRefCount(interp, ret);
}
|
CWE-120
| null | 520,743 |
28549017929944957258053978711680570952
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static char * jsi_FSGetsProc(Jsi_Channel chan, char *s, int size) {
return fgets(s, size, _JSI_GETFP(chan,1));
}
|
CWE-120
| null | 520,744 |
150966636331781005039948406177288150227
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void jsiPush(Jsi_Interp* interp, int n) {
int i = 0;
do {
if (!_jsi_STACKIDX(interp->framePtr->Sp))
_jsi_STACKIDX(interp->framePtr->Sp) = Jsi_ValueNew1(interp);
if (!_jsi_THISIDX(interp->framePtr->Sp))
_jsi_THISIDX(interp->framePtr->Sp) = Jsi_ValueNew1(interp);
if (i++ >= n) break;
interp->framePtr->Sp++;
} while (1);
}
|
CWE-120
| null | 520,745 |
194156400785783524884460031970794377540
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_Value* Jsi_ValueMakeString(Jsi_Interp *interp, Jsi_Value **vPtr, const char *s) {
return Jsi_ValueMakeBlob(interp, vPtr, (unsigned char *)s, Jsi_Strlen(s));
}
|
CWE-120
| null | 520,746 |
264079598672354259679173983085814424429
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static int dbProgressHandler(void *cd) {
Jsi_Db *jdb = (Jsi_Db*)cd;
Jsi_Value *vpargs, *items[3] = {}, *ret;
Jsi_Interp *interp = jdb->interp;
items[0] = Jsi_ValueNewObj(interp, jdb->fobj);
vpargs = Jsi_ValueMakeObject(interp, NULL, Jsi_ObjNewArray(interp, items, 1, 0));
Jsi_IncrRefCount(interp, vpargs);
ret = Jsi_ValueNew1(interp);
int rc = Jsi_FunctionInvoke(interp, jdb->onProgress, vpargs, &ret, NULL);
if( JSI_OK!=rc ) {
jdb->errCnt++;
rc = 1;
} else
rc = dbGetIntBool(interp, ret);
Jsi_DecrRefCount(interp, vpargs);
Jsi_DecrRefCount(interp, ret);
return rc;
}
|
CWE-120
| null | 520,747 |
204919473562726073738805919076089852215
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC freeBindObjTbl(Jsi_Interp *interp, Jsi_HashEntry *hPtr, void *ptr) {
Jsi_Obj *v = (Jsi_Obj *)ptr;
if (!v) return JSI_OK;
SIGASSERT(v,OBJ);
if (v->ot != JSI_OT_FUNCTION)
fprintf(stderr, "invalid func obj\n");
else if (v->d.fobj && v->d.fobj->scope) {
v->d.fobj->scope = NULL;
}
Jsi_ObjDecrRefCount(interp, v);
return JSI_OK;
}
|
CWE-120
| null | 520,748 |
70218674411926405781391784001337855127
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
bool Jsi_ValueIsObjType(Jsi_Interp *interp, Jsi_Value *v, Jsi_otype otype)
{
if (v == NULL || v->vt != JSI_VT_OBJECT)
return 0;
if (otype != JSI_OT_ARRAY)
return (v->d.obj->ot == otype);
if (v->d.obj->ot != JSI_OT_OBJECT || !v->d.obj->isarrlist)
return 0;
return 1;
}
|
CWE-120
| null | 520,749 |
183986860922561008330481043590508225902
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_OptionsDup(Jsi_Interp *interp, const Jsi_OptionSpec *staticSpecs)
{
unsigned int entrySpace = sizeof(Jsi_OptionSpec);
const Jsi_OptionSpec *staticSpecPtr;
Jsi_OptionSpec *newSpecs;
for (staticSpecPtr=staticSpecs; staticSpecPtr->id>=JSI_OPTION_BOOL && staticSpecPtr->id<JSI_OPTION_END && staticSpecPtr->name;
staticSpecPtr++) {
entrySpace += sizeof(Jsi_OptionSpec);
}
newSpecs = (Jsi_OptionSpec *) Jsi_Malloc(entrySpace);
memcpy((void *) newSpecs, (void *) staticSpecs, entrySpace);
return newSpecs;
}
|
CWE-120
| null | 520,750 |
180108349395358756547256074700833407063
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC jsi_wsfreeHandlers(Jsi_Interp *interp, Jsi_HashEntry* hPtr, void *ptr) {
jsi_wsHander *h = (jsi_wsHander*)ptr;
if (!h)
return JSI_OK;
if (h->val)
Jsi_DecrRefCount(interp, h->val);
if (h->objVar)
Jsi_DecrRefCount(interp, h->objVar);
Jsi_Free(h);
return JSI_OK;
}
|
CWE-120
| null | 520,751 |
264375593275710597566223126821372666800
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_Filesystem *jsi_FilesysFind(const char *name)
{
FSList *fsPtr = jsiFSList;
while (fsPtr != NULL) {
if (!Jsi_Strcmp(fsPtr->fsPtr->typeName, name))
return fsPtr->fsPtr;
fsPtr = fsPtr->next;
}
return NULL;
}
|
CWE-120
| null | 520,752 |
160015753429933553086691895837065544825
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
const char *jsi_DbOptionTypeStr(Jsi_OptionId typ, bool cname)
{
const Jsi_OptionTypedef* ti = Jsi_OptionTypeInfo(typ);
if (ti)
return (cname?ti->cName:ti->idName);
return NULL;
}
|
CWE-120
| null | 520,753 |
128919224182451368914648407301427990189
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
int Jsi_OptionsChanged(Jsi_Interp *interp, Jsi_OptionSpec *spec, const char *pattern, ...)
{
va_list argList;
Jsi_OptionSpec *specPtr;
const char *option = pattern;
int cnt = 0;
va_start(argList, pattern);
spec = jsi_GetCachedOptionSpecs(interp, spec);
do {
for (specPtr = spec; specPtr->id>=JSI_OPTION_BOOL && specPtr->id < JSI_OPTION_END; specPtr++) {
if ((Jsi_GlobMatch(option, specPtr->name, 0)) &&
(specPtr->flags & JSI_OPT_IS_SPECIFIED)) {
cnt++;
}
}
assert(specPtr->id == JSI_OPTION_END);
} while ((option = va_arg(argList, char *)) != NULL);
va_end(argList);
return cnt;
}
|
CWE-120
| null | 520,754 |
329343892523709781428396095807465254666
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC FilesysOpenCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr)
{
UdfGet(udf, _this, funcPtr);
if (try_open_file(interp, udf, args) != JSI_OK) {
Jsi_ValueMakeBool(interp, ret, 0);
}
Jsi_ValueMakeBool(interp, ret, 1);
return JSI_OK;
}
|
CWE-120
| null | 520,755 |
235080593084708850370274427295145262643
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC MySqlConfCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr)
{
MySqlObj *jdb;
if (!(jdb = _mysql_getDbHandle(interp, _this, funcPtr))) return JSI_ERROR;
int oms = jdb->maxStmts;
const char *oldu = jdb->user, *oldpw = jdb->password, *olddb = jdb->database;
Jsi_RC rc = Jsi_OptionsConf(interp, SqlOptions, jdb, Jsi_ValueArrayIndex(interp, args, 0), ret, 0);
if (jdb->maxStmts<0 || jdb->maxStmts>MAX_PREPARED_STMTS) {
JSI_DBQUERY_PRINTF( "option maxStmts value %d is not in range 0..%d", jdb->maxStmts, MAX_PREPARED_STMTS);
jdb->maxStmts = oms;
rc = JSI_ERROR;
}
if (oldu != jdb->user || oldpw != jdb->password || olddb != jdb->database)
if (!mysql_change_user(jdb->db, jdb->user, jdb->password, jdb->database)) {
rc = JSI_ERROR;
jdb->user = oldu;
jdb->password = oldpw;
jdb->database = olddb;
}
mdbStmtLimit(jdb);
return rc;
}
|
CWE-120
| null | 520,756 |
49678324033153122067296327085893621549
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_TreeEntry *TreeStringCreate( Jsi_Tree *treePtr, const void *key, bool *newPtr)
{
Jsi_TreeEntry *hPtr;
size_t size;
if ((hPtr = Jsi_TreeEntryFind(treePtr, key))) {
if (newPtr)
*newPtr = 0;
return hPtr;
}
if (newPtr)
*newPtr = 1;
size = sizeof(Jsi_TreeEntry) + Jsi_Strlen((char*)key) /*- sizeof(jsi_TreeKey)*/ + 1;
hPtr = (Jsi_TreeEntry*)Jsi_Calloc(1,size);
SIGINIT(hPtr,TREEENTRY);
hPtr->typ = JSI_MAP_TREE;
hPtr->treePtr = treePtr;
hPtr->value = 0;
Jsi_Strcpy(hPtr->key.string, (char*)key);
treePtr->numEntries++;
return hPtr;
}
|
CWE-120
| null | 520,757 |
330429638130247118945558825817061657466
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC DebugAddCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr)
{
if (!interp->breakpointHash)
interp->breakpointHash = Jsi_HashNew(interp, JSI_KEYS_STRING, jsi_HashFree);
int argc = Jsi_ValueGetLength(interp, args);
jsi_BreakPoint *bptr, bp = {};
Jsi_Number vnum;
if (argc>1 && Jsi_ValueGetBoolean(interp, Jsi_ValueArrayIndex(interp, args, 1), &bp.temp) != JSI_OK)
return Jsi_LogError("bad boolean");
Jsi_Value *v = Jsi_ValueArrayIndex(interp, args, 0);
if (Jsi_ValueGetNumber(interp, v, &vnum) == JSI_OK) {
bp.line = (int)vnum;
bp.file = interp->curFile;
} else {
const char *val = Jsi_ValueArrayIndexToStr(interp, args, 0, NULL);
const char *cp;
if (isdigit(val[0])) {
if (Jsi_GetInt(interp, val, &bp.line, 0) != JSI_OK)
return Jsi_LogError("bad number");
bp.file = interp->curFile;
} else if ((cp = Jsi_Strchr(val, ':'))) {
if (Jsi_GetInt(interp, cp+1, &bp.line, 0) != JSI_OK)
return Jsi_LogError("bad number");
Jsi_DString dStr = {};
Jsi_DSAppendLen(&dStr, val, cp-val);
bp.file = Jsi_KeyAdd(interp, Jsi_DSValue(&dStr));
Jsi_DSFree(&dStr);
} else {
bp.func = Jsi_KeyAdd(interp, val);
}
}
if (bp.line<=0 && !bp.func)
return Jsi_LogError("bad number");
char nbuf[JSI_MAX_NUMBER_STRING];
bp.id = ++interp->debugOpts.breakIdx;
bp.enabled = 1;
snprintf(nbuf, sizeof(nbuf), "%d", bp.id);
bptr = (jsi_BreakPoint*)Jsi_Malloc(sizeof(*bptr));
*bptr = bp;
Jsi_HashSet(interp->breakpointHash, (void*)nbuf, bptr);
Jsi_ValueMakeNumber(interp, ret, (Jsi_Number)bp.id);
return JSI_OK;
}
|
CWE-120
| null | 520,758 |
74660361809172685379316264730077884929
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_subscript(jsi_Pstate *p, jsi_Pline *line, int right_val) { JSI_NEW_CODESLN(0,OP_SUBSCRIPT, right_val); }
|
CWE-120
| null | 520,759 |
285630954401563436575173483685302235002
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_Value *Jsi_StringSplit(Jsi_Interp *interp, const char *str, const char *spliton)
{
char **argv; int argc;
Jsi_DString dStr;
Jsi_DSInit(&dStr);
Jsi_SplitStr(str, &argc, &argv, spliton, &dStr);
Jsi_Value *nret = Jsi_ValueNewArray(interp, NULL, 0);
Jsi_Obj *obj = nret->d.obj;
int i;
for (i = 0; i < argc; ++i) {
Jsi_ObjArraySet(interp, obj, Jsi_ValueNewStringDup(interp, argv[i]), i);
}
Jsi_ObjSetLength(interp, obj, argc);
Jsi_ValueMakeArrayObject(interp, &nret, obj);
Jsi_DSFree(&dStr);
return nret;
}
|
CWE-120
| null | 520,760 |
144229735434035713032136836084470929011
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void jsi_wswebsocketObjErase(jsi_wsCmdObj *cmdPtr)
{
if (cmdPtr->interp) {
if (cmdPtr->event)
Jsi_EventFree(cmdPtr->interp, cmdPtr->event);
cmdPtr->event = NULL;
if (cmdPtr->hasOpts)
Jsi_OptionsFree(cmdPtr->interp, WSOptions, cmdPtr, 0);
cmdPtr->hasOpts = 0;
if (cmdPtr->handlers)
Jsi_HashDelete(cmdPtr->handlers);
cmdPtr->handlers = NULL;
if (cmdPtr->pssTable)
Jsi_HashDelete(cmdPtr->pssTable);
cmdPtr->pssTable = NULL;
if (cmdPtr->fileHash)
Jsi_HashDelete(cmdPtr->fileHash);
cmdPtr->fileHash = NULL;
}
cmdPtr->interp = NULL;
}
|
CWE-120
| null | 520,761 |
270899580680755463378725268170300343091
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_Wide jsi_strtoull(const char *str, char **endptr)
{
#ifdef JSI__LONG_LONG
int sign;
int base;
int i = JsiNumberBase(str, &base, &sign);
if (base != 10) {
Jsi_Wide value = strtoull(str + i, endptr, base);
if (endptr == NULL || *endptr != str + i) {
return value * sign;
}
}
/* Can just do a regular base-10 conversion */
return strtoull(str, endptr, 10);
#else
return (unsigned long)jsi_strtol(str, endptr);
#endif
}
|
CWE-120
| null | 520,762 |
327260075167165191678163826956287073732
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void jsiDumpInstr(Jsi_Interp *interp, jsi_Pstate *ps, Jsi_Value *_this,
jsi_TryList *trylist, jsi_OpCode *ip, Jsi_OpCodes *opcodes)
{
int i;
char buf[JSI_MAX_NUMBER_STRING*2];
jsi_code_decode(interp, ip, ip - opcodes->codes, buf, sizeof(buf));
Jsi_Printf(interp, jsi_Stderr, "%p: %-30.200s : THIS=%s, STACK=[", ip, buf, jsi_evalprint(_this));
for (i = 0; i < interp->framePtr->Sp; ++i) {
Jsi_Printf(interp, jsi_Stderr, "%s%s", (i>0?", ":""), jsi_evalprint(_jsi_STACKIDX(i)));
}
Jsi_Printf(interp, jsi_Stderr, "]");
if (ip->fname) {
const char *fn = ip->fname, *cp = Jsi_Strrchr(fn, '/');
if (cp) fn = cp+1;
Jsi_Printf(interp, jsi_Stderr, ", %s:%d", fn, ip->Line);
}
Jsi_Printf(interp, jsi_Stderr, "\n");
jsi_TryList *tlt = trylist;
for (i = 0; tlt; tlt = tlt->next) i++;
if (ps->last_exception)
Jsi_Printf(interp, jsi_Stderr, "TL: %d, excpt: %s\n", i, jsi_evalprint(ps->last_exception));
}
|
CWE-120
| null | 520,763 |
73565616087531173920973545376053121789
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_Number mdbMyTimeToJS(MYSQL_TIME* mtm)
{
struct tm tm;
tm.tm_sec = mtm->second;
tm.tm_min = mtm->minute;
tm.tm_hour = mtm->hour;
tm.tm_mday = mtm->day;
tm.tm_mon = mtm->month-1;
tm.tm_year = mtm->year - 1900;
time_t tim = mktime(&tm);
if (tim == (time_t)-1)
return -1;
return (Jsi_Number)tim*1000 + (Jsi_Number)mtm->second_part/1000000.0;
}
|
CWE-120
| null | 520,764 |
60471994726938243989047499903633504914
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
char *jsiLNhints(const char *buf, int *color, int *bold) {
int i, len = Jsi_Strlen(buf);
for (i=0; jsiFilePreCmds[i]; i++)
if (!Jsi_Strncmp(buf, jsiFilePreCmds[i], Jsi_Strlen(jsiFilePreCmds[i]))) break;
if (jsiFilePreCmds[i]) {
const char *ce = buf+len-1, *cp = "('<file>";
if ((*ce =='\'' || *ce =='\"') && buf[len-2]=='(') cp+=2;
else if (*ce=='(') cp++;
else return NULL;
*color = 35;
*bold = 0;
return (char*)cp;
}
return NULL;
}
|
CWE-120
| null | 520,765 |
94078854938229209184617471362854377445
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void jsiClearStack(Jsi_Interp *interp, int ofs) {
Jsi_Value **vPtr = &_jsi_STACKIDX(interp->framePtr->Sp-ofs), *v = *vPtr;
if (!v) return;
#ifndef XX_NEWSTACK
Jsi_ValueReset(interp, vPtr);
#else
if (v->refCnt<=1)
Jsi_ValueReset(interp, vPtr);
else {
Jsi_DecrRefCount(interp, v);
_jsi_STACKIDX(interp->framePtr->Sp-ofs) = Jsi_ValueNew1(interp);
}
#endif
}
|
CWE-120
| null | 520,766 |
51991391443931382939202000840595737423
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_inc(jsi_Pstate *p, jsi_Pline *line, int e) { JSI_NEW_CODESLN(0,OP_INC, e); }
|
CWE-120
| null | 520,767 |
14908373141851059121036662353209198124
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC MySqlQueryCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr)
{
Jsi_RC rc = JSI_OK;
MySqlObj *jdb;
if (!(jdb = _mysql_getDbHandle(interp, _this, funcPtr))) return JSI_ERROR;
Jsi_Value *vSql = Jsi_ValueArrayIndex(interp, args, 0);
Jsi_DString eStr = {};
JSI_DSTRING_VAR(dStr, JSI_DB_DSTRING_SIZE);
const char *zSql = Jsi_ValueGetDString(interp, vSql, &eStr, 0);
Jsi_Value *arg = Jsi_ValueArrayIndex(interp, args, 1);
int cnt = 0;
char **apColName = NULL;
Jsi_OptionId *apColType = NULL;
int isopts = 0;
MyDbEvalContext sEval = {};
QueryOpts opts, *oEopt = NULL;
opts = jdb->queryOpts;
opts.callback = NULL;
opts.width = NULL;
Jsi_Value *callback = NULL, *width = NULL;
if (arg) {
if (Jsi_ValueIsFunction(interp,arg))
callback = opts.callback = arg;
else if (Jsi_ValueIsString(interp, arg))
opts.objName = Jsi_ValueString(interp, arg, NULL);
else if (Jsi_ValueIsObjType(interp, arg, JSI_OT_ARRAY))
opts.values = arg;
else if (Jsi_ValueIsObjType(interp, arg, JSI_OT_OBJECT))
isopts = 1;
else {
rc = Jsi_LogError("argument must be null, a function, string, array or options");
goto bail;
}
}
if (isopts) {
if (Jsi_OptionsProcess(interp, QueryFmtOptions, &opts, arg, 0) < 0) {
rc = JSI_ERROR;
goto bail;
}
callback = (opts.callback ? opts.callback : jdb->queryOpts.callback);
width = (opts.width ? opts.width : jdb->queryOpts.width);
}
/* if (jdb->queryOpts.CData) {
char *cdata = (char*)jdb->queryOpts.CData;
MySqlObjMultipleBind* copts = Jsi_CarrayLookup(interp, cdata);
if (!copts)
return Jsi_LogError("unknown CData option: %s", jdb->queryOpts.CData);
int n = MySqlObjQuery(jdb, copts->opts, copts->data, copts->numData, zSql, copts->flags);
Jsi_ValueMakeNumber(interp, ret, (Jsi_Number)n);
return JSI_OK;
} */
if (opts.objName) {
if (Jsi_SqlObjBinds(interp, &eStr, opts.objName, !(opts.objOpts&OBJMODE_NOTYPES),
!(opts.objOpts&OBJMODE_NODEFAULTS), (opts.objOpts&OBJMODE_NULLDEFAULTS)!=0) != JSI_OK)
goto bail;
zSql = Jsi_DSValue(&eStr);
}
if (!opts.separator) {
switch (opts.mode) {
case _mdb_EF_LIST: opts.separator = "|"; break;
case _mdb_EF_COLUMN: opts.separator = " "; break;
case _mdb_EF_TABS: opts.separator = "\t"; break;
default: opts.separator = ",";
}
}
Jsi_DString sStr;
Jsi_DSInit(&sStr);
sEval.nocache = opts.nocache;
if (mdbEvalInit(interp, &sEval, jdb, zSql, &sStr, 0, 0) != JSI_OK) {
rc = JSI_ERROR;
goto bail;
}
sEval.namedParams = (opts.noNamedParams==0 && !opts.values);
sEval.ret = *ret;
oEopt = jdb->optPtr;
jdb->optPtr = &opts;
if (sEval.namedParams) {
rc = mdbEvalPrep(&sEval);
if (rc == JSI_ERROR)
goto bail;
if (rc == JSI_BREAK) {
rc = JSI_OK;
goto bail;
}
}
if (opts.mode == _mdb_EF_NONE)
goto bail;
if (callback) {
sEval.tocall = callback;
if (opts.mode != _mdb_EF_ROWS)
rc = Jsi_LogError("'mode' must be 'rows' with 'callback'");
else
rc = mdbEvalCallCmd(&sEval, interp, JSI_OK);
goto bail;
}
switch (opts.mode) {
case _mdb_EF_NONE:
while(JSI_OK==(rc = mdbEvalStep(&sEval)) ) {
cnt++;
if (opts.limit && cnt>=opts.limit) break;
}
goto bail;
break;
case _mdb_EF_JSON:
if (opts.headers) {
Jsi_DSAppend(dStr, "[ ", NULL);
while( JSI_OK==(rc = mdbEvalStep(&sEval)) ) {
int i;
int nCol;
mdbEvalRowInfo(&sEval, &nCol, &apColName, &apColType);
if (cnt == 0) {
Jsi_DSAppend(dStr, "[", NULL);
for(i=0; i<nCol; i++) {
if (i)
Jsi_DSAppend(dStr, ", ", NULL);
Jsi_JSONQuote(interp, apColName[i], -1, dStr);
}
Jsi_DSAppend(dStr, "]", NULL);
cnt++;
}
if (cnt)
Jsi_DSAppend(dStr, ", ", NULL);
Jsi_DSAppend(dStr, "[", NULL);
for(i=0; i<nCol; i++) {
if (i)
Jsi_DSAppend(dStr, ", ", NULL);
mdbEvalSetColumnJSON(&sEval, i, dStr);
}
Jsi_DSAppend(dStr, "]", NULL);
cnt++;
if (opts.limit && cnt>opts.limit) break;
}
Jsi_DSAppend(dStr, " ]", NULL);
} else {
Jsi_DSAppend(dStr, "[ ", NULL);
while( JSI_OK==(rc = mdbEvalStep(&sEval)) ) {
int i;
int nCol;
mdbEvalRowInfo(&sEval, &nCol, &apColName, &apColType);
if (cnt)
Jsi_DSAppend(dStr, ", ", NULL);
Jsi_DSAppend(dStr, "{", NULL);
for(i=0; i<nCol; i++) {
if (i)
Jsi_DSAppend(dStr, ", ", NULL);
Jsi_JSONQuote(interp, apColName[i], -1, dStr);
Jsi_DSAppend(dStr, ":", NULL);
mdbEvalSetColumnJSON(&sEval, i, dStr);
}
Jsi_DSAppend(dStr, "}", NULL);
cnt++;
if (opts.limit && cnt>=opts.limit) break;
}
Jsi_DSAppend(dStr, " ]", NULL);
}
break;
case _mdb_EF_JSON2: {
while( JSI_OK==(rc = mdbEvalStep(&sEval)) ) {
int i;
int nCol;
mdbEvalRowInfo(&sEval, &nCol, &apColName, &apColType);
if (cnt == 0 && 1) {
Jsi_DSAppend(dStr, "{ \"names\": [ ", NULL);
for(i=0; i<nCol; i++) {
if (i)
Jsi_DSAppend(dStr, ", ", NULL);
Jsi_JSONQuote(interp, apColName[i], -1, dStr);
}
Jsi_DSAppend(dStr, " ], \"values\": [ ", NULL);
}
if (cnt)
Jsi_DSAppend(dStr, ", ", NULL);
Jsi_DSAppend(dStr, "[", NULL);
for(i=0; i<nCol; i++) {
if (i)
Jsi_DSAppend(dStr, ", ", NULL);
mdbEvalSetColumnJSON(&sEval, i, dStr);
}
Jsi_DSAppend(dStr, " ]", NULL);
cnt++;
if (opts.limit && cnt>=opts.limit) break;
}
if (cnt)
Jsi_DSAppend(dStr, " ] } ", NULL);
}
break;
case _mdb_EF_LIST:
while( JSI_OK==(rc = mdbEvalStep(&sEval)) ) {
int i;
int nCol;
mdbEvalRowInfo(&sEval, &nCol, &apColName, &apColType);
if (cnt == 0 && opts.headers) {
for(i=0; i<nCol; i++) {
if (i)
Jsi_DSAppend(dStr, opts.separator, NULL);
Jsi_DSAppend(dStr, apColName[i], NULL);
}
}
if (cnt || opts.headers)
Jsi_DSAppend(dStr, "\n", NULL);
for(i=0; i<nCol; i++) {
if (i)
Jsi_DSAppend(dStr, opts.separator, NULL);
mdbEvalSetColumn(&sEval, i, dStr);
}
cnt++;
if (opts.limit && cnt>=opts.limit) break;
}
break;
case _mdb_EF_COLUMN: {
int *wids = NULL;
Jsi_DString vStr = {};
while( JSI_OK==(rc = mdbEvalStep(&sEval)) ) {
int i, w;
int nCol;
mdbEvalRowInfo(&sEval, &nCol, &apColName, &apColType);
if (cnt == 0 && nCol>0) {
Jsi_DString sStr;
wids = (int*)Jsi_Calloc(nCol, sizeof(int));
Jsi_DSInit(&sStr);
for(i=0; i<nCol; i++) {
int j = Jsi_Strlen(apColName[i]);
wids[i] = (j<10?10:j);
if (width) {
Jsi_Value *wv = Jsi_ValueArrayIndex(interp, width, i);
if (wv) {
Jsi_Number dv;
Jsi_ValueGetNumber(interp, wv, &dv);
if (dv>0)
wids[i] = (int)dv;
}
}
w = (j<wids[i] ? j : wids[i]);
Jsi_DSAppendLen(dStr, apColName[i], w);
w = (j<wids[i] ? wids[i]-j+1 : 0);
while (w-- > 0)
Jsi_DSAppend(dStr, " ", NULL);
}
for(i=0; i<nCol && opts.headers; i++) {
w = wids[i];
w -= Jsi_Strlen(apColName[i]);
if (i) {
Jsi_DSAppend(dStr, opts.separator, NULL);
Jsi_DSAppend(&sStr, opts.separator, NULL);
}
w = wids[i];
while (w-- > 0)
Jsi_DSAppend(&sStr, "-", NULL);
}
if (opts.headers)
Jsi_DSAppend(dStr, "\n", Jsi_DSValue(&sStr), "\n", NULL);
Jsi_DSFree(&sStr);
}
if (cnt)
Jsi_DSAppend(dStr, "\n", NULL);
for(i=0; i<nCol; i++) {
if (i)
Jsi_DSAppend(dStr, opts.separator, NULL);
Jsi_DSSetLength(&vStr, 0);
mdbEvalSetColumn(&sEval, i, &vStr);
int nl = Jsi_DSLength(&vStr);
if (nl > wids[i]) {
Jsi_DSSetLength(&vStr, wids[i]);
w = 0;
} else {
w = wids[i]-nl;
}
Jsi_DSAppend(dStr, Jsi_DSValue(&vStr), NULL);
while (w-- > 0)
Jsi_DSAppend(dStr, " ", NULL);
}
cnt++;
if (opts.limit && cnt>=opts.limit) break;
}
Jsi_DSFree(&vStr);
if (wids)
Jsi_Free(wids);
break;
}
case _mdb_EF_INSERT: {
Jsi_DString vStr = {};
while( JSI_OK==(rc = mdbEvalStep(&sEval)) ) {
int i;
int nCol;
const char *tbl = (opts.table ? opts.table : "table");
if (cnt)
Jsi_DSAppend(dStr, "\n", NULL);
Jsi_DSAppend(dStr, "INSERT INTO ", tbl, " VALUES(", NULL);
mdbEvalRowInfo(&sEval, &nCol, &apColName, &apColType);
for(i=0; i<nCol; i++) {
Jsi_Number dv;
const char *azArg;
Jsi_DSSetLength(&vStr, 0);
mdbEvalSetColumn(&sEval, i, &vStr);
MysqlPrep *prep = sEval.prep;
Jsi_OptionId ptype = prep->fieldResult[i].jsiTypeMap;
azArg = Jsi_DSValue(&vStr);
const char *zSep = i>0 ? ",": "";
if (azArg[i]==0 && ptype != JSI_OPTION_STRING) {
Jsi_DSAppend(dStr, zSep, "NULL", NULL);
} else if( ptype ==JSI_OPTION_STRING) {
if( zSep[0] ) Jsi_DSAppend(dStr,zSep, NULL);
mdbOutputQuotedString(dStr, azArg);
} else if (ptype==JSI_OPTION_BOOL || ptype ==JSI_OPTION_DOUBLE) {
Jsi_DSAppend(dStr, zSep, azArg, NULL);
} else if( Jsi_GetDouble(interp, azArg, &dv) == JSI_OK ) {
Jsi_DSAppend(dStr, zSep, azArg, NULL);
} else {
if( zSep[0] ) Jsi_DSAppend(dStr,zSep, NULL);
mdbOutputQuotedString(dStr, azArg);
}
}
Jsi_DSAppend(dStr, ");", NULL);
cnt++;
if (opts.limit && cnt>=opts.limit) break;
}
Jsi_DSFree(&vStr);
}
case _mdb_EF_TABS:
case _mdb_EF_CSV: {
Jsi_DString vStr = {};
while( JSI_OK==(rc = mdbEvalStep(&sEval)) ) {
int i;
int nCol;
mdbEvalRowInfo(&sEval, &nCol, &apColName, &apColType);
if (cnt == 0 && opts.headers) {
for(i=0; i<nCol; i++) {
if (i)
Jsi_DSAppend(dStr, opts.separator, NULL);
Jsi_DSAppend(dStr, apColName[i], NULL);
}
}
if (cnt || opts.headers)
Jsi_DSAppend(dStr, "\n", NULL);
for(i=0; i<nCol; i++) {
if (i)
Jsi_DSAppend(dStr, opts.separator, NULL);
Jsi_DSSetLength(&vStr, 0);
mdbEvalSetColumn(&sEval, i, &vStr);
if (opts.mode == _mdb_EF_CSV)
mdbOutputCsv(&opts, Jsi_DSValue(&vStr), dStr, 0);
else
Jsi_DSAppend(dStr, Jsi_DSValue(&vStr), NULL);
}
cnt++;
if (opts.limit && cnt>=opts.limit) break;
}
Jsi_DSFree(&vStr);
break;
}
case _mdb_EF_LINE: {
int i, w = 5, ww;
int nCol;
Jsi_DString vStr = {};
while( JSI_OK==(rc = mdbEvalStep(&sEval)) ) {
mdbEvalRowInfo(&sEval, &nCol, &apColName, &apColType);
if (cnt == 0) {
for(i=0; i<nCol; i++) {
ww = Jsi_Strlen(apColName[i]);
if (ww>w)
w = ww;
}
}
for(i=0; i<nCol; i++) {
Jsi_DString eStr;
Jsi_DSInit(&eStr);
Jsi_DSSetLength(&vStr, 0);
mdbEvalSetColumn(&sEval, i, &vStr);
Jsi_DSPrintf(&eStr, "%*s = %s", w, apColName[i], Jsi_DSValue(&vStr));
Jsi_DSAppend(dStr, (cnt?"\n":""), Jsi_DSValue(&eStr), NULL);
Jsi_DSFree(&eStr);
}
cnt++;
if (opts.limit && cnt>=opts.limit) break;
}
Jsi_DSFree(&vStr);
break;
}
case _mdb_EF_HTML: {
Jsi_DString vStr = {};
while( JSI_OK==(rc = mdbEvalStep(&sEval)) ) {
int i;
int nCol;
mdbEvalRowInfo(&sEval, &nCol, &apColName, &apColType);
if (cnt == 0 && opts.headers) {
Jsi_DSAppend(dStr, "<TR>", NULL);
for(i=0; i<nCol; i++) {
Jsi_DSAppend(dStr, "<TH>", NULL);
mdbOutputHtmlString(&opts, apColName[i], dStr);
Jsi_DSAppend(dStr, "</TH>", NULL);
}
Jsi_DSAppend(dStr, "</TR>", NULL);
}
if (cnt || opts.headers)
Jsi_DSAppend(dStr, "\n", NULL);
Jsi_DSAppend(dStr, "<TR>", NULL);
for(i=0; i<nCol; i++) {
Jsi_DSAppend(dStr, "<TD>", NULL);
Jsi_DSSetLength(&vStr, 0);
mdbEvalSetColumn(&sEval, i, &vStr);
mdbOutputHtmlString(&opts, Jsi_DSValue(&vStr), dStr);
Jsi_DSAppend(dStr, "</TD>", NULL);
}
Jsi_DSAppend(dStr, "</TR>", NULL);
cnt++;
if (opts.limit && cnt>=opts.limit) break;
}
Jsi_DSFree(&vStr);
break;
}
case _mdb_EF_ROWS:
{
Jsi_Value *vcur, *vrow;
int cnt = 0;
Jsi_Obj *oall, *ocur;
Jsi_ValueMakeArrayObject(interp, ret, oall = Jsi_ObjNewType(interp, JSI_OT_ARRAY));
while( JSI_OK==(rc = mdbEvalStep(&sEval)) ) {
int i;
int nCol;
mdbEvalRowInfo(&sEval, &nCol, &apColName, &apColType);
ocur = Jsi_ObjNewType(interp, JSI_OT_OBJECT);
vrow = Jsi_ValueMakeObject(interp, NULL, ocur);
for(i=0; i<nCol; i++) {
vcur = mdbEvalSetColumnValue(&sEval, i, NULL);
Jsi_ObjInsert(interp, ocur, apColName[i], vcur, 0);
}
Jsi_ObjArrayAdd(interp, oall, vrow);
cnt++;
if (opts.limit && cnt>=opts.limit) break;
}
mdbEvalFinalize(&sEval);
if (rc != JSI_ERROR)
rc = JSI_OK;
goto bail;
break;
}
case _mdb_EF_ARRAYS:
{
Jsi_Value *vcur, *vrow;
int cnt = 0;
Jsi_Obj *oall, *ocur;
Jsi_ValueMakeArrayObject(interp, ret, oall = Jsi_ObjNewType(interp, JSI_OT_ARRAY));
while( JSI_OK==(rc = mdbEvalStep(&sEval)) ) {
int i;
int nCol;
mdbEvalRowInfo(&sEval, &nCol, &apColName, &apColType);
if (cnt == 0 && opts.headers) {
vrow = Jsi_ValueMakeArrayObject(interp, NULL, ocur = Jsi_ObjNewType(interp, JSI_OT_ARRAY));
for(i=0; i<nCol; i++) {
vcur = Jsi_ValueNewStringDup(interp, apColName[i]);
Jsi_ObjArrayAdd(interp, ocur, vcur);
}
Jsi_ObjArrayAdd(interp, oall, vrow);
}
vrow = Jsi_ValueMakeArrayObject(interp, NULL, ocur = Jsi_ObjNewType(interp, JSI_OT_ARRAY));
for(i=0; i<nCol; i++) {
vcur = mdbEvalSetColumnValue(&sEval, i, NULL);
Jsi_ObjArrayAdd(interp, ocur, vcur);
}
Jsi_ObjArrayAdd(interp, oall, vrow);
cnt++;
if (opts.limit && cnt>=opts.limit) break;
}
mdbEvalFinalize(&sEval);
if (rc != JSI_ERROR)
rc = JSI_OK;
goto bail;
break;
}
case _mdb_EF_ARRAY1D:
{
Jsi_Value *vcur;
int cnt = 0;
Jsi_Obj *oall;
Jsi_ValueMakeArrayObject(interp, ret, oall = Jsi_ObjNewType(interp, JSI_OT_ARRAY));
while( JSI_OK==(rc = mdbEvalStep(&sEval)) ) {
int i;
int nCol;
mdbEvalRowInfo(&sEval, &nCol, &apColName, &apColType);
if (cnt == 0 && opts.headers) {
for(i=0; i<nCol; i++) {
vcur = Jsi_ValueNewStringDup(interp, apColName[i]);
Jsi_ObjArrayAdd(interp, oall, vcur);
}
}
for(i=0; i<nCol; i++) {
vcur = mdbEvalSetColumnValue(&sEval, i, NULL);
Jsi_ObjArrayAdd(interp, oall, vcur);
}
cnt++;
if (opts.limit && cnt>=opts.limit) break;
}
mdbEvalFinalize(&sEval);
if (rc != JSI_ERROR)
rc = JSI_OK;
goto bail;
break;
}
}
if( rc==JSI_BREAK ) {
rc = JSI_OK;
}
Jsi_ValueMakeStringDup(interp, ret, Jsi_DSValue(dStr));
bail:
mdbEvalFinalize(&sEval);
if (isopts) {
Jsi_OptionsFree(interp, QueryFmtOptions, &opts, 0);
}
Jsi_DSFree(dStr);
Jsi_DSFree(&eStr);
jdb->optPtr = oEopt;
return rc;
}
|
CWE-120
| null | 520,768 |
320544127664983019290616314274764885309
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
jsi_wsgetPss(jsi_wsCmdObj *cmdPtr, struct lws *wsi, void *user, int create, int ishttp)
{
Jsi_HashEntry *hPtr;
bool isNew = 0;
jsi_wsPss *pss = NULL;
if (user==NULL)
return NULL;
int sfd = lws_get_socket_fd(wsi);
if (sfd<0) {
return NULL;
}
int sid = ((sfd<<1)|ishttp);
if (create)
hPtr = Jsi_HashEntryNew(cmdPtr->pssTable, (void*)(intptr_t)sid, &isNew);
else
hPtr = Jsi_HashEntryFind(cmdPtr->pssTable, (void*)(intptr_t)sid);
if (hPtr && !isNew)
pss = (typeof(pss))Jsi_HashValueGet(hPtr);
if (!pss) {
if (!create)
return NULL;
pss = (typeof(pss))Jsi_Calloc(1, sizeof(*pss));
Jsi_HashValueSet(hPtr, pss);
pss->sig = JWS_SIG_PWS;
pss->hPtr = hPtr;
Jsi_HashValueSet(hPtr, pss);
pss->cmdPtr = cmdPtr;
pss->wsi = wsi;
pss->user = user; /* unused. */
pss->state = PWS_CONNECTED;
pss->stats.createTime = time(NULL);
pss->cnt = cmdPtr->idx++;
pss->wid = sid;
//pss->sfd = sfd;
pss->udata = Jsi_ValueNewObj(cmdPtr->interp, NULL);
Jsi_IncrRefCount(cmdPtr->interp, pss->udata);
if (cmdPtr->debug>2)
fprintf(stderr, "PSS CREATE: %p/%p/%p (http=%d) = %d\n", pss, user, wsi, ishttp, sid);
if (!ishttp) {
pss->isWebsock = 1;
cmdPtr->stats.connectCnt++;
cmdPtr->createCnt++;
cmdPtr->createLast = time(NULL);
}
}
if (pss) {
WSSIGASSERT(pss, PWS);
pss->stats.eventCnt++;
pss->stats.eventLast = time(NULL);
cmdPtr->stats.eventCnt++;
cmdPtr->stats.eventLast = time(NULL);
}
return pss;
}
|
CWE-120
| null | 520,769 |
232142552437064093248214352320526062886
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC jsiEvalFunction(jsi_Pstate *ps, jsi_OpCode *ip, int discard) {
Jsi_Interp *interp = ps->interp;
int stackargc = (int)(uintptr_t)ip->data;
jsiVarDeref(interp, stackargc + 1);
int tocall_index = interp->framePtr->Sp - stackargc - 1;
Jsi_Value *_this = _jsi_THISIDX(tocall_index),
*tocall = _jsi_STACKIDX(tocall_index), **spargs = _jsi_STACK+(interp->framePtr->Sp - stackargc),
*spretPtr = Jsi_ValueNew1(interp), *spretPtrOld = spretPtr,
*args = Jsi_ValueNewArrayObj(interp, spargs, stackargc, 1);
Jsi_IncrRefCount(interp, args);
if (_this->vt != JSI_VT_OBJECT)
_this = Jsi_ValueDup(interp, interp->Top_object);
else {
_this = Jsi_ValueDup(interp, _this);
jsiClearThis(interp, tocall_index);
}
Jsi_RC rc = jsi_FunctionSubCall(interp, args, _this, &spretPtr, tocall, discard);
jsiPop(interp, stackargc);
jsiClearStack(interp,1);
if (rc == JSI_CONTINUE) {
Jsi_ValueMakeUndef(interp, &_jsi_TOP);
rc = JSI_OK;
}
if (spretPtr == spretPtrOld) {
Jsi_ValueMove(interp, _jsi_TOP, spretPtr);
Jsi_DecrRefCount(interp, spretPtr);
} else {
/* returning a (non-copied) value reference */
Jsi_DecrRefCount(interp, _jsi_TOP);
_jsi_TOP = spretPtr;
}
Jsi_DecrRefCount(interp, args);
return rc;
}
|
CWE-120
| null | 520,770 |
226058145539488703667542570432313527185
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void insert_case3(Jsi_TreeEntry* n) {
Jsi_TreeEntry *g, *u = uncle(n);
if (node_color(u) == _JSI_TREE_RED) {
set_color(n->parent, _JSI_TREE_BLACK);
set_color(u, _JSI_TREE_BLACK);
g = grandparent(n);
set_color(g, _JSI_TREE_RED);
insert_case1(g);
} else {
insert_case4(n);
}
}
|
CWE-120
| null | 520,771 |
249008864163803422487819904808934076536
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void jsi_PstatePush(jsi_Pstate *ps)
{
Jsi_Interp *interp = ps->interp;
if (interp->cur_scope >= (int)(JSI_MAX_SCOPE - 1)) {
Jsi_LogBug("Scope chain too short");
return;
}
interp->cur_scope++;
}
|
CWE-120
| null | 520,772 |
136054295454822952725253263154064314218
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
const char *jsi_OptionTypeStr(Jsi_OptionId typ, bool cName)
{
const Jsi_OptionTypedef* ti = Jsi_OptionTypeInfo(typ);
if (ti)
return (cName?ti->cName:ti->idName);
return NULL;
}
|
CWE-120
| null | 520,773 |
18040517208218615570282211348107560461
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC jsi_NumberIsFiniteCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr, int op)
{
Jsi_Number num;
Jsi_Value *v;
bool b = 0;
int skip = 0;
ChkStringN(_this, funcPtr, v);
if (Jsi_GetNumberFromValue(interp, v, &num) != JSI_OK)
return JSI_ERROR;
switch (op) {
case 1: b = Jsi_NumberIsFinite(num); break;
case 2: b = Jsi_NumberIsInteger(num); break;
case 3: b = Jsi_NumberIsNaN(num); break;
case 4: b = Jsi_NumberIsSafeInteger(num); break;
}
Jsi_ValueMakeBool(interp, ret, b);
skip++;
return JSI_OK;
}
|
CWE-120
| null | 520,774 |
62127200107273129461114781232325230259
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
char *Jsi_Realpath(Jsi_Interp *interp, Jsi_Value *src, char *newname)
{
/* TODO: resolve pwd first. */
void *data;
const char *cp = NULL;
Jsi_Filesystem *fsPtr;
Jsi_DString dStr;
Jsi_DSInit(&dStr);
const char *npath = Jsi_ValueNormalPath(interp, src, &dStr);
if (!npath) return NULL;
Jsi_Value *tPtr = Jsi_ValueNew1(interp);
Jsi_ValueMakeStringDup(interp, &tPtr, npath);
fsPtr = Jsi_FilesystemForPath(interp, tPtr, &data);
if (fsPtr) {
if (fsPtr->realpathProc)
cp = fsPtr->realpathProc(interp, src, newname);
else if (!newname)
cp = Jsi_Strdup(npath);
else {
Jsi_Strncpy(newname, npath, PATH_MAX);
if (Jsi_Strlen(npath)>=PATH_MAX)
newname[PATH_MAX-1] = 0;
}
}
Jsi_DSFree(&dStr);
Jsi_DecrRefCount(interp, tPtr);
return (char*)cp;
}
|
CWE-120
| null | 520,775 |
178903014669997041589558407016714903762
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC Jsi_RegExpMatch(Jsi_Interp *interp, Jsi_Value *pattern, const char *v, int *rc, Jsi_DString *dStr)
{
Jsi_Regex *re;
int regexec_flags = 0;
if (rc)
*rc = 0;
if (pattern == NULL || pattern->vt != JSI_VT_OBJECT || pattern->d.obj->ot != JSI_OT_REGEXP)
return Jsi_LogError("expected pattern");
re = pattern->d.obj->d.robj;
regex_t *reg = &re->reg;
regmatch_t pos = {};
if (dStr)
Jsi_DSInit(dStr);
int r = regexec(reg, v, 1, &pos, regexec_flags);
if (r >= REG_BADPAT) {
char buf[JSI_MAX_NUMBER_STRING];
regerror(r, reg, buf, sizeof(buf));
return Jsi_LogError("error while matching pattern: %s", buf);
}
if (r != REG_NOMATCH) {
if (rc) *rc = 1;
if (dStr && pos.rm_so >= 0 && pos.rm_eo >= 0 && pos.rm_eo >= pos.rm_so)
Jsi_DSAppendLen(dStr, v + pos.rm_so, pos.rm_eo - pos.rm_so);
}
return JSI_OK;
}
|
CWE-120
| null | 520,776 |
283877961520809128639204866232741691141
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_less() { JSI_NEW_CODES(0,OP_LESS, 0); }
|
CWE-120
| null | 520,777 |
184462160338728587966181343969305774066
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC jsi_InitRegexp(Jsi_Interp *interp, int release)
{
if (!release)
interp->RegExp_prototype = Jsi_CommandCreateSpecs(interp, "RegExp", regexpCmds, NULL, JSI_CMDSPEC_ISOBJ);
return JSI_OK;
}
|
CWE-120
| null | 520,778 |
273330127681242313081674162608449001751
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_pop(int n) { JSI_NEW_CODES(0,OP_POP, n); }
|
CWE-120
| null | 520,779 |
76124695754210983331838771326967789072
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void Jsi_MutexUnlock(Jsi_Interp *interp, Jsi_Mutex *mtx) { }
|
CWE-120
| null | 520,780 |
237731288027264610850597544797089329346
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC Jsi_FunctionInvoke(Jsi_Interp *interp, Jsi_Value *func, Jsi_Value *args, Jsi_Value **ret, Jsi_Value *_this)
{
// Arrange for error reporting to point to called function.
Jsi_Func *fstatic = func->d.obj->d.fobj->func;
jsi_OpCode *oldops = interp->curIp;
if (fstatic->opcodes)
interp->curIp = fstatic->opcodes->codes;
Jsi_RC rc = jsi_FunctionInvoke(interp, func, args, ret, _this);
interp->curIp = oldops;
if (Jsi_InterpGone(interp))
return JSI_ERROR;
return rc;
}
|
CWE-120
| null | 520,781 |
30033113096738985356276194316556304186
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC Jsi_ValueToObject(Jsi_Interp *interp, Jsi_Value *v)
{
Jsi_RC rc = JSI_OK;
if (v->vt == JSI_VT_OBJECT) return rc;
Jsi_Obj *o = Jsi_ObjNew(interp);
switch(v->vt) {
case JSI_VT_UNDEF:
case JSI_VT_NULL:
if (interp->strict) {
Jsi_LogError("converting a undefined/null value to object");
rc = JSI_ERROR;
}
o->d.num = 0;
o->ot = JSI_OT_NUMBER;
o->__proto__ = interp->Number_prototype;
break;
case JSI_VT_BOOL: {
o->d.val = v->d.val;
o->ot = JSI_OT_BOOL;
o->__proto__ = interp->Boolean_prototype;
break;
}
case JSI_VT_NUMBER: {
o->d.num = v->d.num;
o->ot = JSI_OT_NUMBER;
o->__proto__ = interp->Number_prototype;
break;
}
case JSI_VT_STRING: {
o->d.s = v->d.s;
if (!v->f.bits.isstrkey)
o->d.s.str = (char*)Jsi_KeyAdd(interp, v->d.s.str);
o->isstrkey = 1;
o->ot = JSI_OT_STRING;
o->__proto__ = interp->String_prototype;
break;
}
default:
Jsi_LogBug("toobject, not suppose to reach here");
}
Jsi_ValueReset(interp,&v);
Jsi_ValueMakeObject(interp, &v, o);
return rc;
}
|
CWE-120
| null | 520,782 |
213678479035519786689143503313450316618
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static int jsi_FSCloseProc(Jsi_Channel chan) { return fclose(_JSI_GETFP(chan,1));}
|
CWE-120
| null | 520,783 |
7723248052610189492284079658071025578
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static jsi_CaseList *caselist_insert(jsi_Pstate *pstate, jsi_CaseList *a, jsi_CaseExprStat *es)
{
jsi_CaseList *b = (jsi_CaseList*)Jsi_Calloc(1,sizeof(*b));
a->sig = JSI_SIG_CASELIST;
b->es = es;
a->tail->next = b;
a->tail = b;
return a;
}
|
CWE-120
| null | 520,784 |
287509044246315095732789980149955080490
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void dbProfileHandler(void *cd, const char *zSql, sqlite_uint64 tm) {
int rc;
Jsi_Db *jdb = (Jsi_Db*)cd;
Jsi_Interp *interp = jdb->interp;
Jsi_Value *vpargs, *items[3] = {}, *ret;
items[0] = Jsi_ValueNewObj(interp, jdb->fobj);
items[1] = Jsi_ValueMakeStringDup(interp, NULL, zSql);
items[2] = Jsi_ValueMakeNumber(interp, NULL, (Jsi_Number)tm);
vpargs = Jsi_ValueMakeObject(interp, NULL, Jsi_ObjNewArray(interp, items, 3, 0));
Jsi_IncrRefCount(interp, vpargs);
ret = Jsi_ValueNew1(interp);
rc = Jsi_FunctionInvoke(interp, jdb->onProfile, vpargs, &ret, NULL);
Jsi_DecrRefCount(interp, vpargs);
Jsi_DecrRefCount(interp, ret);
if (rc != JSI_OK)
jdb->errCnt++;
}
|
CWE-120
| null | 520,785 |
281248496075092561675719297057048242364
| null | null |
other
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.