Blame SOURCES/iputils-reorder-I-parsing.patch

994c6b
commit 1f6f39b84f81cfa6bc243557a68eebeeac7e8ea3
994c6b
Author: Robert Schiele <rschiele@gmail.com>
994c6b
Date:   Mon Mar 14 09:18:08 2016 +0100
994c6b
994c6b
    reorder -I option parsing
994c6b
    
994c6b
    This changes -I option parsing in a way that device is only assigned
994c6b
    if neither an IPv4 nor an IPv6 address is detected.  Otherwise those
994c6b
    addresses are misinterpreted as device names and as such will cause
994c6b
    error messages later in the code.
994c6b
    
994c6b
    Signed-off-by: Robert Schiele <rschiele@gmail.com>
994c6b
994c6b
diff --git a/ping.c b/ping.c
994c6b
index c42d6eb..498c0e8 100644
994c6b
--- a/ping.c
994c6b
+++ b/ping.c
994c6b
@@ -279,10 +279,6 @@ main(int argc, char **argv)
994c6b
 			break;
994c6b
 		}
994c6b
 		case 'I':
994c6b
-			if (inet_pton(AF_INET, optarg, &source.sin_addr) > 0)
994c6b
-				options |= F_STRICTSOURCE;
994c6b
-			else
994c6b
-				device = optarg;
994c6b
 			/* IPv6 */
994c6b
 			if (strchr(optarg, ':')) {
994c6b
 				char *p, *addr = strdup(optarg);
994c6b
@@ -306,6 +302,8 @@ main(int argc, char **argv)
994c6b
 				options |= F_STRICTSOURCE;
994c6b
 
994c6b
 				free(addr);
994c6b
+			} else if (inet_pton(AF_INET, optarg, &source.sin_addr) > 0) {
994c6b
+				options |= F_STRICTSOURCE;
994c6b
 			} else {
994c6b
 				device = optarg;
994c6b
 			}