Set result to SERVFAIL if upstream responded with FORMERR

Commit 2bc4c92e causes the resolver to
respond to a client query with FORMERR when all upstream queries sent to
the servers authoritative for QNAME elicit FORMERR responses.  This
happens because resolver code returns DNS_R_FORMERR in such a case and
dns_result_torcode() acts as a pass-through for all arguments which are
already a valid RCODE.

The correct RCODE to set in the response returned to the client in the
case described above is SERVFAIL.  Make sure this happens by overriding
the RCODE in query_gotanswer(), on the grounds that any format errors in
the client query itself should be caught long before execution reaches
that point.  This change should not reduce query error logging accuracy
as the resolver code itself reports the exact reason for returning a
DNS_R_FORMERR result using log_formerr().

(cherry picked from commit b5c9a8ca)
16 jobs for wpk-servfail-on-upstream-formerr-v9_12 in 7 minutes and 32 seconds (queued for 5 seconds)
Status Job ID Name Coverage
  Precheck
passed #71914
amd64 docker linux
precheck:debian:sid:amd64

00:00:21

 
  Build
passed #71915
amd64 docker linux
build:centos:centos6:amd64

00:02:07

passed #71916
amd64 docker linux
build:centos:centos7:amd64

00:02:15

passed #71917
amd64 docker linux
build:debian:sid:amd64

00:01:35

passed #71918
i386 docker linux
build:debian:sid:i386

00:01:36

 
  Test
passed #71919
amd64 docker linux
docs:debian:sid:amd64

00:00:52

passed #71928
amd64 docker linux
install:debian:sid:amd64

00:02:35

passed #71924
amd64 docker linux
systemtest:centos:centos6:amd64

00:04:38

passed #71925
amd64 docker linux
systemtest:centos:centos7:amd64

00:04:45

passed #71926
amd64 docker linux
systemtest:debian:sid:amd64

00:04:38

passed #71927
i386 docker linux
systemtest:debian:sid:i386

00:04:42

passed #71957
linux docker amd64
unittest:centos:centos6:amd64

00:00:50

passed #71921
amd64 docker linux
unittest:centos:centos7:amd64

00:00:55

passed #71922
amd64 docker linux
unittest:debian:sid:amd64

00:00:46

passed #71923
i386 docker linux
unittest:debian:sid:i386

00:00:52

canceled #71920
amd64 docker linux
unittest:centos:centos6:amd64

00:04:00