Bug 15522

Summary: crash if dhcp server returns a domain with NO (0) dots in it
Product: [Retired] Red Hat Linux Reporter: Need Real Name <markal>
Component: pumpAssignee: Erik Troan <ewt>
Status: CLOSED RAWHIDE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0CC: bsmith3
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2000-08-07 21:48:17 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Need Real Name 2000-08-05 21:45:53 UTC
Verified fix

--- pump.c.orig Thu Feb 17 15:15:48 2000
+++ pump.c      Sat Aug  5 22:26:55 2000
@@ -164,9 +164,10 @@
        fprintf(f, "search");
        chptr = domain;
        do {
+           char *chptr2 = strchr(chptr, '.');
            /* If there is a single . in the search path, write it out
               only if the toplevel domain is com, edu, gov, mil, org */
-           if (!strchr(strchr(chptr, '.') + 1, '.')) {
+           if (chptr2 && !strchr(chptr2 + 1, '.')) {
                char * tail = strchr(chptr, '.');
                if (strcmp(tail, ".com") && strcmp(tail, ".edu") &&
                    strcmp(tail, ".gov") && strcmp(tail, ".mil") &&
@@ -174,7 +175,7 @@
            }
 
            fprintf(f, " %s", chptr);
-           chptr = strchr(chptr, '.');
+           chptr = chptr2;
            if (chptr) {
                chptr++;
                if (!strchr(chptr, '.'))

Comment 1 Bert de Bruijn 2000-08-05 22:54:21 UTC
unrelated to this bug, but related to bug #15192:
why isn't .net listed in this code fragment ?
Bug #15192 is about pump writing an empty search line in /etc/resolv.conf when
domain-name is my.net, but it works ok when domain-name is my.own.net...

Comment 2 Brian Smith 2000-08-07 02:26:10 UTC
Why does pump even care what the top-level domain is? Shouldn't it just pass
whatever the DHCP server says? Some organizations use bogus TLDs on their
internal networks, and this might be problematic for them. Besides, there'll
possibly be new TLDs on the internet soon, you don't want to be adding every
single one into the code, do you?

Comment 3 Erik Troan 2000-08-07 21:48:15 UTC
It's trying to know that it if a hostname is foo.bar.co.uk, the search path
should be

		search bar.co.uk

but if the hostname is foo.bar.oot.com, the search path should be

		search bar.oot.com oot.com

unfortunately, there isn't a good rule to get this right (which is why dhcp
servers should give us a proper search path rather then forcing us to use our
own), so use /etc/pump.conf :-(

Comment 4 Erik Troan 2000-08-07 21:50:25 UTC
diff -u -r1.52 pump.c
--- pump.c	2000/08/07 21:48:22	1.52
This patch (which seems easier) is in pump-0.8.1

+++ pump.c	2000/08/07 21:49:38
@@ -161,6 +161,8 @@
 
     if (domain && isSearchPath) {
 	fprintf(f, "search %s\n", domain);
+    } else if (domain && !strchr(chptr, '.')) {
+	fprintf(f, "search %s\n", domain);
     } else if (domain) {
 	fprintf(f, "search");
 	chptr = domain;