aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Woodhouse <David.Woodhouse@intel.com>2016-08-16 17:01:31 +0100
committerPatrik Flykt <patrik.flykt@linux.intel.com>2016-08-19 10:10:29 +0300
commitdf057700e5a02309476703392490bedc0ad8fd9f (patch)
treebc22635c43011b659169347d94605e3befb7eb85
parent0744e43c8e1278dd23436fea9837584e10803a04 (diff)
downloadpacrunner-df057700e5a02309476703392490bedc0ad8fd9f.tar.gz
mozjs: Fix error handling for wrongly-formatted hostname
In commit d9ea7b8a ("plugins: Do not try to resolve a wrongly formated hostname") we introduced a check on the string before we attempt to resolve it. In the mozjs case we simply return a NULL result instead of raising an exception when this function fails... except that the new sanity check was placed before the JS_SET_RVAL() call, and no return value was set at all. Move it to the right place.
-rw-r--r--plugins/mozjs.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/plugins/mozjs.c b/plugins/mozjs.c
index 130c3c9..feaabd9 100644
--- a/plugins/mozjs.c
+++ b/plugins/mozjs.c
@@ -132,6 +132,8 @@ static JSBool dnsresolve(JSContext *ctx, uintN argc, jsval *vp)
DBG("host %s", host);
+ JS_SET_RVAL(ctx, vp, JSVAL_NULL);
+
/* Q&D test on host to know if it is a proper hostname */
split_res = g_strsplit_set(host, ":%?!,;@\\'*|<>{}[]()+=$&~# \"", -1);
if (split_res) {
@@ -142,8 +144,6 @@ static JSBool dnsresolve(JSContext *ctx, uintN argc, jsval *vp)
goto out;
}
- JS_SET_RVAL(ctx, vp, JSVAL_NULL);
-
if (resolve(host, address, sizeof(address)) < 0)
goto out;