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 03/24/2010 09:59 AM, David Cantrell wrote:
> On Tue, 23 Mar 2010, Brian C. Lane wrote:
> 

>> } 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.

Whoops, good point.

> 
>> 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.
>           */

Yeah, that looks good to me.

- -- 
Brian C. Lane <bcl@xxxxxxxxxx>
Red Hat / Port Orchard, WA
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iQEVAwUBS6pH0BF+jBaO/jp/AQJ2kQf/Zk34Qydkz8D/9rt+uvOGZhw3qXZGOa95
SkOXy/q2zx6CufbtWTn04/LToo7aZT1i6O25ZEJnltWNPZGQLvp+cHGErFF7PhTL
XshqOb0S6klX9UbVxgbn1//xOvgbKo/FUJ4IiRfmDYfD2MMo6w522863cbqKE5tM
tSrMqb2TCkDpbNDnxkFs/9vcwxf78TqwISA1oVGvcAAUbewZFzr3MjQ5hc/8Q3DN
2wpkZGrBZqrbILODucKR0fDEZFGUks+Gfq5aQRqH8iJWyQxcXqVGN6Uo2a9t96Ue
EfX5OXVJsody45sYG/NZufLssiM0LzL1BOVcowAkTo0ziTkG8YEe7w==
=6yDS
-----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