Re: [PATCH] Remove isys/str.c, replace calls with glib.h or string.h calls.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tue, 23 Mar 2010, Brian C. Lane wrote:

On 03/23/2010 12:38 AM, Ales Kozumplik wrote:
Hi,


On 03/22/2010 10:07 PM, David Cantrell wrote:
str.c was from a time when loader was still a statically linked binary.
Times have changed.  Removed str.c and replaced calls with either
string.h or glib.h functions.

For g_ascii_strup() and g_ascii_strdown(), those functions dup the
passed in string, change it, and return that.
---
-    } else if (strcount(str, ':')>  1) {
+    } else if (strstr(str, ":")) {

Or even strchr(str, ':') ?

Actually, per the IRC discussion that doesn't do the same thing. The
else block below this expects an ipv4 address with optional :port at the
end so this compare needs to check for 2 colons to confirm that it is an
ipv6 address.

It also needs to handle the case where there are no colons, so comparing
a strchr and a strrchr doesn't work either. I think it needs to look
like this:

} else if ((strchr(str, ':') != NULL) && (strchr(str, ':') !=
strrchr(str, ':'))) {

This check still doesn't make sure we have more than one colon.  strrchr()
could still return NULL here but the test to make sure it doesn't equal the
first colon still passes.

I don't like calling strchr 2 times, but that's probably about as clean
as adding a temporary char *p to hold the results for the 2nd check.

How about this revision:

diff --git a/loader/net.c b/loader/net.c
index afbc6d8..a987050 100644
- --- a/loader/net.c
+++ b/loader/net.c
@@ -2004,6 +2004,8 @@ int kickstartNetworkUp(struct loaderData_s * loaderData,
i
 void splitHostname (char *str, char **host, char **port)
 {
     char *rightbrack = strchr(str, ']');
+    char *firstcolon = strchr(str, ':');
+    char *secondcolon = strrchr(str, ':');

     *host = NULL;
     *port = NULL;
@@ -2020,7 +2022,7 @@ void splitHostname (char *str, char **host, char **port)
         }
         else
             *host = strndup(str+1, rightbrack-1-str);
- -    } else if (strstr(str, ":")) {
+    } else if (firstcolon && secondcolon && firstcolon != secondcolon) {
         /* An IPv6 address without brackets.  Don't make the user surround
 * the
          * address with brackets if there's no port number.
          */

- -- David Cantrell <dcantrell@xxxxxxxxxx>
Red Hat / Honolulu, HI

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAkuqRQ4ACgkQ5hsjjIy1VklkWwCdHT7YHhlfDlrsahae/wPMix4H
/w4AmQEd1tGlUjs6rtJD/7FggdbIXIOv
=umHb
-----END PGP SIGNATURE-----

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux