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 dbOutputHtmlString(QueryOpts *p, const char *z, Jsi_DString *dStr)
{
while( *z ) {
switch (*z) {
case '<':
Jsi_DSAppend(dStr, "<", NULL);
break;
case '>':
Jsi_DSAppend(dStr, ">", NULL);
break;
case '&':
Jsi_DSAppend(dStr, "&", NULL);
break;
case '\"':
Jsi_DSAppend(dStr, """, NULL);
break;
case '\'':
Jsi_DSAppend(dStr, "'", NULL);
break;
default:
Jsi_DSAppendLen(dStr, z, 1);
break;
}
z++;
}
}
|
CWE-120
| null | 519,986 |
88763400810339366947166417586207315194
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC SqliteCompleteCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr)
{
Jsi_Db *jdb;
if (!(jdb = dbGetDbHandle(interp, _this, funcPtr))) return JSI_ERROR;
Jsi_Value *s = Jsi_ValueArrayIndex(interp, args, 0);
const char *str = Jsi_ValueString(interp, s, NULL);
int isComplete = 0;
if (str)
isComplete = sqlite3_complete( str );
Jsi_ValueMakeBool(interp, ret, isComplete);
return JSI_OK;
}
|
CWE-120
| null | 519,987 |
286434935794724986529728763896047465182
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
int Jsi_Readlink(Jsi_Interp *interp, Jsi_Value* path, char *ret, int len) {
#ifdef __WIN32
return -1;
#else
void *data;
Jsi_Filesystem *fsPtr = Jsi_FilesystemForPath(interp, path, &data);
if (fsPtr == NULL || !fsPtr->readlinkProc) return -1;
return fsPtr->readlinkProc(interp, path, ret, len);
#endif
}
|
CWE-120
| null | 519,988 |
243190519843361106527295605567392448044
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC jsi_JsPreprocessLine(Jsi_Interp* interp, char *buf, size_t bsiz, uint ilen, int jOpts[4], int lineNo) {
if (buf[0]==';' && buf[1] && buf[2]) {
// Wrap ";XXX;" in a puts("XXX ==> ", XXX)
if (!jOpts[0]) {
if (!Jsi_Strcmp(buf, "=!EXPECTSTART!=\n") || !Jsi_Strcmp(buf, "=!INPUTSTART!=\n") ) {
return JSI_OK;
}
} else {
if (!Jsi_Strcmp(buf, "=!EXPECTEND!=\n") || !Jsi_Strcmp(buf, "=!INPUTEND!=\n")) {
jOpts[0] = 0;
return JSI_OK;
}
}
if (buf[ilen-1]=='\n' && buf[ilen-2]==';' && (2*ilen+12)<bsiz) {
if (Jsi_Strchr(buf, '`')) {
return Jsi_LogError("back-tick is illegal in unitTest on line %d: %s", lineNo, buf);
}
char ubuf[bsiz], *ucp = ubuf;
buf[ilen-=2] = 0;
Jsi_Strcpy(ubuf, buf+1);
while (*ucp && isspace(*ucp)) ucp++;
if (ilen>2 && ucp[0]=='\'' && ubuf[ilen-2]=='\'')
snprintf(buf, bsiz, "puts(`%s`);\n", ucp); //output a 'Comment'
else if (interp->debugOpts.testFmtCallback) {
Jsi_DString kStr={};
Jsi_Value *vrc = Jsi_ValueNew1(interp);
Jsi_DSPrintf(&kStr, "[\"%s\", %d ]", ucp, lineNo);
Jsi_RC rcs = Jsi_FunctionInvokeJSON(interp->parent, interp->debugOpts.testFmtCallback, Jsi_DSValue(&kStr), &vrc);
if (rcs == JSI_OK) {
const char *cps = Jsi_ValueString(interp, vrc, NULL);
if (!cps)
rcs = JSI_ERROR;
else
snprintf(buf, bsiz, "%s", cps);
}
Jsi_DecrRefCount(interp, vrc);
Jsi_DSFree(&kStr);
if (rcs != JSI_OK)
return Jsi_LogError("failure in debugOpts.testFmtCallback");
} else if (ilen>3 && ubuf[0]=='/' && ubuf[0]=='/') {
char *ecp = ubuf+2;
while (*ecp && isspace(*ecp)) ecp++;
snprintf(buf, bsiz, "printf(`%%s ==>`, \"%s\"); try { %s; puts('\\nFAIL!\\n'); } "
"catch(err) { puts('\\nPASS!: err =',err); }\n", ecp, ecp);
} else {
snprintf(buf, bsiz, "printf(`%%s ==> `,`%s`),puts(%s);\n", ucp, ucp);
}
}
}
return JSI_OK;
}
|
CWE-120
| null | 519,989 |
69306065742039610147087485933416073147
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_equal() { JSI_NEW_CODES(0,OP_EQUAL, 0); }
|
CWE-120
| null | 519,990 |
43085731197586011214993827642062682980
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
jsi_wsHeader(jsi_wsPss *pss, const char *name, int *lenPtr)
{
int i, nlen = Jsi_Strlen(name);
const char *ret = NULL, *cp = Jsi_DSValue(&pss->dHdrs);
for (i=0; i<pss->hdrNum; i+=2) {
int sz = pss->hdrSz[i];
int mat = (!Jsi_Strncasecmp(cp, name, nlen) && cp[nlen]=='=');
cp += 1 + sz;
if (mat) {
ret = cp;
if (lenPtr)
*lenPtr = pss->hdrSz[i+1];
break;
}
cp += (1 + pss->hdrSz[i+1]);
}
return ret;
}
|
CWE-120
| null | 519,991 |
206604549312661577609012177145536403476
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
const char* jsi_FuncGetCode(Jsi_Interp *interp, Jsi_Func *func, int *lenPtr) {
if (interp->subOpts.noFuncString || !func->bodyStr)
return NULL;
const char *cp, *cp2;
if (func->startPos == -1) {
cp = func->bodyStr;
int cplin = func->bodyline.last_line-1;
while (*cp && cplin>0) {
if (*cp=='\n' && --cplin<=0)
break;
cp++;
}
while (*cp && isspace(*cp))
cp++;
func->startPos = (*cp?(cp - func->bodyStr):-2);
}
if (func->startPos >= 0) {
int len = func->endPos - func->startPos;
cp = func->bodyStr + func->startPos;
while (len>0 && (isspace(cp[len-1]) || cp[len-1]==';')) len--;
if (*cp != 'f' && Jsi_Strncmp(cp, "function", 8) && (cp2=Jsi_Strstr(cp, "function"))) {
len -= (cp2-cp);
cp = cp2;
}
*lenPtr = len;
return cp;
}
return NULL;
}
|
CWE-120
| null | 519,992 |
177257389172379409800386237014642975557
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC mdbIsNumArray(Jsi_Interp *interp, Jsi_Value *value)
{
if (!Jsi_ValueIsArray(interp, value))
return Jsi_LogError("expected array of numbers");
int i, argc = Jsi_ValueGetLength(interp, value);
for (i=0; i<argc; i++) {
Jsi_Value *v = Jsi_ValueArrayIndex(interp, value, i);
if (!Jsi_ValueIsNumber(interp, v))
return Jsi_LogError("expected array of numbers");
}
return JSI_OK;
}
|
CWE-120
| null | 519,993 |
81087480469240948033291119976842199087
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void Jsi_IterGetKeys(Jsi_Interp *interp, Jsi_Value *target, Jsi_IterObj *iterobj, int depth)
{
if (!target) return;
if (target->vt != JSI_VT_OBJECT) {
if (interp->strict)
Jsi_LogWarn("operand is not a object");
return;
}
Jsi_Obj *to = target->d.obj;
Jsi_CmdSpec *cs = NULL;
if (to->ot == JSI_OT_USEROBJ) {
Jsi_UserObj *uobj = to->d.uobj;
cs = uobj->reg->spec;
} else if (to->ot == JSI_OT_FUNCTION) {
Jsi_FuncObj *fobj = to->d.fobj;
if (fobj->func->type == FC_BUILDIN)
cs = fobj->func->cmdSpec;
}
if (cs) {
while (cs->name) {
IterObjInsertKey(iterobj, cs->name);
cs++;
}
return;
}
iterobj->depth = depth;
Jsi_TreeWalk(target->d.obj->tree, IterGetKeysCallback, iterobj, 0);
if (target->d.obj->__proto__ && target != target->d.obj->__proto__)
Jsi_IterGetKeys(interp, target->d.obj->__proto__, iterobj, depth+1);
iterobj->depth = depth;
}
|
CWE-120
| null | 519,994 |
148801314268162268375189594457722061463
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void TreeTest(Jsi_Interp* interp) {
Jsi_Tree *st, *wt, *mt;
Jsi_TreeEntry *hPtr, *hPtr2;
bool isNew, i;
Jsi_TreeSearch srch;
struct tdata {
int n;
int m;
} t1, t2;
char nbuf[JSI_MAX_NUMBER_STRING];
wt = Jsi_TreeNew(interp, JSI_KEYS_ONEWORD, NULL);
mt = Jsi_TreeNew(interp, sizeof(struct tdata), NULL);
Jsi_TreeSet(wt, wt,(void*)0x88);
Jsi_TreeSet(wt, mt,(void*)0x99);
printf("WT: %p\n", Jsi_TreeGet(wt, mt));
printf("WT2: %p\n", Jsi_TreeGet(wt, wt));
Jsi_TreeDelete(wt);
t1.n = 0; t1.m = 1;
t2.n = 1; t2.m = 2;
Jsi_TreeSet(mt, &t1,(void*)0x88);
Jsi_TreeSet(mt, &t2,(void*)0x99);
Jsi_TreeSet(mt, &t2,(void*)0x98);
printf("CT: %p\n", Jsi_TreeGet(mt, &t1));
printf("CT2: %p\n", Jsi_TreeGet(mt, &t2));
Jsi_TreeDelete(mt);
st = Jsi_TreeNew(interp, JSI_KEYS_STRING, NULL);
hPtr = Jsi_TreeEntryNew(st, "bob", &isNew);
Jsi_TreeValueSet(hPtr, (void*)99);
Jsi_TreeSet(st, "zoe",(void*)77);
hPtr2 = Jsi_TreeSet(st, "ted",(void*)55);
Jsi_TreeSet(st, "philip",(void*)66);
Jsi_TreeSet(st, "alice",(void*)77);
puts("SRCH");
for (hPtr=Jsi_TreeSearchFirst(st,&srch, JSI_TREE_ORDER_IN, NULL); hPtr; hPtr=Jsi_TreeSearchNext(&srch))
mycall(st, hPtr, NULL);
Jsi_TreeSearchDone(&srch);
puts("IN");
Jsi_TreeWalk(st, mycall, NULL, JSI_TREE_ORDER_IN);
puts("PRE");
Jsi_TreeWalk(st, mycall, NULL, JSI_TREE_ORDER_PRE);
puts("POST");
Jsi_TreeWalk(st, mycall, NULL, JSI_TREE_ORDER_POST);
puts("LEVEL");
Jsi_TreeWalk(st, mycall, NULL, JSI_TREE_ORDER_LEVEL);
Jsi_TreeEntryDelete(hPtr2);
puts("INDEL");
Jsi_TreeWalk(st, mycall, NULL, 0);
for (i=0; i<1000; i++) {
snprintf(nbuf, sizeof(nbuf), "name%d", i);
Jsi_TreeSet(st, nbuf,(void*)i);
}
Jsi_TreeWalk(st, mycall, NULL, 0);
for (i=0; i<1000; i++) {
Jsi_TreeEntryDelete(st->root);
}
puts("OK");
Jsi_TreeWalk(st, mycall, NULL, 0);
Jsi_TreeDelete(st);
}
|
CWE-120
| null | 519,995 |
217609688868473825725122520541939778090
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void code_reserved_replace(Jsi_OpCodes *ops, int step_len, int break_only,
const char *desire_label, int topop)
{
int i;
for (i = 0; i < ops->code_len; ++i) {
if (ops->codes[i].op != OP_RESERVED) continue;
jsi_ReservedInfo *ri = (jsi_ReservedInfo *)ops->codes[i].data;
if (ri->label) {
if (!desire_label || Jsi_Strcmp(ri->label, desire_label) != 0) {
ri->topop += topop;
continue;
}
}
if (ri->type == RES_CONTINUE) {
if (break_only) {
ri->topop += topop;
continue;
} else {
int topop = ri->topop;
Jsi_Free(ri); /* kill reserved Warn, replace with other opcode */
/* if (ops->codes[i].data && ops->codes[i].alloc) //TODO: memory leak?
Jsi_Free(ops->codes[i].data);*/
if (topop) {
ops->codes[i].data = jpinfo_new(ops->code_len - i, topop);
ops->codes[i].op = OP_JMPPOP;
ops->codes[i].alloc = 1;
} else {
ops->codes[i].data = (void *)(uintptr_t)(ops->code_len - i);
ops->codes[i].op = OP_JMP;
ops->codes[i].alloc = 0;
}
}
} else if (ri->type == RES_BREAK) {
int topop = ri->topop;
Jsi_Free(ri);
/* if (ops->codes[i].data && ops->codes[i].alloc)
Jsi_Free(ops->codes[i].data); */
if (topop) {
ops->codes[i].data = jpinfo_new(step_len + ops->code_len - i, topop);
ops->codes[i].op = OP_JMPPOP;
ops->codes[i].alloc = 1;
} else {
ops->codes[i].data = (void *)(uintptr_t)(step_len + ops->code_len - i);
ops->codes[i].op = OP_JMP;
ops->codes[i].alloc = 0;
}
}
}
}
|
CWE-120
| null | 519,996 |
37021428679543039901326057794833727561
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void jsi_DebugValue(Jsi_Value* v, const char *reason, uint cidx, Jsi_Interp *interp)
{
if (jsi_memDebugBreakIdx && jsi_memDebugBreakIdx == v->VD.Idx)
jsi_memDebugBreak();
return;
}
|
CWE-120
| null | 519,997 |
266470139034918020410991162779349944005
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void mdbFlushStmtCache( MySqlObj *jdb ) {
Jsi_ListClear(jdb->stmtCache);
jdb->numStmts = 0;
}
|
CWE-120
| null | 519,998 |
240300535151936046119312837782543216316
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_OptionCustom* Jsi_OptionCustomBuiltin(Jsi_OptionCustom* cust) {
if ((uintptr_t)cust < (uintptr_t)(sizeof(custOpts)/sizeof(custOpts[0])))
return custOpts[(uintptr_t)cust];
return cust;
}
|
CWE-120
| null | 519,999 |
327083247460467505212997375876586823896
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC jsi_InterpDebugHook(struct Jsi_Interp* interp, const char *curFile,
int curLine, int curLevel, const char *curFunc, const char *opCode, jsi_OpCode *op, const char *emsg)
{
// TODO: when code is run in debugger, parser.y should attribute op for case stmt to skip str compares, etc.
int isfun=0;
if (interp->isInCallback || curLine<=0)
return JSI_OK;
if (op && op->nodebug)
return JSI_OK;
int isbp = 0, bpId = 0, cont = interp->debugOpts.doContinue,
stop = (interp->debugOpts.noFilter || interp->debugOpts.forceBreak);
if (!curFunc)
curFunc = "";
if (interp->parent && interp->parent->sigmask) {
interp->parent->sigmask = 0;
opCode = "SIGINT";
} else if (Jsi_Strcmp(opCode, "DEBUG") || !interp->parent) {
// Avoid overhead of multiple ops on same line of code.
int sameLine = (interp->debugOpts.lastLine == curLine && interp->debugOpts.lastLevel == curLevel
&& interp->debugOpts.lastFile == curFile);
if (sameLine && stop==0 && (interp->debugOpts.bpLast==0
|| (interp->debugOpts.bpOpCnt+10) >= interp->opCnt)) //TODO: need better way to detect bp dups.
goto done;
if (!interp->debugOpts.debugCallback || !interp->parent) {
fprintf(stderr, "FILE %s:%d (%d) %s %s\n", curFile, curLine, curLevel, curFunc, opCode);
return JSI_OK;
}
// Check for breakpoints.
if (interp->breakpointHash) {
Jsi_HashEntry *hPtr;
Jsi_HashSearch search;
for (hPtr = Jsi_HashSearchFirst(interp->breakpointHash, &search);
hPtr != NULL && stop == 0; hPtr = Jsi_HashSearchNext(&search)) {
jsi_BreakPoint* bptr = (jsi_BreakPoint*)Jsi_HashValueGet(hPtr);
if (bptr == NULL || bptr->enabled == 0) continue;
if (bptr->func)
stop = (!Jsi_Strcmp(bptr->func, curFunc));
else
stop = (bptr->line == curLine && !Jsi_Strcmp(bptr->file, curFile));
if (stop) {
isbp = 1;
bpId = bptr->id;
bptr->hits++;
if (bptr->temp)
bptr->enabled = 0;
}
}
}
if (stop == 0) { // No breakpoint.
if (cont // Cmd is "continue"
// Handle "next" by skipping calls into functions.
|| (interp->debugOpts.minLevel>0 && curLevel>interp->debugOpts.minLevel)
|| (isfun=(Jsi_Strcmp(opCode, "PUSHVAR")==0 && op[1].op == OP_PUSHFUN)))
{
if (isfun) {
interp->debugOpts.lastLine = curLine;
interp->debugOpts.lastLevel = curLevel;
interp->debugOpts.lastFile = curFile;
}
done:
return JSI_OK;
}
}
}
interp->debugOpts.bpLast = isbp;
interp->debugOpts.bpOpCnt = interp->opCnt;
interp->debugOpts.lastLine = curLine;
interp->debugOpts.lastLevel = curLevel;
interp->debugOpts.lastFile = curFile;
interp->debugOpts.forceBreak = 0;
Jsi_DString dStr;
Jsi_DSInit(&dStr);
if (emsg && Jsi_Strchr(emsg,'\"'))
emsg = 0;
Jsi_DSPrintf(&dStr, "[\"%s\", %d, %d, \"%s\", \"%s\", %d, \"%s\"]", curFile?curFile:"", curLine, curLevel, curFunc, opCode, bpId, emsg?emsg:"");
interp->isInCallback = 1;
Jsi_RC rc = JSI_ERROR;
if (interp->debugOpts.debugCallback)
rc = Jsi_FunctionInvokeJSON(interp->parent, interp->debugOpts.debugCallback, Jsi_DSValue(&dStr), &interp->retValue);
interp->isInCallback = 0;
if (interp->parent->exited == 0 && rc != JSI_OK)
Jsi_LogError("debugger failure");
return rc;
}
|
CWE-120
| null | 520,000 |
254447853320753397420093146171132851336
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void caselist_free(jsi_CaseList *c)
{
jsi_CaseList *a = c;
while (a) {
a = c->next;
if (c->es) Jsi_Free(c->es);
Jsi_Free(c);
c = a;
}
}
|
CWE-120
| null | 520,001 |
41209885927622275844411066419354631649
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void set_color(Jsi_TreeEntry* n, int color) {
if (color == _JSI_TREE_BLACK && n == NULL) return;
n->f.bits.color = color;
}
|
CWE-120
| null | 520,002 |
76692295480180756081772868972793066309
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
uint Jsi_ListSize(Jsi_List *list) {
SIGASSERT(list, LIST);
return list->numEntries;
}
|
CWE-120
| null | 520,003 |
197026600638123861706913345633686022111
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC Jsi_FSRegister(Jsi_Filesystem *fsPtr, void *data) {
FSList *fsl = (FSList *)Jsi_Calloc(1, sizeof(*fsl));
fsl->fsPtr = fsPtr;
fsl->data = data;
fsl->next = jsiFSList;
jsiFSList = fsl;
return JSI_OK;
}
|
CWE-120
| null | 520,004 |
220996541602127841709559501108228122529
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_Value* Jsi_ValueNew(Jsi_Interp *interp) {
return ValueNew(interp);
}
|
CWE-120
| null | 520,005 |
104575829659197487661274665730061071425
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC jsi_wsfreeFile(Jsi_Interp *interp, Jsi_HashEntry* hPtr, void *ptr) {
jsi_wsFile*h = (jsi_wsFile*)ptr;
if (!h)
return JSI_OK;
if (h->fileVal)
Jsi_DecrRefCount(interp, h->fileVal);
Jsi_Free(h);
return JSI_OK;
}
|
CWE-120
| null | 520,006 |
108904059375707451422922350356797683628
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC WebSocketStatusCmd(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 to non-websock object");
#ifndef OMIT_LWS_WITH_SERVER_STATUS
char cbuf[JSI_BUFSIZ*2];
lws_json_dump_context(cmdPtr->context, cbuf, sizeof(cbuf), 0);
return Jsi_JSONParse(interp, cbuf, ret, 0);
#else
return Jsi_LogError("unsupported");
#endif
}
|
CWE-120
| null | 520,007 |
272733240081158253207967105392756015640
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_bor() { JSI_NEW_CODES(0,OP_BOR, 0); }
|
CWE-120
| null | 520,008 |
76890515861796292792175594476424312690
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_Wide jsi_strtoul(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 = strtoul(str + i, endptr, base);
if (endptr == NULL || *endptr != str + i) {
return value * sign;
}
}
/* Can just do a regular base-10 conversion */
return strtoul(str, endptr, 10);
#else
return (unsigned long)jsi_strtol(str, endptr);
#endif
}
|
CWE-120
| null | 520,009 |
319997043756211897321811620757502018655
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC freeGenObjTbl(Jsi_Interp *interp, Jsi_HashEntry *hPtr, void *ptr) {
Jsi_Obj *obj = (Jsi_Obj *)ptr;
SIGASSERT(obj,OBJ);
if (!obj) return JSI_OK;
Jsi_ObjDecrRefCount(interp, obj);
return JSI_OK;
}
|
CWE-120
| null | 520,010 |
51584128876808789544297069672079643706
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC InterpValueCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr)
{
InterpObj *udf = (InterpObj *)Jsi_UserObjGetData(interp, _this, funcPtr);
Jsi_Interp *sinterp = interp;
if (udf) {
if (!udf->subinterp)
return Jsi_LogError("Sub-interp gone");
sinterp = udf->subinterp;
if (interp->threadId != udf->subinterp->threadId)
return Jsi_LogError("value not supported with threads");
}
Jsi_Value *nw = Jsi_ValueArrayIndex(interp, args, 1);
jsi_Frame *f = sinterp->framePtr;
Jsi_Number nlev = sinterp->framePtr->level;
if (nw && Jsi_GetNumberFromValue(interp, nw, &nlev))
return JSI_ERROR;
int lev = (int)nlev;
if (lev <= 0)
lev = f->level+lev;
if (lev <= 0 || lev > f->level)
return Jsi_LogError("level %d not between 1 and %d", (int)nlev, f->level);
while (f->level != lev && f->parent)
f = f->parent;
const char* arg = Jsi_ValueArrayIndexToStr(interp, args, 0, NULL);
Jsi_Value *val = NULL;
if (arg) {
if (f == sinterp->framePtr)
val = Jsi_NameLookup(sinterp, arg);
else {
jsi_Frame *of = sinterp->framePtr;
sinterp->framePtr = f;
val = Jsi_NameLookup(sinterp, arg);
sinterp->framePtr = of;
}
}
if (!val)
return Jsi_LogError("unknown var: %s", arg);
if (sinterp == interp) {
Jsi_ValueCopy(interp, *ret, val);
return JSI_OK;
}
Jsi_CleanValue(sinterp, interp, val, ret);
return JSI_OK;
}
|
CWE-120
| null | 520,011 |
332763281037483119585946113914063199218
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static int jsi_FSRenameProc(Jsi_Interp *interp, Jsi_Value *src, Jsi_Value *dest) {
const char *zSrc = Jsi_ValueToString(interp, src, NULL);
const char *zDest = Jsi_ValueToString(interp, dest, NULL);
Jsi_DString dStr = {}, eStr = {};
if (*zSrc == '~')
zSrc = jsi_TildePath(interp, zSrc, &dStr);
if (*zDest == '~')
zDest = jsi_TildePath(interp, zDest, &eStr);
int rc = rename(zSrc, zDest);
Jsi_DSFree(&dStr);
Jsi_DSFree(&eStr);
return rc;
}
|
CWE-120
| null | 520,012 |
212427804819668484332664251225177389802
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
int Jsi_NumberIsInfinity(Jsi_Number a) {
#if JSI__MUSL==1 || defined(__FreeBSD__) || defined(__WIN32)
if (!isinf(a))
return 0;
return (a<0 ? -1 : 1);
#else
return isinf(a);
#endif
}
|
CWE-120
| null | 520,013 |
253168449669958849831349598549707248971
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
bool Jsi_ValueIsBoolean(Jsi_Interp *interp, Jsi_Value *pv)
{
return (pv->vt == JSI_VT_BOOL || (pv->vt == JSI_VT_OBJECT && pv->d.obj->ot == JSI_OT_BOOL));
}
|
CWE-120
| null | 520,014 |
191304989619752159322532145167284308127
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void* Jsi_InterpThread(Jsi_Interp *interp) { return interp->threadId; }
|
CWE-120
| null | 520,015 |
238283753489514242837093929118077490948
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC FilesysStatCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr)
{
UdfGet(udf, _this, funcPtr);
#if JSI__FILESYS==1
return jsi_FileStatCmd(interp, udf->fname, _this, ret, funcPtr, 0);
#else
return JSI_ERROR;
#endif
}
|
CWE-120
| null | 520,016 |
114825315979725779800598326488431953836
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void Jsi_ValueMove(Jsi_Interp *interp, Jsi_Value *to, Jsi_Value *from ) {
return jsi_ValueCopyMove(interp, to, from, 0);
}
|
CWE-120
| null | 520,017 |
217942518460909679964429257460852591023
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC IterGetKeysCallback(Jsi_Tree* tree, Jsi_TreeEntry *hPtr, void *data)
{
Jsi_IterObj *io = (Jsi_IterObj *)data;
if (!hPtr->f.bits.dontenum) {
IterObjInsert(io, hPtr);
}
return JSI_OK;
}
|
CWE-120
| null | 520,018 |
128524242570893244287400147950587731254
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_TreeEntry *Jsi_TreeEntryFind (Jsi_Tree *treePtr, const void *key)
{
Jsi_TreeEntry* hPtr = treePtr->root;
int rc;
if (treePtr->flags.destroyed)
return NULL;
if (treePtr->opts.lockTreeProc && (*treePtr->opts.lockTreeProc)(treePtr, 1) != JSI_OK)
return NULL;
while (hPtr != NULL) {
rc = treePtr->opts.compareTreeProc(treePtr, Jsi_TreeKeyGet(hPtr), key);
if (rc == 0) {
break;
}
hPtr = (rc < 0 ? hPtr->left : hPtr->right);
}
if (treePtr->opts.lockTreeProc)
(*treePtr->opts.lockTreeProc)(treePtr, 0);
return hPtr;
}
|
CWE-120
| null | 520,019 |
93848224158981891630888711182138660363
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_greater() { JSI_NEW_CODES(0,OP_GREATER, 0); }
|
CWE-120
| null | 520,020 |
257582253378363231203753873328144010549
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void Jsi_TreeClear (Jsi_Tree *treePtr)
{
SIGASSERTV(treePtr, TREE);
if (treePtr->opts.lockTreeProc && (*treePtr->opts.lockTreeProc)(treePtr, 1) != JSI_OK)
return;
destroy_node(treePtr->opts.interp, treePtr->root);
treePtr->root = NULL;
if (treePtr->opts.lockTreeProc)
(*treePtr->opts.lockTreeProc)(treePtr, 0);
}
|
CWE-120
| null | 520,021 |
225380312086934514238648403483272084085
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_ScopeStrs *jsi_ScopeStrsNew()
{
Jsi_ScopeStrs *ret = (Jsi_ScopeStrs *)Jsi_Calloc(1, sizeof(*ret));
return ret;
}
|
CWE-120
| null | 520,022 |
69824630225120760412238142561830986365
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static int dbCommitHandler(void *cd) {
int rc = 0;
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);
if( JSI_OK!=Jsi_FunctionInvoke(interp, jdb->onCommit, NULL, &ret, NULL) ) {
jdb->errCnt++;
rc = 1;
} else
rc = dbGetIntBool(interp, ret);
Jsi_DecrRefCount(interp, vpargs);
Jsi_DecrRefCount(interp, ret);
return rc;
}
|
CWE-120
| null | 520,023 |
187330528310019210696681295443185694779
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
long long mdbLastInsertRowid(MySqlObj* jdb)
{
return mysql_insert_id(jdb->db);
}
|
CWE-120
| null | 520,024 |
106093012445604869235127856110035613587
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static int dbOptSelect(Jsi_Db *jdb, const char *cmd, OptionBind *obPtr, Jsi_CDataDb *dbopts)
{
void *rec = dbopts[0].data, **recPtrPtr = NULL;
Jsi_Interp *interp = jdb->interp;
Jsi_StructSpec *specPtr, *specs = dbopts[0].sf;
DbEvalContext sEval = {};
int ccnt = 0;
Jsi_Wide flags = 0;
const char *cPtr = Jsi_Strstr(cmd, " %s");
if (!cPtr) cPtr = Jsi_Strstr(cmd, "\t%s");
Jsi_DString *eStr;
#ifdef JSI_DB_DSTRING_SIZE
JSI_DSTRING_VAR(dStr, JSI_DB_DSTRING_SIZE);
#else
Jsi_DString sStr, *dStr = &sStr;
Jsi_DSInit(dStr);
#endif
dbEvalInit(interp, &sEval, jdb, NULL, dStr, 0, 0);
if (dbopts->noCache)
sEval.nocache = 1;
Jsi_DSAppendLen(dStr, cmd, cPtr?(cPtr-cmd):-1);
if (cPtr) {
Jsi_DSAppend(dStr, " ", NULL);
for (specPtr = specs; specPtr->id>=JSI_OPTION_BOOL && specPtr->id < JSI_OPTION_END; specPtr++) {
if (specPtr == obPtr->dirtyPtr || (specPtr->flags&JSI_OPT_DB_IGNORE))
continue;
if (ccnt)
Jsi_DSAppendLen(dStr, ",", 1);
Jsi_DSAppend(dStr, "[", specPtr->name, "]", NULL);
ccnt++;
}
Jsi_DSAppend(dStr, cPtr+3, NULL);
}
sEval.zSql = Jsi_DSValue(dStr);
sEval.nocache = jdb->optPtr->nocache;
int rc = JSI_ERROR, erc = -1, structSize = 0;
int cnt = 0, dataMax = (dbopts->isPtr2?0:1);
int multi = (dbopts->isPtr2!=0);
int dnum = dbopts[0].arrSize;
if (dnum<=0 && !dbopts->isPtr2) {
dataMax = dnum = 1;
}
if (dnum>1) {
multi = 1;
dataMax = dbopts[0].arrSize;
}
if (dbopts->isPtr2) {
recPtrPtr = (void**)rec; /* This is really a void***, but this gets recast below. */
rec = *recPtrPtr;
}
structSize = specs[obPtr->optLen].size;
cnt = 0;
int ncnt = 0, bindMax = -1, dataIdx = -1;
while(1) {
dataIdx++;
if (dataIdx>=dataMax) {
if (!dbopts->isPtr2)
break;
else {
/* Handle fully dynamic allocation of memory. */
#ifndef JSI_DB_MAXDYN_SIZE
#define JSI_DB_MAXDYN_SIZE 100000000
#endif
#ifndef JSI_DB_DYN_INCR
#define JSI_DB_DYN_INCR 16
#endif
int ddMax = (dbopts->maxSize>0?dbopts->maxSize:JSI_DB_MAXDYN_SIZE);
if (dataMax>=ddMax)
break;
int olddm = dataMax;
dataMax += JSI_DB_DYN_INCR;
if (dataMax>ddMax)
dataMax = ddMax;
if (!olddm)
rec = Jsi_Calloc(dataMax+1, sizeof(void*));
else {
rec = Jsi_Realloc(rec, (dataMax+1)*sizeof(void*));
memset((char*)rec+olddm*sizeof(void*), 0, (dataMax-olddm+1)*sizeof(void*));
}
*recPtrPtr = rec;
}
}
rc = dbEvalStepOption(&sEval, obPtr, &ncnt, dataIdx, bindMax, dbopts, &erc);
if (rc == JSI_ERROR)
break;
if (rc != JSI_OK)
break;
cnt += ncnt;
sqlite3_stmt *pStmt = sEval.pPreStmt->pStmt;
int idx;
int nCol;
char **apColName;
const char *str;
int *apColType;
void *prec = rec;
bindMax = 0;
if (dbopts->isPtr2 || dbopts->isPtrs) {
prec = ((void**)rec)[dataIdx];
if (!prec)
((void**)rec)[dataIdx] = prec = Jsi_Calloc(1, structSize);
} else
prec = (char*)rec + (dataIdx * structSize);
dbEvalRowInfo(&sEval, &nCol, &apColName, &apColType);
for (idx=0; idx<nCol; idx++) {
specPtr = dbLookupSpecFromName(specs, apColName[idx]);
if (!specPtr) {
Jsi_LogError("unknown column name: %s", apColName[idx]);
goto bail;
}
if (specPtr->id<JSI_OPTION_BOOL || specPtr->id>=JSI_OPTION_END) {
Jsi_LogError("unknown option type \"%d\" for \"%s\"", specPtr->id, specPtr->name);
goto bail;
}
char *ptr = (char*)prec + specPtr->offset;
switch (specPtr->id) {
case JSI_OPTION_BOOL:
*(int*)ptr = sqlite3_column_int(pStmt, idx);
break;
case JSI_OPTION_INT: *(int*)ptr = (int)sqlite3_column_int64(pStmt, idx); break;
case JSI_OPTION_UINT: *(uint*)ptr = (uint)sqlite3_column_int64(pStmt, idx); break;
case JSI_OPTION_INTPTR_T: *(intptr_t*)ptr = (intptr_t)sqlite3_column_int64(pStmt, idx); break;
case JSI_OPTION_UINTPTR_T: *(uintptr_t*)ptr = (uintptr_t)sqlite3_column_int64(pStmt, idx); break;
case JSI_OPTION_SIZE_T: *(size_t*)ptr = (size_t)sqlite3_column_int64(pStmt, idx); break;
case JSI_OPTION_SSIZE_T: *(ssize_t*)ptr = (ssize_t)sqlite3_column_int64(pStmt, idx); break;
case JSI_OPTION_SHORT: *(short*)ptr = (int)sqlite3_column_int64(pStmt, idx); break;
case JSI_OPTION_USHORT: *(ushort*)ptr = (uint)sqlite3_column_int64(pStmt, idx); break;
case JSI_OPTION_LONG: *(long*)ptr = (int)sqlite3_column_int64(pStmt, idx); break;
case JSI_OPTION_ULONG: *(ulong*)ptr = (uint)sqlite3_column_int64(pStmt, idx); break;
case JSI_OPTION_INT8: *(int8_t*)ptr = (int)sqlite3_column_int64(pStmt, idx); break;
case JSI_OPTION_UINT8: *(uint8_t*)ptr = (uint)sqlite3_column_int64(pStmt, idx); break;
case JSI_OPTION_INT16: *(int16_t*)ptr = (int)sqlite3_column_int64(pStmt, idx); break;
case JSI_OPTION_UINT16: *(uint16_t*)ptr = (uint)sqlite3_column_int64(pStmt, idx); break;
case JSI_OPTION_INT32: *(int32_t*)ptr = (int)sqlite3_column_int64(pStmt, idx); break;
case JSI_OPTION_UINT32: *(uint32_t*)ptr = (uint)sqlite3_column_int64(pStmt, idx); break;
case JSI_OPTION_INT64: *(int64_t*)ptr = (int)sqlite3_column_int64(pStmt, idx); break;
case JSI_OPTION_TIME_W:
case JSI_OPTION_UINT64: *(uint64_t*)ptr = (uint)sqlite3_column_int64(pStmt, idx); break;
case JSI_OPTION_TIME_T:
*(time_t*)ptr = (time_t)sqlite3_column_int64(pStmt, idx);
break;
case JSI_OPTION_NUMBER:
*(Jsi_Number*)ptr = (Jsi_Number)sqlite3_column_double(pStmt, idx);
break;
case JSI_OPTION_TIME_D:
case JSI_OPTION_FLOAT:
*(float*)ptr = (float)sqlite3_column_double(pStmt, idx);
break;
case JSI_OPTION_DOUBLE:
*(double*)ptr = (double)sqlite3_column_double(pStmt, idx);
break;
case JSI_OPTION_LDOUBLE:
*(ldouble*)ptr = (ldouble)sqlite3_column_double(pStmt, idx);
break;
case JSI_OPTION_DSTRING:
eStr = (Jsi_DString*)ptr;
str = (char*)sqlite3_column_text(pStmt, idx );
if (!str)
str = jdb->optPtr->nullvalue;
Jsi_DSSet(eStr, str?str:"");
break;
case JSI_OPTION_STRBUF:
str = (char*)sqlite3_column_text(pStmt, idx );
if (!str)
str = jdb->optPtr->nullvalue;
strncpy((char*)ptr, str?str:"", specPtr->size);
((char*)ptr)[specPtr->size-1] = 0;
break;
case JSI_OPTION_CUSTOM: {
Jsi_OptionCustom* cust = Jsi_OptionCustomBuiltin(specPtr->custom);
if (cust && cust->parseProc) {
str = (char*)sqlite3_column_text(pStmt, idx );
if ((*cust->parseProc)(interp, (Jsi_OptionSpec*)specPtr, NULL, str, prec, flags) != JSI_OK) {
goto bail;
}
} else {
Jsi_LogError("missing or invalid custom for \"%s\"", specPtr->name);
goto bail;
}
break;
}
case JSI_OPTION_STRKEY:
str = (char*)sqlite3_column_text(pStmt, idx );
if (!str)
str = jdb->optPtr->nullvalue;
*(char**)ptr = (str?(char*)Jsi_DbKeyAdd(jdb, str):NULL);
break;
#ifndef JSI_LITE_ONLY
case JSI_OPTION_STRING: {
Jsi_Value *vPtr = *((Jsi_Value **)ptr);
if (!(specPtr->flags&JSI_OPT_NO_DUPVALUE)) {
if (vPtr) Jsi_DecrRefCount(interp, vPtr);
*((Jsi_Value **)ptr) = NULL;
}
str = (char*)sqlite3_column_text(pStmt, idx );
if (!str)
str = jdb->optPtr->nullvalue;
if (str) {
vPtr = Jsi_ValueNewStringDup(interp, str);
*((Jsi_Value **)ptr) = vPtr;
}
break;
}
#else
case JSI_OPTION_STRING:
#endif
case JSI_OPTION_VALUE: /* The rest are unsupported. */
case JSI_OPTION_VAR:
case JSI_OPTION_OBJ:
case JSI_OPTION_ARRAY:
case JSI_OPTION_REGEXP:
case JSI_OPTION_FUNC:
#ifdef __cplusplus
case JSI_OPTION_USEROBJ:
case JSI_OPTION_END:
#else
default:
#endif
JSI_DBQUERY_PRINTF( "unsupported type: %d:%s\n", specPtr->id,
jsi_DbOptionTypeStr(specPtr->id, 0));
break;
}
}
if (dbopts[0].callback)
dbopts[0].callback(interp, dbopts, prec);
cnt++;
if (!multi)
break;
}
dbEvalFinalize(&sEval);
if( rc==JSI_BREAK ) {
rc = JSI_OK;
}
return (rc==JSI_OK?cnt:erc);
bail:
dbEvalFinalize(&sEval);
return erc;
}
|
CWE-120
| null | 520,025 |
48948896012582953611639777262849795548
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC Jsi_TreeConf(Jsi_Tree *treePtr, Jsi_MapOpts *opts, bool set)
{
if (set)
treePtr->opts = *opts;
else
*opts = treePtr->opts;
return JSI_OK;
}
|
CWE-120
| null | 520,026 |
97812323092627013559391298386971973908
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_chthis(jsi_Pstate *p, jsi_Pline *line, int n) { JSI_NEW_CODESLN(0,OP_CHTHIS, n); }
|
CWE-120
| null | 520,027 |
330129204955812576714201558800649699907
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
const char* Jsi_KeyLookup(Jsi_Interp *interp, const char *str)
{
Jsi_MapEntry *hPtr;
hPtr = Jsi_MapEntryFind(interp->strKeyTbl, str);
if (!hPtr) {
return NULL;
}
return (const char*)Jsi_MapKeyGet(hPtr, 0);
}
|
CWE-120
| null | 520,028 |
49894626070592556758156638591866080405
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_greaterequ() { JSI_NEW_CODES(0,OP_GREATEREQU, 0); }
|
CWE-120
| null | 520,029 |
312292893565576103025576612731436611566
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void *Jsi_TreeGet(Jsi_Tree *treePtr, void *key, int flags)
{
Jsi_TreeEntry *hPtr = Jsi_TreeEntryFind(treePtr, key);
if (!hPtr)
return NULL;
return Jsi_TreeValueGet(hPtr);
}
|
CWE-120
| null | 520,030 |
59419202289176466347176922729119655756
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static int jsi_FSLstatProc(Jsi_Interp *interp, Jsi_Value* path, Jsi_StatBuf *buf) {
#ifdef __WIN32
return jsi_FSStatProc(interp, path, buf);
#else
const char *pathPtr = Jsi_ValueToString(interp, path, NULL);
Jsi_DString dStr = {};
if (*pathPtr == '~')
pathPtr = jsi_TildePath(interp, pathPtr, &dStr);
int rc = lstat(pathPtr, buf);
Jsi_DSFree(&dStr);
return rc;
#endif
}
|
CWE-120
| null | 520,031 |
27867959951715756777112286017406928232
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC Jsi_GetBool(Jsi_Interp* interp, const char *string, bool *n)
{
int len = Jsi_Strlen(string);
if (len && (Jsi_Strncasecmp(string, "true", len)==0 && len<=4)) {
*n = 1;
return JSI_OK;
}
if (len && (Jsi_Strncasecmp(string, "false", len)==0 && len<=5)) {
*n = 0;
return JSI_OK;
}
return JSI_ERROR;
}
|
CWE-120
| null | 520,032 |
221071421160996764702530702420677624695
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void jsi_AllValueOp(Jsi_Interp *interp, Jsi_Value* val, int op) {
if (op==1) {
//printf("ADD: %p : %p : %d\n", interp, val, val->VD.Idx);
assert(interp->allValues!=val);
val->next = interp->allValues;
if (interp->allValues)
interp->allValues->prev = val;
interp->allValues = val;
return;
}
if (op==0) {
//printf("DEL: %p : %p\n", interp, val);
if (!val || !interp->allValues) return;
if (val == interp->allValues)
interp->allValues = val->next;
if (val->next)
val->next->prev = val->prev;
if (val->prev)
val->prev->next = val->next;
return;
}
if (op == -1) {
while (interp->allValues) {
printf("NEED CLEANUP: %p\n", interp->allValues);
Jsi_ValueFree(interp, interp->allValues);
}
return;
}
#if JSI__MEMDEBUG
assert(0);
abort();
#endif
}
|
CWE-120
| null | 520,033 |
272275088816621477708466456110134743699
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void mdbEvalSetColumnJSON(MyDbEvalContext *p, int iCol, Jsi_DString *dStr) {
Jsi_Interp *interp = p->jdb->interp;
char nbuf[JSI_MAX_NUMBER_STRING];
MysqlPrep *prep = p->prep;
SqlFieldResults *field = prep->fieldResult+iCol;
if (field->isnull) {
Jsi_DSAppend(dStr, "null", NULL);
return;
}
const char *zBlob = "";
int bytes = 0;
switch(field->jsiTypeMap) {
case JSI_OPTION_BOOL: {
snprintf(nbuf, sizeof(nbuf), "%s", field->buffer.vchar?"true":"false");
Jsi_DSAppend(dStr, nbuf, NULL);
return;
}
case JSI_OPTION_INT64: {
snprintf(nbuf, sizeof(nbuf), "%lld", field->buffer.vlonglong);
Jsi_DSAppend(dStr, nbuf, NULL);
return;
}
case JSI_OPTION_DOUBLE: {
Jsi_NumberToString(interp, field->buffer.vdouble, nbuf, sizeof(nbuf));
Jsi_DSAppend(dStr, nbuf, NULL);
return;
}
//case JSI_OPTION_TIME_T:
case JSI_OPTION_TIME_D:
case JSI_OPTION_TIME_W: {
Jsi_Number jtime = mdbMyTimeToJS(&field->buffer.timestamp);
Jsi_NumberToString(interp, jtime, nbuf, sizeof(nbuf));
Jsi_DSAppend(dStr, nbuf, NULL);
return;
}
case JSI_OPTION_STRING:
zBlob = field->buffer.vstring;
default:
{
if( !zBlob ) {
Jsi_DSAppend(dStr, "null", NULL);
return;
}
Jsi_JSONQuote(interp, zBlob, bytes, dStr);
return;
}
}
}
|
CWE-120
| null | 520,034 |
270089187745734254736744542024448873367
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC Jsi_ValueToBool(Jsi_Interp *interp, Jsi_Value *v)
{
Jsi_RC rc = JSI_OK;
bool a = 0;
switch(v->vt) {
case JSI_VT_BOOL:
a = v->d.val;
break;
case JSI_VT_NULL:
break;
case JSI_VT_UNDEF:
break;
case JSI_VT_NUMBER:
a = (v->d.num ? 1: 0);
break;
case JSI_VT_STRING: /* TODO: NaN, and accept true/false string? */
a = atoi(v->d.s.str);
a = (a ? 1 : 0);
break;
case JSI_VT_OBJECT: {
Jsi_Obj *obj = v->d.obj;
switch(obj->ot) {
case JSI_OT_BOOL:
a = (obj->d.val ? 1.0: 0);
break;
case JSI_OT_NUMBER:
a = obj->d.num;
a = (a ? 1 : 0);
break;
case JSI_OT_STRING:
a = atoi(obj->d.s.str);
a = (a ? 1 : 0);
break;
default:
break;
}
break;
}
default:
Jsi_LogBug("Convert a unknown type: 0x%x to number", v->vt);
return JSI_ERROR;
}
Jsi_ValueReset(interp,&v);
Jsi_ValueMakeBool(interp, &v, a);
return rc;
}
|
CWE-120
| null | 520,035 |
308051492697506754235610210648336973816
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static const char *jsi_TildePath(Jsi_Interp *interp, const char* path, Jsi_DString *dStr) {
if (*path != '~')
return path;
const char *homedir = jsi_GetHomeDir(interp);
if (!homedir)
return path;
Jsi_DSAppend(dStr, homedir, path[1] == '/' ? "" : "/", path+1, NULL);
return Jsi_DSValue(dStr);
}
|
CWE-120
| null | 520,036 |
95751228980578550638889149515234494130
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
int jsi_InitTree(Jsi_Interp *interp, int release)
{
if (release) return JSI_OK;
TreeTest(interp);
return JSI_OK;
}
|
CWE-120
| null | 520,037 |
53049801689113870067084174383820476013
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void jsi_DebugObj(Jsi_Obj* o, const char *reason, uint cidx, Jsi_Interp *interp)
{
if (jsi_memDebugBreakIdx && jsi_memDebugBreakIdx == o->VD.Idx)
jsi_memDebugBreak();
return;
}
|
CWE-120
| null | 520,038 |
205521542554734928438194728571498692034
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static char *dbLocalGetline(Jsi_Interp *interp, char *zPrompt, Jsi_Channel in) {
char *zLine;
int nLine;
int n;
int eol;
nLine = 100;
zLine = (char*)Jsi_Malloc( nLine );
if( zLine==0 ) return 0;
n = 0;
eol = 0;
while( !eol ) {
if( n+100>nLine ) {
nLine = nLine*2 + 100;
zLine = (char*)Jsi_Realloc(zLine, nLine);
if( zLine==0 ) return 0;
}
if( Jsi_Gets(interp, in, &zLine[n], nLine - n)==0 ) {
if( n==0 ) {
Jsi_Free(zLine);
return 0;
}
zLine[n] = 0;
eol = 1;
break;
}
while( zLine[n] ) {
n++;
}
if( n>0 && zLine[n-1]=='\n' ) {
n--;
zLine[n] = 0;
eol = 1;
}
}
zLine = (char*)Jsi_Realloc( zLine, n+1 );
return zLine;
}
|
CWE-120
| null | 520,039 |
333907930897277431201302641514715167805
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC Jsi_GetWide(Jsi_Interp* interp, const char *string, Jsi_Wide *widePtr, int base)
{
char *endptr;
if (base) {
*widePtr = strtoull(string, &endptr, base);
}
else {
*widePtr = jsi_strtoull(string, &endptr);
}
return JsiCheckConversion(string, endptr);
}
|
CWE-120
| null | 520,040 |
143952915801234587179717693960123822909
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC SqliteOnecolumnCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr)
{
Jsi_RC rc;
Jsi_Db *jdb;
if (!(jdb = dbGetDbHandle(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);
DbEvalContext sEval = {};
const char *zSql = Jsi_ValueGetDString(interp, vSql, &dStr, 0);
sEval.nocache = jdb->queryOpts.nocache;
if ((rc = dbEvalInit(interp, &sEval, jdb, zSql, &sStr, 0, 0)) != JSI_OK)
return rc;
sEval.ret = *ret;
sEval.tocall = NULL;
int cnt = 0;
if( JSI_OK==(rc = dbEvalStep(&sEval)) ) {
sqlite3_stmt *pStmt = sEval.pPreStmt->pStmt;
int nCol = sqlite3_column_count(pStmt);
if (nCol>0)
dbEvalSetColumnValue(&sEval, 0, ret);
cnt++;
}
dbEvalFinalize(&sEval);
if( rc==JSI_BREAK ) {
rc = JSI_OK;
}
Jsi_DSFree(&dStr);
return rc;
}
|
CWE-120
| null | 520,041 |
74158409965704065878760743371100527842
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
int Jsi_Lstat(Jsi_Interp *interp, Jsi_Value* path, Jsi_StatBuf *buf) {
void *data;
Jsi_Filesystem *fsPtr = Jsi_FilesystemForPath(interp, path, &data);
if (fsPtr == NULL || !fsPtr->lstatProc) return -1;
return fsPtr->lstatProc(interp, path, buf);
}
|
CWE-120
| null | 520,042 |
32112909108817884896326229051157605224
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC SysGetEnvCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr)
{
extern char **environ;
char *cp;
int i;
if (interp->isSafe)
return Jsi_LogError("no getenv in safe mode");
Jsi_Value *v = Jsi_ValueArrayIndex(interp, args, 0);
if (v != NULL) {
const char *fnam = Jsi_ValueString(interp, v, NULL);
if (!fnam)
return Jsi_LogError("arg1: expected string 'name'");
cp = getenv(fnam);
if (cp != NULL) {
Jsi_ValueMakeStringDup(interp, ret, cp);
}
return JSI_OK;
}
/* Single object containing result members. */
Jsi_Value *vres;
Jsi_Obj *ores = Jsi_ObjNew(interp);
Jsi_Value *nnv;
char *val, nam[JSI_BUFSIZ/2];
//Jsi_ObjIncrRefCount(interp, ores);
vres = Jsi_ValueMakeObject(interp, NULL, ores);
//Jsi_IncrRefCount(interp, vres);
for (i=0; ; i++) {
int n;
cp = environ[i];
if (cp == 0 || ((val = Jsi_Strchr(cp, '='))==NULL))
break;
n = val-cp+1;
if (n>=(int)sizeof(nam))
n = sizeof(nam)-1;
Jsi_Strncpy(nam, cp, n);
val = val+1;
nnv = Jsi_ValueMakeStringDup(interp, NULL, val);
Jsi_ObjInsert(interp, ores, nam, nnv, 0);
}
Jsi_ValueReplace(interp, ret, vres);
return JSI_OK;
}
|
CWE-120
| null | 520,043 |
184262165512025930801807975254318325763
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_push_string(jsi_Pstate *p, jsi_Pline *line, const char *str) {
if (*str == 'c' && !Jsi_Strcmp(str,"callee"))
p->interp->hasCallee = 1;
JSI_NEW_CODESLN(0,OP_PUSHSTR, str);
}
|
CWE-120
| null | 520,044 |
99661404565280490590104132331185458091
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC DebugRemoveCmd_(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr, int op)
{
Jsi_Value *val = Jsi_ValueArrayIndex(interp, args, 0);
if (interp->breakpointHash)
{
int num;
char nbuf[JSI_MAX_NUMBER_STRING];
if (Jsi_GetIntFromValue(interp, val, &num) != JSI_OK)
return Jsi_LogError("bad number");
snprintf(nbuf, sizeof(nbuf), "%d", num);
Jsi_HashEntry *hPtr = Jsi_HashEntryFind(interp->breakpointHash, nbuf);
jsi_BreakPoint* bptr;
if (hPtr && (bptr = (jsi_BreakPoint*)Jsi_HashValueGet(hPtr))) {
switch (op) {
case 1: bptr->enabled = 0; break;
case 2: bptr->enabled = 1; break;
default:
Jsi_HashEntryDelete(hPtr);
}
return JSI_OK;
}
}
return Jsi_LogError("unknown breakpoint");
}
|
CWE-120
| null | 520,045 |
40750339587059243692261000317694812887
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC Jsi_Interactive(Jsi_Interp* interp, int flags)
{
Jsi_RC rc = JSI_OK;
int done = 0, len, quote = (flags & 0xff), istty = 1, chkHelp=0, hasHelp=0;
const char *prompt = interp->subOpts.prompt;
char *buf;
if (jsi_interactiveInterp)
return Jsi_LogError("multiple interactive not supported");
#if JSI__SIGNAL
signal(SIGINT, jsi_InteractiveSignal);
#endif
interp->typeCheck.parse = interp->typeCheck.run = interp->typeCheck.all = 1;
interp->strict = 1;
interp->isInteractive = 1;
jsi_interactiveInterp = interp;
interp->subOpts.istty = 1;
interp->subOpts.logAllowDups = 1;
Jsi_DString dStr;
Jsi_DSInit(&dStr);
#ifndef __WIN32
istty = isatty(fileno(stdin));
#else
istty = _isatty(_fileno(stdin));
#endif
#ifdef JSI_HAS_READLINE
Jsi_DString dHist = {}, sHist = {};
char *hist = NULL;
#ifdef USE_GNU_READLINE
rl_attempted_completion_function = jsiRlGetMatches;
#else
linenoiseSetCompletionCallback(jsiLNGetMatches);
linenoiseSetHintsCallback(jsiLNhints);
#endif
if(interp->subOpts.noReadline == 0 && !interp->parent && !(interp->isSafe && interp->safeMode==jsi_safe_Lockdown))
{
const char *hfile = (interp->historyFile ? interp->historyFile : "~/.jsish_history");
hist = Jsi_NormalPath(interp, hfile, &dHist);
if (hist)
jsi_sh_read_history(hist);
}
#endif
interp->level++;
if (!interp->iskips)
puts("Jsish interactive: see 'help [cmd]' or 'history'. \\ cancels > input."
#if JSI__SIGNAL
" ctrl-c aborts running script."
#endif
);
while (done==0 && interp->exited==0) {
buf = get_inputline(interp, istty, (prompt?prompt:"$ "));
if (buf) {
if (buf[0] == '\\' && !buf[1]) {
Jsi_DSSetLength(&dStr, 0);
prompt = interp->subOpts.prompt;
fprintf(stderr, "abandoned input");
} else
Jsi_DSAppend(&dStr, buf, NULL);
free(buf);
} else {
done = 1;
}
len = Jsi_DSLength(&dStr);
if (done && len == 0)
break;
if (!len) continue;
Jsi_DSAppendLen(&dStr, " ", 1); // Allow for added space.
buf = Jsi_DSValue(&dStr);
if (done == 0 && (!jsi_StrIsBalanced(buf))) {
prompt = interp->subOpts.prompt2;
continue;
}
prompt = interp->subOpts.prompt;
while ((len = Jsi_Strlen(buf))>0 && (isspace(buf[len-1])))
buf[len-1] = 0;
if (buf[0] == 0) {
Jsi_DSSetLength(&dStr, 0);
continue;
}
bool wantHelp = 0;
if (interp->onEval == NULL) {
/* Convenience: add semicolon to "var" statements (required by parser). */
#ifdef JSI_HAS_READLINE
if (!Jsi_Strncmp(buf, "history", 7) && buf[7] == 0) {
fputs(Jsi_DSValue(&sHist), stdout);
Jsi_DSSetLength(&dStr, 0);
continue;
}
#endif
if (!Jsi_Strncmp(buf, "help", 4) && (buf[4] == 0 || isspace(buf[4]))) {
if (!chkHelp++)
hasHelp = (Jsi_PkgRequire(interp, "Help", 0)>=0);
if (hasHelp) {
wantHelp = 1;
char tbuf[BUFSIZ];
snprintf(tbuf, sizeof(tbuf), "return runModule('Help', '%s'.trim().split(null));", buf+4);
rc = Jsi_EvalString(interp, tbuf, JSI_RETURN);
}
}
if (!wantHelp) {
if (!Jsi_Strncmp(buf,"var ", 4) && Jsi_Strchr(buf, '\n')==NULL && Jsi_Strchr(buf, ';')==NULL)
Jsi_Strcpy(buf+Jsi_Strlen(buf), ";"); // Added space above so strcat ok.
rc = Jsi_EvalString(interp, buf, JSI_EVAL_RETURN);
prompt = interp->subOpts.prompt;
#ifdef JSI_HAS_READLINE
if (rc == JSI_OK)
Jsi_DSAppend(&sHist, buf, "\n", NULL);
#endif
}
}
else
{
Jsi_Value *func = interp->onEval;
if (func && Jsi_ValueIsFunction(interp, func)) {
Jsi_Value *items[1] = {};
items[0] = Jsi_ValueNewStringDup(interp, buf);
Jsi_Value *args = Jsi_ValueMakeObject(interp, NULL, Jsi_ObjNewArray(interp, items, 1, 0));
Jsi_IncrRefCount(interp, args);
rc = Jsi_FunctionInvoke(interp, func, args, &interp->retValue, interp->csc);
Jsi_DecrRefCount(interp, args);
if (rc != JSI_OK)
fprintf(stderr, "bad eval");
}
}
if (interp->exited)
break;
jsi_interactiveInterp->interrupted = 0;
if (rc == JSI_OK) {
if (interp->retValue->vt != JSI_VT_UNDEF || interp->subOpts.outUndef) {
Jsi_DString eStr = {};
fputs(Jsi_ValueGetDString(interp, interp->retValue, &eStr, hasHelp?0:quote), stdout);
Jsi_DSFree(&eStr);
fputs("\n", stdout);
}
} else if (!interp->exited && !wantHelp) {
fputs("ERROR\n", stderr);
}
Jsi_DSSetLength(&dStr, 0);
len = 0;
}
interp->level--;
#ifdef JSI_HAS_READLINE
if (hist && !interp->isSafe) {
jsi_sh_stifle_history(100);
jsi_sh_write_history(hist);
}
Jsi_DSFree(&dHist);
Jsi_DSFree(&sHist);
#endif
Jsi_DSFree(&dStr);
if (interp->retValue) {
Jsi_DecrRefCount(interp, interp->retValue);
interp->retValue = NULL;
}
if (interp->exited && interp->level <= 0)
{
rc = JSI_EXIT;
Jsi_InterpDelete(interp);
}
jsi_interactiveInterp = NULL;
return rc;
}
|
CWE-120
| null | 520,046 |
66728271583610959590059190741883915608
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
extern Jsi_otype Jsi_ObjTypeGet(Jsi_Obj *obj)
{
return obj->ot;
}
|
CWE-120
| null | 520,047 |
118506010035158643712277018935760140394
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void jsi_FreeOpcodes(Jsi_OpCodes *ops) {
int i;
if (!ops) return;
for (i=0; i<ops->code_len; i++) {
jsi_OpCode *op = ops->codes+i;
if (op->data && op->alloc)
Jsi_Free(op->data);
_JSI_MEMCLEAR(op);
}
jsiOpCodesCnt[1]++;
jsiOpCodesCnt[2]--;
#ifdef JSI_MEM_DEBUG
if (ops->hPtr)
Jsi_HashEntryDelete(ops->hPtr);
#endif
Jsi_Free(ops->codes);
Jsi_Free(ops);
}
|
CWE-120
| null | 520,048 |
26409605318679605114292648584491527471
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_local(jsi_Pstate *p, jsi_Pline *line, const char *varname) { JSI_NEW_CODESLN(0,OP_LOCAL, varname); }
|
CWE-120
| null | 520,049 |
235793068091529846057371452848885004048
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
jsi_wsFileUploadCB(void *data, const char *name, const char *filename,
char *buf, int len, enum lws_spa_fileupload_states state)
{
jsi_wsPss *pss = (typeof(pss))data;
jsi_wsCmdObj *cmdPtr = pss->cmdPtr;
Jsi_Value* callPtr = (pss->onUpload?pss->onUpload:cmdPtr->onUpload);
Jsi_Interp *interp = cmdPtr->interp;
const char *str;
int slen, n = 0;
if (cmdPtr->deleted) return -1;
Jsi_Obj *oarg1;
Jsi_Value *vpargs, *vargs[10];
if (state == LWS_UFS_OPEN)
pss->file_length = 0;
//id:number, filename:string, data:string, startpos:number, complete:boolean
vargs[n++] = Jsi_ValueNewObj(interp, cmdPtr->fobj);
vargs[n++] = Jsi_ValueNewNumber(interp, (Jsi_Number)(pss->wid));
vargs[n++] = Jsi_ValueNewBlobString(interp, filename);
vargs[n++] = Jsi_ValueNewBlob(interp, (uchar*)buf, (uint)len);
vargs[n++] = Jsi_ValueNewNumber(interp, (Jsi_Number)pss->file_length);
vargs[n++] = Jsi_ValueNewBoolean(interp, (state==LWS_UFS_FINAL_CONTENT));
vpargs = Jsi_ValueMakeObject(interp, NULL, oarg1 = Jsi_ObjNewArray(interp, vargs, n, 0));
Jsi_IncrRefCount(interp, vpargs);
pss->file_length += len;
Jsi_Value *ret = Jsi_ValueNew1(interp);
Jsi_ValueMakeUndef(interp, &ret);
Jsi_RC rc = Jsi_FunctionInvoke(interp, callPtr, vpargs, &ret, NULL);
if ((state==LWS_UFS_FINAL_CONTENT || rc != JSI_OK) && (str=Jsi_ValueString(interp, ret, &slen))) {
Jsi_DSAppendLen(&pss->resultStr, str, slen);
pss->resultCode = rc;
}
Jsi_DecrRefCount(interp, vpargs);
Jsi_DecrRefCount(interp, ret);
if (rc != JSI_OK) {
Jsi_LogError("websock bad rcv eval");
return -1;
}
return 0;
}
|
CWE-120
| null | 520,050 |
170969920500994670731193828727471709865
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC MySqlLastRowidCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr)
{
Jsi_Wide rowid;
MySqlObj *jdb;
if (!(jdb = _mysql_getDbHandle(interp, _this, funcPtr))) return JSI_ERROR;
rowid = mdbLastInsertRowid(jdb);
Jsi_ValueMakeNumber(interp, ret, (Jsi_Number)rowid);
return JSI_OK;
}
|
CWE-120
| null | 520,051 |
289279377270655592513435556467291976092
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void jsi_ValueObjSet(Jsi_Interp *interp, Jsi_Value *target, const char *key, Jsi_Value *value, int flags, int isstrkey)
{
Jsi_TreeEntry *hPtr;
if (target->vt != JSI_VT_OBJECT) {
if (interp->strict)
Jsi_LogWarn("Target is not object: %d", target->vt);
return;
}
hPtr = Jsi_ObjInsert(interp, target->d.obj, key, value, (isstrkey?JSI_OM_ISSTRKEY:0));
if (!hPtr)
return;
hPtr->f.flags |= (flags&JSI_TREE_USERFLAG_MASK);
}
|
CWE-120
| null | 520,052 |
171669220515352240307703063543849697291
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC Jsi_EvalFile(Jsi_Interp* interp, Jsi_Value *fname, int flags)
{
int isnull;
if ((isnull=Jsi_ValueIsNull(interp, fname)) || Jsi_ValueIsUndef(interp, fname))
return Jsi_LogError("invalid file eval %s", (isnull?"null":"undefined"));
int lev = interp->framePtr->level;
return jsi_evalStrFile(interp, fname, NULL, flags, lev);
}
|
CWE-120
| null | 520,053 |
151304264653208914389017490904162474045
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_Value* Jsi_ValueNewNumber(Jsi_Interp *interp, Jsi_Number n) {
Jsi_Value *v = Jsi_ValueNew(interp);
v->vt = JSI_VT_NUMBER;
v->d.num = n;
return v;
}
|
CWE-120
| null | 520,054 |
309063505323667835262025851283017522343
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void jsi_wsgetUriArgValue(Jsi_Interp *interp, struct lws *wsi, Jsi_Value **vPtr, Jsi_Value **oPtr)
{
int n = 0;
char buf[JSI_BUFSIZ*8];
while (lws_hdr_copy_fragment(wsi, buf, sizeof(buf), WSI_TOKEN_HTTP_URI_ARGS, n++) > 0) {
if (!*vPtr) {
*vPtr = Jsi_ValueNewArray(interp, NULL, 0);
Jsi_IncrRefCount(interp, *vPtr);
}
Jsi_ValueArraySet(interp, *vPtr, Jsi_ValueNewStringDup(interp, buf), n-1);
if (!*oPtr) {
*oPtr = Jsi_ValueNewObj(interp, NULL);
Jsi_IncrRefCount(interp, *oPtr);
}
char *cp = Jsi_Strchr(buf, '=');
if (cp) {
*cp = 0;
Jsi_ValueInsertFixed(interp, *oPtr, buf, Jsi_ValueNewStringDup(interp, cp+1));
} else {
Jsi_ValueInsertFixed(interp, *oPtr, buf, Jsi_ValueNewNull(interp));
}
}
}
|
CWE-120
| null | 520,055 |
304715018112305099914435013009401378096
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void mdbEvalSetColumn(MyDbEvalContext *p, int iCol, Jsi_DString *dStr) {
//Jsi_Interp *interp = p->jdb->interp;
char nbuf[JSI_MAX_NUMBER_STRING];
MysqlPrep *prep = p->prep;
SqlFieldResults *field = prep->fieldResult+iCol;
Jsi_Interp *interp = p->jdb->interp;
if (field->isnull)
return;
switch(field->jsiTypeMap) {
case JSI_OPTION_STRING: {
int bytes = field->len;
const char *zBlob = field->buffer.vstring;
if( !zBlob ) {
const char *nv = p->jdb->optPtr->nullvalue;
Jsi_DSAppend(dStr, nv?nv:"null", NULL);
return;
}
Jsi_DSAppendLen(dStr, zBlob, bytes);
return;
}
case JSI_OPTION_BOOL: {
snprintf(nbuf, sizeof(nbuf), "%s", field->buffer.vchar?"true":"false");
Jsi_DSAppend(dStr, nbuf, NULL);
return;
}
case JSI_OPTION_INT64: {
snprintf(nbuf, sizeof(nbuf), "%lld", field->buffer.vlonglong);
Jsi_DSAppend(dStr, nbuf, NULL);
return;
}
//case JSI_OPTION_TIME_T:
case JSI_OPTION_TIME_D:
case JSI_OPTION_TIME_W: {
Jsi_Number jtime = mdbMyTimeToJS(&field->buffer.timestamp);
Jsi_NumberToString(interp, jtime, nbuf, sizeof(nbuf));
Jsi_DSAppend(dStr, nbuf, NULL);
return;
}
case JSI_OPTION_DOUBLE: {
Jsi_NumberToString(interp, field->buffer.vdouble, nbuf, sizeof(nbuf));
Jsi_DSAppend(dStr, nbuf, NULL);
return;
}
default:
Jsi_LogWarn("unknown type: %d", field->jsiTypeMap);
}
}
|
CWE-120
| null | 520,056 |
8185630877947415473932973578637858237
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC Jsi_RegExpMatches(Jsi_Interp *interp, Jsi_Value *pattern, const char *str, int slen, Jsi_Value *ret)
{
return jsi_RegExpMatches(interp, pattern, str, slen, ret, NULL, 0);
}
|
CWE-120
| null | 520,057 |
320037187542051424142301442950107571799
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC StringSubstrCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr)
{
int sLen, bLen;
const char *v;
ChkString(_this, funcPtr, v, &sLen, &bLen);
Jsi_Value *start = Jsi_ValueArrayIndex(interp, args, skip);
Jsi_Value *len = Jsi_ValueArrayIndex(interp, args, skip+1);
Jsi_Number nstart, nlen;
if (!start || Jsi_GetNumberFromValue(interp,start, &nstart) != JSI_OK) {
jsi_ValueMakeBlobDup(interp, ret, (uchar*)v, bLen);
return JSI_OK;
}
int istart = (int)nstart, olen = -1;
Jsi_DString dStr;
char *ostr;
Jsi_DSInit(&dStr);
if (!len || Jsi_GetNumberFromValue(interp,len, &nlen) != 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 ilen = (int)nlen;
if (ilen <= 0) {
Jsi_ValueMakeStringDup(interp, ret, "");
} else {
if (sLen == bLen) {
ostr = jsi_SubstrDup(v, bLen, istart, ilen, &olen);
Jsi_ValueMakeBlob(interp, ret, (uchar*)ostr, olen);
} else {
Jsi_UtfSubstr(v, istart, ilen, &dStr);
Jsi_ValueFromDS(interp, &dStr, ret);
}
}
return JSI_OK;
}
|
CWE-120
| null | 520,058 |
126773274372500353093849173589632196845
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_Db *dbGetDbHandle(Jsi_Interp *interp, Jsi_Value *_this, Jsi_Func *funcPtr)
{
Jsi_Db *jdb = (Jsi_Db*)Jsi_UserObjGetData(interp, _this, funcPtr);
if (!jdb) {
Jsi_LogError("Sqlite call to a non-sqlite object");
return NULL;
}
if (!jdb->db)
{
Jsi_LogError("Sqlite db closed");
return NULL;
}
return jdb;
}
|
CWE-120
| null | 520,059 |
227421009267118520686277431852636822892
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static int tree_preorder(Jsi_Tree *treePtr, Jsi_TreeEntry *hPtr, Jsi_TreeWalkProc *callback, void *data) {
uint epoch = treePtr->epoch;
if (hPtr == NULL) return JSI_OK;
if (callback(treePtr, hPtr, data) != JSI_OK || epoch != treePtr->epoch)
return JSI_ERROR;
if (hPtr->right != NULL) {
if (tree_preorder(treePtr, hPtr->right, callback, data) != JSI_OK || epoch != treePtr->epoch)
return JSI_ERROR;
}
if (hPtr->left != NULL) {
if (tree_preorder(treePtr, hPtr->left, callback, data) != JSI_OK || epoch != treePtr->epoch)
return JSI_ERROR;
}
return JSI_OK;
}
|
CWE-120
| null | 520,060 |
182422761336228166916783641443712958078
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_Value* Jsi_ValueNewStringKey(Jsi_Interp *interp, const char *s) {
Jsi_Value *v = Jsi_ValueNew(interp);
v->vt = JSI_VT_STRING;
v->d.s.str = (char*)Jsi_KeyAdd(interp,s);
v->d.s.len = Jsi_Strlen(s);
v->f.bits.isstrkey = 1;
return v;
}
|
CWE-120
| null | 520,061 |
24551525308081631318157554280221050401
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void Jsi_EventuallyFree(Jsi_Interp* interp, void *data, Jsi_DeleteProc* proc) {
Jsi_HashEntry *hPtr = Jsi_HashEntryFind(interp->preserveTbl, data);
if (!hPtr) {
(*proc)(interp, data);
return;
}
PreserveData *ptr = (PreserveData*)Jsi_HashValueGet(hPtr);
assert(ptr && ptr->interp == interp);
JSI_NOWARN(ptr);
Jsi_HashEntryDelete(hPtr);
}
|
CWE-120
| null | 520,062 |
304921346853680711092451076886343387697
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static int dbSqlCollate(
void *pCtx,
int nA,
const void *zA,
int nB,
const void *zB
) {
SqlCollate *p = (SqlCollate *)pCtx;
Jsi_Interp *interp = p->interp;
int rc;
//Jsi_Db *jdb = (Jsi_Db*)cd;
Jsi_Value *vpargs, *items[3], *ret;
items[0] = Jsi_ValueNewObj(interp, p->jdb->fobj);
items[1] = Jsi_ValueMakeStringDup(interp, NULL, (char*)zA);
items[2] = Jsi_ValueMakeStringDup(interp, NULL, (char*)zB);
vpargs = Jsi_ValueMakeObject(interp, NULL, Jsi_ObjNewArray(interp, items, 3, 0));
ret = Jsi_ValueNew1(interp);
rc = Jsi_FunctionInvoke(interp, p->zScript, vpargs, &ret, NULL);
if( JSI_OK!=rc ) {
//jdb->errCnt++;
rc = 0;
} else
rc = dbGetIntBool(interp, ret);
Jsi_DecrRefCount(interp, vpargs);
Jsi_DecrRefCount(interp, ret);
return rc;
}
|
CWE-120
| null | 520,063 |
289334191353033336226133012938389365393
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC jsi_ParseTypeCheckStr(Jsi_Interp *interp, const char *str) {
uint *iptr = (uint*)&interp->typeCheck;
const char *wcp = str, *wcn = wcp;
while (wcn && wcp) {
int isnot = 0;
if (*wcp == '!') { isnot = 1; wcp++; }
wcn = Jsi_Strchr(wcp, ',');
int ti, wlen = (wcn?(wcn-wcp):(int)Jsi_Strlen(wcp));
#define _JSIPARSETYPES(nam, field) \
if (wlen == (sizeof(#nam)-1) && !Jsi_Strncmp(#nam, wcp, (sizeof(#nam)-1))) { \
interp->field = (1-isnot); \
wcp = (wcn?wcn+1:NULL); \
continue; \
}
_JSIPARSETYPES(Debug, logOpts.Debug)
_JSIPARSETYPES(Trace, logOpts.Trace)
_JSIPARSETYPES(Test, logOpts.Test)
_JSIPARSETYPES(Info, logOpts.Info)
_JSIPARSETYPES(Warn, logOpts.Warn)
_JSIPARSETYPES(Error, logOpts.Error)
_JSIPARSETYPES(full, logOpts.full)
_JSIPARSETYPES(before, logOpts.before)
_JSIPARSETYPES(time, logOpts.time)
_JSIPARSETYPES(date, logOpts.date)
_JSIPARSETYPES(asserts, asserts)
_JSIPARSETYPES(assert, asserts)
_JSIPARSETYPES(noproto, subOpts.noproto)
const char **tstrs = jsi_TypeChkStrs;
for (ti=0; tstrs[ti]; ti++) {
wlen = Jsi_Strlen(tstrs[ti]);
if (!Jsi_Strncmp(tstrs[ti], wcp, wlen) && (!tstrs[ti][wlen] || tstrs[ti][wlen] == ',')) break;
}
if (tstrs[ti]) {
if (isnot)
*iptr &= ~(1<<ti);
else {
*iptr |= (1<<ti);
if (!Jsi_Strcmp(tstrs[ti], "all"))
interp->typeCheck.parse = interp->typeCheck.run = 1;
if (!Jsi_Strcmp(tstrs[ti], "strict")) {
interp->typeCheck.parse = interp->typeCheck.run = interp->typeCheck.all = 1;
if (interp->framePtr->level<=0 || interp->isMain)
interp->strict = 1;
}
}
} else {
Jsi_DString wStr = {};
int i;
tstrs = jsi_TypeChkStrs;
for (i=0; tstrs[i]; i++) Jsi_DSAppend(&wStr, i?", ":"", tstrs[i], NULL);
Jsi_LogWarn("unknown typeCheck warn option(s) \"%s\" not in: Debug, Trace, Test, Info, Warn, Error, assert, %s, noproto, full, before, time, date", str, Jsi_DSValue(&wStr));
Jsi_DSFree(&wStr);
}
wcp = (wcn?wcn+1:NULL);
}
return JSI_OK;
}
|
CWE-120
| null | 520,064 |
181141271788717680383853778582842279860
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC MySqlExtractParmNames(MySqlObj* jdb, const char *sql, Jsi_DString *sStr, Jsi_DString *nStr) {
const char *ocp, *cp = sql;
int cnt = 0;
while (*cp) {
if (*cp == '\"'||*cp == '\'') {
ocp = cp;
cp = mdbFindEndStr(cp);
if (!cp)
return JSI_ERROR;
Jsi_DSAppendLen(sStr, ocp, cp-ocp+1);
} else if ((*cp == '@' || *cp == ':' || *cp == '$' ) && (isalpha(cp[1]) || cp[1] == '_')) {
ocp = cp;
cp+=2;
while (*cp && (isalnum(*cp) || *cp == '_'))
cp++;
if (*ocp == '$' && *cp == '(') {
const char *ttp = NULL, *ttb = NULL, *eq = NULL;
cp++;
if (*cp == '[')
eq = cp++;
while (*cp && (isalnum(*cp) || *cp == '_' || *cp == ':' || *cp == '.' || *cp == ']')) {
if (*cp == ':') {
if (ttp)
return JSI_ERROR;
ttp = cp;
}
if (*cp == ']') {
if (ttb)
return JSI_ERROR;
ttb = cp;
if (cp[1] != ')' && cp[1] != ':' && cp[1] != '.')
return JSI_ERROR;
}
cp++;
}
if (*cp != ')')
return JSI_ERROR;
if (eq && !ttb)
return JSI_ERROR;
if (ttp) {
Jsi_DString tStr = {};
Jsi_DSAppendLen(&tStr, ttp+1, (cp - ttp - 1));
if (!jdb->typeNameHash) mdbTypeNameHashInit(jdb);
int rc = (Jsi_HashEntryFind(jdb->typeNameHash, Jsi_DSValue(&tStr)) != NULL);
if (!rc) {
Jsi_DString eStr = {};
Jsi_HashEntry *hPtr;
Jsi_HashSearch search;
Jsi_Interp *interp = jdb->interp;
int n = 0;
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_DSFree(&tStr);
if (!rc)
return JSI_ERROR;
}
} else
cp--;
if (cnt++)
Jsi_DSAppendLen(nStr, " ", 1);
Jsi_DSAppendLen(nStr, ocp, cp-ocp+1);
Jsi_DSAppendLen(sStr, "?", 1);
} else if (*cp == '\\' && cp[1]) {
Jsi_DSAppendLen(sStr, cp, 2);
cp++;
} else {
Jsi_DSAppendLen(sStr, cp, 1);
}
cp++;
}
return JSI_OK;
}
|
CWE-120
| null | 520,065 |
53741266007210353476080641419679157381
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC Jsi_doneSqlite(Jsi_Interp *interp)
{
Jsi_InterpFreeData(interp, JSI_SQLITE_DB_VFS);
return JSI_OK;
}
|
CWE-120
| null | 520,066 |
21611653295389564130869831866098469539
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
jsi_Pstate *jsi_PstateNew(Jsi_Interp *interp)
{
jsi_Pstate *ps = (jsi_Pstate *)Jsi_Calloc(1,sizeof(*ps));
SIGINIT(ps,PARSER);
ps->lexer = (jsi_Lexer*)Jsi_Calloc(1,sizeof(*ps->lexer));
ps->lexer->pstate = ps;
ps->interp = interp;
ps->fastVarTbl = Jsi_HashNew(interp, JSI_KEYS_ONEWORD, NULL /*fastVarFree*/);
ps->strTbl = Jsi_HashNew(interp, JSI_KEYS_ONEWORD, jsi_StringFree);
return ps;
}
|
CWE-120
| null | 520,067 |
307873964796315982570735313076977971760
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void *Jsi_DbHandle(Jsi_Interp *interp, Jsi_Db* jdb)
{
SQLSIGASSERT(jdb,DB);
return jdb->db;
}
|
CWE-120
| null | 520,068 |
274516258049338244770364562306943122308
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void Jsi_ListValueSet(Jsi_ListEntry *l, const void *value) {
SIGASSERTV(l, LISTENTRY);
l->value = (void*)value;
}
|
CWE-120
| null | 520,069 |
106866680347716918674228199513101591907
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
int Jsi_IncrRefCount(Jsi_Interp* interp, Jsi_Value *v)
{
SIGASSERT(v,VALUE);
assert(v->refCnt>=0);
jsi_DebugValue(v,"Incr", jsi_DebugValueCallIdx(), interp);
return ++(v->refCnt);
}
|
CWE-120
| null | 520,070 |
102580178823178595699404345631421369657
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC dbEvalStepOption(DbEvalContext *p, OptionBind *obPtr, int *cntPtr, int dataIdx, int bindMax, Jsi_CDataDb *dbopts, int *erc) {
Jsi_Db *jdb = p->jdb;
int cnt = 0;
while( p->zSql[0] || p->pPreStmt ) {
Jsi_RC rc;
cnt++;
if( p->pPreStmt==0 ) {
rc = dbPrepareStmt(p->jdb, p->zSql, &p->zSql, &p->pPreStmt);
if( rc!=JSI_OK ) return rc;
}
if (bindMax!=0) {
rc = dbBindOptionStmt(jdb, p->pPreStmt->pStmt, obPtr, dataIdx, bindMax, dbopts);
if( rc!=JSI_OK ) return rc;
}
rc = dbEvalStepSub(p, 1, erc);
if (rc != JSI_BREAK)
return rc;
*cntPtr = cnt;
}
/* Finished */
return JSI_BREAK;
}
|
CWE-120
| null | 520,071 |
290063930812089597012671923524551859971
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC StringSliceCmd(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_Value *start = Jsi_ValueArrayIndex(interp, args, skip);
Jsi_Value *end = Jsi_ValueArrayIndex(interp, args, 1+skip);
int istart, iend, len = Jsi_Strlen(vstr);
if (Jsi_GetIntFromValue(interp, start, &istart)) {
return JSI_ERROR;
}
if (istart < 0)
istart = len+istart;
if (istart < 0)
istart = 0;
if (istart>=len)
istart = len-1;
iend = len;
if (end) {
if (Jsi_GetIntFromValue(interp, end, &iend)) {
return JSI_ERROR;
}
if (iend < 0)
iend = len+iend;
if (iend>=len)
iend = len;
if (iend<istart)
iend = istart;
}
Jsi_DString dStr;
Jsi_DSInit(&dStr);
Jsi_UtfSubstr(vstr, istart, iend, &dStr);
Jsi_ValueFromDS(interp, &dStr, ret);
return JSI_OK;
}
|
CWE-120
| null | 520,072 |
296262294912356976832553072079406791856
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC SqliteImportCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr)
{
Jsi_Db *jdb;
Jsi_RC rv = JSI_OK;
int rc;
char *zTable; /* Insert data into this table */
char *zFile; /* The file from which to extract data */
const char *zConflict; /* The conflict algorithm to use */
sqlite3_stmt *pStmt; /* A statement */
int nCol; /* Number of columns in the table */
int nByte; /* Number of bytes in an SQL string */
int i, j; /* Loop counters */
int nSep; /* Number of bytes in zSep[] */
int nNull; /* Number of bytes in zNull[] */
char *zSql; /* An SQL statement */
char *zLine; /* A single line of input from the file */
char **azCol; /* zLine[] broken up into columns */
const char *onCommit; /* How to commit changes */
Jsi_Channel in; /* The input file */
int lineno = 0; /* Line number of input file */
int created = 0;
const char *zSep;
const char *zNull;
if (!(jdb = dbGetDbHandle(interp, _this, funcPtr))) return JSI_ERROR;
Jsi_Value *arg = Jsi_ValueArrayIndex(interp, args, 2);
ImportData opts = {};
if (arg) {
if (Jsi_OptionsProcess(interp, ImportOptions, &opts, arg, 0) < 0)
return JSI_ERROR;
}
zConflict = copyConflictStrs[opts.conflict];
if(opts.separator ) {
zSep = opts.separator;
} else {
zSep = (opts.csv ? "," : "\t");
}
if(opts.nullvalue ) {
zNull = opts.nullvalue;
} else {
zNull = "";
}
zTable = Jsi_ValueArrayIndexToStr(interp, args, 0, NULL);
Jsi_Value *fname = Jsi_ValueArrayIndex(interp, args, 1);
zFile = Jsi_ValueArrayIndexToStr(interp, args, 1, NULL);
nSep = Jsi_Strlen(zSep);
nNull = Jsi_Strlen(zNull);
if( nSep==0 )
return Jsi_LogError("Error: non-null separator required for copy");
zSql = sqlite3_mprintf("SELECT * FROM '%q'", zTable);
if (zSql==0)
return Jsi_LogError("Error: bad table: %s", zTable);
if (opts.headers) {
in = Jsi_Open(interp, fname, "rb");
if( in==0 )
return Jsi_LogError("Error: cannot open file: %s", zFile);
if ((zLine = dbLocalGetline(interp, 0, in))==0 ) {
Jsi_Close(interp, in);
return JSI_ERROR;
}
Jsi_Close(interp, in);
char *zn, *ze, *z = zLine;
Jsi_DString cStr = {};
int zlen = 0, icnt = 0;
Jsi_DSAppend(&cStr, "CREATE TABLE IF NOT EXISTS '", zTable, "' (", NULL);
while (1) {
zn = Jsi_Strstr(z, zSep);
if (!zn) zlen = Jsi_Strlen(z);
else zlen = zn-z;
if (zlen<=0) break;
ze = z+zlen-1;
Jsi_DSAppend(&cStr, (icnt?",":""), "'", NULL);
icnt++;
if (opts.csv && *z=='"' && zn>z && *ze == '"')
Jsi_DSAppendLen(&cStr, z+1, zlen-2);
else
Jsi_DSAppendLen(&cStr, z, zlen);
Jsi_DSAppend(&cStr, "'", NULL);
if (!zn) break;
z = zn+nSep;
}
Jsi_DSAppend(&cStr, ");", NULL);
Jsi_Free(zLine);
if (zlen<=0) {
Jsi_DSFree(&cStr);
Jsi_LogError("null header problem");
return JSI_ERROR;
}
rc = sqlite3_exec(jdb->db, Jsi_DSValue(&cStr), 0, 0, 0);
Jsi_DSFree(&cStr);
if (rc)
return Jsi_LogError("%s", sqlite3_errmsg(jdb->db));
created = 1;
}
nByte = Jsi_Strlen(zSql);
rc = sqlite3_prepare(jdb->db, zSql, -1, &pStmt, 0);
sqlite3_free(zSql);
if( rc ) {
Jsi_LogError("%s", sqlite3_errmsg(jdb->db));
nCol = 0;
} else {
nCol = sqlite3_column_count(pStmt);
}
sqlite3_finalize(pStmt);
if( nCol==0 ) {
rc = JSI_ERROR;
goto bail;
}
zSql = (char*)Jsi_Malloc( nByte + 50 + nCol*2 );
if( zSql==0 ) {
Jsi_LogError("Error: can't malloc()");
rc = JSI_ERROR;
goto bail;
}
sqlite3_snprintf(nByte+50, zSql, "INSERT OR %q INTO '%q' VALUES(?",
zConflict, zTable);
j = Jsi_Strlen(zSql);
for(i=1; i<nCol; i++) {
zSql[j++] = ',';
zSql[j++] = '?';
}
zSql[j++] = ')';
zSql[j] = 0;
rc = sqlite3_prepare(jdb->db, zSql, -1, &pStmt, 0);
Jsi_Free(zSql);
if( rc ) {
Jsi_LogError("Error: %s", sqlite3_errmsg(jdb->db));
sqlite3_finalize(pStmt);
return JSI_ERROR;
}
in = Jsi_Open(interp, fname, "rb");
if( in==0 ) {
Jsi_LogError("Error: cannot open file: %s", zFile);
sqlite3_finalize(pStmt);
return JSI_ERROR;
}
azCol = (char**)Jsi_Malloc( sizeof(azCol[0])*(nCol+1) );
if( azCol==0 ) {
Jsi_LogError("Error: can't malloc()");
Jsi_Close(interp, in);
rc = JSI_ERROR;
goto bail;
}
(void)sqlite3_exec(jdb->db, "BEGIN", 0, 0, 0);
onCommit = "COMMIT";
while ((zLine = dbLocalGetline(interp, 0, in))!=0 ) {
char *z;
i = 0;
lineno++;
if (opts.limit>0 && lineno > opts.limit) {
Jsi_Free(zLine);
break;
}
if (lineno == 1 && opts.headers) {
Jsi_Free(zLine);
continue;
}
if (opts.csv && Jsi_Strchr(zLine,'"'))
{
char *zn, *z = zLine;
Jsi_DString sStr = {};
int qcnt = 0;
i = -1;
while (*z) if (*z++ == '"') qcnt++;
z = zLine;
if (qcnt%2) { /* aggregate quote spanning newlines */
Jsi_DSAppend(&sStr, zLine, NULL);
do {
lineno++;
Jsi_DSAppend(&sStr, "\n", NULL);
Jsi_Free(zLine);
if (((zLine = dbLocalGetline(interp, 0, in)))==0)
break;
Jsi_DSAppend(&sStr, zLine, NULL);
z = zLine;
while (*z) if (*z++ == '"') qcnt++;
} while (qcnt%2);
z = Jsi_DSValue(&sStr);
}
if (qcnt%2) {
Jsi_DSFree(&sStr);
Jsi_Free(zLine);
Jsi_Close(interp, in);
Jsi_LogError("unterminated string at line: %d", lineno);
break;
}
while (z) {
if (*z != '\"') { /* Handle un-quoted value */
zn = Jsi_Strstr(z, zSep);
azCol[++i] = z;
if (!zn)
break;
*zn = 0;
z = zn+nSep;
continue;
}
/* Handle quoted value */
zn = ++z;
Jsi_DString cStr = {};
while (1) {
if (!zn)
break;
if (*zn != '"')
Jsi_DSAppendLen(&cStr, zn, 1);
else {
if (zn[1] == '"') {
zn++;
Jsi_DSAppendLen(&cStr, "\"", 1);
} else if (zn[1] == 0) {
break;
} else if (Jsi_Strncmp(zn+1,zSep, nSep)==0) {
*zn = 0;
zn += (nSep + 1);
break;
} else {
/* Invalid, comma should be right after close quote, so just eat quote. */
Jsi_DSAppendLen(&cStr, zn, 1);
}
}
zn++;
}
Jsi_Strcpy(z, Jsi_DSValue(&cStr));
Jsi_DSFree(&cStr);
azCol[++i] = z;
z = zn;
}
} else {
azCol[0] = zLine;
for(i=0, z=zLine; *z; z++) {
if( *z==zSep[0] && Jsi_Strncmp(z, zSep, nSep)==0 ) {
*z = 0;
i++;
if( i<nCol ) {
azCol[i] = &z[nSep];
z += nSep-1;
}
}
}
}
if( i+1!=nCol ) {
Jsi_LogError("%s line %d: expected %d columns of data but found %d",
zFile, lineno, nCol, i+1);
onCommit = "ROLLBACK";
break;
}
for(i=0; i<nCol; i++) {
/* check for null data, if so, bind as null */
if( (nNull>0 && Jsi_Strcmp(azCol[i], zNull)==0)
|| Jsi_Strlen(azCol[i])==0
) {
sqlite3_bind_null(pStmt, i+1);
} else {
sqlite3_bind_text(pStmt, i+1, azCol[i], -1, SQLITE_STATIC );
}
}
sqlite3_step(pStmt);
rc = sqlite3_reset(pStmt);
if (zLine)
Jsi_Free(zLine);
if( rc!=SQLITE_OK ) {
Jsi_LogError("%s at line: %d", sqlite3_errmsg(jdb->db), lineno);
onCommit = "ROLLBACK";
break;
}
}
Jsi_Free(azCol);
Jsi_Close(interp, in);
sqlite3_finalize(pStmt);
(void)sqlite3_exec(jdb->db, onCommit, 0, 0, 0);
if( onCommit[0] == 'C' ) {
/* success, set result as number of lines processed */
Jsi_ValueMakeNumber(interp, ret, (Jsi_Number)lineno);
rv = JSI_OK;
} else {
rv = JSI_ERROR;
}
bail:
if (rc != JSI_OK && created && opts.conflict == CC_ROLLBACK) {
Jsi_DString cStr = {};
Jsi_DSAppend(&cStr, "DROP TABLE IF EXISTS '", zTable, "';", NULL);
(void)sqlite3_exec(jdb->db, Jsi_DSValue(&cStr), 0, 0, 0);
Jsi_DSFree(&cStr);
}
return rv;
}
|
CWE-120
| null | 520,073 |
86549263253748062154666923549453844216
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
int Jsi_ListEntryDelete(Jsi_ListEntry *l) {
SIGASSERT(l, LISTENTRY);
if (l->next || l->prev)
Jsi_ListPop(l->list, l);
Jsi_Free(l);
return 1;
}
|
CWE-120
| null | 520,074 |
95297778447752700832457583511152315516
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC freeOnDeleteTbl(Jsi_Interp *interp, Jsi_HashEntry *hPtr, void *ptr) {
if (!ptr) return JSI_OK;
Jsi_DeleteProc *proc = (Jsi_DeleteProc *)ptr;
proc(interp, NULL);
return JSI_OK;
}
|
CWE-120
| null | 520,075 |
319735698890072036051643373483145964016
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void jsi_ValueToPrimitive(Jsi_Interp *interp, Jsi_Value **vPtr)
{
Jsi_Value *v = *vPtr;
if (v->vt != JSI_VT_OBJECT)
return;
DECL_VALINIT(res);
Jsi_Value *rPtr = &res;
Jsi_Obj *obj = v->d.obj;
//rPtr = v;
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:
if (obj->isstrkey) {
res.d.s = obj->d.s;
res.f.bits.isstrkey = 1;
obj->d.s.str = NULL;
} else {
if (obj->refcnt==1) {
Jsi_ValueMakeString(interp, &rPtr, obj->d.s.str);
res.d.s = obj->d.s;
obj->d.s.str = NULL;
} else if (obj->d.s.len >= 0)
{
Assert(obj->refcnt>=1);
obj->refcnt--;
int bytes = obj->d.s.len;
jsi_ValueMakeBlobDup(interp, &rPtr, (uchar*)obj->d.s.str, bytes);
} else
Jsi_ValueMakeStringDup(interp, &rPtr, obj->d.s.str);
}
break;
case JSI_OT_FUNCTION: {
Jsi_DString dStr;
Jsi_DSInit(&dStr);
Jsi_FuncObjToString(interp, obj->d.fobj->func, &dStr, 3);
Jsi_ValueFromDS(interp, &dStr, &rPtr);
break;
}
case JSI_OT_USEROBJ: {
Jsi_DString dStr;
Jsi_DSInit(&dStr);
jsi_UserObjToName(interp, obj->d.uobj, &dStr);
Jsi_ValueFromDS(interp, &dStr, &rPtr);
break;
}
default:
Jsi_ValueMakeStringKey(interp,&rPtr, "[object Object]");
break;
}
Jsi_ValueReset(interp, vPtr);
res.refCnt = v->refCnt;
#ifdef JSI_MEM_DEBUG
memcpy(v, &res, sizeof(res)-sizeof(res.VD));
#else
*v = res;
#endif
}
|
CWE-120
| null | 520,076 |
33711610409745207728681296277708061662
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static int jsi_FSLinkProc(Jsi_Interp *interp, Jsi_Value* path, Jsi_Value *toPath, int linkType) {
const char *pathPtr = Jsi_ValueToString(interp, path, NULL);
const char *toPtr = Jsi_ValueToString(interp, toPath, NULL);
Jsi_DString dStr = {}, eStr = {};
int rc;
if (*pathPtr == '~')
pathPtr = jsi_TildePath(interp, pathPtr, &dStr);
if (*toPtr == '~')
toPtr = jsi_TildePath(interp, toPtr, &eStr);
if (linkType != 0)
rc = link(pathPtr, toPtr);
else
rc = symlink(pathPtr, toPtr);
Jsi_DSFree(&dStr);
Jsi_DSFree(&eStr);
return rc;
}
|
CWE-120
| null | 520,077 |
70769153233212765655510235233554119645
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void Jsi_ListClear(Jsi_List *list) {
Jsi_ListEntry *l;
while (list->head) {
l = list->head;
list->head = list->head->next;
l->next = l->prev = NULL;
if (list->opts.freeListProc && l->value)
(list->opts.freeListProc)(list->opts.interp, l, l->value);
Jsi_ListEntryDelete(l);
}
list->numEntries = 0;
}
|
CWE-120
| null | 520,078 |
178777980771051545036725246976073236467
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_Value *jsi_ValueLookupBase(Jsi_Interp *interp, Jsi_Value *target, Jsi_Value *key, Jsi_Value **ret)
{
if (!target)
return NULL;
if (target->vt != JSI_VT_OBJECT) {
Jsi_LogError("subscript operand is not object");
return NULL;
}
const char *keyStr = Jsi_ValueToString(interp, key, NULL);
if (!keyStr)
return NULL;
bool isStrKey = (key->vt == JSI_VT_STRING && key->f.bits.isstrkey);
Jsi_Value *v = Jsi_ValueObjLookup(interp, target, (char*)keyStr, isStrKey);
if (v)
return v;
if (target->d.obj->__proto__)
return jsi_ValueLookupBase(interp, target->d.obj->__proto__, key, ret);
return NULL;
}
|
CWE-120
| null | 520,079 |
255774881628267778316356771757410909346
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_HashClear(Jsi_Hash *tablePtr)
{
Jsi_HashEntry *hPtr, *nextPtr;
size_t i;
if (!tablePtr)
return;
if (tablePtr->opts.lockHashProc && (*tablePtr->opts.lockHashProc)(tablePtr, 1) != JSI_OK)
return;
for (i = 0; i < (size_t)tablePtr->numBuckets; i++) {
hPtr = tablePtr->buckets[i];
while (hPtr != NULL) {
nextPtr = hPtr->nextPtr;
if (tablePtr->opts.freeHashProc && hPtr->clientData)
(tablePtr->opts.freeHashProc)(tablePtr->opts.interp, hPtr, hPtr->clientData);
Jsi_Free(hPtr);
hPtr = nextPtr;
tablePtr->buckets[i] = hPtr;
}
}
if (tablePtr->buckets != tablePtr->staticBuckets) {
Jsi_Free(tablePtr->buckets);
}
if (tablePtr->opts.lockHashProc)
(*tablePtr->opts.lockHashProc)(tablePtr, 0);
}
|
CWE-120
| null | 520,080 |
272004674257203019425947097520461875561
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_Tree *Jsi_TreeNew(Jsi_Interp *interp, unsigned int keyType, Jsi_TreeDeleteProc *freeProc)
{
Jsi_Tree* treePtr = (Jsi_Tree*)Jsi_Calloc(1,sizeof(Jsi_Tree));
SIGINIT(treePtr,TREE);
treePtr->opts.mapType = (Jsi_Map_Type)JSI_MAP_TREE;
treePtr->typ = (Jsi_Map_Type)JSI_MAP_TREE;
treePtr->root = NULL;
treePtr->opts.interp = interp;
treePtr->numEntries = 0;
treePtr->epoch = 0;
treePtr->opts.keyType = (Jsi_Key_Type)keyType;
treePtr->keyType = (Jsi_Key_Type)keyType;
treePtr->opts.freeTreeProc = freeProc;
switch (keyType) {
case JSI_KEYS_STRING: /* NULL terminated string keys. */
treePtr->opts.compareTreeProc = StringCompare;
treePtr->createProc = TreeStringCreate;
break;
case JSI_KEYS_STRINGKEY: /* */
treePtr->opts.compareTreeProc = StringPtrCompare;
treePtr->createProc = StringPtrCreate;
break;
case JSI_KEYS_ONEWORD: /* 32 or 64 bit atomic keys. */
treePtr->opts.compareTreeProc = OneWordCompare;
treePtr->createProc = OneWordCreate;
break;
default: /* Struct. */
if (keyType < JSI_KEYS_STRUCT_MINSIZE) {
Jsi_LogError("Jsi_TreeNew: Key size can't be %d, must be > %d", keyType, JSI_KEYS_STRUCT_MINSIZE);
Jsi_Free(treePtr);
return NULL;
}
treePtr->opts.compareTreeProc = TreeArrayCompare;
treePtr->createProc = TreeArrayCreate;
break;
}
return treePtr;
}
|
CWE-120
| null | 520,081 |
289544070225950087337175317327125820138
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static int TreeArrayCompare(Jsi_Tree *treePtr, const void *key1, const void *key2)
{
return memcmp(key1, key2, treePtr->keyType);
}
|
CWE-120
| null | 520,082 |
22585790522046550642396623649077630292
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_Value *Jsi_NameLookup2(Jsi_Interp *interp, const char *name, const char *inObj)
{
Jsi_Value *v;
if (!name)
return NULL;
if (!inObj)
return Jsi_VarLookup(interp, name);
v = Jsi_VarLookup(interp, inObj);
if (!v)
return NULL;
if (Jsi_ValueIsArray(interp, v)) {
int n;
if (!isdigit(name[0]))
return NULL;
if (Jsi_GetInt(interp, name, &n, 0) != JSI_OK)
return NULL;
if (n>=0 && n<(int)v->d.obj->arrCnt)
return v->d.obj->arr[n];
return NULL;
}
if (v->vt != JSI_VT_OBJECT || (v->d.obj->ot != JSI_OT_OBJECT && v->d.obj->ot != JSI_OT_FUNCTION))
return NULL;
return Jsi_ValueObjLookup(interp, v, name, 0);
}
|
CWE-120
| null | 520,083 |
273240536621476398635165828175690277588
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC jsi_EvalLogErr(Jsi_Interp *interp, const char *str) { Jsi_LogMsg(interp, JSI_ERROR, "%s", str); return JSI_ERROR; }
|
CWE-120
| null | 520,084 |
140597769205461252318497802357923517020
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_nneq() { JSI_NEW_CODES(0,OP_STRICTNEQ, 0); }
|
CWE-120
| null | 520,085 |
65636025148607745106240172086723785408
| null | null |
other
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.