]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Print usage and exit when -N used with invalid IP. 2227/head
authorChris Darroch <chrisd@apache.org>
Tue, 8 May 2018 06:42:33 +0000 (23:42 -0700)
committerChris Darroch <chrisd@apache.org>
Tue, 8 May 2018 06:42:33 +0000 (23:42 -0700)
Check for all possible error return values from inet_pton(),
particularly zero, as this indicates an invalid IP address was
passed in the input string, whereas -1 is returned only when the
address family parameter is invalid, which is never the case
here because it's always AF_INET.

src/main/radwho.c

index 4ea9846649c0504d57241ad681bedce6907882b7..7f2ce6dbf444b5a290bfcc6a16941486edf6853b 100644 (file)
@@ -233,7 +233,7 @@ int main(int argc, char **argv)
                        showname = 0;
                        break;
                case 'N':
-                       if (inet_pton(AF_INET, optarg, &nas_ip_address) < 0) {
+                       if (inet_pton(AF_INET, optarg, &nas_ip_address) <= 0) {
                                usage(1);
                        }
                        break;