<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "http://bugs.gentoo.org/bugzilla.dtd">

<bugzilla version="2.22.7"
          urlbase="http://bugs.gentoo.org/"
          maintainer="bugzilla@gentoo.org"
>

    <bug>
          <bug_id>231247</bug_id>
          
          <creation_ts>2008-07-09 00:40 0000</creation_ts>
          <short_desc>net-dns/bind-tools-9.5.0: lwconfig is a bit too greedy when parsing /etc/resolv.conf</short_desc>
          <delta_ts>2008-07-23 19:01:02 0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Gentoo Linux</product>
          <component>Unspecified</component>
          <version>unspecified</version>
          <rep_platform>AMD64</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>walch.martin@web.de</reporter>
          <assigned_to>bind@gentoo.org</assigned_to>
          

      

      
          <long_desc isprivate="0">
            <who>walch.martin@web.de</who>
            <bug_when>2008-07-09 00:40:42 0000</bug_when>
            <thetext>When given a corrupt resolv.conf, it is possible that the function
lwres_conf_parse in lib/lwres/lwconfig.c eats silently the following line,
which is probably an unexpected and undesired behavior.
This happens whenever a line contains only a single word, immediately followed
by a newline character.

The usual behavior is: the first word of a line is interpreted as a keyword.
If this keyword is known, then the line is being parsed. If everything is
fine, then LWRES_R_SUCCESS is returned. If a problem has occurred then
LWRES_R_FAILURE is the return value and the running program will refuse work.
If the keyword is unknown, then the line is being skipped and LWRES_R_SUCCESS
remains the return value.

However, when the keyword is immediately followed by a newline, the next line
is treated as arguments for the keyword, no matter if the keyword is valid or
not. No error is being returned if the keyword is known or if the keyword is
unknown and ignored, but the next line is broken.

The attached patch tries to fix this problem and also contains a minor optimization for the function getword which IMO also
improves readability.

The patch should be applicable for bind-tools 9.5.0 as well as for 9.5.0-P1 and 9.5.1b1. I have sent this to ISC several weeks ago, but did not get any response.

Reproducible: Always

Steps to Reproduce:
1. create the file /etc/resolv.conf with the following content:

search
nameserver 192.168.0.1

(replace 192.168.0.1 with a valid address)

2. run a tool from bind-tools like dig or host to resolve a hostname that will be dynamically resolved (especially not listed in /etc/hosts):

host gentoo.org

Actual Results:  
host tries to resolve gentoo.org until timeout.

Expected Results:  
host should have been complaining about a malformed /etc/resolv.conf

