Add a check to the user supplied value of the local port.

I haven't used the return value of strtonum since pflag is used later as a 
pointer.

ok?

-mark


Index: netcat.c
===================================================================
RCS file: /cvs/src/usr.bin/nc/netcat.c,v
retrieving revision 1.98
diff -u -p -r1.98 netcat.c
--- netcat.c    3 Jul 2010 04:44:51 -0000       1.98
+++ netcat.c    23 Sep 2010 07:13:51 -0000
@@ -174,6 +174,9 @@ main(int argc, char *argv[])
                        Pflag = optarg;
                        break;
                case 'p':
+                       strtonum(optarg, 1, PORT_MAX, &errstr);
+                       if (errstr)
+                               errx(1, "source port %s: %s", errstr, optarg);
                        pflag = optarg;
                        break;
                case 'r':

Reply via email to