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 |
static void replace_node(Jsi_TreeEntry* oldn, Jsi_TreeEntry* newn) {
Assert(oldn);
Jsi_Tree* t = oldn->treePtr;
if (oldn->parent == NULL) {
t->root = newn;
} else {
if (oldn == oldn->parent->left)
oldn->parent->left = newn;
else
oldn->parent->right = newn;
}
if (newn != NULL) {
newn->parent = oldn->parent;
}
}
|
CWE-120
| null | 520,186 |
334460767052814838878013343501088667982
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
HashOneWordCreate( Jsi_Hash *tablePtr, const void *key, bool *newPtr)
{
Jsi_HashEntry **bucketPtr;
Jsi_HashEntry *hPtr;
size_t hindex;
hindex = RANDOM_INDEX(tablePtr, key);
for (hPtr = tablePtr->buckets[hindex]; hPtr != NULL;
hPtr = hPtr->nextPtr) {
if (hPtr->key.oneWordValue == key) {
if (newPtr)
*newPtr = 0;
return hPtr;
}
}
if (newPtr)
*newPtr = 1;
hPtr = (Jsi_HashEntry*)Jsi_Calloc(1, sizeof(*hPtr));
hPtr->typ = JSI_MAP_HASH;
bucketPtr = tablePtr->buckets + hindex;
hPtr->tablePtr = tablePtr;
hPtr->nextPtr = *bucketPtr;
hPtr->hval = (jsi_Hash)key;
hPtr->clientData = 0;
hPtr->key.oneWordValue = (void *)key;
*bucketPtr = hPtr;
tablePtr->numEntries++;
if (tablePtr->numEntries >= tablePtr->rebuildSize)
RebuildTable(tablePtr);
return hPtr;
}
|
CWE-120
| null | 520,187 |
43255085202565171588687052883222011634
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void jsi_FuncCallCheck(jsi_Pstate *p, jsi_Pline *line, int argc, bool isNew, const char *name, const char *namePre, Jsi_OpCodes *argCodes)
{
Jsi_Interp *interp = p->interp;
if (name == NULL || !(interp->typeCheck.funcsig|interp->typeCheck.all|interp->typeCheck.parse))
return;
if (name && isdigit(name[0]))
return;
Jsi_Value *val;
val = Jsi_NameLookup2(interp, name, namePre);
Jsi_Func *f = NULL;
if (val != NULL) {
if (Jsi_ValueIsFunction(interp, val))
f = val->d.obj->d.fobj->func;
} else if (interp->staticFuncsTbl) {
f = (Jsi_Func*)Jsi_HashGet(interp->staticFuncsTbl, (void*)name, 0);
}
if (f)
jsi_RunFuncCallCheck(interp, f, argc, name, line, argCodes, 1);
else if (interp->typeCheck.funcsig && (namePre==NULL || jsi_BuiltinCmd(interp, namePre))) {
if (line)
interp->parseLine = line;
Jsi_LogWarn("called function '%s' with no previous definition", name);
jsi_TypeMismatch(interp);
if (line)
interp->parseLine = NULL;
}
}
|
CWE-120
| null | 520,188 |
53093763840554872844111771796394384287
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC Jsi_DoneMySql(Jsi_Interp *interp)
{
if (Jsi_UserObjUnregister(interp, &mysqlobject) != JSI_OK)
return JSI_ERROR;
Jsi_PkgProvide(interp, "MySql", -1, NULL);
return JSI_OK;
}
|
CWE-120
| null | 520,189 |
135131275416039819242591230724908498141
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void delete_case1(Jsi_TreeEntry* n) {
if (n->parent != NULL)
delete_case2(n);
}
|
CWE-120
| null | 520,190 |
179547611868289210057354302813576854070
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_mul() { JSI_NEW_CODES(0,OP_MUL, 0); }
|
CWE-120
| null | 520,191 |
219886047328345077785498236973292243069
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC Jsi_MutexLock(Jsi_Interp *interp, Jsi_Mutex *mtx) { if (interp) interp->lockRefCnt++; return MutexLock(interp, mtx);}
|
CWE-120
| null | 520,192 |
327877923739179037326552482656259457142
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void jsi_ValueToPrimitiveRes(Jsi_Interp *interp, Jsi_Value *v, Jsi_Value *rPtr)
{
if (v->vt != JSI_VT_OBJECT) {
#ifdef JSI_MEM_DEBUG
memcpy(rPtr, v, sizeof(*v)-sizeof(v->VD));
#else
*rPtr = *v; //TODO: usde only by ValueCompare, so refCnt doesn't matter?
#endif
return;
}
Jsi_Obj *obj = v->d.obj;
switch(obj->ot) {
case JSI_OT_BOOL:
Jsi_ValueMakeBool(interp, &rPtr, obj->d.val);
break;
case JSI_OT_NUMBER:
Jsi_ValueMakeNumber(interp, &rPtr, obj->d.num);
break;
case JSI_OT_STRING:
rPtr->vt = JSI_VT_STRING;
rPtr->d.s = obj->d.s;
rPtr->f.bits.isstrkey = 1;
break;
default:
break;
}
}
|
CWE-120
| null | 520,193 |
104647504146051266288301836902878058291
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC jsi_CArrayToValue(Jsi_Interp *interp, Jsi_OptionSpec* spec, Jsi_Value **outValue, Jsi_DString *dStr, void *record, Jsi_Wide flags)
{
Jsi_Obj *obj = NULL;
if (dStr)
return JSI_ERROR;
uchar *s = (uchar*)((char*)record) + spec->offset;
Jsi_OptionSpec *subSpec = spec->init.OPT_CARRAY;
int i, cnt, isize, size = spec->arrSize;
if (!subSpec || size<=0 || (isize=subSpec->size)<=0)
goto bail;
isize = isize/size;
#ifndef JSI_LITE_ONLY //TODO: already in lite #ifdef
obj = Jsi_ObjNewType(interp, JSI_OT_ARRAY);
cnt = 0;
for (i=0; i<size; i++) {
Jsi_Value *v = Jsi_ValueNew1(interp);
cnt++;
Jsi_RC rc = Jsi_OptionsGet(interp, subSpec, s, spec->name, &v, 0);
Jsi_ObjArrayAdd(interp, obj, v);
Jsi_DecrRefCount(interp, v);
if (JSI_OK != rc)
goto bail;
s += isize;
}
Jsi_ValueMakeArrayObject(interp, outValue, obj);
#endif
return JSI_OK;
bail:
if (obj)
Jsi_ObjFree(interp, obj);
Jsi_LogError("bad config");
return JSI_ERROR;
}
|
CWE-120
| null | 520,194 |
3171093245649847636692496575345183572
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void SetupStdChan(Jsi_Chan* ch, FILE *fp, Jsi_Filesystem *fsPtr, int flags) {
memset(ch, 0, sizeof(*ch));
ch->fp = fp;
ch->fsPtr = fsPtr;
ch->flags = flags|JSI_FS_NOCLOSE;
}
|
CWE-120
| null | 520,195 |
244292074890772171786557552052845459273
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
jsi_wsdeletePss(jsi_wsPss *pss)
{
jsi_wsCmdObj*cmdPtr = pss->cmdPtr;
if (pss->sig == 0)
return;
WSSIGASSERT(pss, PWS);
if (pss->state == PWS_DEAD)
return;
if (cmdPtr && cmdPtr->debug>3)
fprintf(stderr, "PSS DELETE: %p\n", pss);
jsi_wsrecv_flush(cmdPtr, pss);
if (pss->hPtr) {
Jsi_HashValueSet(pss->hPtr, NULL);
Jsi_HashEntryDelete(pss->hPtr);
pss->hPtr = NULL;
}
Jsi_Interp *interp = cmdPtr->interp;
if (pss->stack) {
Jsi_StackFreeElements(interp, pss->stack, jsi_wsDelPss);
Jsi_StackFree(pss->stack);
}
Jsi_DSFree(&pss->dHdrs);
if (pss->isWebsock)
pss->cmdPtr->stats.connectCnt--;
Jsi_OptionsFree(cmdPtr->interp, WPSOptions, pss, 0);
pss->state = PWS_DEAD;
Jsi_DSFree(&pss->resultStr);
Jsi_DSFree(&pss->paramDS);
if (pss->lastData)
Jsi_Free(pss->lastData);
pss->lastData = NULL;
if (pss->spa)
lws_spa_destroy(pss->spa);
Jsi_Free(pss);
}
|
CWE-120
| null | 520,196 |
189727943773706030794685385218718017248
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *codes_join4(Jsi_OpCodes *a, Jsi_OpCodes *b, Jsi_OpCodes *c, Jsi_OpCodes *d)
{
return codes_join(codes_join(a, b), codes_join(c, d));
}
|
CWE-120
| null | 520,197 |
222464676545415736641002048282951269359
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC Jsi_PrototypeDefine(Jsi_Interp *interp, const char *key, Jsi_Value *value)
{
bool isNew;
Jsi_HashEntry *hPtr = Jsi_HashEntryNew(interp->protoTbl, key, &isNew);
if (!hPtr)
return JSI_ERROR;
Jsi_HashValueSet(hPtr, value);
return JSI_OK;
}
|
CWE-120
| null | 520,198 |
40987141491234370225203442649582331932
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static bool jsi_wsIsSSIExt(Jsi_Interp *interp, jsi_wsCmdObj *cmdPtr, jsi_wsPss *pss, const char *ext) {
if (cmdPtr->ssiExts) {
Jsi_Value *mVal = Jsi_ValueObjLookup(interp, cmdPtr->ssiExts, ext, 1);
if (mVal) {
bool b = 0;
if (Jsi_ValueGetBoolean(interp, mVal, &b) != JSI_OK) {
Jsi_LogWarn("expected bool for ssiExts '%s': disabling all\n", ext);
Jsi_DecrRefCount(interp, cmdPtr->ssiExts);
cmdPtr->ssiExts = NULL;
}
return b;
}
}
if (ext[0]=='s' && (!Jsi_Strcmp(ext, "shtml")
|| !Jsi_Strcmp(ext, "scss") || !Jsi_Strcmp(ext, "sjs")))
return 1;
return 0;
}
|
CWE-120
| null | 520,199 |
26744431030949970698129497308877228299
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void jsi_DebuggerStmt(void) {
// Called for "debugger" statement.
}
|
CWE-120
| null | 520,200 |
235251350275175038222090533505664784422
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
int Jsi_TreeEntryDelete (Jsi_TreeEntry *entryPtr)
{
int cnt = 0;
Jsi_TreeEntry* n = entryPtr;
Jsi_Tree* treePtr = n->treePtr;
if (treePtr->flags.destroyed || treePtr->flags.nonredblack == 1 /* || entryPtr->f.bits.deletesub */) {
goto dodel;
}
/*printf("DEL(tree=%p,root=%p): (%p)%s\n", treePtr, treePtr->root, entryPtr,(char*)entryPtr->key.string);*/
/*dumpTree(treePtr);*/
if (treePtr->opts.lockTreeProc && (*treePtr->opts.lockTreeProc)(treePtr, 1) != JSI_OK)
return -1;
entryPtr->treePtr->epoch++;
if (n->left != NULL && n->right != NULL) {
/* swap key/values delete pred instead */
Jsi_TreeEntry* pred = maximum_node(n->left);
switch (treePtr->keyType) {
case JSI_KEYS_STRINGKEY:
case JSI_KEYS_ONEWORD: {
void *nv = n->value;
n->value = pred->value;
pred->value = nv;
nv = n->key.oneWordValue;
n->key.oneWordValue = pred->key.oneWordValue;
pred->key.oneWordValue = nv;
n = pred;
break;
}
case JSI_KEYS_STRING:
SwapNodes(n,pred);
break;
default: { // Struct keys have the same length so we swap bytes.
uint i;
void *nv = n->value;
n->value = pred->value;
pred->value = nv;
char ct, *cs = (char*)(n->key.string), *cd = (char*)(pred->key.string);
for (i=0; i<treePtr->keyType; i++, cs++, cd++) {
ct = *cd;
*cd = *cs;
*cs = ct;
}
}
}
}
delete_one_child(n);
cnt++;
/*dumpTree(treePtr);*/
dodel:
treePtr->numEntries--;
n->treePtr = NULL;
if (treePtr->opts.freeTreeProc && n && n->value)
(treePtr->opts.freeTreeProc)(treePtr->opts.interp, n, n->value);
Jsi_Free(n);
if (treePtr->opts.lockTreeProc)
(*treePtr->opts.lockTreeProc)(treePtr, 0);
return cnt;
}
|
CWE-120
| null | 520,201 |
92328180022091264659978128459301620220
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_assign(jsi_Pstate *p, jsi_Pline *line, int h) { JSI_NEW_CODESLN(0,OP_ASSIGN, h); }
|
CWE-120
| null | 520,202 |
169789138237245203583366798750563620990
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC freeEventTbl(Jsi_Interp *interp, Jsi_HashEntry *hPtr, void *ptr) {
Jsi_Event *event = (Jsi_Event *)ptr;
SIGASSERT(event,EVENT);
if (!ptr) return JSI_OK;
Jsi_HashValueSet(event->hPtr, NULL);
event->hPtr = NULL;
Jsi_EventFree(interp, event);
return JSI_OK;
}
|
CWE-120
| null | 520,203 |
158601774381236007105758349822655831634
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static int fastVarFree(Jsi_Interp *interp, void *ptr) {
FastVar *fv = ptr;
Jsi_Value *v = fv->var.lval;
if (v) {
//printf("FV FREE: %p (%d/%d)\n", fv, v->refCnt, v->vt == JSI_VT_OBJECT?v->d.obj->refcnt:-99);
//Jsi_DecrRefCount(interp, v);
}
return JSI_OK;
}
|
CWE-120
| null | 520,204 |
291627311141765038312968886684977464946
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static int jsi_GetListType(Jsi_MapEntry *h) {
Jsi_HashEntry *hPtr =(Jsi_HashEntry *)h;
return hPtr->typ;
}
|
CWE-120
| null | 520,205 |
291803549225744743902638106760443559847
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC StringTrimRightCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr)
{
return _StringTrimCmd(interp, args, _this, ret, funcPtr, 2);
}
|
CWE-120
| null | 520,206 |
220766103487593694541175352707749674055
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
bool jsi_FuncIsNoop(Jsi_Interp* interp, Jsi_Value *func) {
Jsi_FuncObj *funcPtr;
Jsi_Func *f;
if (func->vt != JSI_VT_OBJECT || func->d.obj->ot != JSI_OT_FUNCTION)
return 0;
funcPtr = func->d.obj->d.fobj;
f = funcPtr->func;
return (f->callback == jsi_NoOpCmd);
}
|
CWE-120
| null | 520,207 |
215466666567696998438291598722968919753
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void MutexInit(Jsi_Mutex *mtx) {
pthread_mutexattr_t Attr;
pthread_mutexattr_init(&Attr);
if (mtx->flags & JSI_MUTEX_RECURSIVE)
pthread_mutexattr_settype(&Attr, PTHREAD_MUTEX_RECURSIVE);
pthread_mutex_init(&mtx->mtx, &Attr);
}
|
CWE-120
| null | 520,208 |
98472879386324108207859187945739279157
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
bool Jsi_ValueKeyPresent(Jsi_Interp *interp, Jsi_Value *target, const char *key, int isstrkey)
{
SIGASSERT(interp,INTERP);
//SIGASSERT(target,VALUE);
if (Jsi_TreeObjGetValue(target->d.obj, key, isstrkey))
return 1;
if (target->d.obj->__proto__ == NULL || target->d.obj->__proto__ == target)
return 0;
return Jsi_ValueKeyPresent(interp, target->d.obj->__proto__, key, isstrkey);
}
|
CWE-120
| null | 520,209 |
29717231299240988396814494966283260234
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void Jsi_ValueFree(Jsi_Interp *interp, Jsi_Value* v)
{
interp->dbPtr->valueCnt--;
jsi_DebugValue(v, "Free", jsi_DebugValueCallIdx(), interp);
ValueFree(interp, v);
#ifdef JSI_MEM_DEBUG
//if (v->VD.interp != interp) //TODO: InterpAliasCmd leaking Values.
// fprintf(stderr, "cross interp delete: %p\n", v);
if (v->VD.hPtr && !interp->cleanup) {
if (!Jsi_HashEntryDelete(v->VD.hPtr))
fprintf(stderr, "Value not in hash\n");
}
memset(v, 0, (sizeof(*v)-sizeof(v->VD)));
#endif
Jsi_Free(v);
}
|
CWE-120
| null | 520,210 |
2555573385974961673019466005591660054
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC jsi_ValueToNull(Jsi_Interp *interp, Jsi_OptionSpec* spec, Jsi_Value *inValue, const char *inStr, void *record, Jsi_Wide flags)
{
return JSI_OK;
}
|
CWE-120
| null | 520,211 |
63350432820959314663033916612682486968
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void Jsi_StackFreeElements(Jsi_Interp *interp, Jsi_Stack *stack, Jsi_DeleteProc *freeProc)
{
int i;
for (i = 0; i < stack->len; i++)
freeProc(interp, stack->vector[i]);
stack->len = 0;
}
|
CWE-120
| null | 520,212 |
35944132989186885802654962537527472642
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC MySqlPingCmd(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 n = mysql_ping(jdb->db);
bool noErr = 0;
Jsi_Value *val = Jsi_ValueArrayIndex(interp, args, 0);
if (val)
Jsi_ValueGetBoolean(interp, val, &noErr);
if (n && noErr==0)
return Jsi_LogError("ping failed: (%d) %s", n, mysql_error(jdb->db));
Jsi_ValueMakeNumber(interp, ret, (Jsi_Number)n);
return JSI_OK;
}
|
CWE-120
| null | 520,213 |
92096911010995425722606085888839631999
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC MySqlErrorStateCmd(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;
const char *str = mysql_sqlstate(jdb->db);
if (str)
Jsi_ValueMakeStringDup(interp, ret, str);
return JSI_OK;
}
|
CWE-120
| null | 520,214 |
241630670996600108581417220079003649321
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_Channel jsi_FSOpenProc(Jsi_Interp *interp, Jsi_Value *file, const char *modeString)
{
return Jsi_Open(interp, file, modeString);
}
|
CWE-120
| null | 520,215 |
93587641039941267346855770935852146987
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static bool jsi_wsAddStdHeader(Jsi_Interp *interp, jsi_wsCmdObj *cmdPtr, struct lws *wsi, Jsi_DString *hStr) {
uchar buffer[JSI_BUFSIZ];
uchar *p = (unsigned char *)buffer, *end = p + sizeof(buffer);
const char *srv = cmdPtr->server;
if (!srv) srv = "jsiWebSocket";
int n = 0;
if (srv[0] && lws_add_http_header_by_token(wsi, WSI_TOKEN_HTTP_SERVER, (uchar*)srv, Jsi_Strlen(srv), &p, end))
return false;
n = p - buffer;
if (n>0) {
Jsi_DSAppendLen(hStr, (char*)buffer, n);
p = buffer;
}
return true;
}
|
CWE-120
| null | 520,216 |
100615911248830129049052375991361041134
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC regExpFree(Jsi_Interp *interp, Jsi_HashEntry *hPtr, void *ptr) {
Jsi_RegExpFree((Jsi_Regex*)ptr);
return JSI_OK;
}
|
CWE-120
| null | 520,217 |
289263247801746413407648493377006052449
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void *Jsi_ThisDataGet(Jsi_Interp *interp, Jsi_Value *_this)
{
Jsi_HashEntry *hPtr;
hPtr = Jsi_HashEntryFind(interp->thisTbl, _this);
if (!hPtr)
return NULL;
return Jsi_HashValueGet(hPtr);
}
|
CWE-120
| null | 520,218 |
263670038333808639201515165742750485555
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void dbSetupCallbacks(Jsi_Db *jdb, Jsi_Db *ojdb)
{
if (jdb->onAuth && (!ojdb || !ojdb->onAuth) )
sqlite3_set_authorizer(jdb->db, dbAuthCallback, jdb);
else
sqlite3_set_authorizer(jdb->db, 0, 0);
if (jdb->onCommit && (!ojdb || !ojdb->onCommit) )
sqlite3_commit_hook(jdb->db, dbCommitHandler, jdb);
else
sqlite3_commit_hook(jdb->db, 0, 0);
if (jdb->onBusy && (!ojdb || !ojdb->onBusy) )
sqlite3_busy_handler(jdb->db, dbBusyHandler, jdb);
else
sqlite3_busy_handler(jdb->db, 0, 0);
if (jdb->onTrace && (!ojdb || !ojdb->onTrace) )
sqlite3_trace(jdb->db, dbTraceHandler, jdb);
else
sqlite3_trace(jdb->db, 0, 0);
if (jdb->onNeedCollate && (!ojdb || !ojdb->onNeedCollate) )
sqlite3_collation_needed(jdb->db, jdb, dbCollateNeeded);
else
sqlite3_collation_needed(jdb->db, 0, 0);
if (jdb->onUpdate && (!ojdb || !ojdb->onUpdate) )
sqlite3_update_hook(jdb->db, dbUpdateHandler, jdb);
else
sqlite3_update_hook(jdb->db, 0, 0);
if (jdb->onWalHook && (!ojdb || !ojdb->onWalHook) )
sqlite3_wal_hook(jdb->db, dbWalHandler, jdb);
else
sqlite3_wal_hook(jdb->db, 0, 0);
if (jdb->onRollback && (!ojdb || !ojdb->onRollback) )
sqlite3_rollback_hook(jdb->db, dbRollbackHandler, jdb);
else
sqlite3_rollback_hook(jdb->db, 0, 0);
if (jdb->onProfile && (!ojdb || !ojdb->onProfile) )
sqlite3_profile(jdb->db, dbProfileHandler, jdb);
else
sqlite3_profile(jdb->db, 0, 0);
if (jdb->onProgress && jdb->progressSteps && (!ojdb || !ojdb->onProgress || ojdb->progressSteps != jdb->progressSteps) )
sqlite3_progress_handler(jdb->db, jdb->progressSteps, dbProgressHandler, jdb);
else
sqlite3_progress_handler(jdb->db, 0, 0, 0);
if (!ojdb || jdb->load != ojdb->load)
sqlite3_enable_load_extension(jdb->db, jdb->load);
if (!ojdb || jdb->timeout != ojdb->timeout)
sqlite3_busy_timeout( jdb->db, jdb->timeout );
/* if (jdb->onUnlock && (!ojdb || !ojdb->onUnlock) )
sqlite3_unlock_notify(jdb->db, dbUnlockNotify, (void*)jdb);
else
sqlite3_unlock_notify(jdb->db, 0, 0);
*/
}
|
CWE-120
| null | 520,219 |
280174076190562286576064575227495710992
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_band() { JSI_NEW_CODES(0,OP_BAND, 0); }
|
CWE-120
| null | 520,220 |
244151816419499222063402363322462442516
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_OptionsCustomPrint(void* clientData, Jsi_Interp *interp, const char *name, void *rec, int offset)
{
char *record = (char*)rec;
Jsi_Value *valuePtr;
valuePtr = *(Jsi_Value **)(record + offset);
return valuePtr;
}
|
CWE-120
| null | 520,221 |
145479368382773030511144691650036327721
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_Db* Jsi_DbNew(const char *zFile, int inFlags /* JSI_DBI_* */)
{
char *zErrMsg;
int flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE;
#ifdef SQLITE_JSI_DEFAULT_FULLMUTEX
flags |= SQLITE_OPEN_FULLMUTEX;
#else
flags |= SQLITE_OPEN_NOMUTEX;
#endif
if (!zFile)
zFile = ":memory:";
zErrMsg = 0;
Jsi_Db *db = (Jsi_Db*)Jsi_Calloc(1, sizeof(*db) );
if( db==0 ) {
JSI_DBQUERY_PRINTF( "malloc failed\n");
return NULL;
}
db->sig = SQLITE_SIG_DB;
db->stmtCacheMax = NUM_PREPARED_STMTS;
db->optPtr = &db->queryOpts;
if (inFlags&JSI_DBI_READONLY) {
flags &= ~(SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE);
flags |= SQLITE_OPEN_READONLY;
} else {
flags &= ~SQLITE_OPEN_READONLY;
flags |= SQLITE_OPEN_READWRITE;
if (inFlags&JSI_DBI_NOCREATE) {
flags &= ~SQLITE_OPEN_CREATE;
}
}
if(inFlags&JSI_DBI_NO_MUTEX) {
flags |= SQLITE_OPEN_NOMUTEX;
flags &= ~SQLITE_OPEN_FULLMUTEX;
} else {
flags &= ~SQLITE_OPEN_NOMUTEX;
}
if(inFlags&JSI_DBI_FULL_MUTEX) {
flags |= SQLITE_OPEN_FULLMUTEX;
flags &= ~SQLITE_OPEN_NOMUTEX;
} else {
flags &= ~SQLITE_OPEN_FULLMUTEX;
}
char cpath[PATH_MAX];
char *npath = Jsi_FileRealpathStr(NULL, zFile, cpath);
if (SQLITE_OK != sqlite3_open_v2(npath, &db->db, flags, NULL)) {
JSI_DBQUERY_PRINTF( "db open failed: %s\n", npath);
goto bail;
}
//Jsi_DSFree(&translatedFilename);
if( SQLITE_OK!=sqlite3_errcode(db->db) ) {
zErrMsg = sqlite3_mprintf("%s", sqlite3_errmsg(db->db));
DbClose(db->db);
db->db = 0;
}
if( db->db==0 ) {
JSI_DBQUERY_PRINTF( "Db open failed %s\n", zErrMsg);
sqlite3_free(zErrMsg);
goto bail;
}
db->stmtHash = Jsi_HashNew(NULL, JSI_KEYS_STRING, NULL);
db->strKeyTbl = Jsi_HashNew(NULL, JSI_KEYS_STRING, NULL);
db->stmtCache = Jsi_ListNew((Jsi_Interp*)db, 0, dbStmtFreeProc);
return db;
bail:
return NULL;
}
|
CWE-120
| null | 520,222 |
308225199028238145750057831709689137029
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
bool Jsi_ValueIsTrue(Jsi_Interp *interp, Jsi_Value *v)
{
switch(v->vt) {
case JSI_VT_UNDEF:
case JSI_VT_NULL: return 0;
case JSI_VT_BOOL: return v->d.val ? 1:0;
case JSI_VT_NUMBER:
if (v->d.num == 0.0 || Jsi_NumberIsNaN(v->d.num)) return 0;
return 1;
case JSI_VT_STRING: return (Jsi_ValueStrlen(v)!=0);
case JSI_VT_OBJECT: {
Jsi_Obj *o = v->d.obj;
if (o->ot == JSI_OT_STRING)
return (Jsi_ValueStrlen(v)!=0);
if (o->ot == JSI_OT_NUMBER)
return (o->d.num != 0);
if (o->ot == JSI_OT_BOOL)
return (o->d.val != 0);
if (o->ot == JSI_OT_USEROBJ && o->d.uobj->interp == interp) {
return jsi_UserObjIsTrue(interp, o->d.uobj);
}
return 1;
}
default: Jsi_LogBug("TOP is type incorrect: %d", v->vt);
}
return 0;
}
|
CWE-120
| null | 520,223 |
138243784934725792763904688221052097146
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_efinal(jsi_Pstate *p, jsi_Pline *line) { JSI_NEW_CODESLN(0,OP_EFINAL, 0); }
|
CWE-120
| null | 520,224 |
139212407103075135597498152271588159703
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC WebSocketIdsCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr)
{
jsi_wsCmdObj *cmdPtr = (jsi_wsCmdObj*)Jsi_UserObjGetData(interp, _this, funcPtr);
if (!cmdPtr)
return Jsi_LogError("Apply in a non-websock object");
const char *val = Jsi_ValueArrayIndexToStr(interp, args, 0, NULL);
Jsi_DString dStr = {"["};
jsi_wsPss *pss = NULL;
Jsi_HashEntry *hPtr;
Jsi_HashSearch cursor;
int cnt = 0;
for (hPtr = Jsi_HashSearchFirst(cmdPtr->pssTable, &cursor);
hPtr != NULL; hPtr = Jsi_HashSearchNext(&cursor)) {
pss = (jsi_wsPss*)Jsi_HashValueGet(hPtr);
WSSIGASSERT(pss, PWS);
if (pss->state == PWS_DEAD) continue;
if (val && Jsi_Strcmp(pss->key, val)) continue;
Jsi_DSPrintf(&dStr, "%s%d", (cnt++?",":""), pss->wid);
if (val) break;
}
Jsi_DSAppend(&dStr, "]", NULL);
Jsi_RC rc = Jsi_JSONParse(interp, Jsi_DSValue(&dStr), ret, 0);
Jsi_DSFree(&dStr);
return rc;
}
|
CWE-120
| null | 520,225 |
40201599579986574513339946898598197186
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
const char *jsi_ScopeStrsGet(Jsi_ScopeStrs *ss, int i)
{
if (i < 0 || i >= ss->count)
return NULL;
return ss->args[i].name;
}
|
CWE-120
| null | 520,226 |
129081084752037141294057625207455630711
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void delete_one_child(Jsi_TreeEntry*n)
{
Jsi_TreeEntry *child;
Assert(n->left == NULL || n->right == NULL);
child = n->right == NULL ? n->left : n->right;
#if 1
if (node_color(n) == _JSI_TREE_BLACK) {
set_color(n, node_color(child));
delete_case1(n);
}
replace_node(n, child);
if (n->parent == NULL && child != NULL)
set_color(child, _JSI_TREE_BLACK);
#else
replace_node(n, child);
if (node_color(n) == _JSI_TREE_BLACK) {
if (node_color(child) == _JSI_TREE_RED)
child->f.bits.color = _JSI_TREE_BLACK;
else
delete_case1(n);
}
#endif
}
|
CWE-120
| null | 520,227 |
11580635033216502415695182567404753380
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC StringToUpperCaseCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr)
{
int sLen, bLen;
const char *vstr;
ChkString(_this, funcPtr, vstr, &sLen, &bLen);
Jsi_DString dStr;
Jsi_DSInit(&dStr);
jsi_utf_tocase(vstr, 1, &dStr);
Jsi_ValueFromDS(interp, &dStr, ret);
return JSI_OK;
}
|
CWE-120
| null | 520,228 |
213263161148600379115158943283808219929
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
char *Jsi_FileRealpathStr(Jsi_Interp *interp, const char *path, char *newname)
{
if (!path || !path[0]) return NULL;
Jsi_DString dStr, eStr;
char *npath = (char*)path, *apath;
Jsi_DSInit(&dStr); Jsi_DSInit(&eStr);
if (*path == '~') {
#ifndef __WIN32
struct passwd pw, *pwp; /* TODO: could fallback to using env HOME. */
char buf[JSI_BUFSIZ];
int n = getpwuid_r(getuid(), &pw, buf, sizeof(buf), &pwp);
const char *homedir = (n == 0 ? pwp->pw_dir : "");
Jsi_DSAppend(&dStr, homedir, path[1] == '/' ? "" : "/", path+1, NULL);
#else
const char *homedir = getenv("HOMEPATH");
if (!homedir) homedir = "/";
const char *homedrv = getenv("HOMEDRIVE");
if (!homedrv) homedrv = "";
Jsi_DSAppend(&dStr, homedrv, homedir, path[1] == '/' ? "" : "/", path+1, NULL);
#endif
npath = Jsi_DSValue(&dStr);
}
#ifdef __WIN32
if (Jsi_Strncmp(path, JSI_ZVFS_DIR, sizeof(JSI_ZVFS_DIR)-1)==0 || Jsi_Strncmp(path, JSI_VFS_DIR, sizeof(JSI_VFS_DIR)-1)==0)
apath = NULL;
else
#endif
apath = realpath(npath, newname);
if (!apath) {
if ((path[0] == '.' && path[1] == '/') || (path[0] != '/' &&
!(path[0] == '.' && path[1] == '.') && path[1] != ':')) {
Jsi_GetCwd(interp, &eStr);
Jsi_DSAppend(&eStr, "/", path, NULL);
npath = Jsi_DSValue(&eStr);
apath = realpath(npath, newname);
//npath = (char*)path;
}
}
if (!apath) {
if (newname)
Jsi_Strcpy(apath=newname, npath);
else
apath = Jsi_Strdup(npath);
#ifndef __WIN32
/* If path not exists on unix we try to eliminate ../ and /./ etc.*/
NormalizeUnixPath(interp, apath);
#endif
}
#ifdef __WIN32
DeBackSlashify(apath);
#endif
Jsi_DSFree(&dStr); Jsi_DSFree(&eStr);
return apath;
}
|
CWE-120
| null | 520,229 |
165726582866307077120591158511262294185
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC dbBindStmt(Jsi_Db *jdb, SqlPreparedStmt *prep)
{
sqlite3_stmt *pStmt = prep->pStmt; /* Object used to cache statement */
Jsi_Interp *interp = jdb->interp;
int i, btype = 0, bindArr=0, n;
Jsi_RC rc = JSI_OK;
Jsi_Number r;
Jsi_Wide wv;
Jsi_Value *pv = NULL, *apv = NULL;
int nVar = sqlite3_bind_parameter_count(pStmt);
char tname[50];
/* Bind values to parameters that begin with @, $, :, or ? */
for(i=1; i<=nVar; i++) {
tname[0] = 0;
int isInt = 0, isBlob = 0;
const char *zVar = sqlite3_bind_parameter_name(pStmt, i);
if (zVar == NULL) {
if (!jdb->optPtr || !(apv=jdb->optPtr->values))
return Jsi_LogError("? bind without values for param %d", i);
if (!(pv =Jsi_ValueArrayIndex(interp, apv, i-1)))
return Jsi_LogError("array element %d missing", nVar);
}
else if((zVar[0]=='$' || zVar[0]==':' || zVar[0]=='@') ) {
int zvLen = Jsi_Strlen(zVar);
char *zcp;
if (zVar[0] =='$' && ((zcp = (char*)Jsi_Strchr(zVar,'('))) && zVar[zvLen-1] == ')')
{
bindArr = 1;
Jsi_DString vStr;
Jsi_DSInit(&vStr);
Jsi_DSAppendLen(&vStr, zVar+1, (zcp-zVar-1));
int slen = Jsi_Strlen(zcp);
const char *ttp;
if ((ttp = Jsi_Strchr(zVar,':'))) { // Extract bind-type.
Jsi_DString tStr = {};
int tlen = Jsi_Strlen(ttp+1);
Jsi_DSAppendLen(&tStr, ttp+1, tlen-1);
if (!jdb->typeNameHash)
dbTypeNameHashInit(jdb);
Jsi_HashEntry *htPtr = Jsi_HashEntryFind(jdb->typeNameHash, Jsi_DSValue(&tStr));
int rc = ( htPtr != NULL);
if (!htPtr) {
Jsi_DString eStr = {};
Jsi_HashSearch search;
Jsi_Interp *interp = jdb->interp;
int n = 0;
Jsi_HashEntry *hPtr;
for (hPtr = Jsi_HashSearchFirst(jdb->typeNameHash, &search);
hPtr != NULL; hPtr = Jsi_HashSearchNext(&search)) {
const char *key = (char*)Jsi_HashKeyGet(hPtr);
Jsi_DSAppend(&eStr, (n++?", ":""), key, NULL);
}
Jsi_LogWarn("bind type \"%s\" is not one of: %s", Jsi_DSValue(&tStr), Jsi_DSValue(&eStr));
Jsi_DSFree(&eStr);
}
Jsi_Strcpy(tname, Jsi_DSValue(&tStr));
Jsi_DSFree(&tStr);
if (!rc)
return JSI_ERROR;
btype = (uintptr_t)Jsi_HashValueGet(htPtr);
Jsi_DSFree(&tStr);
slen -= tlen;
}
if (isdigit(zcp[1])) {
Jsi_DSAppendLen(&vStr, "[", 1);
Jsi_DSAppendLen(&vStr, zcp+1, slen-2);
Jsi_DSAppendLen(&vStr, "]", 1);
} else {
if (zcp[1] != '[')
Jsi_DSAppendLen(&vStr, ".", 1);
Jsi_DSAppendLen(&vStr, zcp+1, slen-2);
}
pv = Jsi_NameLookup(interp, Jsi_DSValue(&vStr));
Jsi_DSFree(&vStr);
} else
pv = Jsi_VarLookup(interp, &zVar[1]);
} else
return Jsi_LogError("can not find bind var %s", zVar);
if(!pv ) {
if (!jdb->bindWarn) {
Jsi_LogError("unknown bind param: %s", zVar);
rc = JSI_ERROR;
break;
} else
Jsi_LogWarn("unknown bind param: %s", zVar);
} else {
int match = 1, cast = (jdb->optPtr->typeCheck==dbTypeCheck_Cast);
if (btype && !Jsi_ValueIsUndef(interp, pv)) {
switch (btype) {
case JSI_OPTION_STRBUF:
isBlob = 1;
case JSI_OPTION_STRING:
if (cast)
Jsi_ValueToString(interp, pv, &n);
else
match = Jsi_ValueIsString(interp, pv);
break;
case JSI_OPTION_NUMBER:
case JSI_OPTION_DOUBLE:
if (cast)
Jsi_ValueToNumber(interp, pv);
else
match = Jsi_ValueIsNumber(interp, pv);
break;
case JSI_OPTION_TIME_W:
case JSI_OPTION_TIME_T:
case JSI_OPTION_INT64:
isInt = 1;
if (cast)
Jsi_ValueToNumber(interp, pv);
else
match = Jsi_ValueIsNumber(interp, pv);
break;
case JSI_OPTION_BOOL:
if (cast)
Jsi_ValueToBool(interp, pv);
else
match = Jsi_ValueIsNumber(interp, pv);
break;
case JSI_OPTION_TIME_D:
if (cast)
Jsi_ValueToNumber(interp, pv); //TODO: do something more for dates?
else
match = Jsi_ValueIsNumber(interp, pv);
break;
default:
Jsi_LogBug("Unhandled bind type: %s = %d", tname, btype);
}
if (cast == 0 && match == 0) {
int ltyp = (jdb->optPtr->typeCheck==dbTypeCheck_Error?JSI_LOG_ERROR:JSI_LOG_WARN);
Jsi_LogMsg(interp, ltyp, "bind param \"%s\" type is not \"%s\"", zVar, tname);
if (ltyp == JSI_LOG_ERROR)
return JSI_ERROR;
}
}
bool bn, isArr;
const char *dectyp;
if (Jsi_ValueIsBoolean(interp, pv)) {
Jsi_GetBoolFromValue(interp, pv, &bn);
sqlite3_bind_int(pStmt, i, bn);
} else if (Jsi_ValueIsNumber(interp, pv)) {
Jsi_GetNumberFromValue(interp, pv, &r);
wv = (Jsi_Wide)r;
if (isInt || (jdb->forceInt && (((Jsi_Number)wv)-r)==0))
sqlite3_bind_int64(pStmt, i,wv);
else
sqlite3_bind_double(pStmt, i,(double)r);
} else if (Jsi_ValueIsNull(interp, pv) || (Jsi_ValueIsUndef(interp, pv) && jdb->queryOpts.mapundef)) {
sqlite3_bind_null(pStmt, i);
} else if (Jsi_ValueIsString(interp, pv)) {
const char *sstr = Jsi_ValueGetStringLen(interp, pv, &n);
if (!sstr) sstr = "";
if (isBlob)
sqlite3_bind_blob(pStmt, i, (char *)sstr, n, SQLITE_TRANSIENT );
else
sqlite3_bind_text(pStmt, i, (char *)sstr, n, SQLITE_TRANSIENT );
} else if (!jdb->noJsonConv && bindArr && ((isArr=Jsi_ValueIsArray(interp, pv))
|| Jsi_ValueIsObjType(interp, pv, JSI_OT_OBJECT))
&& (((dectyp = sqlite3_column_decltype(pStmt, i))==NULL) ||
!Jsi_Strncasecmp(dectyp,"charjson",8))) {
// Limitation: on INSERT can not access decltype.
Jsi_DString jStr = {};
Jsi_ValueGetDString(interp, pv, &jStr, JSI_OUTPUT_JSON|JSI_JSON_STRICT);
n = Jsi_DSLength(&jStr);
sqlite3_bind_text(pStmt, i, Jsi_DSValue(&jStr), n, SQLITE_TRANSIENT );
Jsi_DSFree(&jStr);
} else {
if (!jdb->bindWarn) {
Jsi_LogError("bind param must be string/number/bool/null: %s", zVar);
rc = JSI_ERROR;
break;
} else
Jsi_LogWarn("bind param must be string/number/bool/null: %s", zVar);
sqlite3_bind_null(pStmt, i);
}
}
}
return rc;
}
|
CWE-120
| null | 520,230 |
83091599656840996830990924646380177332
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void sqliteObjErase(Jsi_Db *jdb)
{
dbDeleteCmd(jdb);
jdb->db = NULL;
}
|
CWE-120
| null | 520,231 |
68206332799550443537448313685973823259
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC freeFuncsTbl(Jsi_Interp *interp, Jsi_HashEntry *hPtr, void *ptr) {
Jsi_Func *func = (Jsi_Func *)ptr;
if (!func) return JSI_OK;
SIGASSERT(func,FUNC);
func->hPtr = NULL;
jsi_FuncFree(interp, func);
return JSI_OK;
}
|
CWE-120
| null | 520,232 |
165460557597445655435712822426764308737
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void jsi_OBJCHK(Jsi_Obj *obj) {
SIGASSERTV(obj,OBJ);
assert(obj->ot <= JSI_OT__MAX);
}
|
CWE-120
| null | 520,233 |
248472711877144352070324351149667157785
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *opassign(jsi_Pstate *pstate, jsi_Pline *line, Jsi_OpCodes *lval, Jsi_OpCodes *oprand, Jsi_OpCodes *op)
{
Jsi_OpCodes *ret;
if ((lval)->lvalue_flag == 1) {
ret = codes_join3(lval,
codes_join3(code_push_top(), oprand, op),
code_assign(pstate, line, 1));
} else {
ret = codes_join3(lval,
codes_join4(code_push_top2(), code_subscript(pstate, line, 1), oprand, op),
code_assign(pstate, line, 2));
}
return ret;
}
|
CWE-120
| null | 520,234 |
84113526470257136050543336660967119107
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_StructSpec* dbLookupSpecFromName(Jsi_StructSpec *specs, const char *name) {
Jsi_StructSpec *specPtr = NULL;
for (specPtr = specs; specPtr->id>=JSI_OPTION_BOOL && specPtr->id < JSI_OPTION_END; specPtr++) {
if (specPtr->flags&JSI_OPT_DB_IGNORE)
continue;
const char *cname = specPtr->name;
if (cname[0] == name[0] && !Jsi_Strncasecmp(cname, name, -1))
return specPtr;
}
return NULL;
}
|
CWE-120
| null | 520,235 |
211664748363745212980362829014119024713
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void Jsi_MapValueSet(Jsi_MapEntry *h, const void *value){
switch (jsi_GetListType(h)) {
case JSI_MAP_HASH: return Jsi_HashValueSet((Jsi_HashEntry*)h, (void*)value);
case JSI_MAP_TREE: return Jsi_TreeValueSet((Jsi_TreeEntry*)h, (void*)value);
case JSI_MAP_LIST: return Jsi_ListValueSet((Jsi_ListEntry*)h, (void*)value);
case JSI_MAP_NONE: break;
}
}
|
CWE-120
| null | 520,236 |
166099578159539832208577420664168966020
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC JsiCheckConversion(const char *str, const char *endptr)
{
if (str[0] == '\0' || str == endptr) {
return JSI_ERROR;
}
if (endptr[0] != '\0') {
while (*endptr) {
if (!isspace(UCHAR(*endptr))) {
return JSI_ERROR;
}
endptr++;
}
}
return JSI_OK;
}
|
CWE-120
| null | 520,237 |
158983604071478751990889016424421375434
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_Value* Jsi_ValueNewBoolean(Jsi_Interp *interp, int bval) {
Jsi_Value *v = Jsi_ValueNew(interp);
v->vt = JSI_VT_BOOL;
v->d.val = bval;
return v;
}
|
CWE-120
| null | 520,238 |
321102942163954513018830316027792646400
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void MutexUnlock(Jsi_Mutex *mtx) { pthread_mutex_unlock(&mtx->mtx); }
|
CWE-120
| null | 520,239 |
300554543386543446970815683251094589153
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void DeleteAllInterps() { /* Delete toplevel interps. */
Jsi_HashEntry *hPtr;
Jsi_HashSearch search;
if (!jsiIntData.interpsTbl)
return;
for (hPtr = Jsi_HashSearchFirst(jsiIntData.interpsTbl, &search); hPtr; hPtr = Jsi_HashSearchNext(&search)) {
Jsi_Interp *interp = (Jsi_Interp *)Jsi_HashKeyGet(hPtr);
Jsi_HashEntryDelete(hPtr);
interp->destroying = 1;
Jsi_InterpDelete(interp);
}
Jsi_HashDelete(jsiIntData.interpsTbl);
jsiIntData.interpsTbl = NULL;
jsiIntData.isInit = 0;
}
|
CWE-120
| null | 520,240 |
126227050414106257462102503112315730540
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_push_args() { JSI_NEW_CODES(0,OP_PUSHARG, 0); }
|
CWE-120
| null | 520,241 |
78631499434785983872432195275579336028
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
const Jsi_OptionTypedef* Jsi_OptionTypeInfo(Jsi_OptionId typ) {
if (typ>=JSI_OPTION_BOOL && typ < JSI_OPTION_END)
return jsi_OptTypeInfo+typ;
return NULL;
}
|
CWE-120
| null | 520,242 |
192815752114019836976469697901836106055
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_ScopeStrs *jsi_ScopeGetVarlist(jsi_Pstate *ps)
{
Jsi_Interp *interp = ps->interp;
return jsi_ScopeStrsDup(ps, interp->scopes[interp->cur_scope]);
}
|
CWE-120
| null | 520,243 |
239810602247940299831178735904595431380
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
int jsiPopArgs(Jsi_OpCodes *argCodes, int i)
{
int m=i-1, n = (uintptr_t)argCodes->codes[i].data, cnt = 0;
if (argCodes->codes[i].op == OP_OBJECT)
n *= 2;
for (; m>=0 && cnt<n; m--, cnt++) {
int op = argCodes->codes[m].op;
if (op == OP_ARRAY || op == OP_OBJECT)
m = jsiPopArgs(argCodes, m);
}
return m+1;
}
|
CWE-120
| null | 520,244 |
112037399243717563296257302018350075468
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
bool Jsi_FunctionIsConstructor(Jsi_Func *funcPtr)
{
return (funcPtr->f.bits.iscons);
}
|
CWE-120
| null | 520,245 |
48531031046503027755542854923325139532
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_push_bool(int v) { JSI_NEW_CODES(0,OP_PUSHBOO, v); }
|
CWE-120
| null | 520,246 |
318472756670492565205701701686241714791
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void *Jsi_HashValueGet(Jsi_HashEntry *h)
{
return h->clientData;
}
|
CWE-120
| null | 520,247 |
244501755374873495948478000258803826309
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void *Jsi_StackPop(Jsi_Stack *stack)
{
if (stack->len == 0)
return NULL;
stack->len--;
return stack->vector[stack->len];
}
|
CWE-120
| null | 520,248 |
37331949947655256636077187517392677739
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void *Jsi_HashKeyGet(Jsi_HashEntry *hPtr)
{
Jsi_Hash *t = hPtr->tablePtr;
return (t->keyType == JSI_KEYS_ONEWORD || t->keyType == JSI_KEYS_STRINGKEY ? hPtr->key.oneWordValue : hPtr->key.string);
}
|
CWE-120
| null | 520,249 |
3387064763475963393200928648713080562
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_nop() { JSI_NEW_CODES(0,OP_NOP, 0); }
|
CWE-120
| null | 520,250 |
8946333110179426586166776413373159959
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_stry(jsi_Pstate *p, jsi_Pline *line, int trylen, int catchlen, int finlen)
{
jsi_TryInfo *ti = (jsi_TryInfo *)Jsi_Calloc(1,sizeof(*ti));
ti->trylen = trylen;
ti->catchlen = catchlen;
ti->finallen = finlen;
JSI_NEW_CODESLN(1,OP_STRY, ti);
}
|
CWE-120
| null | 520,251 |
20932672892887559448960956957000641246
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void* Jsi_InterpThread(Jsi_Interp *interp) { return NULL; }
|
CWE-120
| null | 520,252 |
29128969711728865424902376978755429568
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
const char *jsi_PstateGetFilename(jsi_Pstate *ps)
{
Jsi_Interp *interp = ps->interp;
return interp->curFile;
}
|
CWE-120
| null | 520,253 |
340090555475027343406558373628896348330
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void jsi_DelAssocData(Jsi_Interp *interp, void *data) {
AssocData *ptr = (AssocData *)data;
if (!ptr) return;
if (ptr->delProc)
ptr->delProc(interp, ptr->data);
Jsi_Free(ptr);
}
|
CWE-120
| null | 520,254 |
224975560994294631699142346548294873598
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC StringFromCharCodeCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr)
{
if (_this->vt != JSI_VT_OBJECT || _this->d.obj->ot == JSI_OT_STRING)
return Jsi_LogError("should be called via String.fromCharCode");
Jsi_DString dStr = {};
int n, i, len, argc = Jsi_ValueGetLength(interp, args);
for (i=0; i<argc; i++) {
Jsi_Value *v = Jsi_ValueArrayIndex(interp, args, i);
if (!Jsi_ValueIsNumber(interp, v) || Jsi_GetIntFromValue(interp, v, &n) != JSI_OK) {
Jsi_DSFree(&dStr);
return Jsi_LogError("expected int value at arg %d", i+1);
}
char dest[5];
len = Jsi_UniCharToUtf((Jsi_UniChar)n, dest);
Jsi_DSAppendLen(&dStr, dest, len);
}
Jsi_ValueMakeDStringObject(interp, ret, &dStr);
return JSI_OK;
}
|
CWE-120
| null | 520,255 |
182355588540314267368107177267341687154
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_Value *Jsi_NameLookup(Jsi_Interp *interp, const char *name)
{
uint cnt = 0, len, isq;
char *nam = (char*)name, *cp, *cp2, *ocp, *kstr;
//DECL_VALINIT(tv);
DECL_VALINIT(nv);
DECL_VALINIT(key);
Jsi_Value *v = NULL, *nvPtr = &nv;
Jsi_Value *kPtr = &key; // Note: a string key so no reset needed.
Jsi_DString dStr = {};
cp2 = Jsi_Strchr(nam,'[');
cp = Jsi_Strchr(nam, '.');
if (cp2 && (cp==0 || cp2<cp))
cp = cp2;
if (!cp)
return Jsi_VarLookup(interp, nam);
//fprintf(stderr, "NAM: %s\n", nam);
Jsi_DSSetLength(&dStr, 0);
Jsi_DSAppendLen(&dStr, nam, cp-nam);
v = Jsi_VarLookup(interp, Jsi_DSValue(&dStr));
if (!v)
goto bail;
while (v && cnt++ < 1000) {
ocp = cp;
nam = cp+1;
isq = 0;
if (*cp == '[') {
cp = FindEndB(cp+1); /* handle [] in strings. */
if (!cp) goto bail;
len = cp-nam;
cp++;
if (len>=2 && ((nam[0] == '\"' && nam[len-1] == '\"') || (nam[0] == '\'' && nam[len-1] == '\''))) {
nam += 1;
len -= 2;
isq = 1;
}
} else if (*cp == '.') {
cp2 = Jsi_Strchr(nam,'[');
cp = Jsi_Strchr(nam, '.');
if (cp2 && (cp==0 || cp2<cp))
cp = cp2;
len = (cp ? (uint)(cp-nam) : Jsi_Strlen(nam));
} else {
goto bail;
}
Jsi_DSSetLength(&dStr, 0);
Jsi_DSAppendLen(&dStr, nam, len);
kstr = Jsi_DSValue(&dStr);
if (*ocp == '[' && isq == 0 && isdigit(kstr[0]) && Jsi_ValueIsArray(interp, v)) {
int nn;
if (Jsi_GetInt(interp, kstr, &nn, 0) != JSI_OK)
goto bail;
v = Jsi_ValueArrayIndex(interp, v, nn);
if (!v)
goto bail;
} else if (*ocp == '[' && isq == 0) {
Jsi_Value *kv = Jsi_VarLookup(interp, kstr);
if (!kv)
goto bail;
v = jsi_ValueSubscript(interp, v, kv, &nvPtr);
goto keyon;
} else {
Jsi_ValueMakeStringKey(interp, &kPtr, kstr);
v = jsi_ValueSubscript(interp, v, kPtr, &nvPtr);
keyon:
if (!v)
goto bail;
}
if (cp == 0 || *cp == 0) break;
}
//Jsi_ValueReset(interp, &ret);
Jsi_DSFree(&dStr);
if (v && v == nvPtr) {
v = Jsi_ValueNew(interp);
//Jsi_ValueMove(interp, v, &tv);
#ifdef JSI_MEM_DEBUG
memcpy(v, &nv, sizeof(nv)-sizeof(nv.VD));
v->VD.label3 = nv.VD.func;
if (interp->memDebug>1)
v->VD.label2 = Jsi_KeyAdd(interp, name);
#else
*v = nv;
#endif
}
return v;
bail:
Jsi_DSFree(&dStr);
return NULL;
}
|
CWE-120
| null | 520,256 |
303904144013522993443574152155884077588
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void dbEvalRowInfo(
DbEvalContext *p, /* Evaluation context */
int *pnCol, /* OUT: Number of column names */
char ***papColName, /* OUT: Array of column names */
int **papColType
) {
/* Compute column names */
// Jsi_Interp *interp = p->jdb->interp;
if( 0==p->apColName ) {
sqlite3_stmt *pStmt = p->pPreStmt->pStmt;
int i; /* Iterator variable */
int nCol; /* Number of columns returned by pStmt */
char **apColName = 0; /* Array of column names */
int *apColType = 0;
const char *zColName; /* Column name */
int numRid = 0; /* Number of times rowid seen. */
p->nCol = nCol = sqlite3_column_count(pStmt);
if( nCol>0 && (papColName || p->pArray) ) {
int cnLen = sizeof(char*)*nCol, cnStart = cnLen;
for(i=0; i<nCol && cnLen<sizeof(p->staticColNames); i++)
cnLen += Jsi_Strlen(sqlite3_column_name(pStmt,i))+1;
if (cnLen>=sizeof(p->staticColNames)) {
apColName = (char**)Jsi_Calloc(nCol, sizeof(char*) );
cnStart = 0;
} else {
apColName = (char**)p->staticColNames;
}
if (papColType) {
if (nCol < SQL_MAX_STATIC_TYPES)
apColType = p->staticColTypes;
else
apColType = (int*)Jsi_Calloc(nCol, sizeof(int));
}
for(i=0; i<nCol; i++) {
zColName = sqlite3_column_name(pStmt,i);
if (cnStart==0)
apColName[i] = Jsi_Strdup(zColName);
else {
apColName[i] = p->staticColNames+cnStart;
Jsi_Strcpy(apColName[i], zColName);
cnStart += Jsi_Strlen(zColName)+1;
}
if (apColType)
apColType[i] = sqlite3_column_type(pStmt,i);
/* Check if rowid appears first, and more than once. */
if ((i == 0 || numRid>0) &&
(zColName[0] == 'r' && Jsi_Strcmp(zColName,"rowid") == 0)) {
numRid++;
}
}
/* Change first rowid to oid. */
if (numRid > 1) {
if (apColName != (char**)p->staticColNames) {
Jsi_Free(apColName[0]);
apColName[0] = Jsi_Strdup("oid");
} else {
Jsi_Strcpy(apColName[0], "oid");
}
}
p->apColName = apColName;
p->apColType = apColType;
}
}
if( papColName ) {
*papColName = p->apColName;
}
if( papColType ) {
*papColType = p->apColType;
}
if( pnCol ) {
*pnCol = p->nCol;
}
}
|
CWE-120
| null | 520,257 |
143582800291191624819161237806431767646
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
const Jsi_OptionTypedef* Jsi_OptionsStr2Type(const char *str, bool cName) {
int typ;
for (typ=JSI_OPTION_BOOL; typ < JSI_OPTION_END; typ++) {
const char *snam = (cName?jsi_OptTypeInfo[typ].cName:jsi_OptTypeInfo[typ].idName);
if (snam && snam[0] && !Jsi_Strcmp(str, snam))
return jsi_OptTypeInfo+typ;
}
return NULL;
}
|
CWE-120
| null | 520,258 |
245433094959822581094367209537921044116
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC dbPrepareStmt(
Jsi_Db *jdb, /* Database object */
char const *zIn, /* SQL to compile */
char const **pzOut, /* OUT: Pointer to next SQL statement */
SqlPreparedStmt **ppPreStmt /* OUT: Object used to cache statement */
) {
const char *zSql = zIn; /* Pointer to first SQL statement in zIn */
sqlite3_stmt *pStmt; /* Prepared statement object */
SqlPreparedStmt *pPreStmt = 0; /* Pointer to cached statement */
// int nSql; /* Length of zSql in bytes */
//int nVar; /* Number of variables in statement */
//int iParm = 0; /* Next free entry in apParm */
Jsi_RC rc = JSI_OK;
Jsi_Interp *interp = jdb->interp;
JSI_NOTUSED(interp);
*ppPreStmt = 0;
/* Trim spaces from the start of zSql and calculate the remaining length. */
while( isspace(zSql[0]) ) {
zSql++;
}
//nSql = Jsi_Strlen(zSql);
Jsi_HashEntry *entry = Jsi_HashEntryFind(jdb->stmtHash, zSql);
if (entry && ((pPreStmt = (SqlPreparedStmt*)Jsi_HashValueGet(entry)))) {
if (jdb->debug & TMODE_PREPARE)
JSI_DBQUERY_PRINTF( "DEBUG: prepare cache-hit: %s\n", zSql);
pStmt = pPreStmt->pStmt;
*pzOut = &zSql[pPreStmt->nSql];
/* When a prepared statement is found, unlink it from the
** cache list. It will later be added back to the beginning
** of the cache list in order to implement LRU replacement.
*/
Jsi_ListPop(jdb->stmtCache, pPreStmt->elPtr);
jdb->stmtCacheCnt = Jsi_ListSize(jdb->stmtCache);
}
/* If no prepared statement was found. Compile the SQL text. Also allocate
** a new SqlPreparedStmt structure. */
if( pPreStmt==0 ) {
int nByte;
if( SQLITE_OK!=sqlite3_prepare_v2(jdb->db, zSql, -1, &pStmt, pzOut) )
return Jsi_LogError("PREPARE: %s", sqlite3_errmsg(jdb->db));
if( pStmt==0 ) {
if( SQLITE_OK!=sqlite3_errcode(jdb->db) ) {
/* A compile-time error in the statement. */
Jsi_LogError("PREP: %s", sqlite3_errmsg(jdb->db));
return JSI_ERROR;
} else {
/* The statement was a no-op. Continue to the next statement
** in the SQL string.
*/
return JSI_OK;
}
}
if (jdb->debug & TMODE_PREPARE)
JSI_DBQUERY_PRINTF( "DEBUG: prepare new: %s\n", zSql);
assert( pPreStmt==0 );
//nVar = sqlite3_bind_parameter_count(pStmt);
jdb->stmtCacheCnt++;
nByte = sizeof(SqlPreparedStmt); // + nVar*sizeof(Jsi_Obj *);
pPreStmt = (SqlPreparedStmt*)Jsi_Calloc(1, nByte);
pPreStmt->sig = SQLITE_SIG_STMT;
pPreStmt->pStmt = pStmt;
pPreStmt->nSql = (*pzOut - zSql);
pPreStmt->zSql = sqlite3_sql(pStmt);
bool isNew = 0;
pPreStmt->entry = Jsi_HashEntryNew(jdb->stmtHash, zSql, &isNew);
if (!isNew)
JSI_DBQUERY_PRINTF( "sqlite dup stmt entry");
Jsi_HashValueSet(pPreStmt->entry, pPreStmt);
//pPreStmt->apParm = (Jsi_Value **)&pPreStmt[1];
}
assert( pPreStmt );
assert( Jsi_Strlen(pPreStmt->zSql)==pPreStmt->nSql );
assert( 0==memcmp(pPreStmt->zSql, zSql, pPreStmt->nSql) );
*ppPreStmt = pPreStmt;
//pPreStmt->nParm = iParm;
return rc;
}
|
CWE-120
| null | 520,259 |
333287212738270553385100718343050935135
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
bool Jsi_TreeUnset(Jsi_Tree *treePtr, void *key) {
Jsi_TreeEntry *hPtr = Jsi_TreeEntryFind(treePtr, key);
if (!hPtr)
return false;
Jsi_TreeEntryDelete(hPtr);
return true;
}
|
CWE-120
| null | 520,260 |
144916150938214333606081608080398361540
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
char* jsi_KeyFind(Jsi_Interp *interp, const char *str, int nocreate, int *isKey)
{
Jsi_MapEntry *hPtr;
if (isKey) *isKey = 0;
if (!nocreate) {
*isKey = 1;
if (isKey) *isKey = 1;
return (char*)Jsi_KeyAdd(interp, str);
}
hPtr = Jsi_MapEntryFind(interp->strKeyTbl, str);
if (!hPtr) {
return Jsi_Strdup(str);;
}
if (isKey) *isKey = 1;
*isKey = 1;
return (char*)Jsi_MapKeyGet(hPtr, 0);
}
|
CWE-120
| null | 520,261 |
50106733237993823057373418839016312191
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static int jsi_FSTruncateProc(Jsi_Channel chan, unsigned int len) { return ftruncate(fileno(_JSI_GETFP(chan,1)), len);}
|
CWE-120
| null | 520,262 |
334965507151458604390278615882278711335
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void SplitChar(const char *str, int *argcPtr,
char ***argvPtr, char ch, Jsi_DString *dStr)
{
char *cp, *ep, *p, **argv;
int cnt = 1, len, i;
len = Jsi_Strlen(str);
cp = (char*)str;
while (*cp) {
if (ch)
cp = Jsi_Strchr(cp,ch);
else {
while (*cp && !isspace(*cp))
cp++;
}
if (cp == NULL || *cp == 0) break;
cp++;
cnt++;
}
//argv = (char**)Jsi_Calloc(1,(sizeof(char*)*(cnt+3) + sizeof(char)*(len+6)));
Jsi_DSSetLength(dStr, (sizeof(char*)*(cnt+3) + sizeof(char)*(len+6)));
argv = (char**)Jsi_DSValue(dStr);
*argvPtr = argv;
*argcPtr = cnt;
p = (char*)&(argv[cnt+2]);
argv[cnt+1] = p;
Jsi_Strcpy(p, str);
cp = p;
i = 0;
argv[i++] = p;
while (*cp) {
if (ch)
ep = Jsi_Strchr(cp,ch);
else {
ep = cp;
while (*ep && !isspace(*ep))
ep++;
}
if (ep == NULL || *ep == 0) break;
*ep = 0;
cp = ep+1;
argv[i++] = cp;
}
argv[cnt] = NULL;
}
|
CWE-120
| null | 520,263 |
166242035651613304372000593081658167395
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_Value *Jsi_ValueDupJSON(Jsi_Interp *interp, Jsi_Value *val)
{
Jsi_DString pStr;
Jsi_DSInit(&pStr);
Jsi_ValueGetDString(interp, val, &pStr, JSI_OUTPUT_JSON);
Jsi_Value *valPtr = NULL;
if (Jsi_JSONParse(interp, Jsi_DSValue(&pStr), &valPtr, 0) != JSI_OK)
Jsi_LogBug("bad json parse");
Jsi_DSFree(&pStr);
return valPtr;
}
|
CWE-120
| null | 520,264 |
318211347955100020761200690149072543555
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
jsi_wscallback_websock(struct lws *wsi,
enum lws_callback_reasons reason,
void *user, void *in, size_t len)
{
struct lws_context *context = lws_get_context(wsi);
jsi_wsPss *pss = NULL;
jsi_wsCmdObj *cmdPtr = (jsi_wsCmdObj *)lws_context_user(context);
if (!cmdPtr) {
fprintf(stderr, "null ws context\n");
return -1;
}
Jsi_Interp *interp = cmdPtr->interp;
char *inPtr = (char*)in;
int sLen, n, rc =0;
WSSIGASSERT(cmdPtr, OBJ);
if (Jsi_InterpGone(interp))
cmdPtr->deleted = 1;
if (cmdPtr->debug>=32) {
switch (reason) {
case LWS_CALLBACK_SERVER_WRITEABLE:
case LWS_CALLBACK_CLIENT_WRITEABLE:
break;
default:
fprintf(stderr, "WS CALLBACK: len=%d, %p %d:%s\n", (int)len, user, reason, jsw_getReasonStr(reason));
}
}
switch (reason) {
case LWS_CALLBACK_PROTOCOL_INIT:
if (cmdPtr->noWebsock)
return 1;
break;
case LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION:
pss = jsi_wsgetPss(cmdPtr, wsi, user, 1, 1);
Jsi_DSSet(&pss->url, inPtr);
if (cmdPtr->instCtx == context && (cmdPtr->clientName[0] || cmdPtr->clientIP[0])) {
pss->clientName = cmdPtr->clientName;
pss->clientIP = cmdPtr->clientIP;
}
if (cmdPtr->onFilter && !cmdPtr->deleted) {
if (!pss)
pss = jsi_wsgetPss(cmdPtr, wsi, user, 1, 0);
int killcon = 0, n = 0;
Jsi_Obj *oarg1;
Jsi_Value *vpargs, *vargs[10], *ret = Jsi_ValueNew1(interp);
vargs[n++] = Jsi_ValueNewObj(interp, cmdPtr->fobj);
vargs[n++] = Jsi_ValueNewNumber(interp, (Jsi_Number)(pss->wid));
vargs[n++] = Jsi_ValueNewBlob(interp, (uchar*)in, len);
vargs[n++] = Jsi_ValueNewBoolean(interp, 0);
vpargs = Jsi_ValueMakeObject(interp, NULL, oarg1 = Jsi_ObjNewArray(interp, vargs, n, 0));
Jsi_IncrRefCount(interp, vpargs);
Jsi_ValueMakeUndef(interp, &ret);
rc = Jsi_FunctionInvoke(interp, cmdPtr->onFilter, vpargs, &ret, NULL);
if (rc == JSI_OK && Jsi_ValueIsFalse(interp, ret)) {
if (cmdPtr->debug>1)
fprintf(stderr, "WS:KILLING CONNECTION: %p\n", user);
killcon = 1;
}
Jsi_DecrRefCount(interp, vpargs);
Jsi_DecrRefCount(interp, ret);
if (rc != JSI_OK) {
Jsi_LogError("websock bad rcv eval");
return 1;
}
if (killcon)
return 1;
}
break;
case LWS_CALLBACK_CLIENT_ESTABLISHED:
case LWS_CALLBACK_ESTABLISHED:
if (cmdPtr->bufferPwr2>0) {
char nbuf[JSI_MAX_NUMBER_STRING];
snprintf(nbuf, sizeof(nbuf), "%d", cmdPtr->bufferPwr2);
lws_set_extension_option(wsi, "permessage-deflate", "rx_buf_size", nbuf);
lws_set_extension_option(wsi, "permessage-deflate", "tx_buf_size", nbuf);
}
if (!pss)
pss = jsi_wsgetPss(cmdPtr, wsi, user, 1, 0);
if (cmdPtr->onOpen && !cmdPtr->deleted) {
/* Pass 2 args: ws id. */
Jsi_Obj *oarg1;
Jsi_Value *vpargs, *vargs[10];
int n = 0;
vargs[n++] = Jsi_ValueNewObj(interp, cmdPtr->fobj);
vargs[n++] = Jsi_ValueNewNumber(interp, (Jsi_Number)(pss->wid));
vpargs = Jsi_ValueMakeObject(interp, NULL, oarg1 = Jsi_ObjNewArray(interp, vargs, n, 0));
Jsi_IncrRefCount(interp, vpargs);
Jsi_Value *ret = Jsi_ValueNew1(interp);
Jsi_ValueMakeUndef(interp, &ret);
rc = Jsi_FunctionInvoke(interp, cmdPtr->onOpen, vpargs, &ret, NULL);
Jsi_DecrRefCount(interp, vpargs);
Jsi_DecrRefCount(interp, ret);
if (rc != JSI_OK)
return Jsi_LogError("websock bad rcv eval");
}
break;
case LWS_CALLBACK_WSI_DESTROY:
break;
case LWS_CALLBACK_CLOSED:
case LWS_CALLBACK_PROTOCOL_DESTROY:
pss = jsi_wsgetPss(cmdPtr, wsi, user, 0, 0);
if (!pss) break;
if (cmdPtr->onClose || pss->onClose) {
rc = jsi_wsrecv_callback(interp, cmdPtr, pss, inPtr, len, 1);
if (rc != JSI_OK)
return Jsi_LogError("websock bad rcv eval");
}
jsi_wsdeletePss(pss);
if (cmdPtr->stats.connectCnt<=0 && cmdPtr->onCloseLast && !Jsi_InterpGone(interp)) {
Jsi_RC jrc;
Jsi_Value *retStr = Jsi_ValueNew1(interp);
// 1 args: ws
Jsi_Value *vpargs, *vargs[10];
int n = 0;
vargs[n++] = (cmdPtr->deleted?Jsi_ValueNewNull(interp):Jsi_ValueNewObj(interp, cmdPtr->fobj));
vpargs = Jsi_ValueMakeObject(interp, NULL, Jsi_ObjNewArray(interp, vargs, n, 0));
Jsi_IncrRefCount(interp, vpargs);
jrc = Jsi_FunctionInvoke(interp, cmdPtr->onCloseLast, vpargs, &retStr, NULL);
Jsi_DecrRefCount(interp, vpargs);
Jsi_DecrRefCount(interp, retStr);
if (Jsi_InterpGone(interp))
return JSI_ERROR;
return jrc;
}
break;
case LWS_CALLBACK_CLIENT_WRITEABLE:
case LWS_CALLBACK_SERVER_WRITEABLE: {
pss = jsi_wsgetPss(cmdPtr, wsi, user, 0, 0);
if (!pss || !pss->stack) break;
if (pss->lastData)
Jsi_Free(pss->lastData);
n=0;
char *data = pss->lastData = (char*)Jsi_StackUnshift(pss->stack);
unsigned char *p;
if (data == NULL)
break;
pss->stats.msgQLen--;
pss->state = PWS_SENT;
p = (unsigned char *)data+LWS_PRE;
sLen = Jsi_Strlen((char*)p);
n = jsi_wswrite(pss, wsi, p, sLen, (pss->stats.isBinary?LWS_WRITE_BINARY:LWS_WRITE_TEXT));
if (cmdPtr->debug>=10)
fprintf(stderr, "WS:CLIENT WRITE(%p): %d=>%d\n", pss, sLen, n);
if (n >= 0) {
cmdPtr->stats.sentCnt++;
cmdPtr->stats.sentLast = time(NULL);
pss->stats.sentCnt++;
pss->stats.sentLast = time(NULL);
} else {
lwsl_err("ERROR %d writing to socket\n", n);
pss->state = PWS_SENDERR;
pss->stats.sentErrCnt++;
pss->stats.sentErrLast = time(NULL);
cmdPtr->stats.sentErrCnt++;
cmdPtr->stats.sentErrLast = time(NULL);
rc = 1;
}
break;
}
case LWS_CALLBACK_CLIENT_RECEIVE:
case LWS_CALLBACK_RECEIVE:
{
pss = jsi_wsgetPss(cmdPtr, wsi, user, 0, 0);
if (!pss) break;
pss->stats.recvCnt++;
pss->stats.recvLast = time(NULL);
cmdPtr->stats.recvCnt++;
cmdPtr->stats.recvLast = time(NULL);
if (cmdPtr->onRecv || pss->onRecv) {
/* Pass 2 args: id and data. */
int nlen = len;
if (nlen<=0)
return 0;
int rblen = Jsi_DSLength(&pss->recvBuf),
bmax = cmdPtr->recvBufMax,
isfin = pss->stats.isFinal = lws_is_final_fragment(wsi);
pss->stats.isBinary = lws_frame_is_binary(wsi);
if (rblen) {
if (bmax && rblen>bmax) {
fprintf(stderr, "WS: Recv exceeds recvBufMax: %d>%d\n", rblen, bmax);
rc = 1;
break;
}
Jsi_DSAppendLen(&pss->recvBuf, inPtr, len);
if (!isfin) break;
cmdPtr->recvBufCnt--;
nlen = Jsi_DSLength(&pss->recvBuf);
inPtr = Jsi_DSFreeDup(&pss->recvBuf);
} else {
if (!isfin) {
cmdPtr->recvBufCnt++;
Jsi_DSAppendLen(&pss->recvBuf, inPtr, len);
break;
}
}
rc = jsi_wsrecv_callback(interp, cmdPtr, pss, inPtr, nlen, 0);
if (inPtr != in)
Jsi_Free(inPtr);
if (rc != JSI_OK) {
Jsi_LogError("websock bad rcv eval");
return 1;
}
}
lws_callback_on_writable_all_protocol(cmdPtr->context, lws_get_protocol(wsi));
break;
}
default:
break;
}
return rc;
}
|
CWE-120
| null | 520,265 |
189038256504416077753898624438900995493
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void *Jsi_TreeValueGet(Jsi_TreeEntry *hPtr)
{
return hPtr->value;
}
|
CWE-120
| null | 520,266 |
177404076905518107368370225652195787722
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC jsi_wsrecv_callback(Jsi_Interp *interp, jsi_wsCmdObj *cmdPtr, jsi_wsPss *pss,
const char *inPtr, int nlen, bool isClose)
{
Jsi_Value *vpargs, *vargs[10];
Jsi_Value* func = NULL;
if (Jsi_InterpGone(interp) || (cmdPtr->deleted && !isClose)) return JSI_ERROR;
int n = 0;
if (isClose)
func = ((pss && pss->onClose)?pss->onClose:cmdPtr->onClose);
else
func = ((pss && pss->onRecv)?pss->onRecv:cmdPtr->onRecv);
if (!func)
return JSI_OK;
vargs[n++] = (cmdPtr->deleted?Jsi_ValueNewNull(interp):Jsi_ValueNewObj(interp, cmdPtr->fobj));
vargs[n++] = Jsi_ValueNewNumber(interp, (Jsi_Number)(pss?pss->wid:0));
if (!isClose) {
if (nlen<=0)
return JSI_OK;
vargs[n++] = Jsi_ValueNewBlob(interp, (uchar*)inPtr, nlen);
if ((cmdPtr->echo||(pss && pss->echo)) && inPtr)
Jsi_LogInfo("WS-RECV: %s\n", inPtr);
}
vpargs = Jsi_ValueMakeObject(interp, NULL, Jsi_ObjNewArray(interp, vargs, n, 0));
Jsi_IncrRefCount(interp, vpargs);
Jsi_Value *ret = Jsi_ValueNew1(interp);
Jsi_RC rc = Jsi_FunctionInvoke(interp, func, vpargs, &ret, NULL);
if (rc == JSI_OK && Jsi_ValueIsUndef(interp, ret)==0 && !isClose) {
/* TODO: should we handle callback return data??? */
}
Jsi_DecrRefCount(interp, vpargs);
Jsi_DecrRefCount(interp, ret);
return rc;
}
|
CWE-120
| null | 520,267 |
154035739466905716594795804316653444108
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC MySqlConstructor(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr)
{
MySqlObj *jdb;
Jsi_Value *arg = Jsi_ValueArrayIndex(interp, args, 0);
Jsi_LogTest("Creating new MySql");
jdb = (MySqlObj*)Jsi_Calloc(1, sizeof(*jdb));
SQLSIGINIT(jdb, DB);
const char *groupname = "mysqljsi";
jdb->_ = &mydbObjCmd;
jdb->_->newCnt++;
jdb->_->activeCnt++;
jdb->maxStmts = NUM_PREPARED_STMTS;
jdb->forceInt = 1;
jdb->interp = interp;
jdb->hasOpts = (arg != NULL && !Jsi_ValueIsNull(interp,arg));
if (jdb->hasOpts && Jsi_OptionsProcess(interp, SqlOptions, jdb, arg, 0) < 0) {
jdb->deleted = 1;
mysqlObjFree(interp, jdb);
return JSI_ERROR;
}
if (!jdb->udata) {
jdb->udata = Jsi_ValueNewObj(interp, NULL);
Jsi_IncrRefCount(interp, jdb->udata);
}
jdb->db = mysql_init(NULL);
jdb->version = (MYSQL_VERSION_MAJOR + ((Jsi_Number)MYSQL_VERSION_MINOR/100.0) + ((Jsi_Number)MYSQL_VERSION_PATCH/10000.0));
#if (MYSQL_VERSION_ID>=32350)
if (jdb->reconnect)
{
my_bool reconnect = 1;
mysql_options(jdb->db, MYSQL_OPT_RECONNECT, &reconnect);
}
mysql_options(jdb->db, MYSQL_READ_DEFAULT_GROUP, groupname);
#endif
#if (MYSQL_VERSION_ID >= 40107)
if (jdb->sslKey) {
const char *sslcert = Jsi_ValueString(interp, jdb->sslCert, NULL),
*sslca = Jsi_ValueString(interp, jdb->sslCA, NULL),
*sslcapath = Jsi_ValueString(interp, jdb->sslCAPath, NULL),
*sslcipher = Jsi_ValueString(interp, jdb->sslCipher, NULL),
*sslkey = Jsi_ValueString(interp, jdb->sslKey, NULL);
mysql_ssl_set(jdb->db, sslkey, sslcert, sslca, sslcapath, sslcipher);
jdb->dbflags |= CLIENT_SSL;
}
#endif
if (!mdbConnect(interp, jdb)) {
Jsi_LogError("connect failed %s", mysql_error(jdb->db));
mysqlObjFree(interp, jdb);
return JSI_ERROR;
}
if (jdb->enableMulti) {
if (mysql_set_server_option(jdb->db, MYSQL_OPTION_MULTI_STATEMENTS_ON))
Jsi_LogWarn("multi on failed %s", mysql_error(jdb->db));
}
//jdb->event = Jsi_EventNew(interp, mysqlUpdate, jdb); //TODO: events
Jsi_Value *toacc = NULL;
if (Jsi_FunctionIsConstructor(funcPtr)) {
toacc = _this;
} else {
Jsi_Obj *o = Jsi_ObjNew(interp);
Jsi_PrototypeObjSet(interp, "MySql", o);
Jsi_ValueMakeObject(interp, ret, o);
toacc = *ret;
}
Jsi_Obj *fobj = Jsi_ValueGetObj(interp, toacc);
if ((jdb->objId = Jsi_UserObjNew(interp, &mysqlobject, fobj, jdb))<0) {
mysqlObjFree(interp, jdb);
Jsi_ValueMakeUndef(interp, ret);
return JSI_ERROR;
}
jdb->stmtHash = Jsi_HashNew(interp, JSI_KEYS_STRING, NULL);
jdb->userObjPtr = fobj;
jdb->optPtr = &jdb->queryOpts;
jdb->stmtCache = Jsi_ListNew((Jsi_Interp*)jdb, 0, mdbStmtFreeProc);
return JSI_OK;
}
|
CWE-120
| null | 520,268 |
20458334786871526244165592219256622862
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC jsi_evalSubscript(Jsi_Interp *interp, Jsi_Value *src, Jsi_Value *idx, jsi_OpCode *ip, jsi_OpCode *end,
Jsi_Value *currentScope)
{
Jsi_RC rc = JSI_OK;
jsiVarDeref(interp,2);
int isnull;
if ((isnull=Jsi_ValueIsNull(interp, src)) || Jsi_ValueIsUndef(interp, src)) {
Jsi_LogError("invalid subscript of %s", (isnull?"null":"undefined"));
jsiPop(interp, 1);
return JSI_ERROR;
}
Jsi_String *str = jsi_ValueString(src);
if (str && Jsi_ValueIsNumber(interp, idx)) {
int bLen, cLen;
char bbuf[10], *cp = Jsi_ValueString(interp, src, &bLen);
int n = (int)idx->d.num;
cLen = bLen;
#if JSI__UTF8
if (str->flags&JSI_IS_UTF || !(str->flags&JSI_UTF_CHECKED)) {
cLen = Jsi_NumUtfChars(cp, bLen);
str->flags |= JSI_UTF_CHECKED;
if (cLen != bLen)
str->flags |= JSI_IS_UTF;
}
#endif
if (n<0 || n>=cLen) {
Jsi_ValueMakeUndef(interp, &src);
} else {
if (cLen != bLen)
Jsi_UtfGetIndex(cp, n, bbuf);
else {
bbuf[0] = cp[n];
bbuf[1] = 0;
}
Jsi_ValueMakeStringDup(interp, &src, bbuf);
}
jsiPop(interp, 1);
return rc;
}
Jsi_ValueToObject(interp, src);
if (interp->hasCallee && (src->d.obj == currentScope->d.obj || (interp->framePtr->arguments && src->d.obj == interp->framePtr->arguments->d.obj))) {
if (idx->vt == JSI_VT_STRING && Jsi_Strcmp(idx->d.s.str, "callee") == 0) {
jsiClearStack(interp,1);
Jsi_ValueMakeStringKey(interp, &idx, "\1callee\1");
}
}
int bsc = Jsi_ValueIsObjType(interp, src, JSI_OT_NUMBER); // Previous bad subscript.
if (bsc == 0 && interp->lastSubscriptFail && interp->lastSubscriptFail->vt != JSI_VT_UNDEF)
Jsi_ValueReset(interp, &interp->lastSubscriptFail);
if (src->vt != JSI_VT_UNDEF) {
int right_val = (uintptr_t)ip->data;
Jsi_Value res = VALINIT,
*resPtr = &res,
*vp = jsi_ValueSubscript(interp, src, idx, &resPtr);
if (!vp && bsc == 0) {
/* eg. so we can list available commands for "db.xx()" */
if (idx->vt == JSI_VT_STRING)
interp->lastSubscriptFailStr = idx->d.s.str;
Jsi_ValueDup2(interp, &interp->lastSubscriptFail, src);
}
if (vp)
Jsi_IncrRefCount(interp, vp);
jsiClearStack(interp,2);
if (!vp)
Jsi_ValueMakeUndef(interp, &src);
else {
//printf("IDX(%p): %s\n", idx, Jsi_ValueString(interp, idx, NULL));
if (right_val || vp->f.bits.readonly) {
if (vp == resPtr && (res.vt == JSI_VT_OBJECT || res.vt == JSI_VT_STRING)) // TODO:*** Undo using ValueCopy. ***
Jsi_ValueMove(interp, src, vp);
else
Jsi_ValueCopy(interp, src, vp);
} else {
assert(vp != resPtr);
res.vt = JSI_VT_VARIABLE;
res.d.lval = vp;
Jsi_ValueCopy(interp, src, resPtr);
}
Jsi_DecrRefCount(interp, vp);
}
}
jsiPop(interp, 1);
return rc;
}
|
CWE-120
| null | 520,269 |
142578461389429089066143825580976369059
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static bool interpObjEqual(void *data1, void *data2)
{
return (data1 == data2);
}
|
CWE-120
| null | 520,270 |
184011817831187364057482376676095640929
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void jsi_code_decode(Jsi_Interp *interp, jsi_OpCode *op, int currentip, char *buf, int bsiz)
{
if (_JSICASTINT(op->op) < 0 || op->op >= OP_LASTOP) {
snprintf(buf, bsiz, "Bad opcode[%d] at %d", op->op, currentip);
}
char nbuf[JSI_MAX_NUMBER_STRING];
snprintf(nbuf, sizeof(nbuf), "%d#%d", currentip, op->Line);
snprintf(buf, bsiz, "%-8s %s ", nbuf, jsi_op_names[op->op]);
int sl = Jsi_Strlen(buf);
char *bp = buf + sl;
bsiz -= sl;
if (op->op == OP_PUSHBOO || op->op == OP_FCALL || op->op == OP_EVAL ||
op->op == OP_POP || op->op == OP_ASSIGN ||
op->op == OP_RET || op->op == OP_NEWFCALL ||
op->op == OP_DELETE || op->op == OP_CHTHIS ||
op->op == OP_OBJECT || op->op == OP_ARRAY ||
op->op == OP_SHF ||
op->op == OP_INC || op->op == OP_DEC) snprintf(bp, bsiz, "%" PRId64, (Jsi_Wide)(uintptr_t)op->data);
else if (op->op == OP_PUSHNUM) Jsi_NumberDtoA(interp, *((Jsi_Number *)op->data), bp, bsiz, 0);
else if (op->op == OP_PUSHVSTR) {
Jsi_String *ss = (Jsi_String*)op->data;
snprintf(bp, bsiz, "\"%s\"", ss->str);
} else if (op->op == OP_PUSHSTR || op->op == OP_LOCAL ||
op->op == OP_SCATCH) snprintf(bp, bsiz, "\"%s\"", op->data ? (char*)op->data:"(NoCatch)");
else if (op->op == OP_PUSHVAR) snprintf(bp, bsiz, "var: \"%s\"", ((jsi_FastVar *)op->data)->varname);
else if (op->op == OP_PUSHFUN) snprintf(bp, bsiz, "func: 0x%" PRIx64, (Jsi_Wide)(uintptr_t)op->data);
else if (op->op == OP_JTRUE || op->op == OP_JFALSE ||
op->op == OP_JTRUE_NP || op->op == OP_JFALSE_NP ||
op->op == OP_JMP) snprintf(bp, bsiz, "{%" PRIu64 "}\t#%" PRIu64 "", (Jsi_Wide)(uintptr_t)op->data, (Jsi_Wide)((uintptr_t)currentip + (uintptr_t)op->data));
else if (op->op == OP_JMPPOP) {
jsi_JmpPopInfo *jp = (jsi_JmpPopInfo*)op->data;
snprintf(bp, bsiz, "{%d},%d\t#%d", jp->off, jp->topop, currentip + jp->off);
}
else if (op->op == OP_STRY) {
jsi_TryInfo *t = (jsi_TryInfo *)op->data;
snprintf(bp, bsiz, "{try:%d, catch:%d, final:%d}", t->trylen, t->catchlen, t->finallen);
}
}
|
CWE-120
| null | 520,271 |
256073490189761173249406925909313947636
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
int Jsi_Truncate(Jsi_Interp *interp, Jsi_Channel chan, unsigned int len) {
if (chan->fsPtr==0 || !chan->fsPtr->truncateProc) return -1;
return chan->fsPtr->truncateProc(chan, len);
}
|
CWE-120
| null | 520,272 |
281653252226692129039881309598036867819
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC FilesysEofCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr)
{
UdfGet(udf, _this, funcPtr);
Jsi_ValueMakeBool(interp, ret, Jsi_Eof(interp, udf->chan));
return JSI_OK;
}
|
CWE-120
| null | 520,273 |
8997589075172562956446015578138807753
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
bool jsi_FuncArgCheck(Jsi_Interp *interp, Jsi_Func *f, const char *argStr)
{
int i, atyp, ftyp, rc = 0, acnt;
Jsi_DString dStr;
Jsi_DSInit(&dStr);
int argc = 0;
char **argv, *sname, *stype, *cp;
if (!argStr)
goto done;
if (f->type == FC_BUILDIN) {
// Check builtin cmd
jsi_CommandArgCheck(interp, f->cmdSpec, f, f->parentName);
goto done;
}
if ((cp=Jsi_Strchr(argStr, '='))) {
Jsi_LogWarn("may not have default value in option, expected: %s", argStr);
goto done;
}
if (Jsi_Strstr(argStr, "...")) {
Jsi_LogWarn("may not have ... in args, expected: %s", argStr);
goto done;
}
if (argStr[0]) {
Jsi_SplitStr(argStr, &argc, &argv, ",", &dStr);
if (argc<=0)
goto done;
}
if (!f->argnames) {
if (argStr[0])
Jsi_LogWarn("function has no args, expected: %s", argStr);
else
rc = 1;
goto done;
} else {
if (f->argnames->varargs) { // TODO: could allow varargs...
if (argc < f->argnames->argCnt) {
Jsi_LogWarn("vararg argument mismatch, expected: %s", argStr);
goto done;
}
}
else if (f->argnames->argCnt != argc) {
if (argc)
Jsi_LogWarn("argument mismatch, expected: %s", argStr);
else
Jsi_LogWarn("function should have no arguments");
goto done;
}
}
acnt = f->argnames->argCnt;
for (i=0; i<argc && i<acnt; i++) {
sname = argv[i];
stype = NULL;
while (sname && *sname && isspace(*sname)) { sname++; }
if ((cp=Jsi_Strchr(sname, ':')))
{
stype = cp+1;
*cp = 0;
while (*stype && isspace(*stype)) { stype++; }
if (*stype) {
cp = stype+Jsi_Strlen(stype)-1;
while (cp>=stype && isspace(*cp)) { *cp = 0; cp--; }
}
}
if (sname && *sname) {
cp = sname+Jsi_Strlen(sname)-1;
while (cp>=sname && isspace(*cp)) { *cp = 0; cp--; }
}
ftyp = f->argnames->args[i].type;
if (ftyp<=0 || (ftyp&JSI_TT_ANY))
continue;
atyp = jsi_typeGet(interp, stype);
if (ftyp != atyp && atyp) {
Jsi_LogWarn("argument %d of function \"%s\" does not match \"func(%s)\"" ,
i+1, f->name, argStr);
goto done;
}
}
rc = 1;
done:
Jsi_DSFree(&dStr);
if (!rc)
jsi_TypeMismatch(interp);
return rc;
}
|
CWE-120
| null | 520,274 |
327115058813705492219687499334009718859
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC freeValueTbl(Jsi_Interp *interp, Jsi_HashEntry *hPtr, void *ptr) {
Jsi_Value *val = (Jsi_Value *)ptr;
if (!val) return JSI_OK;
SIGASSERT(val,VALUE);
//printf("GEN: %p\n", val);
/* if (val->refCnt>1)
Jsi_DecrRefCount(interp, val);*/
Jsi_DecrRefCount(interp, val);
return JSI_OK;
}
|
CWE-120
| null | 520,275 |
266638243915901700175882989962449722495
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC freeUserdataTbl(Jsi_Interp *interp, Jsi_HashEntry *hPtr, void *ptr) {
if (ptr)
jsi_UserObjDelete(interp, ptr);
return JSI_OK;
}
|
CWE-120
| null | 520,276 |
153785144224135665877905621736740782124
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
int jsi_BuiltinCmd(Jsi_Interp *interp, const char *name)
{
Jsi_Value *val = Jsi_NameLookup(interp, name);
if (!name)
return 0;
if (!Jsi_ValueIsFunction(interp, val))
return 0;
Jsi_Func *f = val->d.obj->d.fobj->func;
return (f->type == FC_BUILDIN);
}
|
CWE-120
| null | 520,277 |
242164617532650162853145460645336623408
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void jsi_PstateFree(jsi_Pstate *ps)
{
/* TODO: when do we free opcodes */
jsi_PstateClear(ps);
Jsi_Free(ps->lexer);
if (ps->opcodes)
jsi_FreeOpcodes(ps->opcodes);
if (ps->hPtr)
Jsi_HashEntryDelete(ps->hPtr);
if (ps->argsTbl)
Jsi_HashDelete(ps->argsTbl);
if (ps->fastVarTbl)
Jsi_HashDelete(ps->fastVarTbl);
if (ps->strTbl)
Jsi_HashDelete(ps->strTbl);
if (ps->last_exception)
Jsi_DecrRefCount(ps->interp, ps->last_exception);
_JSI_MEMCLEAR(ps);
Jsi_Free(ps);
}
|
CWE-120
| null | 520,278 |
59621353031839221951070124901128566549
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void mdbOutputQuotedString(Jsi_DString *dStr, const char *z) {
int i;
int nSingle = 0;
for(i=0; z[i]; i++) {
if( z[i]=='\'' ) nSingle++;
}
if( nSingle==0 ) {
Jsi_DSAppend(dStr,"'", z, "'", NULL);
} else {
Jsi_DSAppend(dStr,"'", NULL);
while( *z ) {
for(i=0; z[i] && z[i]!='\''; i++) {}
if( i==0 ) {
Jsi_DSAppend(dStr,"''", NULL);
z++;
} else if( z[i]=='\'' ) {
Jsi_DSAppendLen(dStr,z, i);
Jsi_DSAppend(dStr,"''", NULL);
z += i+1;
} else {
Jsi_DSAppend(dStr, z, NULL);
break;
}
}
Jsi_DSAppend(dStr,"'", NULL);
}
}
|
CWE-120
| null | 520,279 |
173662558843845666241773719016868881013
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC StringSubstringCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr)
{
int sLen = 0, bLen;
const char *v;
ChkString(_this, funcPtr, v, &sLen, &bLen);
Jsi_Value *start = Jsi_ValueArrayIndex(interp, args, skip);
Jsi_Value *end = Jsi_ValueArrayIndex(interp, args, skip+1);
Jsi_Number nstart, nend;
if (!start || Jsi_GetNumberFromValue(interp,start, &nstart) != JSI_OK) {
Jsi_ValueMakeStringDup(interp, ret, v);
return JSI_OK;
}
int istart = (int)nstart, olen = -1;
Jsi_DString dStr;
Jsi_DSInit(&dStr);
char *ostr;
if (!end || Jsi_GetNumberFromValue(interp,end, &nend) != JSI_OK) {
if (sLen == bLen) {
ostr = jsi_SubstrDup(v, bLen, istart, -1, &olen);
Jsi_ValueMakeBlob(interp, ret, (uchar*)ostr, olen);
} else {
Jsi_UtfSubstr(v, istart, -1, &dStr);
Jsi_ValueFromDS(interp, &dStr, ret);
}
return JSI_OK;
}
int iend = (int)nend;
if (iend>sLen)
iend = sLen;
if (iend < istart) {
Jsi_ValueMakeStringDup(interp, ret, "");
} else {
if (sLen == bLen) {
ostr = jsi_SubstrDup(v, bLen, istart, iend-istart+1, &olen);
Jsi_ValueMakeBlob(interp, ret, (uchar*)ostr, olen);
} else {
Jsi_UtfSubstr(v, istart, iend-istart+1, &dStr);
Jsi_ValueFromDS(interp, &dStr, ret);
}
}
return JSI_OK;
}
|
CWE-120
| null | 520,280 |
199926709295890444403198851565848399417
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_ecatch(jsi_Pstate *p, jsi_Pline *line) { JSI_NEW_CODESLN(0,OP_ECATCH, 0); }
|
CWE-120
| null | 520,281 |
148802395212775460423704061974910558015
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
bool Jsi_NumberIsSubnormal(Jsi_Number a) { return fpclassify(a) == FP_SUBNORMAL; }
|
CWE-120
| null | 520,282 |
128042209507949064968941352696342325065
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
int Jsi_Link(Jsi_Interp *interp, Jsi_Value* src, Jsi_Value *dest, int typ) {
void *data;
Jsi_Filesystem *fsPtr = Jsi_FilesystemForPath(interp, src, &data);
if (fsPtr == NULL || !fsPtr->linkProc) return -1;
return fsPtr->linkProc(interp, src, dest, typ);
}
|
CWE-120
| null | 520,283 |
34556767910298374971371467237076139414
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void Jsi_NumberUtoA10(Jsi_UWide value, char* buf, int bsiz)
{
snprintf(buf, bsiz, "%" PRIu64, value);
}
|
CWE-120
| null | 520,284 |
276809847276580956111342415400997960968
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_throw(jsi_Pstate *p, jsi_Pline *line) { JSI_NEW_CODESLN(0,OP_THROW, 0); }
|
CWE-120
| null | 520,285 |
87790051065105582643275152031605662780
| null | null |
other
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.