From: Christian Hofstaedtler Date: Sat, 24 Aug 2013 09:37:05 +0000 (+0200) Subject: add error checking in exp. recursor webserver X-Git-Tag: rec-3.6.0-rc1~506^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8989097d0a9d5f036c0990c88ea90053f529a327;p=thirdparty%2Fpdns.git add error checking in exp. recursor webserver pdns_recursor will now fail to start when it can't bind to the webserver socket. Fix for Coverity CID 1029992, 1029999 --- diff --git a/pdns/json_ws.cc b/pdns/json_ws.cc index 6055878c94..d200bf4df8 100644 --- a/pdns/json_ws.cc +++ b/pdns/json_ws.cc @@ -32,9 +32,14 @@ JWebserver::JWebserver(FDMultiplexer* fdm) : d_fdm(fdm) { RecursorControlParser rcp; // inits d_socket = socket(AF_INET6, SOCK_STREAM, 0); + if(d_socket<0) { + throw PDNSException("Making webserver socket: "+stringerror()); + } setSocketReusable(d_socket); ComboAddress local("::", 8082); - bind(d_socket, (struct sockaddr*)&local, local.getSocklen()); + if(bind(d_socket, (struct sockaddr*)&local, local.getSocklen())<0) { + throw PDNSException("Binding webserver socket: "+stringerror()); + } listen(d_socket, 5); d_fdm->addReadFD(d_socket, boost::bind(&JWebserver::newConnection, this)); diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index f489004866..2d3e40a11d 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -1892,7 +1892,13 @@ try if(!t_id) { if(::arg().mustDo("experimental-json-interface")) { L<getName() << "' multiplexer"<