From df057700e5a02309476703392490bedc0ad8fd9f Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Tue, 16 Aug 2016 17:01:31 +0100 Subject: 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. --- plugins/mozjs.c | 4 ++-- 1 file 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; -- cgit 1.2.3-korg