project
stringclasses 633
values | commit_id
stringlengths 7
81
| target
int64 0
1
| func
stringlengths 5
484k
| cwe
stringclasses 131
values | big_vul_idx
float64 0
189k
⌀ | idx
int64 0
522k
| hash
stringlengths 34
39
| size
float64 1
24k
⌀ | message
stringlengths 0
11.5k
⌀ | dataset
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_Value *jsi_MakeFuncValue(Jsi_Interp *interp, Jsi_CmdProc *callback, const char *name, Jsi_Value** toVal, Jsi_CmdSpec *cspec)
{
Jsi_Obj *o = Jsi_ObjNew(interp);
Jsi_Func *f = jsi_FuncNew(interp);
Jsi_ObjIncrRefCount(interp, o);
o->ot = JSI_OT_FUNCTION;
f->type = FC_BUILDIN;
f->callback = callback;
f->privData = NULL;
o->d.fobj = jsi_FuncObjNew(interp, f);
f->cmdSpec = cspec;
if (!cspec) {
f->cmdSpec = (Jsi_CmdSpec*)Jsi_Calloc(2,sizeof(Jsi_CmdSpec));
f->cmdSpec->reserved[3] = (void*)0x1;
f->cmdSpec->maxArgs = -1;
if (name)
f->cmdSpec->name = (char*)Jsi_KeyAdd(interp, name);
}
f->script = interp->curFile;
f->callback = callback;
return Jsi_ValueMakeObject(interp, toVal, o);
}
|
CWE-120
| null | 520,486 |
170740563029134335298238523187498624149
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
jsi_HashArrayCreate( Jsi_Hash *tablePtr, const void *key, bool *newPtr)
{
jsi_Hash hval = jsi_HashArray(key, tablePtr->keyType);
size_t size, hindex = hval & tablePtr->mask;
Jsi_HashEntry *hPtr = tablePtr->buckets[hindex];
for (; hPtr != NULL; hPtr = hPtr->nextPtr)
if (hPtr->hval == hval && !memcmp(hPtr->key.string, key, tablePtr->keyType)) {
if (newPtr)
*newPtr = 0;
return hPtr;
}
/* Entry not found. Add a new one to the bucket. */
if (newPtr)
*newPtr = 1;
assert(tablePtr->keyType >= JSI_KEYS_STRUCT_MINSIZE);
size = sizeof(Jsi_HashEntry) + tablePtr->keyType;
if ((uint)tablePtr->keyType > sizeof(jsi_HashKey)) // Avoid memory checker problems by not truncating struct.
size -= sizeof(jsi_HashKey);
hPtr = (Jsi_HashEntry*)Jsi_Calloc(1, size);
Jsi_HashEntry **bucketPtr = tablePtr->buckets + hindex;
hPtr->typ = JSI_MAP_HASH;
hPtr->tablePtr = tablePtr;
hPtr->nextPtr = *bucketPtr;
hPtr->hval = hval;
hPtr->clientData = 0;
memcpy(hPtr->key.string, key, tablePtr->keyType);
*bucketPtr = hPtr;
tablePtr->numEntries++;
/*
* If the table has exceeded a decent size, rebuild it with many
* more buckets.
*/
if (tablePtr->numEntries >= tablePtr->rebuildSize)
RebuildTable(tablePtr);
return hPtr;
}
|
CWE-120
| null | 520,487 |
94409310411742873959745261554293249030
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void jsi_TraceFuncCall(Jsi_Interp *interp, Jsi_Func *fstatic, jsi_OpCode *iPtr,
Jsi_Value *_this, Jsi_Value* args, Jsi_Value *ret, int tc)
{
jsi_OpCode *ip = (iPtr ? iPtr : interp->curIp);
if (!ip)
return;
const char *ff, *fname = ip->fname?ip->fname:"";
if ((tc&jsi_callTraceFullPath)==0 && ((ff=Jsi_Strrchr(fname,'/'))))
fname = ff+1;
if (interp->traceHook)
(*interp->traceHook)(interp, fstatic->name, ip->fname, ip->Line, fstatic->cmdSpec, _this, args, ret);
else {
const char *fp = ((tc&jsi_callTraceNoParent)?NULL:fstatic->parentName);
if (fp && !*fp)
fp = NULL;
Jsi_DString aStr;
Jsi_DSInit(&aStr);
Jsi_DString dStr;
Jsi_DSInit(&dStr);
Jsi_DString pStr;
Jsi_DSInit(&pStr);
Jsi_DString *sPtr = NULL;
int plen = 0;
if (ret) {
sPtr = &dStr;
Jsi_DSAppend(sPtr, " <-- ", NULL);
plen = Jsi_DSLength(sPtr);
Jsi_ValueGetDString(interp, ret, sPtr, 0);
} else if ((tc&jsi_callTraceArgs)) {
sPtr = &aStr;
Jsi_ValueGetDString(interp, args, sPtr, JSI_OUTPUT_JSON);
}
if (sPtr) {
if (!(tc&jsi_callTraceNoTrunc)) {
const char *cp0 = Jsi_DSValue(sPtr), *cp1 = Jsi_Strchr(cp0, '\n');
int nlen = 0, clen = Jsi_DSLength(sPtr);
if (cp1) {
nlen = (cp1-cp0);
if (nlen>60) nlen = 60;
} else if (clen>60)
nlen = 60;
else nlen = clen;
if (nlen != clen && clen>plen) {
Jsi_DSSetLength(sPtr, nlen);
Jsi_DSAppend(sPtr, "...", NULL);
}
}
}
if (interp->parent && interp->debugOpts.traceCallback) {
Jsi_DString jStr={}, kStr={}, lStr={};
Jsi_DSPrintf(&kStr, "[\"%s%s%s\", %s, %s, \"%s\", %d, %d ]",
(fp?fp:""), (fp?".":""), fstatic->name,
(ret?"null":Jsi_JSONQuote(interp, Jsi_DSValue(&aStr),-1, &jStr)),
(ret?Jsi_JSONQuote(interp, Jsi_DSValue(&dStr),-1, &lStr):"null"),
fname, ip->Line, ip->Lofs);
if (Jsi_FunctionInvokeJSON(interp->parent, interp->debugOpts.traceCallback, Jsi_DSValue(&kStr), NULL) != JSI_OK)
Jsi_DSPrintf(&pStr, "failed trace call\n");
Jsi_DSFree(&jStr);
Jsi_DSFree(&kStr);
Jsi_DSFree(&lStr);
} else if ((tc&jsi_callTraceBefore))
Jsi_DSPrintf(&pStr, "%s:%d %*s#%d: %c %s%s%s(%s) %s\n",
fname, ip->Line,
(interp->level-1)*2, "", interp->level,
(ret?'<':'>'), (fp?fp:""), (fp?".":""), fstatic->name, Jsi_DSValue(&aStr), Jsi_DSValue(&dStr));
else {
if (!interp->curIp || !interp->logOpts.before) {
Jsi_DSPrintf(&pStr, "%*s#%d: %c %s%s%s(%s) in %s:%d%s\n", (interp->level-1)*2, "", interp->level,
(ret?'<':'>'), (fp?fp:""), (fp?".":""), fstatic->name, Jsi_DSValue(&aStr),
fname, ip->Line, Jsi_DSValue(&dStr));
} else {
int quote = 0;
jsi_SysPutsCmdPrefix(interp, &interp->logOpts, &pStr, "e, NULL);
Jsi_DSPrintf(&pStr, "%*s#%d: %c %s%s%s(%s) \n", (interp->level-1)*2, "", interp->level,
(ret?'<':'>'), (fp?fp:""), (fp?".":""), fstatic->name, Jsi_DSValue(&aStr));
Jsi_DSAppend(&pStr, Jsi_DSValue(&dStr), NULL);
}
}
if (Jsi_DSLength(&pStr))
Jsi_Puts(interp, jsi_Stderr, Jsi_DSValue(&pStr), -1);
Jsi_DSFree(&pStr);
Jsi_DSFree(&dStr);
Jsi_DSFree(&aStr);
}
}
|
CWE-120
| null | 520,488 |
199125460669976022495199625203071215778
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
bool Jsi_ValueIsUndef(Jsi_Interp *interp, Jsi_Value *pv)
{
return (pv->vt == JSI_VT_UNDEF);
}
|
CWE-120
| null | 520,489 |
105256705745409490272654132221951095227
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_MapEntry* Jsi_MapSet(Jsi_Map *mapPtr, const void *key, const void *value){
SIGASSERT(mapPtr, MAP);
Jsi_MapEntry* mptr = NULL;
switch (mapPtr->typ) {
case JSI_MAP_HASH: mptr = (Jsi_MapEntry*)Jsi_HashSet(mapPtr->v.hash, (void*)key, (void*)value); break;
case JSI_MAP_TREE: mptr = (Jsi_MapEntry*)Jsi_TreeSet(mapPtr->v.tree, (void*)key, (void*)value); break;
case JSI_MAP_LIST: {
mptr = Jsi_MapEntryNew(mapPtr, key, NULL);
Jsi_MapValueSet(mptr, (void*)value);
break;
}
case JSI_MAP_NONE: break;
}
return mptr;
}
|
CWE-120
| null | 520,490 |
159015593200915442448289274137905279339
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
bool Jsi_ValueIsString(Jsi_Interp *interp, Jsi_Value *pv)
{
return (pv->vt == JSI_VT_STRING || (pv->vt == JSI_VT_OBJECT && pv->d.obj->ot == JSI_OT_STRING));
}
|
CWE-120
| null | 520,491 |
253224482946971119801410850542820701706
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_Channel Jsi_FSNameToChannel(Jsi_Interp *interp, const char *name)
{
if (Jsi_Strlen(name)==1) {
switch (name[0]) {
case '0' : return jsiIntData.stdChans;
case '1' : return jsiIntData.stdChans+1;
case '2' : return jsiIntData.stdChans+2;
}
}
if (!Jsi_Strcmp(name, "stdin")) return jsiIntData.stdChans;
if (!Jsi_Strcmp(name, "stdout")) return jsiIntData.stdChans+1;
if (!Jsi_Strcmp(name, "stderr")) return jsiIntData.stdChans+2;
Jsi_Obj *obj = jsi_UserObjFromName(interp, name);
if (!obj)
return NULL;
Jsi_UserObj *uobj = obj->d.uobj;
if (uobj->reg != &fileobject)
return NULL;
FileObj *fobj = (FileObj *)uobj->data;
return fobj->chan;
}
|
CWE-120
| null | 520,492 |
84868377306534435898519430084577532145
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static bool jsi_FSPathInFilesystemProc(Jsi_Interp *interp, Jsi_Value* path,void **clientDataPtr) {return 1;}
|
CWE-120
| null | 520,493 |
278222362453681596277346825235611465270
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_Value *jsonNewStringObj(Jsi_Interp *interp, const char* str, int len)
{
Jsi_Value *v = NULL;
Jsi_DString dStr;
Jsi_DSInit(&dStr);
jsonNewDString(interp, &dStr, str, len);
v = Jsi_ValueNew(interp);
Jsi_ValueFromDS(interp, &dStr, &v);
//Jsi_DSFree(&dStr);
return v;
}
|
CWE-120
| null | 520,494 |
251703606439472329414046753505853146760
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static int tree_inorder(Jsi_Tree *treePtr, Jsi_TreeEntry *hPtr, Jsi_TreeWalkProc *callback, void *data) {
uint epoch = treePtr->epoch;
if (hPtr == NULL) return JSI_OK;
if (hPtr->right != NULL) {
if (tree_inorder(treePtr, hPtr->right, callback, data) != JSI_OK || epoch != treePtr->epoch)
return JSI_ERROR;
}
if (callback(treePtr, hPtr, data) != JSI_OK || epoch != treePtr->epoch)
return JSI_ERROR;
Assert(hPtr->treePtr);
if (hPtr->left != NULL) {
if (tree_inorder(treePtr, hPtr->left, callback, data) != JSI_OK || epoch != treePtr->epoch)
return JSI_ERROR;
}
return JSI_OK;
}
|
CWE-120
| null | 520,495 |
168073957422170716390990539529456416252
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
jsi_GetOption(Jsi_Interp *interp, Jsi_OptionSpec *specPtr, void* record, const char *option, Jsi_Value **valuePtr, Jsi_Wide flags)
{
char *ptr;
if (specPtr == NULL)
return Jsi_LogError("no such option: %s", option);
//isNull = ((*string == '\0') && (specPtr->flags & JSI_OPTION_NULL_OK));
ptr = (char *)record + specPtr->offset;
if (_JSICASTINT(specPtr->id)<0 || specPtr->id>=JSI_OPTION_END)
return Jsi_LogError("no such option: %s", option);
if (specPtr->custom) {
Jsi_OptionCustom* cust = Jsi_OptionCustomBuiltin(specPtr->custom);
if (cust->formatProc)
return (*cust->formatProc) (interp, specPtr, valuePtr, NULL, record, flags);
}
switch (specPtr->id) {
case JSI_OPTION_BOOL:
Jsi_ValueMakeBool(interp, valuePtr,*(bool*)ptr );
break;
case JSI_OPTION_INT:
Jsi_ValueMakeNumber(interp, valuePtr, (Jsi_Number)(*(int *)ptr));
break;
case JSI_OPTION_UINT:
Jsi_ValueMakeNumber(interp, valuePtr, (Jsi_Number)(*(uint *)ptr));
break;
case JSI_OPTION_INT8:
Jsi_ValueMakeNumber(interp, valuePtr, (Jsi_Number)(*(int8_t *)ptr));
break;
case JSI_OPTION_INT16:
Jsi_ValueMakeNumber(interp, valuePtr, (Jsi_Number)(*(int16_t *)ptr));
break;
case JSI_OPTION_INT32:
Jsi_ValueMakeNumber(interp, valuePtr, (Jsi_Number)(*(int32_t *)ptr));
break;
case JSI_OPTION_INT64:
Jsi_ValueMakeNumber(interp, valuePtr, (Jsi_Number)(*(Jsi_Wide *)ptr));
break;
case JSI_OPTION_UINT8:
Jsi_ValueMakeNumber(interp, valuePtr, (Jsi_Number)(*(uint8_t *)ptr));
break;
case JSI_OPTION_UINT16:
Jsi_ValueMakeNumber(interp, valuePtr, (Jsi_Number)(*(uint16_t *)ptr));
break;
case JSI_OPTION_UINT32:
Jsi_ValueMakeNumber(interp, valuePtr, (Jsi_Number)(*(uint32_t *)ptr));
break;
case JSI_OPTION_UINT64:
Jsi_ValueMakeNumber(interp, valuePtr, (Jsi_Number)(*(uint64_t *)ptr));
break;
case JSI_OPTION_FLOAT:
Jsi_ValueMakeNumber(interp, valuePtr, (Jsi_Number)*(float *)ptr);
break;
case JSI_OPTION_DOUBLE:
Jsi_ValueMakeNumber(interp, valuePtr, (Jsi_Number)*(double *)ptr);
break;
case JSI_OPTION_LDOUBLE:
Jsi_ValueMakeNumber(interp, valuePtr, (Jsi_Number)*(ldouble *)ptr);
break;
case JSI_OPTION_NUMBER:
Jsi_ValueMakeNumber(interp, valuePtr, *(Jsi_Number *)ptr);
break;
case JSI_OPTION_SIZE_T:
Jsi_ValueMakeNumber(interp, valuePtr, *(size_t *)ptr);
break;
case JSI_OPTION_SSIZE_T:
Jsi_ValueMakeNumber(interp, valuePtr, *(ssize_t *)ptr);
break;
case JSI_OPTION_INTPTR_T:
Jsi_ValueMakeNumber(interp, valuePtr, *(intptr_t *)ptr);
break;
case JSI_OPTION_UINTPTR_T:
Jsi_ValueMakeNumber(interp, valuePtr, *(uintptr_t *)ptr);
break;
case JSI_OPTION_LONG:
Jsi_ValueMakeNumber(interp, valuePtr, *(long *)ptr);
break;
case JSI_OPTION_ULONG:
Jsi_ValueMakeNumber(interp, valuePtr, *(ulong *)ptr);
break;
case JSI_OPTION_SHORT:
Jsi_ValueMakeNumber(interp, valuePtr, *(short *)ptr);
break;
case JSI_OPTION_USHORT:
Jsi_ValueMakeNumber(interp, valuePtr, *(ushort *)ptr);
break;
case JSI_OPTION_DSTRING:
Jsi_ValueFromDS(interp, (Jsi_DString*)ptr, valuePtr);
break;
case JSI_OPTION_TIME_W: {
Jsi_DString dStr = {};
Jsi_DatetimeFormat(interp, (Jsi_Number)(*(Jsi_Wide*)ptr), "", 0, &dStr);
Jsi_ValueFromDS(interp, &dStr, valuePtr);
break;
}
case JSI_OPTION_TIME_D: {
Jsi_DString dStr = {};
Jsi_DatetimeFormat(interp, (Jsi_Number)(*(double*)ptr), "", 0, &dStr);
Jsi_ValueFromDS(interp, &dStr, valuePtr);
break;
}
case JSI_OPTION_TIME_T: {
Jsi_DString dStr = {};
Jsi_DatetimeFormat(interp, 1000LL* (Jsi_Number)*(time_t*)ptr, "%Y-%m-%d %H:%M:%S", 0, &dStr);
Jsi_ValueFromDS(interp, &dStr, valuePtr);
break;
}
case JSI_OPTION_STRBUF:
if (ptr)
Jsi_ValueMakeStringDup(interp, valuePtr, ptr);
else
Jsi_ValueMakeNull(interp, valuePtr);
break;
case JSI_OPTION_STRKEY:
ptr = *(char **)ptr;
if (ptr)
Jsi_ValueMakeStringDup(interp, valuePtr, ptr);
else
Jsi_ValueMakeNull(interp, valuePtr);
break;
case JSI_OPTION_STRING:
case JSI_OPTION_VAR:
case JSI_OPTION_FUNC:
case JSI_OPTION_USEROBJ:
case JSI_OPTION_OBJ:
case JSI_OPTION_VALUE:
case JSI_OPTION_REGEXP:
case JSI_OPTION_ARRAY:
if (*(Jsi_Value **)ptr)
Jsi_ValueCopy(interp, *valuePtr, *(Jsi_Value **)ptr);
else
Jsi_ValueMakeNull(interp, valuePtr);
break;
case JSI_OPTION_CUSTOM:
break;
#ifdef __cplusplus
case JSI_OPTION_END:
#else
default:
#endif
Jsi_LogBug("invalid option id %d", specPtr->id);
return JSI_ERROR;
}
return JSI_OK;
}
|
CWE-120
| null | 520,496 |
153880175823811539776926027558265563789
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC Jsi_GetNumberFromValue(Jsi_Interp* interp, Jsi_Value *value, Jsi_Number *n)
{
if (!value)
return JSI_ERROR;
if (value->vt == JSI_VT_NUMBER) {
*n = value->d.num;
return JSI_OK;
}
if (value->vt == JSI_VT_OBJECT && value->d.obj->ot == JSI_OT_NUMBER) {
*n = value->d.obj->d.num;
return JSI_OK;
}
if (interp)
Jsi_LogError("invalid number");
return JSI_ERROR;
}
|
CWE-120
| null | 520,497 |
81927064809925935558708541739271832644
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void ValueFree(Jsi_Interp *interp, Jsi_Value* v)
{
SIGASSERTV(v,VALUE);
//printf("FREE: %d\n", interp->valueCnt);
switch (v->vt) {
case JSI_VT_OBJECT:
Jsi_ObjDecrRefCount(interp, v->d.obj);
break;
case JSI_VT_VARIABLE:
assert(v->d.lval != v);
Jsi_DecrRefCount(interp, v->d.lval);
break;
case JSI_VT_STRING:
if (v->d.s.str && !v->f.bits.isstrkey) {
Jsi_Free(v->d.s.str);
/*Jsi_HashEntry *hPtr;
if ((hPtr = Jsi_HashEntryFind(strDebug, v->d.s.str)))
Jsi_HashEntryDelete(hPtr);*/
}
break;
default:
break;
}
v->vt = JSI_VT_UNDEF;
}
|
CWE-120
| null | 520,498 |
232809863767425498053588711803941958695
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC WebSocketHeaderCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr)
{
return WebSocketIdCmdOp(interp, args, _this, ret, funcPtr, 1);
}
|
CWE-120
| null | 520,499 |
191435524102719406821398695618442566333
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC jsi_InitOptions(Jsi_Interp *interp, int release) {
if (release) return JSI_OK;
assert((sizeof(jsi_OptTypeInfo)/sizeof(jsi_OptTypeInfo[0])) == (JSI_OPTION_END+1));
int i;
for (i=JSI_OPTION_BOOL; i<JSI_OPTION_END; i++)
assert(jsi_OptTypeInfo[i].id == (Jsi_OptionId)i);
return JSI_OK;
}
|
CWE-120
| null | 520,500 |
186649310645915708755442134278065226563
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC WebSocketQueryCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr)
{
return WebSocketIdCmdOp(interp, args, _this, ret, funcPtr, 2);
}
|
CWE-120
| null | 520,501 |
298040200240688758771272881010723860739
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void mdbTypeNameHashInit(MySqlObj *jdb) {
Jsi_Interp *interp = jdb->interp;
Jsi_Hash *hPtr = jdb->typeNameHash = Jsi_HashNew(interp, JSI_KEYS_STRING, NULL);
Jsi_HashSet(hPtr, (void*)"string", (void*)MYSQL_TYPE_STRING);
Jsi_HashSet(hPtr, (void*)"double", (void*)MYSQL_TYPE_DOUBLE);
Jsi_HashSet(hPtr, (void*)"integer", (void*)MYSQL_TYPE_LONGLONG);
Jsi_HashSet(hPtr, (void*)"bool", (void*)MYSQL_TYPE_TINY);
Jsi_HashSet(hPtr, (void*)"blob", (void*)MYSQL_TYPE_BLOB);
Jsi_HashSet(hPtr, (void*)"date", (void*)MYSQL_TYPE_DATE);
Jsi_HashSet(hPtr, (void*)"time", (void*)MYSQL_TYPE_TIME);
Jsi_HashSet(hPtr, (void*)"timestamp", (void*)MYSQL_TYPE_TIMESTAMP);
Jsi_HashSet(hPtr, (void*)"datetime", (void*)MYSQL_TYPE_DATETIME);
}
|
CWE-120
| null | 520,502 |
296956078704336651221656593455622930315
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static bool jsi_wsAddHeader(Jsi_Interp *interp, jsi_wsCmdObj *cmdPtr, struct lws *wsi, Jsi_Value *hdrs,
Jsi_DString *hStr) {
uchar buffer[JSI_BUFSIZ];
uchar *p = (unsigned char *)buffer, *end = p + sizeof(buffer);
int n = 0;
int i, hvl, argc = Jsi_ValueGetLength(interp, hdrs);
for (i=0; i<argc; i+=2) {
const char *hn = Jsi_ValueArrayIndexToStr(interp, hdrs, i, NULL),
*hv = Jsi_ValueArrayIndexToStr(interp, hdrs, i+1, &hvl);
if (hn && hv) {
if (lws_add_http_header_by_name(wsi, (const uchar *)hn, (const uchar *)hv, hvl, &p, end))
return false;
n = p - buffer;
if (n>0)
Jsi_DSAppendLen(hStr, (char*)buffer, n);
p = buffer;
}
}
return true;
}
|
CWE-120
| null | 520,503 |
12823441761328134967271185063509259406
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
int Jsi_ValueStrlen(Jsi_Value* v) {
//if (v->vt == JSI_VT_OBJECT && v->d.obj->ot == JSI_OT_STRING && v->d.obj->isBlob)
// return v->d.obj->d.s.len;
Jsi_String *s = jsi_ValueString(v);
if (s == 0 || s->str == 0)
return 0;
#if JSI__UTF8
return (int)Jsi_NumUtfChars(s->str, s->len);
#else
if (s->len>=0) return s->len;
return (int)Jsi_NumUtfChars(s->str, s->len);
#endif
}
|
CWE-120
| null | 520,504 |
113607344153243615646107004078044659094
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
bool Jsi_IsShared(Jsi_Interp* interp, Jsi_Value *v)
{
SIGASSERT(v,VALUE);
return (v->refCnt > 1);
}
|
CWE-120
| null | 520,505 |
199185875850253049365052653509662676974
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_Value *Jsi_ValueObjLookup(Jsi_Interp *interp, Jsi_Value *target, const char *key, int isstrkey)
{
Jsi_Obj *obj;
Jsi_Value *v = NULL;
if (interp->subOpts.noproto && key) {
if (key[0] == 'p' && Jsi_Strcmp(key, "prototype")==0) {
Jsi_LogError("inheritance is disabled in interp");
return NULL;
}
}
if (target->vt != JSI_VT_OBJECT) {
if (interp->strict)
Jsi_LogWarn("Target is not object: %d", target->vt);
return NULL;
}
obj = target->d.obj;
#if (defined(JSI_HAS___PROTO__) && JSI_HAS___PROTO__==2)
if (*key == '_' && Jsi_Strcmp(key, "__proto__")==0 && interp->noproto==0)
return obj->__proto__;
#endif
if (*key == 't' && Jsi_Strcmp(key, "this")==0)
return interp->framePtr->inthis;
if (obj->arr)
v = jsi_ObjArrayLookup(interp, obj, key);
if (!v)
v= Jsi_TreeObjGetValue(obj, key, isstrkey);
return v; /* TODO: redo with copy */
}
|
CWE-120
| null | 520,506 |
286239023390340905435019121063871037555
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
bool Jsi_ValueIsFunction(Jsi_Interp *interp, Jsi_Value *v)
{
int rc = (v!=NULL && v->vt == JSI_VT_OBJECT && v->d.obj->ot == JSI_OT_FUNCTION);
if (!rc) return rc;
if (interp == v->d.obj->d.fobj->interp)
return 1;
fprintf(stderr, "OOPS: function in wrong interp %s: %s\n",
interp->parent?"(string came in from parent interp?)":"",
v->d.obj->d.fobj->func->name);
return 0;
}
|
CWE-120
| null | 520,507 |
62675642507332587520700599898788959917
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_push_this(jsi_Pstate *p, jsi_Pline *line) { JSI_NEW_CODESLN(0,OP_PUSHTHS, 0); }
|
CWE-120
| null | 520,508 |
115539059811335017983042846567363231394
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void* Jsi_MapKeyGet(Jsi_MapEntry *h, int flags){
switch (jsi_GetListType(h)) {
case JSI_MAP_HASH: return Jsi_HashKeyGet((Jsi_HashEntry*)h);
case JSI_MAP_TREE: return Jsi_TreeKeyGet((Jsi_TreeEntry*)h);
case JSI_MAP_LIST: break;
case JSI_MAP_NONE: break;
}
return NULL;
}
|
CWE-120
| null | 520,509 |
272836245845892776153840767809521745874
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_Value* dbEvalSetColumnValue(DbEvalContext *p, int iCol, Jsi_Value **val) {
Jsi_Interp *interp = p->jdb->interp;
sqlite3_stmt *pStmt = p->pPreStmt->pStmt;
const char *str;
switch( sqlite3_column_type(pStmt, iCol) ) {
case SQLITE_BLOB: {
int bytes = sqlite3_column_bytes(pStmt, iCol);
const char *zBlob = (char*)sqlite3_column_blob(pStmt, iCol);
if( !zBlob )
return Jsi_ValueMakeNull(interp, val);
unsigned char *uptr = (unsigned char*)Jsi_Malloc(bytes+1);
memcpy(uptr, zBlob, bytes);
uptr[bytes] = 0;
return Jsi_ValueMakeBlob(interp, val, uptr, bytes);
break;
}
case SQLITE_INTEGER: {
sqlite_int64 v = sqlite3_column_int64(pStmt, iCol);
if (v==0 ||v==1) {
const char *dectyp = sqlite3_column_decltype(pStmt, iCol);
if (dectyp && !Jsi_Strncasecmp(dectyp,"bool", 4)) {
return Jsi_ValueMakeBool(interp, val, v);
}
}
if( v>=-2147483647 && v<=2147483647 ) {
return Jsi_ValueMakeNumber(interp, val, v);
} else {
return Jsi_ValueMakeNumber(interp, val, v);
}
break;
}
case SQLITE_FLOAT: {
return Jsi_ValueMakeNumber(interp, val, (Jsi_Number)sqlite3_column_double(pStmt, iCol));
break;
}
case SQLITE_NULL: {
return Jsi_ValueMakeNull(interp, val);
break;;
}
case SQLITE_TEXT: {
if (!p->jdb->noJsonConv) {
const char *dectyp = sqlite3_column_decltype(pStmt, iCol);
if (dectyp && !Jsi_Strncasecmp(dectyp, "charjson", 8)) {
Jsi_Value *v = Jsi_ValueNew(interp);// NULL; //Jsi_ValueNew1(interp);
str = (char*)sqlite3_column_text(pStmt, iCol );
if (JSI_OK != Jsi_JSONParse(interp, str, &v, 0))
Jsi_LogWarn("JSON parse failure for CHARJSON column");
return v;
}
}
}
default:
str = (char*)sqlite3_column_text(pStmt, iCol );
if (!str)
str = p->jdb->optPtr->nullvalue;
return Jsi_ValueMakeStringDup(interp, val, str?str:"");
}
return Jsi_ValueNew1(interp);
}
|
CWE-120
| null | 520,510 |
167086824818780533504583700868766402989
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static char *jsiRlCmdMatches(const char *text, int state) {
static int idx, len;
const char *name;
Jsi_Interp* interp = jsi_interactiveInterp;
if (completeValues == NULL || !Jsi_ValueIsArray(interp, completeValues))
return NULL;
Jsi_Value **arr = completeValues->d.obj->arr;
int aLen = completeValues->d.obj->arrCnt;
if (!state)
{
idx = 0;
len = Jsi_Strlen(text)-jsiRlStart;
}
while (idx<aLen)
{
name = Jsi_ValueString(interp, arr[idx], NULL);
if (!name) name = "";
idx++;
if (Jsi_Strncmp(name, text+jsiRlStart, len) == 0)
return (Jsi_Strdup(name));
}
return NULL;
}
|
CWE-120
| null | 520,511 |
103631065936957762219705937664022957759
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *codes_join3(Jsi_OpCodes *a, Jsi_OpCodes *b, Jsi_OpCodes *c)
{
return codes_join(codes_join(a, b), c);
}
|
CWE-120
| null | 520,512 |
176755075327941615191717296102857560201
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void jsi_push_try(Jsi_Interp* interp, jsi_TryList **head, jsi_TryList *n)
{
interp->tryList = n;
interp->framePtr->tryDepth++;
n->next = *head;
*head = n;
}
|
CWE-120
| null | 520,513 |
307049799788005417984188118227511753981
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static const char *JsiCharsetMatch(const char *pattern, int c, int flags)
{
int inot = 0;
int pchar;
int match = 0;
int nocase = 0;
if (flags & JSI_CMP_NOCASE) {
nocase++;
c = toupper(c);
}
if (flags & JSI_CMP_CHARSET_SCAN) {
if (*pattern == '^') {
inot++;
pattern++;
}
/* Special case. If the first char is ']', it is part of the set */
if (*pattern == ']') {
goto first;
}
}
while (*pattern && *pattern != ']') {
/* Exact match */
if (pattern[0] == '\\') {
first:
pattern += Jsi_UtfToUniCharCase(pattern, &pchar, nocase);
}
else {
/* Is this a range? a-z */
int start;
int end;
pattern += Jsi_UtfToUniCharCase(pattern, &start, nocase);
if (pattern[0] == '-' && pattern[1]) {
/* skip '-' */
pattern += Jsi_UtfToUniChar(pattern, &pchar);
pattern += Jsi_UtfToUniCharCase(pattern, &end, nocase);
/* Handle reversed range too */
if ((c >= start && c <= end) || (c >= end && c <= start)) {
match = 1;
}
continue;
}
pchar = start;
}
if (pchar == c) {
match = 1;
}
}
if (inot) {
match = !match;
}
return match ? pattern : NULL;
}
|
CWE-120
| null | 520,514 |
172225825001913548200333896154704651733
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC jsi_InitNumber(Jsi_Interp *interp, int release)
{
if (release) return JSI_OK;
Jsi_Value *val, *global = interp->csc;
val = interp->Number_prototype = Jsi_CommandCreateSpecs(interp, "Number", numberCmds, NULL, JSI_CMDSPEC_ISOBJ);
Jsi_Value *NaN = Jsi_ValueMakeNumber(interp, NULL, Jsi_NumberNaN());
Jsi_Value *Inf = Jsi_ValueMakeNumber(interp, NULL, Jsi_NumberInfinity(1));
Jsi_ValueInsertFixed(interp, global, "NaN", NaN);
Jsi_ValueInsertFixed(interp, global, "Infinity", Inf);
interp->NaNValue = NaN;
interp->InfValue = Inf;
#define MCONST(name,v) Jsi_ValueInsert(interp, val, name, Jsi_ValueNewNumber(interp, v), JSI_OM_READONLY)
MCONST("MAX_VALUE", DBL_MAX);
MCONST("MIN_VALUE", DBL_MIN);
MCONST("NEGATIVE_INFINITY", Jsi_NumberInfinity(-1));
Jsi_ValueInsertFixed(interp, val, "POSITIVE_INFINITY", Inf);
Jsi_ValueInsertFixed(interp, val, "NaN", NaN);
return JSI_OK;
}
|
CWE-120
| null | 520,515 |
204636669702976490457713868157248968418
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC freeCmdSpecTbl(Jsi_Interp *interp, Jsi_MapEntry *hPtr, void *ptr) {
if (!ptr) return JSI_OK;
jsi_CmdSpecDelete(interp, ptr);
return JSI_OK;
}
|
CWE-120
| null | 520,516 |
178139991423463372473788552680514216914
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static int jsi_FromHexStr(const char *in, uchar *outdata) {
int n = 0;
while (in[0] && in[1]) {
if (!isxdigit(in[0]) || isxdigit(in[0]))
return -1;
outdata[n++] = jsi_fromHexChar(in[0]) << 4 | jsi_fromHexChar(in[1]);
in+=2;
}
return n;
}
|
CWE-120
| null | 520,517 |
20193206844041919838633629397453499361
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static bool fileObjIsTrue(void *data)
{
FileObj *fo = (FileObj *)data;
SIGASSERT(fo,FILEOBJ);
if (!fo->filename) return JSI_OK;
else return 1;
}
|
CWE-120
| null | 520,518 |
133337812394905770987965090687791296660
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC StringToTitleCmd(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, 2, &dStr);
Jsi_ValueFromDS(interp, &dStr, ret);
return JSI_OK;
}
|
CWE-120
| null | 520,519 |
233409270199294173635534678523403571058
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC WebSocketVersionCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr)
{
const char *verStr = NULL;
verStr = lws_get_library_version();
if (verStr) {
char buf[JSI_MAX_NUMBER_STRING], *cp;
snprintf(buf, sizeof(buf), "%s", verStr);
cp = Jsi_Strchr(buf, ' ');
if (cp) *cp = 0;
Jsi_ValueMakeStringDup(interp, ret, buf);
}
return JSI_OK;
}
|
CWE-120
| null | 520,520 |
198030334923492593360701580494410750128
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_Obj *Jsi_ValueGetObj(Jsi_Interp *interp, Jsi_Value* v)
{
if (v->vt == JSI_VT_OBJECT) {
return v->d.obj;
}
return NULL;
}
|
CWE-120
| null | 520,521 |
89690716050428013091504633367824918339
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static int jsi_FSCreateDirectoryProc(Jsi_Interp *interp, Jsi_Value* path) {
const char *pathPtr = Jsi_ValueToString(interp, path, NULL);
Jsi_DString dStr = {};
int rc;
if (*pathPtr == '~')
pathPtr = jsi_TildePath(interp, pathPtr, &dStr);
#ifdef __WIN32
rc = mkdir(pathPtr);
#else
rc = mkdir(pathPtr, 0666);
#endif
Jsi_DSFree(&dStr);
return rc;
}
|
CWE-120
| null | 520,522 |
324030058186311483894416117764194587854
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void jsi_SortDString(Jsi_Interp *interp, Jsi_DString *dStr, const char *sep) {
int argc, i;
char **argv;
Jsi_DString sStr;
Jsi_DSInit(&sStr);
Jsi_SplitStr(Jsi_DSValue(dStr), &argc, &argv, sep, &sStr);
qsort(argv, argc, sizeof(char*), jsi_cmpstringp);
Jsi_DSSetLength(dStr, 0);
for (i=0; i<argc; i++)
Jsi_DSAppend(dStr, (i?" ":""), argv[i], NULL);
Jsi_DSFree(&sStr);
}
|
CWE-120
| null | 520,523 |
16174063317264844540303759187780020713
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC SqliteEvalCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr)
{
int rc = SQLITE_OK, rc2;
Jsi_Db *jdb;
sqlite3_stmt *pStmt = NULL;
if (!(jdb = dbGetDbHandle(interp, _this, funcPtr))) return JSI_ERROR;
sqlite3 *db = jdb->db;
const char *zSql = Jsi_ValueArrayIndexToStr(interp, args, 0, NULL);
const char *zStart = zSql, *zLeftover = NULL, *zErrMsg = NULL;
int lnum = 1;
if (jdb->echo && zSql)
Jsi_LogInfo("SQL-EVAL: %s\n", zSql);
while( zSql && zSql[0] && (SQLITE_OK == rc) ) {
rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zLeftover);
if( SQLITE_OK != rc ) {
break;
} else {
if( !pStmt ) {
/* this happens for a comment or white-space */
zSql = zLeftover;
while( isspace(zSql[0]) ) zSql++;
continue;
}
do {
if (jdb->debug & TMODE_STEP)
JSI_DBQUERY_PRINTF( "DEBUG: step: %s\n", zSql);
rc = sqlite3_step(pStmt);
} while( rc == SQLITE_ROW );
rc2 = sqlite3_finalize(pStmt);
if( rc!=SQLITE_NOMEM ) rc = rc2;
if( rc==SQLITE_OK ) {
zSql = zLeftover;
while( isspace(zSql[0]) ) zSql++;
} else {
}
}
}
if (rc == SQLITE_OK) {
Jsi_ValueMakeNumber(interp, ret, (Jsi_Number)sqlite3_changes(jdb->db));
return JSI_OK;
}
while (zSql && zStart<zSql) {
if (zStart[0] == '\n') lnum++;
zStart++;
}
zErrMsg = sqlite3_errmsg(db);
Jsi_LogError("sqlite error: %s in statement at line %d", (zErrMsg ? zErrMsg : ""), lnum);
return JSI_ERROR;
}
|
CWE-120
| null | 520,524 |
139415105350799170736459128323214028129
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_List *Jsi_ListNew(Jsi_Interp *interp, Jsi_Wide flags, Jsi_HashDeleteProc *freeProc)
{
Jsi_List *list = (Jsi_List *)Jsi_Calloc(1, sizeof(Jsi_List));
list->sig = JSI_SIG_LIST;
list->opts.flags = flags;
list->opts.freeHashProc = freeProc;
list->opts.interp = interp;
list->opts.mapType = JSI_MAP_LIST;
list->opts.keyType = (Jsi_Key_Type)-1;
return list;
}
|
CWE-120
| null | 520,525 |
97525562406110418251846140712436616344
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC NumberIsSafeIntegerCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr) {
return jsi_NumberIsFiniteCmd(interp, args, _this, ret, funcPtr, 4);
}
|
CWE-120
| null | 520,526 |
276702392903878074686708448054490157854
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static int StringPtrCompare(Jsi_Tree *treePtr, const void *key1, const void *key2)
{
//return (key1 - key2);
if (key1 == key2) return 0;
//return Jsi_DictionaryCompare((char*)key1, (char*)key2);
return Jsi_Strcmp((char*)key1, (char*)key2);
}
|
CWE-120
| null | 520,527 |
105064895618521470005904667176916531897
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void jsi_mark_local(Jsi_OpCodes *ops) // Mark variables as declared with "var"
{
return;
int i = 0;
if (ops == NULL || ops->codes == NULL)
return;
while (i < ops->code_len) {
if (ops->codes[i].op == OP_PUSHVAR)
ops->codes[i].local = 1;
i++;
}
}
|
CWE-120
| null | 520,528 |
177377491421743159541153720173559684445
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
int Jsi_Ungetc(Jsi_Interp *interp, Jsi_Channel chan, int ch) {
if (chan->fsPtr==0 || !chan->fsPtr->ungetcProc) return -1;
return chan->fsPtr->ungetcProc(chan, ch);
}
|
CWE-120
| null | 520,529 |
100772658394612262186916851365434782099
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
jsi_HashArray(const void *key, size_t length )
{
const uchar *string = (const uchar *) key;
unsigned int result = 0;
int i;
for (i=0 ; i<(int)length; i++) {
result += (result<<3) + string[i];
}
return (jsi_Hash)result;
}
|
CWE-120
| null | 520,530 |
265069707717248850996769677116424715636
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void *Jsi_DbHandle(Jsi_Interp *interp, Jsi_Db* jdb)
{
if (!jsi_dbVfsPtr) {
printf( "Sqlite unsupported\n");
return NULL;
}
return jsi_dbVfsPtr->dbHandle(interp, jdb);
}
|
CWE-120
| null | 520,531 |
26655568518568000285050821741330924763
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC StringConcatCmd(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_DSAppend(&dStr, vstr, NULL);
int i, argc = Jsi_ValueGetLength(interp, args);
for (i=skip; i<argc; i++)
{
Jsi_Value *s = Jsi_ValueArrayIndex(interp, args, i);
if (Jsi_GetStringFromValue(interp, s, &vstr)) {
Jsi_LogError("String get failure");
Jsi_DSFree(&dStr);
return JSI_ERROR;
}
Jsi_DSAppend(&dStr, vstr, NULL);
}
Jsi_ValueFromDS(interp, &dStr, ret);
return JSI_OK;
}
|
CWE-120
| null | 520,532 |
80761277175573313356022368719803625775
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void jsi_DumpFunctions(Jsi_Interp *interp, const char *spnam) {
Jsi_DString dStr;
Jsi_DSInit(&dStr);
Jsi_MapEntry *hPtr;
Jsi_MapSearch search;
Jsi_CmdSpecItem *csi = NULL;
Jsi_CmdSpec *cs;
Jsi_Value *lsf = interp->lastSubscriptFail;
Jsi_Obj *lso = ((lsf && lsf->vt == JSI_VT_OBJECT)?lsf->d.obj:0);
const char *varname = NULL;
int m = 0;
if (lso) {
spnam = interp->lastSubscriptFailStr;
if (!spnam) spnam = interp->lastPushStr;
if (!spnam) spnam = "";
if (lso->ot == JSI_OT_USEROBJ && lso->d.uobj->reg && lso->d.uobj->interp == interp) {
cs = lso->d.uobj->reg->spec;
if (cs)
goto dumpspec;
} else if (lso->ot == JSI_OT_FUNCTION) {
cs = lso->d.fobj->func->cmdSpec;
if (cs)
goto dumpspec;
} else if (lso->ot == JSI_OT_OBJECT) {
jsiObjGetNames(interp, lso, &dStr, JSI_NAME_FUNCTIONS);
Jsi_LogError("'%s', functions are: %s.",
spnam, Jsi_DSValue(&dStr));
Jsi_DSFree(&dStr);
return;
} else {
const char *sustr = NULL;
switch (lso->ot) {
case JSI_OT_STRING: sustr = "String"; break;
case JSI_OT_NUMBER: sustr = "Number"; break;
case JSI_OT_BOOL: sustr = "Boolean"; break;
default: break;
}
if (sustr) {
hPtr = Jsi_MapEntryFind(interp->cmdSpecTbl, sustr);
csi = (Jsi_CmdSpecItem*)Jsi_MapValueGet(hPtr);
cs = csi->spec;
if (!spnam[0])
spnam = sustr;
goto dumpspec;
}
}
}
if (!spnam) spnam = "";
if (!*spnam) {
for (hPtr = Jsi_MapSearchFirst(interp->cmdSpecTbl, &search, 0);
hPtr; hPtr = Jsi_MapSearchNext(&search)) {
csi = (Jsi_CmdSpecItem*)Jsi_MapValueGet(hPtr);
if (csi->name && csi->name[0])
Jsi_DSAppend(&dStr, (m++?" ":""), csi->name, NULL);
}
Jsi_MapSearchDone(&search);
}
varname = spnam;
if ((hPtr = Jsi_MapEntryFind(interp->cmdSpecTbl, spnam))) {
csi = (Jsi_CmdSpecItem*)Jsi_MapValueGet(hPtr);
while (csi) {
int n;
cs = csi->spec;
dumpspec:
n = 0;
while (cs->name) {
if (n != 0 || !(cs->flags & JSI_CMD_IS_CONSTRUCTOR)) {
if (!*cs->name) continue;
Jsi_DSAppend(&dStr, (m?" ":""), cs->name, NULL);
n++; m++;
}
cs++;
}
csi = (csi?csi->next:NULL);
}
jsi_SortDString(interp, &dStr, " ");
if (varname)
spnam = varname;
else if (interp->lastPushStr && !spnam[0])
spnam = interp->lastPushStr;
Jsi_LogError("'%s' sub-commands are: %s.",
spnam, Jsi_DSValue(&dStr));
Jsi_DSFree(&dStr);
} else {
Jsi_LogError("can not execute expression: '%s' not a function",
varname ? varname : "");
}
}
|
CWE-120
| null | 520,533 |
233125545879558678371635305479063037960
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
char *Jsi_FileRealpath(Jsi_Interp *interp, Jsi_Value *spath, char *newname)
{
char *path = Jsi_ValueString(interp, spath, 0);
if (!path) return NULL;
return Jsi_FileRealpathStr(interp, path, newname);
}
|
CWE-120
| null | 520,534 |
302992397006854748914746463775061726824
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC MySqlErrorNoCmd(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_errno(jdb->db);
Jsi_ValueMakeNumber(interp, ret, (Jsi_Number)n);
return JSI_OK;
}
|
CWE-120
| null | 520,535 |
183880683482561460318084055917586741611
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_ValueGetIndex( Jsi_Interp *interp, Jsi_Value *valPtr,
const char **tablePtr, const char *msg, int flags, int *indexPtr)
{
char *val = Jsi_ValueString(interp, valPtr, NULL);
if (val == NULL)
return Jsi_LogError("expected string");
return Jsi_GetIndex(interp, val, tablePtr, msg, flags, indexPtr);
}
|
CWE-120
| null | 520,536 |
293798961704065972899669480258374488600
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC Jsi_CommandInvokeJSON(Jsi_Interp *interp, const char *cmdstr, const char *json, Jsi_Value **ret)
{
Jsi_Value *func = Jsi_NameLookup(interp, cmdstr);
if (func)
return Jsi_FunctionInvokeJSON(interp, func, json, ret);
return Jsi_LogError("can not find cmd: %s", cmdstr);
}
|
CWE-120
| null | 520,537 |
248353621286578347167602170249360363742
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
jsonGen1Value(Jsi_Interp *interp, Jsi_JsonParser *p, const char *js, uint i, uint *endPos, int incr)
{
uint len;
const char *t;
Jsi_Value *v = NULL;
switch (p->tokens[i].type) {
case JSI_JTYPE_PRIMITIVE:
t = Jsi_JsonGetTokstr(p, js, i, &len);
if (len == 4 && Jsi_Strncmp(t, "true", len)==0)
v = Jsi_ValueMakeBool(interp, NULL, 1);
else if (len == 5 && Jsi_Strncmp(t, "false", len)==0)
v = Jsi_ValueMakeBool(interp, NULL, 0);
else if (len == 4 && Jsi_Strncmp(t, "null", len)==0)
v = Jsi_ValueMakeNull(interp, NULL);
else if (len == 9 && Jsi_Strncmp(t, "undefined", len)==0)
v = Jsi_ValueMakeNull(interp, NULL);
else {
char *ep;
Jsi_Number d;
d = strtod(t,&ep);
if (ep>(t+len))
Jsi_LogWarn("bad number %*s", len, t);
v = Jsi_ValueMakeNumber(interp, NULL, d);
}
break;
case JSI_JTYPE_STRING:
t = Jsi_JsonGetTokstr(p, js, i, &len);
v = jsonNewStringObj(interp, t, len);
break;
case JSI_JTYPE_ARRAY:
v = jsonGenArray(interp, p, js, i, &i);
i--;
break;
case JSI_JTYPE_OBJECT:
v = jsonGenObject(interp, p, js, i, &i);
i--;
break;
default:
break;
}
if (endPos)
*endPos = i;
if (v == NULL)
v = Jsi_ValueMakeUndef(interp, NULL);
if (incr)
Jsi_IncrRefCount(interp, v);
return v;
}
|
CWE-120
| null | 520,538 |
335301614109703024088554135379237492522
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void Jsi_MutexUnlock(Jsi_Interp *interp, Jsi_Mutex *mtx) { MutexUnlock(mtx); if (interp) interp->lockRefCnt--; }
|
CWE-120
| null | 520,539 |
90704323463363384146395371084718075112
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *make_forin(Jsi_OpCodes *lval, jsi_Pline *line, Jsi_OpCodes *expr, Jsi_OpCodes *stat, const char *label, int isof)
{
Jsi_OpCodes *keycode = code_key();
keycode->codes[0].isof = isof;
keycode->codes[0].Line = line->first_line;
Jsi_OpCodes *init = codes_join(expr, keycode);
Jsi_OpCodes *cond = codes_join3(lval, code_next(),
code_jfalse(stat->code_len + 2));
Jsi_OpCodes *stat_jmp = code_jmp(-(cond->code_len + stat->code_len));
code_reserved_replace(stat, 1, 0, label, 2);
return codes_join3(codes_join(init, cond),
codes_join(stat, stat_jmp), code_pop(2));
}
|
CWE-120
| null | 520,540 |
249582228277303182162969680817058146376
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_Value* mdbEvalSetColumnValue(MyDbEvalContext *p, int iCol, Jsi_Value **val) {
Jsi_Interp *interp = p->jdb->interp;
MysqlPrep *prep = p->prep;
SqlFieldResults *field = prep->fieldResult+iCol;
if (field->isnull)
return Jsi_ValueMakeNull(interp, val);
switch(field->jsiTypeMap) {
case JSI_OPTION_STRING: {
int bytes = field->len;
char *zBlob = field->buffer.vstring;
if( !zBlob ) {
return Jsi_ValueMakeNull(interp, val);
}
zBlob = (char*)Jsi_Malloc(bytes+1);
memcpy(zBlob, field->buffer.vstring, bytes);
zBlob[bytes] = 0;
return Jsi_ValueMakeBlob(interp, val, (unsigned char*)zBlob, bytes+1);
}
case JSI_OPTION_BOOL:
return Jsi_ValueMakeBool(interp, val, field->buffer.vchar);
case JSI_OPTION_INT64:
return Jsi_ValueMakeNumber(interp, val, (Jsi_Number)field->buffer.vlonglong);
//case JSI_OPTION_TIME_T:
case JSI_OPTION_TIME_D:
case JSI_OPTION_TIME_W: {
Jsi_Number jtime = mdbMyTimeToJS(&field->buffer.timestamp);
return Jsi_ValueMakeNumber(interp, val, jtime);
}
case JSI_OPTION_DOUBLE:
return Jsi_ValueMakeNumber(interp, val, (Jsi_Number)field->buffer.vdouble);
default:
Jsi_LogWarn("unknown type: %d", field->jsiTypeMap);
}
return Jsi_ValueNew1(interp);
}
|
CWE-120
| null | 520,541 |
140693783160521130717167160261053719592
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC SqliteFunctionCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr)
{
SqlFunc *pFunc;
Jsi_Value *tocall, *nVal;
char *zName;
int rc, nArg = -1, argc;
argc = Jsi_ValueGetLength(interp, args);
Jsi_Db *jdb;
if (!(jdb = dbGetDbHandle(interp, _this, funcPtr))) return JSI_ERROR;
zName = Jsi_ValueArrayIndexToStr(interp, args, 0, NULL);
tocall = Jsi_ValueArrayIndex(interp, args, 1);
if (zName == NULL)
return Jsi_LogError("expected name");
if (!Jsi_ValueIsFunction(interp, tocall))
return Jsi_LogError("expected function");
if (argc == 3) {
nVal = Jsi_ValueArrayIndex(interp, args, 2);
if (Jsi_GetIntFromValue(interp, nVal, &nArg) != JSI_OK)
return JSI_ERROR;
} else {
Jsi_FunctionArguments(interp, tocall, &nArg);
}
if (nArg > SQLITE_LIMIT_FUNCTION_ARG)
return Jsi_LogError("to many args");
/* if( argc==6 ){
const char *z = Jsi_GetString(objv[3]);
int n = Jsi_Strlen(z);
if( n>2 && strncmp(z, "-argcount",n)==0 ){
if( Jsi_GetIntFromObj(interp, objv[4], &nArg) ) return JSI_ERROR;
if( nArg<0 )
return Jsi_LogError( "number of arguments must be non-negative");
}
pScript = objv[5];
}else if( argc!=4 ){
Jsi_WrongNumArgs(interp, 2, objv, "NAME [-argcount N] SCRIPT");
return JSI_ERROR;
}else{
pScript = objv[3];
}*/
pFunc = dbFindSqlFunc(jdb, zName);
if( pFunc==0 ) return JSI_ERROR;
SQLSIGASSERT(pFunc,FUNC);
pFunc->tocall = tocall;
Jsi_IncrRefCount(interp, pFunc->tocall);
rc = sqlite3_create_function(jdb->db, zName, nArg, SQLITE_UTF8,
pFunc, jsiSqlFunc, 0, 0);
if( rc!=SQLITE_OK ) {
rc = JSI_ERROR;
Jsi_LogError("function create error: %s", (char *)sqlite3_errmsg(jdb->db));
}
return JSI_OK;
}
|
CWE-120
| null | 520,542 |
139269101109681197559399633135234655280
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_key() { JSI_NEW_CODES(0,OP_KEY, 0); }
|
CWE-120
| null | 520,543 |
88366905564881650321833186330793342674
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC Jsi_JSONParse(Jsi_Interp *interp, const char *js, Jsi_Value **ret, int flags)
{
uint i = 0, r;
Jsi_RC result = JSI_OK;
int strict = (flags & JSI_JSON_STRICT);
Jsi_JsonTok *tok;
Jsi_Value *v;
const char *err;
Jsi_Number d;
if (js == NULL)
return JSI_OK;
while (isspace(*js))
js++;
if (js[0] == 0)
return JSI_OK;
switch (js[0]) {
case 't': if (Jsi_Strcmp(js,"true")==0) { if (ret) Jsi_ValueMakeBool(interp, ret, 1); return JSI_OK; } break;
case 'f': if (Jsi_Strcmp(js,"false")==0) { if (ret) Jsi_ValueMakeBool(interp, ret, 0); return JSI_OK; } break;
case 'n': if (Jsi_Strcmp(js,"null")==0) { if (ret) Jsi_ValueMakeNull(interp, ret); return JSI_OK; } break;
case '0': case '1': case '2': case '3': case '4': case '5':
case '6': case '7': case '8': case '9': case '-':
if (Jsi_GetDouble(interp, js, &d) == JSI_OK) { if (ret) Jsi_ValueMakeNumber(interp, ret, d); return JSI_OK; } break;
}
JSI_JSON_DECLARE(pp, tokens, 0);
Jsi_JsonParser *p = &pp;
pp.strict = strict;
pp.flags = flags;
r = Jsi_JsonParse(p, js);
if (r != JSI_JSON_ERR_NONE) {
int ofs = pp.pos, len = Jsi_Strlen(js);
if (ofs<0 || ofs>len)
ofs = 0;
err = p->errStr;
if (!err)
err = Jsi_JsonGetErrname(r);
if (interp)
Jsi_LogError("JSON parse error (%s) at offset %d \"%.30s\"", err, ofs, js+ofs);
result = JSI_ERROR;
goto done;
}
if (!ret)
goto done;
tok = p->tokens;
if (tok->size<=0) {
if (!*ret)
*ret = Jsi_ValueNew1(interp);
if (tok->type == JSI_JTYPE_OBJECT)
Jsi_ValueMakeObject(interp, ret, Jsi_ObjNewObj(interp, NULL, 0));
else if (tok->type == JSI_JTYPE_ARRAY)
Jsi_ValueMakeArrayObject(interp, ret, Jsi_ObjNew(interp));
else
Jsi_ValueMakeUndef(interp, ret);
goto done;
}
v = jsonGen1Value(interp, p, js, i, &i, 1);
Jsi_ValueReplace(interp, ret, v);
Jsi_DecrRefCount(interp, v);
done:
Jsi_JsonFree(&pp);
return result;
}
|
CWE-120
| null | 520,544 |
18688628632518632499128350868668964054
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void* Jsi_Realloc(void *m,unsigned int size) {
void *v = realloc(m,size);
Assert(v);
return v;
}
|
CWE-120
| null | 520,545 |
38111814169857567912715524185276263802
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_Value *ValueNew1(Jsi_Interp *interp)
{
Jsi_Value *v = ValueNew(interp);
Jsi_IncrRefCount(interp, v);
return v;
}
|
CWE-120
| null | 520,546 |
20594877803278705331165751977747344780
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void Jsi_ValueCopy(Jsi_Interp *interp, Jsi_Value *to, Jsi_Value *from ) {
return jsi_ValueCopyMove(interp, to, from, 1);
}
|
CWE-120
| null | 520,547 |
173348529131096427431362283682233580813
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
int Jsi_Close(Jsi_Interp *interp, Jsi_Channel chan) {
if (chan->fsPtr==0 || !chan->fsPtr->closeProc) return -1;
if (chan->flags&JSI_FS_NOCLOSE) return -1;
int rc = chan->fsPtr->closeProc(chan);
if (rc == 0)
Jsi_Free(chan);
return rc;
}
|
CWE-120
| null | 520,548 |
291995141725108892717059787745358441369
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
extern void jsi_TypeMismatch(Jsi_Interp* interp)
{
interp->typeMismatchCnt++;
if (interp->typeWarnMax<=0)
return;
if (interp->typeMismatchCnt>=interp->typeWarnMax) {
memset(&interp->typeCheck, 0, sizeof(interp->typeCheck));
Jsi_LogWarn("Max warnings exceeded %d: typeCheck disabled", interp->typeWarnMax);
}
}
|
CWE-120
| null | 520,549 |
277320391355045616088731038638135449093
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC Jsi_GetIntFromValueBase(Jsi_Interp* interp, Jsi_Value *value, int *n, int base, int flags)
{
int noMsg = (flags & JSI_NO_ERRMSG);
/* TODO: inefficient to convert to double then back. */
if (!value)
return JSI_ERROR;
Jsi_Number d = Jsi_ValueToNumberInt(interp, value, 1);
if (!Jsi_NumberIsFinite(d))
{
if (!noMsg)
Jsi_LogError("invalid number");
return JSI_ERROR;
}
Jsi_ValueReset(interp,&value);
Jsi_ValueMakeNumber(interp, &value, d);
*n = (int)d;
return JSI_OK;
}
|
CWE-120
| null | 520,550 |
230931882402986232407114627304187606681
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_in() { JSI_NEW_CODES(0,OP_IN, 0); }
|
CWE-120
| null | 520,551 |
130749059057343167071956970504583099066
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void insert_case5(Jsi_TreeEntry* n) {
Jsi_TreeEntry* g = grandparent(n);
set_color(n->parent, _JSI_TREE_BLACK);
set_color(g, _JSI_TREE_RED);
if (n == n->parent->left) {
rotate_right(g);
} else {
Assert (n == n->parent->right);
rotate_left(g);
}
}
|
CWE-120
| null | 520,552 |
302817571135848523341126435129185365399
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC FilesysGetsCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr)
{
int len;
UdfGet(udf, _this, funcPtr);
if (!udf->filename) {
Jsi_ValueMakeUndef(interp, ret);
return JSI_OK;
}
char buf[JSI_BUFSIZ];
if (!Jsi_Gets(interp, udf->chan, buf, sizeof(buf))) {
Jsi_ValueMakeUndef(interp, ret);
return JSI_OK;
}
buf[sizeof(buf)-1] = 0;
len = Jsi_Strlen(buf);
if (len > 0 && buf[len-1] == '\n')
buf[len-1] = 0;
Jsi_ValueMakeStringDup(interp, ret, buf);
return JSI_OK;
}
|
CWE-120
| null | 520,553 |
117777081383425629473706142151945745241
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
int Jsi_Chdir(Jsi_Interp *interp, Jsi_Value* path) {
void *data;
int rc = 0;
const char *pathPtr = Jsi_ValueToString(interp, path, NULL);
if (interp->isSafe && Jsi_InterpAccess(interp, path, JSI_INTACCESS_READ) != JSI_OK)
return Jsi_LogError("read access denied");
Jsi_Filesystem *fsPtr = Jsi_FilesystemForPath(interp, path, &data);
if (fsPtr == &jsiFilesystem) {
rc = chdir(pathPtr);
if (rc < 0)
return -1;
/* If change out of native fs, GetCwd will use pwdStr */
fsPtr = NULL;
}
Jsi_DSSetLength(&jsiIntData.pwdStr, 0);
Jsi_DSAppendLen(&jsiIntData.pwdStr, pathPtr, -1);
jsiIntData.cwdFsPtr = fsPtr;
jsiIntData.pwd = fsPtr ? Jsi_DSValue(&jsiIntData.pwdStr) : NULL;
return rc;
}
|
CWE-120
| null | 520,554 |
250445992921730788653424438372928924201
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_Channel Jsi_Open(Jsi_Interp *interp, Jsi_Value *file, const char *modeString)
{
/* Find fsys, and use open there. */
Jsi_Filesystem *fsPtr;
Jsi_Chan *ch = NULL;
void *data;
int fnl = 0;
const char *fileName = Jsi_ValueString(interp, file, &fnl), *oldFN = fileName;
if (!fileName || !fnl) {
Jsi_LogError("expected string filename");
return NULL;
}
if (!Jsi_Strcmp(fileName, "stdin")) return jsiIntData.stdChans;
if (!Jsi_Strcmp(fileName, "stdout")) return jsiIntData.stdChans+1;
if (!Jsi_Strcmp(fileName, "stderr")) return jsiIntData.stdChans+2;
const char *s = modeString;
bool quiet = 0;
if (s[0]=='-') {
quiet = true;
s++;
}
char Mode[sizeof(ch->modes)];
Jsi_StatBuf sb;
Jsi_Value *path = NULL;
int n, i, mode = 0, rc, writ, aflag;
if (!s)
s = "r";
if (Jsi_Strlen(s) >= sizeof(ch->modes)) {
Jsi_LogError("mode too long: %s", s);
return NULL;
}
if (Jsi_Strchr(s, 'z') || Jsi_Strchr(s, 'Z')) {
Jsi_Filesystem *fsPtr = jsi_FilesysFind("jfz");
if (!fsPtr) {
Jsi_LogError("compressed files unsupported");
return NULL;
}
ch = fsPtr->openProc(interp, file, s);
if (!ch) {
if (!quiet)
Jsi_LogError("File open failed '%s'", fileName);
return NULL;
}
Jsi_Chan *nch = (Jsi_Chan *)Jsi_Calloc(1,sizeof(*nch));
*nch = *ch;
nch->fsPtr = fsPtr;
return nch;
}
for (i=0, n = 0; s[i]; i++) {
switch (s[i]) {
case '+': break;
case 'b': break;
case 'r': if (!Jsi_Strchr(s,'+')) mode |= JSI_FS_READONLY; break;
case 'a':
case 'w': if (!Jsi_Strchr(s,'+')) mode |= JSI_FS_WRITEONLY; break;
default: Jsi_LogError("unknown mode char: %c", s[i]); return NULL;
}
Mode[n++] = s[i];
}
Mode[n] = 0;
/* Fixup files in the ~ dir */
rc = Jsi_Stat(interp, file,&sb);
if ((rc != 0 || *fileName == '~') && (fileName = Jsi_FileRealpath(interp, file, NULL))) {
path = Jsi_ValueNewString(interp, fileName, -1);
Jsi_IncrRefCount(interp, path);
rc = Jsi_Stat(interp, path, &sb);
if (rc == 0)
file = path;
}
if (!fileName) {
Jsi_LogError("file error: %s", oldFN);
return NULL;
}
if (rc == 0 && sb.st_mode & S_IFDIR )
{
Jsi_LogError("can not open directory: %s", fileName);
goto done;
}
fsPtr = Jsi_FilesystemForPath(interp, file, &data);
writ = (Jsi_Strchr(s,'w') || Jsi_Strchr(s,'a') || Jsi_Strchr(s,'+'));
aflag = (writ ? JSI_INTACCESS_WRITE : JSI_INTACCESS_READ);
if (fsPtr && fsPtr != &jsiFilesystem) {
ch = fsPtr->openProc(interp, file, Mode);
if (ch)
ch->isNative = 0;
else
Jsi_LogError("File open failed '%s'", fileName);
} else {
if (interp->isSafe && ((rc && Jsi_InterpAccess(interp, file, JSI_INTACCESS_CREATE) != JSI_OK)
|| Jsi_InterpAccess(interp, file, aflag) != JSI_OK)) {
Jsi_LogError("%s access denied: %s", writ?"write":"read", fileName);
goto done;
}
FILE *fp = fopen(fileName, Mode);
fsPtr = &jsiFilesystem;
if (!fp) {
if (!quiet)
Jsi_LogError("File open failed '%s'", fileName);
goto done;
}
ch = (Jsi_Chan *)Jsi_Calloc(1,sizeof(*ch));
ch->fp = fp;
ch->isNative = 1;
}
if (ch) {
ch->flags |= mode; // + (zLevel<<24);
Jsi_Strcpy(ch->modes, s);
ch->fsPtr = fsPtr;
ch->fname = fileName;
}
done:
if (path)
Jsi_DecrRefCount(interp, path);
return ch;
}
|
CWE-120
| null | 520,555 |
334273453534114036717909317611948129119
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_Value *Jsi_Executable(Jsi_Interp *interp)
{
return jsiIntData.execValue;
}
|
CWE-120
| null | 520,556 |
127356492028624186066906256141870011439
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_TreeEntry* uncle(Jsi_TreeEntry* n) {
Assert (n != NULL);
Assert (n->parent != NULL);
Assert (n->parent->parent != NULL);
return sibling(n->parent);
}
|
CWE-120
| null | 520,557 |
76704433290770486672510845230285324958
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC Jsi_MapConf(Jsi_Map *mapPtr, Jsi_MapOpts *opts, bool set)
{
switch (mapPtr->typ) {
case JSI_MAP_HASH: return Jsi_HashConf(mapPtr->v.hash, opts, set);
case JSI_MAP_TREE: return Jsi_TreeConf(mapPtr->v.tree, opts, set);
case JSI_MAP_LIST: return Jsi_ListConf(mapPtr->v.list, opts, set);
case JSI_MAP_NONE: break;
}
return JSI_ERROR;
}
|
CWE-120
| null | 520,558 |
326132196939290698075134153557630880519
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC jsi_RegExpValueNew(Jsi_Interp *interp, const char *regtxt, Jsi_Value *ret)
{
Jsi_DString dStr = {};
Jsi_DSAppend(&dStr, "/", regtxt, "/", NULL);
Jsi_Regex *re = Jsi_RegExpNew(interp, Jsi_DSValue(&dStr), 0);
Jsi_DSFree(&dStr);
if (re == NULL)
return JSI_ERROR;
Jsi_Obj *o = Jsi_ObjNewType(interp, JSI_OT_REGEXP);
Jsi_ValueMakeObject(interp, &ret, o);
ret->d.obj->d.robj = re;
ret->d.obj->ot = JSI_OT_REGEXP;
return JSI_OK;
}
|
CWE-120
| null | 520,559 |
325618006211480156266000536508084134899
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void mdbRelease1Stmt( MySqlObj *jdb, MysqlPrep *prep ) {
// TODO: split out parts reusable by cached query.
int i;
if (prep->deleting)
return;
prep->deleting = 1;
if (prep->myStmt)
mysql_stmt_close(prep->myStmt);
if (prep->resultMetaData)
mysql_free_result(prep->resultMetaData);
if (prep->paramMetaData)
mysql_free_result(prep->paramMetaData);
if (prep->bindParam)
Jsi_Free(prep->bindParam);
if (prep->fieldParam)
Jsi_Free(prep->fieldParam);
if (prep->bindResult) {
for (i=0; i<prep->numCol; i++) {
MYSQL_BIND *bind = prep->bindResult+i;
if (bind->buffer_type == MYSQL_TYPE_STRING && bind->buffer)
Jsi_Free(bind->buffer);
}
Jsi_Free(prep->bindResult);
}
if (prep->fieldResult)
Jsi_Free(prep->fieldResult);
if (prep->colTypes)
Jsi_Free(prep->colTypes);
if (prep->colNames)
Jsi_Free(prep->colNames);
if (prep->zSql)
Jsi_Free(prep->zSql);
if (prep->naStr) {
Jsi_Free(prep->origSql);
Jsi_DSFree(prep->naStr);
Jsi_Free(prep->naStr);
}
if (prep->entry)
Jsi_HashEntryDelete(prep->entry);
if (prep->elPtr) {
Jsi_ListEntry *pPtr = prep->elPtr;
prep->elPtr = NULL;
Jsi_ListEntryDelete(pPtr);
}
Jsi_Free(prep);
jdb->numStmts--;
}
|
CWE-120
| null | 520,560 |
208832652120575444956295659204812740460
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC fileObjFree(Jsi_Interp *interp, void *data)
{
FileObj *fo = (FileObj *)data;
SIGASSERT(fo,FILEOBJ);
fileObjErase(fo);
Jsi_Free(fo);
return JSI_OK;
}
|
CWE-120
| null | 520,561 |
207102894507542153646972281471555721748
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
bool Jsi_StrIsAlnum(const char *cp)
{
if (!cp || !*cp) return 0;
while (*cp)
if (isalnum(*cp) || *cp == '_')
cp++;
else
return 0;
return 1;
}
|
CWE-120
| null | 520,562 |
213270611736231514159133228421966712824
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC jsi_InterpDelete(Jsi_Interp *interp, void *ptr) {
if (jsi_vf)
Jsi_DecrRefCount(interp, jsi_vf);
jsi_vf = NULL;
jsi_exitCode = interp->exitCode;
jsi_deleted = 1;
return JSI_OK;
}
|
CWE-120
| null | 520,563 |
69343115687411174222568053300210029033
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC Jsi_CommandInvoke(Jsi_Interp *interp, const char *cmdstr, Jsi_Value *args, Jsi_Value **ret)
{
Jsi_Value *func = Jsi_NameLookup(interp, cmdstr);
if (func)
return Jsi_FunctionInvoke(interp, func, args, ret, NULL);
return Jsi_LogError("can not find cmd: %s", cmdstr);
}
|
CWE-120
| null | 520,564 |
246962905040741281354775822110392248322
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_RC Jsi_LogMsg(Jsi_Interp *interp, uint code, const char *format,...) {
va_list va;
va_start (va, format);
const char *mt = (code <= JSI__LOGLAST ? jsi_LogCodes[code] : "");
fputs(mt, stderr);
vfprintf(stderr, format, va);
fputs("\n", stderr);
va_end(va);
return JSI_ERROR;
}
|
CWE-120
| null | 520,565 |
88313978479205703389718512854876718824
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_jtrue(int off) { JSI_NEW_CODES(0,OP_JTRUE, off); }
|
CWE-120
| null | 520,566 |
232403096721878644994683530587219964084
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
char *Jsi_ValueString(Jsi_Interp *interp, Jsi_Value* v, int *lenPtr)
{
if (!v) return NULL;
Jsi_String *s = jsi_ValueString(v);
if (s) {
if (lenPtr)
*lenPtr = (s->len<0 ? (int)Jsi_Strlen(s->str) : s->len);
return s->str;
}
if (lenPtr)
*lenPtr = 0;
return NULL;
}
|
CWE-120
| null | 520,567 |
291303626600857622089398050202233826266
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_Value* Jsi_ValueMakeBool(Jsi_Interp *interp, Jsi_Value **vPtr, int b) {
Jsi_Value *v = (vPtr?*vPtr:NULL);
if (!v)
v = Jsi_ValueNew(interp);
else
Jsi_ValueReset(interp, vPtr);
v->vt = JSI_VT_BOOL;
v->d.val = b;
return v;
}
|
CWE-120
| null | 520,568 |
297189259976538116300321024181404269120
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static int jsi_FSRemoveProc(Jsi_Interp *interp, Jsi_Value* path, int flags) {
const char *pathPtr = Jsi_ValueToString(interp, path, NULL);
Jsi_DString dStr = {};
if (*pathPtr == '~')
pathPtr = jsi_TildePath(interp, pathPtr, &dStr);
int rc = remove(pathPtr);
Jsi_DSFree(&dStr);
return rc;
}
|
CWE-120
| null | 520,569 |
203651528748102170281759400022643839218
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void* Jsi_MapValueGet(Jsi_MapEntry *h){
switch (jsi_GetListType(h)) {
case JSI_MAP_HASH: return Jsi_HashValueGet((Jsi_HashEntry*)h);
case JSI_MAP_TREE: return Jsi_TreeValueGet((Jsi_TreeEntry*)h);
case JSI_MAP_LIST: return Jsi_ListValueGet((Jsi_ListEntry*)h);
case JSI_MAP_NONE: break;
}
return NULL;
}
|
CWE-120
| null | 520,570 |
328291580935657761940417585398309557761
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static void rotate_right(Jsi_TreeEntry* n) {
Jsi_TreeEntry* l;
Assert(n);
l = n->left;
replace_node(n, l);
n->left = l->right;
if (l->right != NULL) {
l->right->parent = n;
}
l->right = n;
n->parent = l;
}
|
CWE-120
| null | 520,571 |
152609082677294784282407579743878119219
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC StringMatchCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr)
{
int sLen, bLen;
const char *source_str;
ChkString(_this, funcPtr, source_str, &sLen, &bLen);
const char *v = source_str;
Jsi_Value *seq = Jsi_ValueArrayIndex(interp, args, skip);
if (Jsi_ValueIsString(interp, seq)) {
char *cp = Jsi_ValueString(interp, seq, NULL);
if (jsi_RegExpValueNew(interp, cp, seq) != JSI_OK)
return JSI_ERROR;
}
/* TODO: differentiate from re.exec() */
return jsi_RegExpMatches(interp, seq, v, bLen, *ret, NULL, 1);
}
|
CWE-120
| null | 520,572 |
145691040110590666576979291184817361448
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_etry(jsi_Pstate *p, jsi_Pline *line) { JSI_NEW_CODESLN(0,OP_ETRY, 0); }
|
CWE-120
| null | 520,573 |
253805648277377048599469999859164921682
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC jsi_wsDelPss(Jsi_Interp *interp, void *data) {
Jsi_Free(data);
return JSI_OK;
}
|
CWE-120
| null | 520,574 |
14475332028475513508834243774101933176
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_TreeEntry* grandparent(Jsi_TreeEntry* n) {
Assert (n != NULL);
Assert (n->parent != NULL);
Assert (n->parent->parent != NULL);
return n->parent->parent;
}
|
CWE-120
| null | 520,575 |
16821894130312506149626345987350931211
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void Jsi_SplitStr(const char *str, int *argcPtr,
char ***argvPtr, const char *ch, Jsi_DString *dStr)
{
char *cp, *ep, *p, **argv;
int cnt = 1, len, i, clen;
if (!ch)
ch = "";
clen = Jsi_Strlen(ch);
if (clen<=0)
return SplitChar(str, argcPtr, argvPtr, *ch, dStr);
len = Jsi_Strlen(str);
cp = (char*)str;
while (*cp) {
cp = Jsi_Strstr(cp,ch);
if (cp == NULL || *cp == 0) break;
cp += clen;
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) {
ep = Jsi_Strstr(cp,ch);
if (ep == NULL || *ep == 0) break;
*ep = 0;
cp = ep+clen;
argv[i++] = cp;
}
argv[cnt] = NULL;
}
|
CWE-120
| null | 520,576 |
71242137609727014786533801210233104718
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_JSONQuote(Jsi_Interp *interp, const char *str, int len, Jsi_DString *dsPtr)
{
const char *cp = str;
int i = 0;
if (len<0)
len = Jsi_Strlen(str);
char cbuf[10];
Jsi_DSAppend(dsPtr,"\"",NULL);
while (*cp && i++<len) {
if (*cp == '\\' /* || *cp == '/' */ || *cp == '\"') {
cbuf[0] = '\\';
cbuf[1] = *cp;
cbuf[2] = 0;
Jsi_DSAppend(dsPtr,cbuf,NULL);
} else if (!isprint(*cp)) {
int ilen;
switch (*cp) {
case '\b': Jsi_DSAppend(dsPtr,"\\b",NULL); break;
case '\n': Jsi_DSAppend(dsPtr,"\\n",NULL); break;
case '\r': Jsi_DSAppend(dsPtr,"\\r",NULL); break;
case '\f': Jsi_DSAppend(dsPtr,"\\f",NULL); break;
case '\t': Jsi_DSAppend(dsPtr,"\\t",NULL); break;
default:
if ((ilen = Jsi_UtfEncode(cp, cbuf))) {
Jsi_DSAppend(dsPtr,cbuf,NULL);
cp += (ilen-1);
}
}
} else {
cbuf[0] = *cp;
cbuf[1] = 0;
Jsi_DSAppend(dsPtr,cbuf,NULL);
}
cp++;
}
Jsi_DSAppend(dsPtr,"\"", NULL);
return Jsi_DSValue(dsPtr);;
}
|
CWE-120
| null | 520,577 |
146439445981093104001991594776783892162
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void jsi_DebugDumpValues(Jsi_Interp *interp)
{
if (jsiIntData.mainInterp != interp) return;
int vdLev = interp->memDebug;
int have = (interp->dbPtr->valueDebugTbl->numEntries || interp->dbPtr->objDebugTbl->numEntries);
if ((have && vdLev>0) || vdLev>=3) {
// First traverse all Object trees/arrays and mark all values contained therein.
Jsi_HashSearch search;
Jsi_HashEntry *hPtr;
for (hPtr = Jsi_HashSearchFirst(interp->dbPtr->objDebugTbl, &search);
hPtr != NULL; hPtr = Jsi_HashSearchNext(&search)) {
Jsi_Obj *vp = (Jsi_Obj *)Jsi_HashKeyGet(hPtr);
if (vp!=NULL && vp->sig == JSI_SIG_OBJ) {
jsiFlagDebugValues(interp, vp);
}
}
if (interp->dbPtr->valueDebugTbl->numEntries != interp->dbPtr->valueCnt)
fprintf(stderr, "\n\nValues table/alloc mismatch: table=%d, alloc=%d\n",
interp->dbPtr->valueDebugTbl->numEntries, interp->dbPtr->valueCnt);
// Dump unfreed values and objs.
int refSum=0, refsum=0;
int bcnt[4] = {};
if (vdLev>1 && interp->dbPtr->valueDebugTbl->numEntries)
fprintf(stderr, "\n\nUNFREED VALUES \"[*ptr,#refCnt,type,idx:label,label2]: @file:line in func() ...\"\n");
for (hPtr = Jsi_HashSearchFirst(interp->dbPtr->valueDebugTbl, &search);
hPtr != NULL; hPtr = Jsi_HashSearchNext(&search)) {
Jsi_Value *vp = (Jsi_Value *)Jsi_HashKeyGet(hPtr);
if (vp==NULL || vp->sig != JSI_SIG_VALUE) {
bcnt[0]++;
if (vdLev>1)
fprintf(stderr, "BAD VALUE: %p\n", vp);
} else {
bcnt[1]++;
refSum += vp->refCnt;
if (vdLev>1) {
char ebuf[JSI_BUFSIZ], ebuf2[JSI_MAX_NUMBER_STRING];
ebuf[0] = 0;
if (vp->vt==JSI_VT_OBJECT)
snprintf(ebuf, sizeof(ebuf), " {obj=%p, otype=%s}", vp->d.obj, Jsi_ObjTypeStr(interp, vp->d.obj));
else if (vp->vt==JSI_VT_NUMBER)
snprintf(ebuf, sizeof(ebuf), " {num=%s}", Jsi_NumberToString(interp, vp->d.num, ebuf2, sizeof(ebuf2)));
else if (vp->vt==JSI_VT_BOOL)
snprintf(ebuf, sizeof(ebuf), " {bool=%s}", vp->d.val?"true":"false");
else if (vp->vt==JSI_VT_STRING) {
const char *sbuf = ((vp->d.s.str && Jsi_Strlen(vp->d.s.str)>40)?"...":"");
snprintf(ebuf, sizeof(ebuf), " {string=\"%.40s%s\"}", (vp->d.s.str?vp->d.s.str:""), sbuf);
}
const char *pfx = "";
if (!(vp->VD.flags&MDB_INOBJ))
pfx = "!"; // Value is not contained in an object.
fprintf(stderr, "[%s*%p,#%d,%s,%d:%s%s%s]:%s @%s:%d in %s()%s\n", pfx,
vp, vp->refCnt, Jsi_ValueTypeStr(interp, vp), vp->VD.Idx,
(vp->VD.label?vp->VD.label:""), (vp->VD.label2?":":""),
(vp->VD.label2?vp->VD.label2:""), vp->VD.interp==jsiIntData.mainInterp?"":"!",
vp->VD.fname, vp->VD.line, vp->VD.func, ebuf);
}
}
}
if (interp->dbPtr->objDebugTbl->numEntries != interp->dbPtr->objCnt)
fprintf(stderr, "\n\nObject table/alloc mismatch: table=%d, alloc=%d\n",
interp->dbPtr->objDebugTbl->numEntries, interp->dbPtr->objCnt);
if (vdLev>1 && interp->dbPtr->objDebugTbl->numEntries)
fprintf(stderr, "\n\nUNFREED OBJECTS \"[*ptr,#refCnt,type,idx:label,label2]: @file:line in func() ...\"\n");
for (hPtr = Jsi_HashSearchFirst(interp->dbPtr->objDebugTbl, &search);
hPtr != NULL; hPtr = Jsi_HashSearchNext(&search)) {
Jsi_Obj *vp = (Jsi_Obj *)Jsi_HashKeyGet(hPtr);
if (vp==NULL || vp->sig != JSI_SIG_OBJ) {
bcnt[2]++;
fprintf(stderr, "BAD OBJ: %p\n", vp);
} else {
bcnt[3]++;
refsum += vp->refcnt;
if (vdLev>1) {
char ebuf[JSI_BUFSIZ], ebuf2[JSI_MAX_NUMBER_STRING];
ebuf[0] = 0;
if (vp->ot==JSI_OT_OBJECT) {
if (vp->isarrlist)
snprintf(ebuf, sizeof(ebuf), "tree#%d, array#%d", (vp->tree?vp->tree->numEntries:0), vp->arrCnt);
else
snprintf(ebuf, sizeof(ebuf), "tree#%d", (vp->tree?vp->tree->numEntries:0));
} else if (vp->ot==JSI_OT_NUMBER)
snprintf(ebuf, sizeof(ebuf), "num=%s", Jsi_NumberToString(interp, vp->d.num, ebuf2, sizeof(ebuf2)));
else if (vp->ot==JSI_OT_BOOL)
snprintf(ebuf, sizeof(ebuf), "bool=%s", vp->d.val?"true":"false");
else if (vp->ot==JSI_OT_STRING) {
const char *sbuf = ((vp->d.s.str && Jsi_Strlen(vp->d.s.str)>40)?"...":"");
snprintf(ebuf, sizeof(ebuf), "string=\"%.40s%s\"", (vp->d.s.str?vp->d.s.str:""), sbuf);
}
fprintf(stderr, "[*%p,#%d,%s,%d:%s%s%s]:%s @%s:%d in %s() {%s}\n",
vp, vp->refcnt, Jsi_ObjTypeStr(interp, vp), vp->VD.Idx, vp->VD.label?vp->VD.label:"",
vp->VD.label2?":":"",vp->VD.label2?vp->VD.label2:"", vp->VD.interp==jsiIntData.mainInterp?"":"!",
vp->VD.fname, vp->VD.line,
vp->VD.func, ebuf);
}
}
}
fprintf(stderr, "\nVALUES: bad=%d,unfreed=%d,allocs=%d,refsum=%d | OBJECTS: bad=%d,unfreed=%d,allocs=%d,refsum=%d interp=%p\n",
bcnt[0], bcnt[1], interp->dbPtr->valueAllocCnt, refSum, bcnt[2], bcnt[3], interp->dbPtr->objAllocCnt, refsum, interp);
if (interp->codesTbl)
for (hPtr = Jsi_HashSearchFirst(interp->codesTbl, &search);
hPtr != NULL; hPtr = Jsi_HashSearchNext(&search)) {
Jsi_OpCodes *vp = (Jsi_OpCodes *)Jsi_HashKeyGet(hPtr);
fprintf(stderr, "unfreed opcodes: %d\n", vp->id);
}
}
Jsi_HashDelete(interp->dbPtr->valueDebugTbl);
Jsi_HashDelete(interp->dbPtr->objDebugTbl);
Jsi_HashDelete(interp->codesTbl);
bool isMainInt = (interp == jsiIntData.mainInterp);
if (isMainInt && vdLev>3)
_exit(1); // Avoid sanitize output.
}
|
CWE-120
| null | 520,578 |
246898211143671966732973699199792128612
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_RC MySqlInfoCmd(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;
Jsi_Obj *nobj = Jsi_ObjNew(interp);
Jsi_ValueMakeObject(interp, ret, nobj);
const char *str, *svals[20];
int i = 0;
svals[i++] = "clientInfo";
svals[i++] = mysql_get_client_info();
svals[i++] = "hostInfo";
svals[i++] = mysql_get_host_info(jdb->db);
svals[i++] = "serverInfo";
svals[i++] = mysql_get_server_info(jdb->db);
svals[i++] = "stat";
svals[i++] = mysql_stat(jdb->db);
svals[i++] = 0;
i = 0;
while (svals[i]) {
str = svals[i+1];
Jsi_ObjInsert(interp, nobj, svals[i], str?Jsi_ValueNewStringDup(interp, str):Jsi_ValueNewNull(interp), 0);
}
Jsi_ObjInsert(interp, nobj, "threadId", Jsi_ValueNewNumber(interp, (Jsi_Number)mysql_thread_id(jdb->db)), 0);
Jsi_ObjInsert(interp, nobj, "protocolVersion", Jsi_ValueNewNumber(interp, (Jsi_Number)mysql_get_proto_info(jdb->db)), 0);
Jsi_ObjInsert(interp, nobj, "clientVersion", Jsi_ValueNewNumber(interp, (Jsi_Number)mysql_get_client_version()), 0);
Jsi_ObjInsert(interp, nobj, "serverVersion", Jsi_ValueNewNumber(interp, (Jsi_Number)mysql_get_server_version(jdb->db)), 0);
Jsi_ObjInsert(interp, nobj, "warningCount", Jsi_ValueNewNumber(interp, (Jsi_Number)mysql_warning_count(jdb->db)), 0);
return JSI_OK;
}
|
CWE-120
| null | 520,579 |
41750984701194234621334929719660407204
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void Jsi_StackFree(Jsi_Stack *stack)
{
Jsi_Free(stack->vector);
Jsi_Free(stack);
}
|
CWE-120
| null | 520,580 |
250781961272318927767569228137136312476
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_Value* Jsi_ValueMakeStringKey(Jsi_Interp *interp, Jsi_Value **vPtr, const char *s) {
Jsi_Value *v = (vPtr?*vPtr:NULL);
if (!v)
v = Jsi_ValueNew(interp);
else
Jsi_ValueReset(interp, vPtr);
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,581 |
95536320485166974668255689081218396650
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_push_func(jsi_Pstate *p, jsi_Pline *line, Jsi_Func *fun) {
Jsi_OpCodes* codes = code_push_func_sub(p, line, fun);
if (codes && fun && fun->name)
codes->codes[0].local = 1;
return codes;
}
|
CWE-120
| null | 520,582 |
138719758125301556063831228252608709292
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
void jsi_ValueDebugLabel_(jsi_ValueDebug *vd, const char *l1, const char *l2)
{
if (l1)
vd->label = l1;
if (l2)
vd->label2 = l2;
}
|
CWE-120
| null | 520,583 |
188193383274218032768952711686247915273
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
static Jsi_OpCodes *code_lessequ() { JSI_NEW_CODES(0,OP_LESSEQU, 0); }
|
CWE-120
| null | 520,584 |
92561982811989651247866372365240938358
| null | null |
other
|
jsish
|
430ea27accd4d4ffddc946c9402e7c9064835a18
| 0 |
Jsi_Func *jsi_FuncNew(Jsi_Interp *interp)
{
Jsi_Func *func = (Jsi_Func*)Jsi_Calloc(1, sizeof(Jsi_Func));
SIGINIT(func, FUNC);
func->hPtr = Jsi_HashSet(interp->funcsTbl, func, func);
func->refCnt = 1;
interp->funcCnt++;
return func;
}
|
CWE-120
| null | 520,585 |
183083004110699532397264695470129059189
| null | null |
other
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.