mirror of
https://github.com/remittor/zapret-openwrt.git
synced 2025-12-13 23:16:51 +03:00
luci: Catch incorrect JSON into function decode_svc_info
This commit is contained in:
@@ -160,10 +160,25 @@ return baseclass.extend({
|
|||||||
}
|
}
|
||||||
let plist = this.get_pid_list(proc_list.stdout);
|
let plist = this.get_pid_list(proc_list.stdout);
|
||||||
|
|
||||||
let jdata = JSON.parse(svc_info.stdout);
|
if (plist.length < 4) {
|
||||||
if (typeof(jdata) !== 'object') {
|
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
|
if (typeof(svc_info.stdout) !== 'string') {
|
||||||
|
return -4;
|
||||||
|
}
|
||||||
|
if (svc_info.stdout.length < 3) {
|
||||||
|
return -5;
|
||||||
|
}
|
||||||
|
let jdata;
|
||||||
|
try {
|
||||||
|
jdata = JSON.parse(svc_info.stdout);
|
||||||
|
} catch (e) {
|
||||||
|
console.log('Incorrect JSON: ' + svc_info.stdout);
|
||||||
|
return -6;
|
||||||
|
}
|
||||||
|
if (typeof(jdata) !== 'object') {
|
||||||
|
return -7;
|
||||||
|
}
|
||||||
if (typeof(jdata.zapret) == 'object') {
|
if (typeof(jdata.zapret) == 'object') {
|
||||||
result.dmn.inited = true;
|
result.dmn.inited = true;
|
||||||
let dmn_list = jdata.zapret.instances;
|
let dmn_list = jdata.zapret.instances;
|
||||||
|
|||||||
Reference in New Issue
Block a user