On Wed, 22 Jan 2003, Lev Walkin wrote: > Giorgos Keramidas wrote: > > I have been trying to think of a good way to check for overflow of > > port numbers of PF_INET sockets that are passed by the user. So far, > > this is what I have come up with: > > > > : > > : errno == 0;
I hope I'm not being pedantic, but don't you mean errno = 0; > > : tmp = strtol(argv[1], &errp, 0); > > : if (errp == argv[1] || errno == EINVAL || errno == ERANGE) > > : errx(1, "invalid number '%s'", argv[1]); > > : if (tmp > IPPORT_MAX) > > : errx(1, "%ld will overflow as a port number (max %d)", > > : tmp, IPPORT_MAX); > > > > Does this look ok to you all? > > Have I missed anything obvious that I should also check? > > tmp <= 0. > Steve To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-hackers" in the body of the message