emerge --info
Portage 2.1.5.6 (default/linux/amd64/2008.0/desktop, gcc-4.2.4, glibc-2.6.1-r0, 2.6.25-gentoo-r6 x86_64)
=================================================================
System uname: 2.6.25-gentoo-r6 x86_64 Intel(R) Core(TM)2 CPU 4300 @ 1.80GHz
Timestamp of tree: Tue, 08 Jul 2008 13:45:03 +0000
ccache version 2.4 [enabled]
app-shells/bash:     3.2_p33
dev-java/java-config: 1.3.7, 2.1.6
dev-lang/python:     2.5.2-r5
dev-util/ccache:     2.4-r7
sys-apps/baselayout: 2.0.0
sys-apps/openrc:     0.2.4-r1
sys-apps/sandbox:    1.2.18.1-r2
sys-devel/autoconf:  2.13, 2.61-r2
sys-devel/automake:  1.5, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10.1
sys-devel/binutils:  2.18-r3
sys-devel/gcc-config: 1.4.0-r4
sys-devel/libtool:   1.5.26
virtual/os-headers:  2.6.23-r3
ACCEPT_KEYWORDS=&quot;amd64&quot;
CBUILD=&quot;x86_64-pc-linux-gnu&quot;
CFLAGS=&quot;-O2 -fomit-frame-pointer -pipe -march=native -fgcse-after-reload&quot;
CHOST=&quot;x86_64-pc-linux-gnu&quot;
CONFIG_PROTECT=&quot;/etc /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/kde/4.1/env /usr/kde/4.1/share/config /usr/kde/4.1/shutdown /usr/share/config /var/lib/hsqldb&quot;
CONFIG_PROTECT_MASK=&quot;/etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/terminfo /etc/texmf/web2c /etc/udev/rules.d&quot;
CXXFLAGS=&quot;-O2 -fomit-frame-pointer -pipe -march=native -fgcse-after-reload&quot;
DISTDIR=&quot;/usr/portage/distfiles&quot;
FEATURES=&quot;ccache distlocks fixpackages metadata-transfer parallel-fetch prelink sandbox sfperms strict unmerge-orphans userfetch&quot;
GENTOO_MIRRORS=&quot;http://mirrors.sec.informatik.tu-darmstadt.de/gentoo/ http://ftp-stud.fht-esslingen.de/pub/Mirrors/gentoo/ http://mirror.switch.ch/ftp/mirror/gentoo/&quot;
LANG=&quot;de_DE.utf8&quot;
LC_ALL=&quot;de_DE.utf8&quot;
LDFLAGS=&quot;-Wl,-O1&quot;
LINGUAS=&quot;de&quot;
MAKEOPTS=&quot;-j4&quot;
PKGDIR=&quot;/usr/portage/packages&quot;
PORTAGE_RSYNC_OPTS=&quot;--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages&quot;
PORTAGE_TMPDIR=&quot;/var/tmp&quot;
PORTDIR=&quot;/usr/portage&quot;
PORTDIR_OVERLAY=&quot;/usr/portage/local/layman/kdesvn-portage /usr/local/portage&quot;
SYNC=&quot;rsync://rsync.europe.gentoo.org/gentoo-portage&quot;
USE=&quot;X Xaw3d a52 aac aalib accessibility acl acpi additions agg akode alsa amarok amd64 apache2 arts bash-completion berkdb blender-game bluetooth branding bzip2 cairo cdaudio cdr cdrom cjk cli clucene cracklib crypt cups curl daap dbus dga dri dvd dvdnav dvdr dvdread dxr3 eds emacs emboss encode evo fam fbcon ffmpeg fftw firefox flac fortran gcj gdbm ggi gif glibc-omitfp glitz gpg gpm gstreamer gtk hal hdri iceweasel iconv imagemagick insecure-savers ipv6 isdnlog jabber jack java java5 javascript jingle jms jpeg kde kdeenablefinal kdehiddenvisibility kerberos latex lcms ldap libcaca libnotify libwww lm_sensors lua mad matroska mdnsresponder-compat midi mikmod mmx mng mp3 mpeg mpeg2 mudflap mule multilib musepack mysql ncurses nls noamazon nptl nptlonly nsplugin offensive ogg ogg123 openal openexr opengl openmp oss pam pcre pdf perl plasma png posix povray ppds pppd python qt3 qt3support qt4 quicktime readline reflection reiser4 reiserfs sdl sdl-image sensord session sndfile solver songs sound speex spell spl sse sse2 ssl startup-notification svg tcpd tetex theora tidy tiff timidity truetype type1 unicode visualization vorbis wav wavpack xemacs xine xml xorg xosd xprint xscreensaver xulrunner xv zlib&quot; ALSA_CARDS=&quot;ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci&quot; ALSA_PCM_PLUGINS=&quot;adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mulaw multi null plug rate route share shm softvol&quot; APACHE2_MODULES=&quot;actions alias auth_basic auth_digest authn_anon authn_dbd authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock dbd deflate dir disk_cache env expires ext_filter file_cache filter headers ident imagemap include info log_config logio mem_cache mime mime_magic negotiation proxy proxy_ajp proxy_balancer proxy_connect proxy_http rewrite setenvif so speling status unique_id userdir usertrack vhost_alias&quot; ELIBC=&quot;glibc&quot; INPUT_DEVICES=&quot;mouse keyboard&quot; KERNEL=&quot;linux&quot; LCD_DEVICES=&quot;bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text&quot; LINGUAS=&quot;de&quot; USERLAND=&quot;GNU&quot; VIDEO_CARDS=&quot;i810 nv vesa&quot;
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>walch.martin@web.de</who>
            <bug_when>2008-07-09 00:41:58 0000</bug_when>
            <thetext>Created an attachment (id=159925)
the patch mentioned in the first comment

</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>dertobi123@gentoo.org</who>
            <bug_when>2008-07-23 19:01:02 0000</bug_when>
            <thetext>Thanks for you patch, this is fixed in bind-tools-9.5.0_p1-r1.</thetext>
          </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>159925</attachid>
            <date>2008-07-09 00:41 0000</date>
            <desc>the patch mentioned in the first comment</desc>
            <filename>lwconfig.diff</filename>
            <type>text/plain</type>
            <data encoding="base64">LS0tIGxpYi9sd3Jlcy9sd2NvbmZpZy5jLm9sZAkyMDA3LTA2LTIwIDAxOjQ3OjIyLjAwMDAwMDAw
MCArMDIwMAorKysgbGliL2x3cmVzL2x3Y29uZmlnLmMJMjAwOC0wNi0xNSAwMjo1NzowMi4wMDAw
MDAwMDAgKzAyMDAKQEAgLTE3NSwxMyArMTc1LDggQEAKIAlSRVFVSVJFKGJ1ZmZlciAhPSBOVUxM
KTsKIAlSRVFVSVJFKHNpemUgPiAwVSk7CiAKLQkqcCA9ICdcMCc7Ci0KIAljaCA9IGVhdHdoaXRl
KGZwKTsKIAotCWlmIChjaCA9PSBFT0YpCi0JCXJldHVybiAoRU9GKTsKLQogCWRvIHsKIAkJKnAg
PSAnXDAnOwogCkBAIC01OTIsMjMgKzU4NywzNyBAQAogCQlpZiAoc3RybGVuKHdvcmQpID09IDBV
KQogCQkJcnZhbCA9IExXUkVTX1JfU1VDQ0VTUzsKIAkJZWxzZSBpZiAoc3RyY21wKHdvcmQsICJu
YW1lc2VydmVyIikgPT0gMCkKLQkJCXJ2YWwgPSBsd3Jlc19jb25mX3BhcnNlbmFtZXNlcnZlcihj
dHgsIGZwKTsKKw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