Skip to content
Snippets Groups Projects
Commit c0034a16 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Throw an exception in bbs.exec_xtrn() when passed no argument

... or when passed an invalid external program code or number, rather just just returning false. The underlying exec_xtrn() C++ function may return false (failure) for other reasons, so let's not obfuscate the other potential failure causes.
parent a287dcf7
No related branches found
No related tags found
No related merge requests found
......@@ -1351,24 +1351,25 @@ js_exec_xtrn(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
if(argc) {
if(JSVAL_IS_STRING(argv[0])) {
JSVALUE_TO_ASTRING(cx,argv[0],code, LEN_CODE+2, NULL);
if(code==NULL)
return(JS_FALSE);
if(!js_argc(cx, argc, 1))
return JS_FALSE;
for(i=0;i<sbbs->cfg.total_xtrns;i++)
if(!stricmp(sbbs->cfg.xtrn[i]->code,code))
break;
} else if(JSVAL_IS_NUMBER(argv[0])) {
if(!JS_ValueToECMAUint32(cx,argv[0],&i))
return JS_FALSE;
}
if(JSVAL_IS_STRING(argv[0])) {
JSVALUE_TO_ASTRING(cx,argv[0],code, LEN_CODE+2, NULL);
if(code==NULL)
return(JS_FALSE);
for(i=0;i<sbbs->cfg.total_xtrns;i++)
if(!stricmp(sbbs->cfg.xtrn[i]->code,code))
break;
} else if(JSVAL_IS_NUMBER(argv[0])) {
if(!JS_ValueToECMAUint32(cx,argv[0],&i))
return JS_FALSE;
}
if(i>=sbbs->cfg.total_xtrns) {
JS_SET_RVAL(cx, arglist, JSVAL_FALSE);
return(JS_TRUE);
JS_ReportError(cx, "Invalid external program specified");
return JS_FALSE;
}
rc=JS_SUSPENDREQUEST(cx);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment