Author: truckman Date: Thu May 12 05:43:54 2016 New Revision: 299516 URL: https://svnweb.freebsd.org/changeset/base/299516
Log: Check for socket creation success before calling bind(). Reported by: Coverity CID: 1194209 Modified: head/sbin/ping/ping.c Modified: head/sbin/ping/ping.c ============================================================================== --- head/sbin/ping/ping.c Thu May 12 05:12:24 2016 (r299515) +++ head/sbin/ping/ping.c Thu May 12 05:43:54 2016 (r299516) @@ -285,6 +285,16 @@ main(int argc, char *const *argv) err(EX_NOPERM, "setuid() failed"); uid = getuid(); + if (ssend < 0) { + errno = ssend_errno; + err(EX_OSERR, "ssend socket"); + } + + if (srecv < 0) { + errno = srecv_errno; + err(EX_OSERR, "srecv socket"); + } + alarmtimeout = df = preload = tos = 0; outpack = outpackhdr + sizeof(struct ip); @@ -625,16 +635,6 @@ main(int argc, char *const *argv) } #endif - if (ssend < 0) { - errno = ssend_errno; - err(EX_OSERR, "ssend socket"); - } - - if (srecv < 0) { - errno = srecv_errno; - err(EX_OSERR, "srecv socket"); - } - if (connect(ssend, (struct sockaddr *)&whereto, sizeof(whereto)) != 0) err(1, "connect"); _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"