svn commit: r310892 - head/usr.sbin/bsnmpd/tools/bsnmptools
Author: ngie Date: Sat Dec 31 09:43:35 2016 New Revision: 310892 URL: https://svnweb.freebsd.org/changeset/base/310892 Log: Don't call snmp_pdu_free(..) until finished with the pdu and when ready to allocate a new one via snmp_pdu_create(..) This fixes bsnmpwalk, so it no longer crashes after r310729 X-MFC with: r310729 MFC after:12 days Modified: head/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c Modified: head/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c == --- head/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.cSat Dec 31 07:50:14 2016(r310891) +++ head/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.cSat Dec 31 09:43:35 2016(r310892) @@ -498,7 +498,6 @@ snmptool_walk(struct snmp_toolinfo *snmp } outputs += rc; - snmp_pdu_free(&resp); if ((u_int)rc < resp.nbindings) break; @@ -518,8 +517,6 @@ snmptool_walk(struct snmp_toolinfo *snmp snmp_output_err_resp(snmptoolctx, &resp); else snmp_output_resp(snmptoolctx, &(resp), NULL); - - snmp_pdu_free(&resp); } else warn("Snmp dialog"); } @@ -529,6 +526,8 @@ snmptool_walk(struct snmp_toolinfo *snmp break; } + snmp_pdu_free(&resp); + snmp_pdu_create(&req, op); } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r310893 - head/usr.sbin/syslogd
Author: hrs Date: Sat Dec 31 09:52:00 2016 New Revision: 310893 URL: https://svnweb.freebsd.org/changeset/base/310893 Log: Remove extra NULL-check before free(3). Modified: head/usr.sbin/syslogd/syslogd.c Modified: head/usr.sbin/syslogd/syslogd.c == --- head/usr.sbin/syslogd/syslogd.c Sat Dec 31 09:43:35 2016 (r310892) +++ head/usr.sbin/syslogd/syslogd.c Sat Dec 31 09:52:00 2016 (r310893) @@ -710,8 +710,7 @@ main(int argc, char *argv[]) (*sl->sl_recv)(sl); } } - if (fdsr) - free(fdsr); + free(fdsr); } static int ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r310894 - head/usr.sbin/bsnmpd/tools/bsnmptools
Author: ngie Date: Sat Dec 31 10:01:25 2016 New Revision: 310894 URL: https://svnweb.freebsd.org/changeset/base/310894 Log: snmp_pdu_free the right object at the right time in snmptool_walk r310892 was on the right track, but unfortunately it was resolving the problem incorrectly and accidentally leaking memory in the process. - Call snmp_pdu_free on req before calling snmp_pdu_create on it at the bottom of the outer while loop - Call snmp_pdu_free on resp after calling snmpwalk_nextpdu_create in the inner loop MFC after:12 days X-MFC with: r310729, r310892 Reported by: valgrind Modified: head/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c Modified: head/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c == --- head/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.cSat Dec 31 09:52:00 2016(r310893) +++ head/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.cSat Dec 31 10:01:25 2016(r310894) @@ -422,6 +422,7 @@ snmptool_get(struct snmp_toolinfo *snmpt snmp_pdu_create(&req, GET_PDUTYPE(snmptoolctx)); } + snmp_pdu_free(&req); snmp_pdu_free(&resp); return (0); @@ -507,6 +508,7 @@ snmptool_walk(struct snmp_toolinfo *snmp if (op == SNMP_PDU_GETBULK) snmpget_fix_getbulk(&req, GET_MAXREP(snmptoolctx), GET_NONREP(snmptoolctx)); + snmp_pdu_free(&resp); } /* Just in case our root was a leaf. */ @@ -517,6 +519,7 @@ snmptool_walk(struct snmp_toolinfo *snmp snmp_output_err_resp(snmptoolctx, &resp); else snmp_output_resp(snmptoolctx, &(resp), NULL); + snmp_pdu_free(&resp); } else warn("Snmp dialog"); } @@ -526,11 +529,13 @@ snmptool_walk(struct snmp_toolinfo *snmp break; } - snmp_pdu_free(&resp); - + snmp_pdu_free(&req); snmp_pdu_create(&req, op); } + snmp_pdu_free(&req); + snmp_pdu_free(&resp); + if (rc == 0) return (0); else ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r310907 - head/sys/vm
Author: mjg Date: Sat Dec 31 10:37:56 2016 New Revision: 310907 URL: https://svnweb.freebsd.org/changeset/base/310907 Log: Use vrefact in vnode_pager_alloc. Modified: head/sys/vm/vnode_pager.c Modified: head/sys/vm/vnode_pager.c == --- head/sys/vm/vnode_pager.c Sat Dec 31 10:37:50 2016(r310906) +++ head/sys/vm/vnode_pager.c Sat Dec 31 10:37:56 2016(r310907) @@ -265,7 +265,7 @@ retry: #endif VM_OBJECT_WUNLOCK(object); } - vref(vp); + vrefact(vp); return (object); } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r310921 - head/usr.sbin/inetd
Author: hrs Date: Sat Dec 31 11:03:34 2016 New Revision: 310921 URL: https://svnweb.freebsd.org/changeset/base/310921 Log: - Add static for symbols which need not to be exported. - Clean up warnings to the WARNS=6 level. Modified: head/usr.sbin/inetd/builtins.c head/usr.sbin/inetd/inetd.c head/usr.sbin/inetd/inetd.h Modified: head/usr.sbin/inetd/builtins.c == --- head/usr.sbin/inetd/builtins.c Sat Dec 31 11:02:33 2016 (r310920) +++ head/usr.sbin/inetd/builtins.c Sat Dec 31 11:03:34 2016 (r310921) @@ -52,25 +52,24 @@ __FBSDID("$FreeBSD$"); #include "inetd.h" -void chargen_dg(int, struct servtab *); -void chargen_stream(int, struct servtab *); -void daytime_dg(int, struct servtab *); -void daytime_stream(int, struct servtab *); -void discard_dg(int, struct servtab *); -void discard_stream(int, struct servtab *); -void echo_dg(int, struct servtab *); -void echo_stream(int, struct servtab *); +static voidchargen_dg(int, struct servtab *); +static voidchargen_stream(int, struct servtab *); +static voiddaytime_dg(int, struct servtab *); +static voiddaytime_stream(int, struct servtab *); +static voiddiscard_dg(int, struct servtab *); +static voiddiscard_stream(int, struct servtab *); +static voidecho_dg(int, struct servtab *); +static voidecho_stream(int, struct servtab *); static int get_line(int, char *, int); -void iderror(int, int, int, const char *); -void ident_stream(int, struct servtab *); -void initring(void); -uint32_t machtime(void); -void machtime_dg(int, struct servtab *); -void machtime_stream(int, struct servtab *); - -char ring[128]; -char *endring; +static voididerror(int, int, int, const char *); +static voidident_stream(int, struct servtab *); +static voidinitring(void); +static uint32_tmachtime(void); +static voidmachtime_dg(int, struct servtab *); +static voidmachtime_stream(int, struct servtab *); +static char ring[128]; +static char *endring; struct biltin biltins[] = { /* Echo received data */ @@ -105,7 +104,7 @@ struct biltin biltins[] = { * any regard for input. */ -void +static void initring(void) { int i; @@ -122,7 +121,7 @@ initring(void) * characters chosen from the range 0 to 512. We send LINESIZ+2. */ /* ARGSUSED */ -void +static void chargen_dg(int s, struct servtab *sep) { struct sockaddr_storage ss; @@ -159,7 +158,7 @@ chargen_dg(int s, struct servtab *sep) /* Character generator */ /* ARGSUSED */ -void +static void chargen_stream(int s, struct servtab *sep) { int len; @@ -196,7 +195,7 @@ chargen_stream(int s, struct servtab *se /* Return human-readable time of day */ /* ARGSUSED */ -void +static void daytime_dg(int s, struct servtab *sep) { char buffer[256]; @@ -221,7 +220,7 @@ daytime_dg(int s, struct servtab *sep) /* Return human-readable time of day */ /* ARGSUSED */ -void +static void daytime_stream(int s, struct servtab *sep __unused) { char buffer[256]; @@ -240,7 +239,7 @@ daytime_stream(int s, struct servtab *se /* Discard service -- ignore data */ /* ARGSUSED */ -void +static void discard_dg(int s, struct servtab *sep __unused) { char buffer[BUFSIZE]; @@ -250,7 +249,7 @@ discard_dg(int s, struct servtab *sep __ /* Discard service -- ignore data */ /* ARGSUSED */ -void +static void discard_stream(int s, struct servtab *sep) { int ret; @@ -273,7 +272,7 @@ discard_stream(int s, struct servtab *se /* Echo service -- echo data back */ /* ARGSUSED */ -void +static void echo_dg(int s, struct servtab *sep) { char buffer[65536]; /* Should be sizeof(max datagram). */ @@ -294,7 +293,7 @@ echo_dg(int s, struct servtab *sep) /* Echo service -- echo data back */ /* ARGSUSED */ -void +static void echo_stream(int s, struct servtab *sep) { char buffer[BUFSIZE]; @@ -322,7 +321,7 @@ echo_stream(int s, struct servtab *sep) /* Generic ident_stream error-sending func */ /* ARGSUSED */ -void +static void iderror(int lport, int fport, int s, const char *er) { char *p; @@ -340,7 +339,7 @@ iderror(int lport, int fport, int s, con /* Ident service (AKA "auth") */ /* ARGSUSED */ -void +static void ident_stream(int s, struct servtab *sep) { struct utsname un; @@ -688,7 +687,7 @@ printit: * some seventy years Bell Labs was asleep. */ -uint32_t +static uint32_t machtime(void) { @@ -698,7 +697,7 @@ machtime(void) } /* ARGSUSED */ -void +static void machtime_dg(int s, struct servtab *sep) { uint32_t result; @@ -719,7 +718,7 @@ machtime_dg(int s, struct servtab *sep) } /* ARGSUSED */ -void +static void machtime_stream(int s, struct servtab *sep __unused) { uint32_t result; Modified:
svn commit: r310925 - head/sys/sys
Author: kib Date: Sat Dec 31 11:07:33 2016 New Revision: 310925 URL: https://svnweb.freebsd.org/changeset/base/310925 Log: Remove unused declaration. The setconf() implementation was removed by r52778 Nov 1 1999. Sponsored by: The FreeBSD Foundation MFC after:1 week Modified: head/sys/sys/conf.h Modified: head/sys/sys/conf.h == --- head/sys/sys/conf.h Sat Dec 31 11:06:19 2016(r310924) +++ head/sys/sys/conf.h Sat Dec 31 11:07:33 2016(r310925) @@ -285,7 +285,6 @@ int make_dev_physpath_alias(int _flags, const char *_physpath); void dev_lock(void); void dev_unlock(void); -void setconf(void); #ifdef KLD_MODULE #defineMAKEDEV_ETERNAL_KLD 0 ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r310931 - head/contrib/bsnmp/lib
Author: ngie Date: Sat Dec 31 11:13:00 2016 New Revision: 310931 URL: https://svnweb.freebsd.org/changeset/base/310931 Log: Use strdup in snmp_parse_server(..) when possible instead of malloc+strcpy This simplifies the code and mutes a Coverity warning about sc->cport being improperly allocated Reported by: Coverity CID: 1018247 MFC after:1 week Modified: head/contrib/bsnmp/lib/snmpclient.c Modified: head/contrib/bsnmp/lib/snmpclient.c == --- head/contrib/bsnmp/lib/snmpclient.c Sat Dec 31 11:12:26 2016 (r310930) +++ head/contrib/bsnmp/lib/snmpclient.c Sat Dec 31 11:13:00 2016 (r310931) @@ -1937,20 +1937,18 @@ snmp_parse_server(struct snmp_client *sc } /* port */ free(sc->cport); - if ((sc->cport = malloc(strlen(p + 1) + 1)) == NULL) { + if ((sc->cport = strdup(p + 1)) == NULL) { seterr(sc, "%s", strerror(errno)); return (-1); } - strcpy(sc->cport, p + 1); } else if (p > s) { /* host */ free(sc->chost); - if ((sc->chost = malloc(strlen(s) + 1)) == NULL) { + if ((sc->chost = strdup(strlen(s))) == NULL) { seterr(sc, "%s", strerror(errno)); return (-1); } - strcpy(sc->chost, s); } return (0); } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r310942 - head/contrib/bsnmp/lib
Author: ngie Date: Sat Dec 31 11:24:12 2016 New Revision: 310942 URL: https://svnweb.freebsd.org/changeset/base/310942 Log: Unbreak the build by passing the string to strdup, not its length MFC after:1 week X-MFC with: r310931 Pointyhat to: ngie Modified: head/contrib/bsnmp/lib/snmpclient.c Modified: head/contrib/bsnmp/lib/snmpclient.c == --- head/contrib/bsnmp/lib/snmpclient.c Sat Dec 31 11:23:43 2016 (r310941) +++ head/contrib/bsnmp/lib/snmpclient.c Sat Dec 31 11:24:12 2016 (r310942) @@ -1945,7 +1945,7 @@ snmp_parse_server(struct snmp_client *sc } else if (p > s) { /* host */ free(sc->chost); - if ((sc->chost = strdup(strlen(s))) == NULL) { + if ((sc->chost = strdup(s)) == NULL) { seterr(sc, "%s", strerror(errno)); return (-1); } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r310950 - head/contrib/bsnmp/snmp_mibII
Author: ngie Date: Sat Dec 31 11:50:36 2016 New Revision: 310950 URL: https://svnweb.freebsd.org/changeset/base/310950 Log: MIB-II: use strlcpy when copying interface names to .ifr_name .ifra_name is assumed to be NUL terminated; using strlcpy(3) ensures that it's indeed NUL terminated whereas strncpy does not. Tested and verified as follows with a combination of ifconfig, snmpget, and snmpset: % ifconfig create lo1 127.0.0.2/8 % SNMPARGS="-v 3 -n '' -u bsnmp -A bsnmptest -l authPriv -a sha -x des -X bsnmptest localhost" % snmpget $SNMPARGS IF-MIB::ifAdminStatus.4 IF-MIB::ifAdminStatus.4 = INTEGER: up(1) % snmpset $SNMPARGS IF-MIB::ifAdminStatus.4 i 2 IF-MIB::ifAdminStatus.4 = INTEGER: down(2) % snmpget $SNMPARGS IF-MIB::ifAdminStatus.4 IF-MIB::ifAdminStatus.4 = INTEGER: down(2) % snmpset $SNMPARGS IF-MIB::ifAdminStatus.4 i 1 IF-MIB::ifAdminStatus.4 = INTEGER: up(1) % snmpget $SNMPARGS IF-MIB::ifAdminStatus.4 IF-MIB::ifAdminStatus.4 = INTEGER: up(1) MFC after:2 weeks Reported by: Coverity CID: 1009652-1009656, 1349850 Modified: head/contrib/bsnmp/snmp_mibII/mibII.c head/contrib/bsnmp/snmp_mibII/mibII_interfaces.c Modified: head/contrib/bsnmp/snmp_mibII/mibII.c == --- head/contrib/bsnmp/snmp_mibII/mibII.c Sat Dec 31 11:42:57 2016 (r310949) +++ head/contrib/bsnmp/snmp_mibII/mibII.c Sat Dec 31 11:50:36 2016 (r310950) @@ -265,7 +265,7 @@ mib_if_admin(struct mibif *ifp, int up) { struct ifreq ifr; - strncpy(ifr.ifr_name, ifp->name, sizeof(ifr.ifr_name)); + strlcpy(ifr.ifr_name, ifp->name, sizeof(ifr.ifr_name)); if (ioctl(mib_netsock, SIOCGIFFLAGS, &ifr) == -1) { syslog(LOG_ERR, "SIOCGIFFLAGS(%s): %m", ifp->name); return (-1); @@ -515,7 +515,7 @@ mib_fetch_ifmib(struct mibif *ifp) } out: - strncpy(irr.ifr_name, ifp->name, sizeof(irr.ifr_name)); + strlcpy(irr.ifr_name, ifp->name, sizeof(irr.ifr_name)); irr.ifr_buffer.buffer = MIBIF_PRIV(ifp)->alias; irr.ifr_buffer.length = sizeof(MIBIF_PRIV(ifp)->alias); if (ioctl(mib_netsock, SIOCGIFDESCR, &irr) == -1) { @@ -1384,7 +1384,7 @@ siocaifaddr(char *ifname, struct in_addr struct sockaddr_in *sa; memset(&addreq, 0, sizeof(addreq)); - strncpy(addreq.ifra_name, ifname, sizeof(addreq.ifra_name)); + strlcpy(addreq.ifra_name, ifname, sizeof(addreq.ifra_name)); sa = (struct sockaddr_in *)(void *)&addreq.ifra_addr; sa->sin_family = AF_INET; @@ -1414,7 +1414,7 @@ siocdifaddr(const char *ifname, struct i struct sockaddr_in *sa; memset(&delreq, 0, sizeof(delreq)); - strncpy(delreq.ifr_name, ifname, sizeof(delreq.ifr_name)); + strlcpy(delreq.ifr_name, ifname, sizeof(delreq.ifr_name)); sa = (struct sockaddr_in *)(void *)&delreq.ifr_addr; sa->sin_family = AF_INET; sa->sin_len = sizeof(*sa); @@ -1433,7 +1433,7 @@ verify_ifa(const char *name, struct mibi struct sockaddr_in *sa; memset(&req, 0, sizeof(req)); - strncpy(req.ifr_name, name, sizeof(req.ifr_name)); + strlcpy(req.ifr_name, name, sizeof(req.ifr_name)); sa = (struct sockaddr_in *)(void *)&req.ifr_addr; sa->sin_family = AF_INET; sa->sin_len = sizeof(*sa); Modified: head/contrib/bsnmp/snmp_mibII/mibII_interfaces.c == --- head/contrib/bsnmp/snmp_mibII/mibII_interfaces.cSat Dec 31 11:42:57 2016(r310949) +++ head/contrib/bsnmp/snmp_mibII/mibII_interfaces.cSat Dec 31 11:50:36 2016(r310950) @@ -77,7 +77,7 @@ ifchange_func(struct snmp_context *ctx _ switch (op) { case SNMP_DEPOP_COMMIT: - strncpy(ifr.ifr_name, ifp->name, sizeof(ifr.ifr_name)); + strlcpy(ifr.ifr_name, ifp->name, sizeof(ifr.ifr_name)); if (ioctl(mib_netsock, SIOCGIFFLAGS, &ifr) == -1) { syslog(LOG_ERR, "GIFFLAGS(%s): %m", ifp->name); return (SNMP_ERR_GENERR); @@ -95,7 +95,7 @@ ifchange_func(struct snmp_context *ctx _ ifc->rb |= IFRB_FLAGS; } if (ifc->rb & IFRB_FLAGS) { - strncpy(ifr1.ifr_name, ifp->name, sizeof(ifr1.ifr_name)); + strlcpy(ifr1.ifr_name, ifp->name, sizeof(ifr1.ifr_name)); if (ioctl(mib_netsock, SIOCGIFFLAGS, &ifr1) == -1) { syslog(LOG_ERR, "GIFFLAGS(%s): %m", ifp->name); return (SNMP_ERR_GENERR); @@ -116,7 +116,7 @@ ifchange_func(struct snmp_context *ctx _ case SNMP_DEPOP_ROLLBACK: if (ifc->rb & IFRB_FLAGS) { - strncpy(ifr.ifr_name, ifp->name, s
svn commit: r310952 - head/contrib/bsnmp/snmp_mibII
Author: ngie Date: Sat Dec 31 12:03:25 2016 New Revision: 310952 URL: https://svnweb.freebsd.org/changeset/base/310952 Log: MIB-II: use strlcpy instead of strcpy when copying {descr,name} This is of course to avoid buffer overruns The remaining strcpy instance in the module needs to be audited for correctness MFC after:1 week Reported by: Coverity CID: 1006827, 1006828 Modified: head/contrib/bsnmp/snmp_mibII/mibII.c Modified: head/contrib/bsnmp/snmp_mibII/mibII.c == --- head/contrib/bsnmp/snmp_mibII/mibII.c Sat Dec 31 11:57:37 2016 (r310951) +++ head/contrib/bsnmp/snmp_mibII/mibII.c Sat Dec 31 12:03:25 2016 (r310952) @@ -204,7 +204,7 @@ mib_if_set_dyn(const char *name) return; if ((d = malloc(sizeof(*d))) == NULL) err(1, NULL); - strcpy(d->name, name); + strlcpy(d->name, name, sizeof(d->name)); SLIST_INSERT_HEAD(&mibdynif_list, d, link); } @@ -774,8 +774,8 @@ mibif_create(u_int sysindex, const char memset(ifp->private, 0, sizeof(struct mibif_private)); ifp->sysindex = sysindex; - strcpy(ifp->name, name); - strcpy(ifp->descr, name); + strlcpy(ifp->name, name, sizeof(ifp->name)); + strlcpy(ifp->descr, name, sizeof(ifp->descr)); ifp->spec_oid = oid_zeroDotZero; map = NULL; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r310954 - head/usr.sbin/bsnmpd/tools/libbsnmptools
Author: ngie Date: Sat Dec 31 12:14:25 2016 New Revision: 310954 URL: https://svnweb.freebsd.org/changeset/base/310954 Log: Set value->v.octetstring.len to a correct value on malloc success/failure The previous code always set value->v.octetstring.len to len, regardless of the result from the malloc call. This misleads the caller on malloc failure. Set .len to len on success and 0 on failure. MFC after:1 week Reported by: Coverity CID: 1007590 Modified: head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c Modified: head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c == --- head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c Sat Dec 31 12:06:27 2016(r310953) +++ head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c Sat Dec 31 12:14:25 2016(r310954) @@ -266,13 +266,13 @@ parse_octetstring(struct snmp_value *val return (-1); } - value->v.octetstring.len = len; - - if((value->v.octetstring.octets = malloc(len)) == NULL) { + if ((value->v.octetstring.octets = malloc(len)) == NULL) { + value->v.octetstring.len = 0; syslog(LOG_ERR, "malloc failed: %s", strerror(errno)); return (-1); } + value->v.octetstring.len = len; memcpy(value->v.octetstring.octets, val, len); value->syntax = SNMP_SYNTAX_OCTETSTRING; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r310957 - head/contrib/bsnmp/snmpd
Author: ngie Date: Sat Dec 31 12:18:17 2016 New Revision: 310957 URL: https://svnweb.freebsd.org/changeset/base/310957 Log: Use strlcpy when copying `com` to pdu->community to avoid potential buffer overruns MFC after:1 week Reported by: Coverity CID: 1006823, 1006824 Modified: head/contrib/bsnmp/snmpd/trap.c Modified: head/contrib/bsnmp/snmpd/trap.c == --- head/contrib/bsnmp/snmpd/trap.c Sat Dec 31 12:16:21 2016 (r310956) +++ head/contrib/bsnmp/snmpd/trap.c Sat Dec 31 12:18:17 2016 (r310957) @@ -422,7 +422,7 @@ snmp_create_v1_trap(struct snmp_pdu *pdu const struct asn_oid *trap_oid) { memset(pdu, 0, sizeof(*pdu)); - strcpy(pdu->community, com); + strlcpy(pdu->community, com, sizeof(pdu->community)); pdu->version = SNMP_V1; pdu->type = SNMP_PDU_TRAP; @@ -439,7 +439,7 @@ snmp_create_v2_trap(struct snmp_pdu *pdu const struct asn_oid *trap_oid) { memset(pdu, 0, sizeof(*pdu)); - strcpy(pdu->community, com); + strlcpy(pdu->community, com, sizeof(pdu->community)); pdu->version = SNMP_V2c; pdu->type = SNMP_PDU_TRAP2; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r310958 - head/contrib/bsnmp/snmpd
Author: ngie Date: Sat Dec 31 12:30:14 2016 New Revision: 310958 URL: https://svnweb.freebsd.org/changeset/base/310958 Log: Initialize ret to SNMPD_INPUT_OK at the top of snmp_input_start(..) to avoid returning an uninitialized value There are some really complicated, snakey if-statements combined with switch statements that could result in an invalid value being returned as `ret` MFC after:1 week Reported by: Coverity CID: 1006551 Modified: head/contrib/bsnmp/snmpd/main.c Modified: head/contrib/bsnmp/snmpd/main.c == --- head/contrib/bsnmp/snmpd/main.c Sat Dec 31 12:18:17 2016 (r310957) +++ head/contrib/bsnmp/snmpd/main.c Sat Dec 31 12:30:14 2016 (r310958) @@ -492,6 +492,8 @@ snmp_input_start(const u_char *buf, size b.asn_cptr = buf; b.asn_len = len; + ret = SNMPD_INPUT_OK; + /* look whether we have enough bytes for the entire PDU. */ switch (sret = snmp_pdu_snoop(&b)) { @@ -520,8 +522,6 @@ snmp_input_start(const u_char *buf, size } code = snmp_pdu_decode_scoped(&b, pdu, ip); - ret = SNMPD_INPUT_OK; - decoded: snmpd_stats.inPkts++; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r310960 - head/contrib/bsnmp/snmpd
Author: ngie Date: Sat Dec 31 12:37:53 2016 New Revision: 310960 URL: https://svnweb.freebsd.org/changeset/base/310960 Log: Similar to r310954, set .len to 0 on malloc failure and to `len` only on success MFC after:1 week Modified: head/contrib/bsnmp/snmpd/export.c Modified: head/contrib/bsnmp/snmpd/export.c == --- head/contrib/bsnmp/snmpd/export.c Sat Dec 31 12:32:50 2016 (r310959) +++ head/contrib/bsnmp/snmpd/export.c Sat Dec 31 12:37:53 2016 (r310960) @@ -114,9 +114,11 @@ string_get(struct snmp_value *value, con } if (len == -1) len = strlen(ptr); - value->v.octetstring.len = (u_long)len; - if ((value->v.octetstring.octets = malloc((size_t)len)) == NULL) + if ((value->v.octetstring.octets = malloc((size_t)len)) == NULL) { + value->v.octetstring.len = 0; return (SNMP_ERR_RES_UNAVAIL); + } + value->v.octetstring.len = (u_long)len; memcpy(value->v.octetstring.octets, ptr, (size_t)len); return (SNMP_ERR_NOERROR); } @@ -138,9 +140,11 @@ string_get_max(struct snmp_value *value, len = strlen(ptr); if ((size_t)len > maxlen) len = maxlen; - value->v.octetstring.len = (u_long)len; - if ((value->v.octetstring.octets = malloc((size_t)len)) == NULL) + if ((value->v.octetstring.octets = malloc((size_t)len)) == NULL) { + value->v.octetstring.len = 0; return (SNMP_ERR_RES_UNAVAIL); + } + value->v.octetstring.len = (u_long)len; memcpy(value->v.octetstring.octets, ptr, (size_t)len); return (SNMP_ERR_NOERROR); } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r310961 - head/sbin/sysctl
Author: avos Date: Sat Dec 31 12:39:15 2016 New Revision: 310961 URL: https://svnweb.freebsd.org/changeset/base/310961 Log: sysctl(8): fix typename for uint32_t. MFC after:5 days. Modified: head/sbin/sysctl/sysctl.c Modified: head/sbin/sysctl/sysctl.c == --- head/sbin/sysctl/sysctl.c Sat Dec 31 12:37:53 2016(r310960) +++ head/sbin/sysctl/sysctl.c Sat Dec 31 12:39:15 2016(r310961) @@ -114,7 +114,7 @@ static const char *ctl_typename[CTLTYPE+ [CTLTYPE_ULONG] = "unsigned long", [CTLTYPE_U8] = "uint8_t", [CTLTYPE_U16] = "uint16_t", - [CTLTYPE_U32] = "uint16_t", + [CTLTYPE_U32] = "uint32_t", [CTLTYPE_U64] = "uint64_t", [CTLTYPE_S8] = "int8_t", [CTLTYPE_S16] = "int16_t", ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r310963 - in head: . sys/sys
Author: bapt Date: Sat Dec 31 12:41:42 2016 New Revision: 310963 URL: https://svnweb.freebsd.org/changeset/base/310963 Log: Bump copyright year. Happy New Year 2017! Modified: head/COPYRIGHT head/sys/sys/copyright.h Modified: head/COPYRIGHT == --- head/COPYRIGHT Sat Dec 31 12:39:34 2016(r310962) +++ head/COPYRIGHT Sat Dec 31 12:41:42 2016(r310963) @@ -4,7 +4,7 @@ The compilation of software known as FreeBSD is distributed under the following terms: -Copyright (c) 1992-2016 The FreeBSD Project. All rights reserved. +Copyright (c) 1992-2017 The FreeBSD Project. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions Modified: head/sys/sys/copyright.h == --- head/sys/sys/copyright.hSat Dec 31 12:39:34 2016(r310962) +++ head/sys/sys/copyright.hSat Dec 31 12:41:42 2016(r310963) @@ -34,7 +34,7 @@ /* FreeBSD */ #define COPYRIGHT_FreeBSD \ - "Copyright (c) 1992-2016 The FreeBSD Project.\n" + "Copyright (c) 1992-2017 The FreeBSD Project.\n" /* Foundation */ #defineTRADEMARK_Foundation \ ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r310972 - head/sys/boot/fdt/dts/arm
Author: jmcneill Date: Sat Dec 31 13:10:06 2016 New Revision: 310972 URL: https://svnweb.freebsd.org/changeset/base/310972 Log: Fix a typo in the third address of the reg property for the usbphy node. MFC after:1 week Modified: head/sys/boot/fdt/dts/arm/a83t.dtsi Modified: head/sys/boot/fdt/dts/arm/a83t.dtsi == --- head/sys/boot/fdt/dts/arm/a83t.dtsi Sat Dec 31 13:07:09 2016 (r310971) +++ head/sys/boot/fdt/dts/arm/a83t.dtsi Sat Dec 31 13:10:06 2016 (r310972) @@ -178,7 +178,7 @@ compatible = "allwinner,sun8i-a83t-usb-phy"; reg = <0x01c19400 0x2c>, <0x01c1a800 0x4>, - <0x01c1a800 0x4>; + <0x01c1b800 0x4>; clocks = <&usb_clk 8>, <&usb_clk 9>, <&usb_clk 10>, ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r310974 - head/usr.sbin/syslogd
Author: hrs Date: Sat Dec 31 13:15:52 2016 New Revision: 310974 URL: https://svnweb.freebsd.org/changeset/base/310974 Log: - Use more descriptive names for variables. - Set O_CLOEXEC to the signal pipe and /dev/klog. - Use a single signal handler to catch both SIGHUP and SIGCHLD. - Fix a bug which did FD_SET() the writer-end of the pipe. Modified: head/usr.sbin/syslogd/syslogd.c Modified: head/usr.sbin/syslogd/syslogd.c == --- head/usr.sbin/syslogd/syslogd.c Sat Dec 31 13:10:08 2016 (r310973) +++ head/usr.sbin/syslogd/syslogd.c Sat Dec 31 13:15:52 2016 (r310974) @@ -321,7 +321,7 @@ static int LogFacPri; /* Put facility an static int KeepKernFac;/* Keep remotely logged kernel facility */ static int needdofsync = 0; /* Are any file(s) waiting to be fsynced? */ static struct pidfh *pfh; -static int sigp[2];/* Pipe to catch a signal during select(). */ +static int sigpipe[2]; /* Pipe to catch a signal during select(). */ static volatile sig_atomic_t MarkSet, WantDie, WantInitialize, WantReapchild; @@ -341,7 +341,6 @@ static void dofsync(void); static voiddomark(int); static voidfprintlog(struct filed *, int, const char *); static voidinit(int); -static voidinit_sh(int); static voidlogerror(const char *); static voidlogmsg(int, const char *, const char *, int); static voidlog_deadchild(pid_t, int, const char *); @@ -350,12 +349,12 @@ static intsocksetup(struct peer *); static int socklist_recv_file(struct socklist *); static int socklist_recv_sock(struct socklist *); static int socklist_recv_signal(struct socklist *); +static voidsighandler(int); static int skip_message(const char *, const char *, int); static voidprintline(const char *, char *, int); static voidprintsys(char *); static int p_open(const char *, pid_t *); static voidreapchild(int); -static voidreapchild_sh(int); static const char *ttymsg_check(struct iovec *, int, char *, int); static voidusage(void); static int validate(struct sockaddr *, const char *); @@ -582,18 +581,18 @@ main(int argc, char *argv[]) usage(); /* Pipe to catch a signal during select(). */ - s = pipe2(sigp, O_NONBLOCK); + s = pipe2(sigpipe, O_CLOEXEC); if (s < 0) { err(1, "cannot open a pipe for signals"); } else { addsock(NULL, 0, &(struct socklist){ - .sl_socket = sigp[1], + .sl_socket = sigpipe[0], .sl_recv = socklist_recv_signal }); } /* Listen by default: /dev/klog. */ - s = open(_PATH_KLOG, O_RDONLY|O_NONBLOCK, 0); + s = open(_PATH_KLOG, O_RDONLY | O_NONBLOCK | O_CLOEXEC, 0); if (s < 0) { dprintf("can't open %s (%d)\n", _PATH_KLOG, errno); } else { @@ -646,8 +645,8 @@ main(int argc, char *argv[]) (void)signal(SIGTERM, dodie); (void)signal(SIGINT, Debug ? dodie : SIG_IGN); (void)signal(SIGQUIT, Debug ? dodie : SIG_IGN); - (void)signal(SIGHUP, init_sh); - (void)signal(SIGCHLD, reapchild_sh); + (void)signal(SIGHUP, sighandler); + (void)signal(SIGCHLD, sighandler); (void)signal(SIGALRM, domark); (void)signal(SIGPIPE, SIG_IGN); /* We'll catch EPIPE instead. */ (void)alarm(TIMERINTVL); @@ -717,12 +716,31 @@ static int socklist_recv_signal(struct socklist *sl __unused) { ssize_t len; - static char buf[BUFSIZ]; - - /* Clear an wake-up signal by reading dummy data. */ - while ((len = read(sigp[0], buf, sizeof(buf))) > 0) - ; + int i, nsig, signo; + if (ioctl(sigpipe[0], FIONREAD, &i) != 0) { + logerror("ioctl(FIONREAD)"); + err(1, "signal pipe read failed"); + } + nsig = i / sizeof(signo); + dprintf("# of received signals = %d\n", nsig); + for (i = 0; i < nsig; i++) { + len = read(sigpipe[0], &signo, sizeof(signo)); + if (len != sizeof(signo)) { + logerror("signal pipe read failed"); + err(1, "signal pipe read failed"); + } + dprintf("Received signal: %d from fd=%d\n", signo, + sigpipe[0]); + switch (signo) { + case SIGHUP: + WantInitialize = 1; + break; + case SIGCHLD: + WantReapchild = 1; + break; + } + } return (0); } @@ -1512,17 +1530,6 @@ ttymsg_check(struct iovec *iov, int iovc } static void -reapchild_sh(int signo) -{ - static char buf[BUFSIZ]; - - WantReapchild = signo; - /* Send an wake-up signal to the select() loop. */ -
svn commit: r310976 - head/lib/libc/locale
Author: pfg Date: Sat Dec 31 15:30:00 2016 New Revision: 310976 URL: https://svnweb.freebsd.org/changeset/base/310976 Log: Move __hidden attribute towards the end of the declaration. Apple had them at the start but moving them to the end is better for faster reading and fits better what is done in other FreeBSD headers. MFC after:5 days Modified: head/lib/libc/locale/mblocal.h Modified: head/lib/libc/locale/mblocal.h == --- head/lib/libc/locale/mblocal.h Sat Dec 31 13:23:28 2016 (r310975) +++ head/lib/libc/locale/mblocal.h Sat Dec 31 15:30:00 2016 (r310976) @@ -65,18 +65,18 @@ extern struct xlocale_ctype __xlocale_gl /* * Rune initialization function prototypes. */ -__hidden int _none_init(struct xlocale_ctype *, _RuneLocale *); -__hidden int _ascii_init(struct xlocale_ctype *, _RuneLocale *); -__hidden int _UTF8_init(struct xlocale_ctype *, _RuneLocale *); -__hidden int _EUC_CN_init(struct xlocale_ctype *, _RuneLocale *); -__hidden int _EUC_JP_init(struct xlocale_ctype *, _RuneLocale *); -__hidden int _EUC_KR_init(struct xlocale_ctype *, _RuneLocale *); -__hidden int _EUC_TW_init(struct xlocale_ctype *, _RuneLocale *); -__hidden int _GB18030_init(struct xlocale_ctype *, _RuneLocale *); -__hidden int _GB2312_init(struct xlocale_ctype *, _RuneLocale *); -__hidden int _GBK_init(struct xlocale_ctype *, _RuneLocale *); -__hidden int _BIG5_init(struct xlocale_ctype *, _RuneLocale *); -__hidden int _MSKanji_init(struct xlocale_ctype *, _RuneLocale *); +int_none_init(struct xlocale_ctype *, _RuneLocale *) __hidden; +int_UTF8_init(struct xlocale_ctype *, _RuneLocale *) __hidden; +int_EUC_CN_init(struct xlocale_ctype *, _RuneLocale *) __hidden; +int_EUC_JP_init(struct xlocale_ctype *, _RuneLocale *) __hidden; +int_EUC_KR_init(struct xlocale_ctype *, _RuneLocale *) __hidden; +int_EUC_TW_init(struct xlocale_ctype *, _RuneLocale *) __hidden; +int_GB18030_init(struct xlocale_ctype *, _RuneLocale *) __hidden; +int_GB2312_init(struct xlocale_ctype *, _RuneLocale *) __hidden; +int_GBK_init(struct xlocale_ctype *, _RuneLocale *) __hidden; +int_BIG5_init(struct xlocale_ctype *, _RuneLocale *) __hidden; +int_MSKanji_init(struct xlocale_ctype *, _RuneLocale *) __hidden; +int_ascii_init(struct xlocale_ctype *, _RuneLocale *) __hidden; typedef size_t (*mbrtowc_pfn_t)(wchar_t * __restrict, const char * __restrict, size_t, mbstate_t * __restrict); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r310977 - head/sys/sys
Author: pfg Date: Sat Dec 31 15:58:15 2016 New Revision: 310977 URL: https://svnweb.freebsd.org/changeset/base/310977 Log: Addition of clang nullability qualifiers. Add two new qualifiers for use by the static checkers: _Nonnull The _Nonnull nullability qualifier indicates that null is not a meaningful value for a value of the _Nonnull pointer type. _Nullable The _Nullable nullability qualifier indicates that a value of the _Nullable pointer type can be null. These were introduced in Clang 3.7. For more information, see: http://clang.llvm.org/docs/AttributeReference.html#nonnull We add these now without using them so that the GCC ports have time to pick up the header change. Hinted by:Android Bionic libc [1] Also seen in: Apple's Libc-1158.20.4 [1] https://github.com/android/platform_bionic/commit/baa2a973bd776a51bb05a8590ab05d86eea7b321 Modified: head/sys/sys/cdefs.h Modified: head/sys/sys/cdefs.h == --- head/sys/sys/cdefs.hSat Dec 31 15:30:00 2016(r310976) +++ head/sys/sys/cdefs.hSat Dec 31 15:58:15 2016(r310977) @@ -804,6 +804,14 @@ #endif /* + * Nullability qualifiers: currently only supported by Clang. + */ +#if !(defined(__clang__) && __has_feature(nullability)) +#define_Nonnull +#define_Nullable +#endif + +/* * Type Safety Checking * * Clang provides additional attributes to enable checking type safety ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r310982 - head/sys/vm
Author: kib Date: Sat Dec 31 19:30:22 2016 New Revision: 310982 URL: https://svnweb.freebsd.org/changeset/base/310982 Log: Ansify vm/vm_pager.c. Style. Reviewed by: alc Sponsored by: The FreeBSD Foundation MFC after:1 week Modified: head/sys/vm/vm_pager.c Modified: head/sys/vm/vm_pager.c == --- head/sys/vm/vm_pager.c Sat Dec 31 17:05:09 2016(r310981) +++ head/sys/vm/vm_pager.c Sat Dec 31 19:30:22 2016(r310982) @@ -109,43 +109,35 @@ static vm_object_t dead_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot, vm_ooffset_t off, struct ucred *cred) { - return NULL; + + return (NULL); } static void -dead_pager_putpages(object, m, count, flags, rtvals) - vm_object_t object; - vm_page_t *m; - int count; - int flags; - int *rtvals; +dead_pager_putpages(vm_object_t object, vm_page_t *m, int count, +int flags, int *rtvals) { int i; - for (i = 0; i < count; i++) { + for (i = 0; i < count; i++) rtvals[i] = VM_PAGER_AGAIN; - } } static int -dead_pager_haspage(object, pindex, prev, next) - vm_object_t object; - vm_pindex_t pindex; - int *prev; - int *next; +dead_pager_haspage(vm_object_t object, vm_pindex_t pindex, int *prev, int *next) { - if (prev) + + if (prev != NULL) *prev = 0; - if (next) + if (next != NULL) *next = 0; - return FALSE; + return (FALSE); } static void -dead_pager_dealloc(object) - vm_object_t object; +dead_pager_dealloc(vm_object_t object) { - return; + } static struct pagerops deadpagerops = { @@ -181,7 +173,7 @@ static int bswneeded; vm_offset_t swapbkva; /* swap buffers kva */ void -vm_pager_init() +vm_pager_init(void) { struct pagerops **pgops; @@ -191,11 +183,11 @@ vm_pager_init() */ for (pgops = pagertab; pgops < &pagertab[nitems(pagertab)]; pgops++) if ((*pgops)->pgo_init != NULL) - (*(*pgops)->pgo_init) (); + (*(*pgops)->pgo_init)(); } void -vm_pager_bufferinit() +vm_pager_bufferinit(void) { struct buf *bp; int i; @@ -232,7 +224,7 @@ vm_pager_allocate(objtype_t type, void * ops = pagertab[type]; if (ops) - ret = (*ops->pgo_alloc) (handle, size, prot, off, cred); + ret = (*ops->pgo_alloc)(handle, size, prot, off, cred); else ret = NULL; return (ret); @@ -242,8 +234,7 @@ vm_pager_allocate(objtype_t type, void * * The object must be locked. */ void -vm_pager_deallocate(object) - vm_object_t object; +vm_pager_deallocate(vm_object_t object) { VM_OBJECT_ASSERT_WLOCKED(object); @@ -366,12 +357,13 @@ vm_pager_object_lookup(struct pagerlst * static void initpbuf(struct buf *bp) { + KASSERT(bp->b_bufobj == NULL, ("initpbuf with bufobj")); KASSERT(bp->b_vp == NULL, ("initpbuf with vp")); bp->b_rcred = NOCRED; bp->b_wcred = NOCRED; bp->b_qindex = 0; /* On no queue (QUEUE_NONE) */ - bp->b_kvabase = (caddr_t) (MAXPHYS * (bp - swbuf)) + swapbkva; + bp->b_kvabase = (caddr_t)(MAXPHYS * (bp - swbuf)) + swapbkva; bp->b_data = bp->b_kvabase; bp->b_kvasize = MAXPHYS; bp->b_flags = 0; @@ -404,9 +396,8 @@ getpbuf(int *pfreecnt) struct buf *bp; mtx_lock(&pbuf_mtx); - for (;;) { - if (pfreecnt) { + if (pfreecnt != NULL) { while (*pfreecnt == 0) { msleep(pfreecnt, &pbuf_mtx, PVM, "wswbuf0", 0); } @@ -424,9 +415,8 @@ getpbuf(int *pfreecnt) if (pfreecnt) --*pfreecnt; mtx_unlock(&pbuf_mtx); - initpbuf(bp); - return bp; + return (bp); } /* @@ -446,14 +436,10 @@ trypbuf(int *pfreecnt) return NULL; } TAILQ_REMOVE(&bswlist, bp, b_freelist); - --*pfreecnt; - mtx_unlock(&pbuf_mtx); - initpbuf(bp); - - return bp; + return (bp); } /* ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r310983 - head/sys/kern
Author: mjg Date: Sat Dec 31 19:59:31 2016 New Revision: 310983 URL: https://svnweb.freebsd.org/changeset/base/310983 Log: vfs: switch nodes_created, recycles_count and free_owe_inact to counter(9) Reviewed by: kib Modified: head/sys/kern/vfs_subr.c Modified: head/sys/kern/vfs_subr.c == --- head/sys/kern/vfs_subr.cSat Dec 31 19:30:22 2016(r310982) +++ head/sys/kern/vfs_subr.cSat Dec 31 19:59:31 2016(r310983) @@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -124,9 +125,9 @@ static unsigned longnumvnodes; SYSCTL_ULONG(_vfs, OID_AUTO, numvnodes, CTLFLAG_RD, &numvnodes, 0, "Number of vnodes in existence"); -static u_long vnodes_created; -SYSCTL_ULONG(_vfs, OID_AUTO, vnodes_created, CTLFLAG_RD, &vnodes_created, -0, "Number of vnodes created by getnewvnode"); +static counter_u64_t vnodes_created; +SYSCTL_COUNTER_U64(_vfs, OID_AUTO, vnodes_created, CTLFLAG_RD, &vnodes_created, +"Number of vnodes created by getnewvnode"); static u_long mnt_free_list_batch = 128; SYSCTL_ULONG(_vfs, OID_AUTO, mnt_free_list_batch, CTLFLAG_RW, @@ -180,8 +181,8 @@ static u_long freevnodes; SYSCTL_ULONG(_vfs, OID_AUTO, freevnodes, CTLFLAG_RD, &freevnodes, 0, "Number of \"free\" vnodes"); -static u_long recycles_count; -SYSCTL_ULONG(_vfs, OID_AUTO, recycles, CTLFLAG_RD, &recycles_count, 0, +static counter_u64_t recycles_count; +SYSCTL_COUNTER_U64(_vfs, OID_AUTO, recycles, CTLFLAG_RD, &recycles_count, "Number of vnodes recycled to meet vnode cache targets"); /* @@ -193,8 +194,8 @@ static int reassignbufcalls; SYSCTL_INT(_vfs, OID_AUTO, reassignbufcalls, CTLFLAG_RW, &reassignbufcalls, 0, "Number of calls to reassignbuf"); -static u_long free_owe_inact; -SYSCTL_ULONG(_vfs, OID_AUTO, free_owe_inact, CTLFLAG_RD, &free_owe_inact, 0, +static counter_u64_t free_owe_inact; +SYSCTL_COUNTER_U64(_vfs, OID_AUTO, free_owe_inact, CTLFLAG_RD, &free_owe_inact, "Number of times free vnodes kept on active list due to VFS " "owing inactivation"); @@ -476,6 +477,11 @@ vntblinit(void *dummy __unused) NULL, NULL, pctrie_zone_init, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE | UMA_ZONE_VM); uma_prealloc(buf_trie_zone, nbuf); + + vnodes_created = counter_u64_alloc(M_WAITOK); + recycles_count = counter_u64_alloc(M_WAITOK); + free_owe_inact = counter_u64_alloc(M_WAITOK); + /* * Initialize the filesystem syncer. */ @@ -922,7 +928,7 @@ vlrureclaim(struct mount *mp, int reclai } KASSERT((vp->v_iflag & VI_DOOMED) == 0, ("VI_DOOMED unexpectedly detected in vlrureclaim()")); - atomic_add_long(&recycles_count, 1); + counter_u64_add(recycles_count, 1); vgonel(vp); VOP_UNLOCK(vp, 0); vdropl(vp); @@ -1287,7 +1293,7 @@ vtryrecycle(struct vnode *vp) return (EBUSY); } if ((vp->v_iflag & VI_DOOMED) == 0) { - atomic_add_long(&recycles_count, 1); + counter_u64_add(recycles_count, 1); vgonel(vp); } VOP_UNLOCK(vp, LK_INTERLOCK); @@ -1446,7 +1452,7 @@ getnewvnode(const char *tag, struct moun atomic_add_long(&numvnodes, 1); mtx_unlock(&vnode_free_list_mtx); alloc: - atomic_add_long(&vnodes_created, 1); + counter_u64_add(vnodes_created, 1); vp = (struct vnode *) uma_zalloc(vnode_zone, M_WAITOK); /* * Locks are given the generic name "vnode" when created. @@ -2938,7 +2944,7 @@ _vdrop(struct vnode *vp, bool locked) mtx_unlock(&mp->mnt_listmtx); } else { VI_UNLOCK(vp); - atomic_add_long(&free_owe_inact, 1); + counter_u64_add(free_owe_inact, 1); } return; } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r310984 - head/lib/libc/net
Author: ngie Date: Sat Dec 31 21:00:08 2016 New Revision: 310984 URL: https://svnweb.freebsd.org/changeset/base/310984 Log: Use calloc instead of malloc + memset(.., 0, ..) MFC after:1 week Modified: head/lib/libc/net/getaddrinfo.c Modified: head/lib/libc/net/getaddrinfo.c == --- head/lib/libc/net/getaddrinfo.c Sat Dec 31 19:59:31 2016 (r310983) +++ head/lib/libc/net/getaddrinfo.c Sat Dec 31 21:00:08 2016 (r310984) @@ -691,9 +691,8 @@ reorder(struct addrinfo *sentinel) return(n); /* allocate a temporary array for sort and initialization of it. */ - if ((aio = malloc(sizeof(*aio) * n)) == NULL) + if ((aio = calloc(1, sizeof(*aio) * n)) == NULL) return(n); /* give up reordering */ - memset(aio, 0, sizeof(*aio) * n); /* retrieve address selection policy from the kernel */ TAILQ_INIT(&policyhead); @@ -1449,9 +1448,8 @@ copy_ai(const struct addrinfo *pai) size_t l; l = sizeof(*ai) + pai->ai_addrlen; - if ((ai = (struct addrinfo *)malloc(l)) == NULL) + if ((ai = calloc(1, l)) == NULL) return NULL; - memset(ai, 0, l); memcpy(ai, pai, sizeof(*ai)); ai->ai_addr = (struct sockaddr *)(void *)(ai + 1); memcpy(ai->ai_addr, pai->ai_addr, pai->ai_addrlen); @@ -1874,8 +1872,7 @@ addrinfo_unmarshal_func(char *buffer, si size = new_ai.ai_addrlen + sizeof(struct addrinfo) + _ALIGNBYTES; - sentinel = (struct addrinfo *)malloc(size); - memset(sentinel, 0, size); + sentinel = calloc(1, size); memcpy(sentinel, &new_ai, sizeof(struct addrinfo)); sentinel->ai_addr = (struct sockaddr *)_ALIGN((char *)sentinel + @@ -1888,8 +1885,7 @@ addrinfo_unmarshal_func(char *buffer, si memcpy(&size, p, sizeof(size_t)); p += sizeof(size_t); - sentinel->ai_canonname = (char *)malloc(size + 1); - memset(sentinel->ai_canonname, 0, size + 1); + sentinel->ai_canonname = calloc(1, size + 1); memcpy(sentinel->ai_canonname, p, size); p += size; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r310985 - head
Author: asomers Date: Sat Dec 31 21:31:58 2016 New Revision: 310985 URL: https://svnweb.freebsd.org/changeset/base/310985 Log: Update ObsoleteFiles.inc for r310803 MFC after:26 days X-MFC-with: 310803 Modified: head/ObsoleteFiles.inc Modified: head/ObsoleteFiles.inc == --- head/ObsoleteFiles.inc Sat Dec 31 21:00:08 2016(r310984) +++ head/ObsoleteFiles.inc Sat Dec 31 21:31:58 2016(r310985) @@ -40,6 +40,10 @@ # 20161230: libarchive ACL pax test renamed to test_acl_pax_posix1e.tar.uu OLD_FILES+=usr/tests/lib/libarchive/test_acl_pax.tar.uu +# 20161229: Three files from gnop tests consolidated into one +OLD_FILES+=usr/tests/sys/geom/class/nop/1_test.sh +OLD_FILES+=usr/tests/sys/geom/class/nop/2_test.sh +OLD_FILES+=usr/tests/sys/geom/class/nop/conf.sh # 20161217: new clang import which bumps version from 3.9.0 to 3.9.1. OLD_FILES+=usr/lib/clang/3.9.0/include/sanitizer/allocator_interface.h OLD_FILES+=usr/lib/clang/3.9.0/include/sanitizer/asan_interface.h ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r310984 - head/lib/libc/net
On 12/31/16 16:00, Ngie Cooper wrote: Author: ngie Date: Sat Dec 31 21:00:08 2016 New Revision: 310984 URL: https://svnweb.freebsd.org/changeset/base/310984 Log: Use calloc instead of malloc + memset(.., 0, ..) MFC after:1 week Modified: head/lib/libc/net/getaddrinfo.c Modified: head/lib/libc/net/getaddrinfo.c == --- head/lib/libc/net/getaddrinfo.c Sat Dec 31 19:59:31 2016 (r310983) +++ head/lib/libc/net/getaddrinfo.c Sat Dec 31 21:00:08 2016 (r310984) @@ -691,9 +691,8 @@ reorder(struct addrinfo *sentinel) return(n); /* allocate a temporary array for sort and initialization of it. */ - if ((aio = malloc(sizeof(*aio) * n)) == NULL) + if ((aio = calloc(1, sizeof(*aio) * n)) == NULL) return(n); /* give up reordering */ This should be calloc(n, sizeof(*aio))) FWIW, the other cases are not very useful. Generally, replacing any malloc(x) with a calloc(1, x) doesn't bring any advantage as it won't catch any overflow. Pedro. ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r310984 - head/lib/libc/net
> On Dec 31, 2016, at 13:49, Pedro Giffuni wrote: > > > > On 12/31/16 16:00, Ngie Cooper wrote: >> Author: ngie >> Date: Sat Dec 31 21:00:08 2016 >> New Revision: 310984 >> URL: https://svnweb.freebsd.org/changeset/base/310984 >> >> Log: >> Use calloc instead of malloc + memset(.., 0, ..) >> >> MFC after: 1 week >> >> Modified: >> head/lib/libc/net/getaddrinfo.c >> >> Modified: head/lib/libc/net/getaddrinfo.c >> == >> --- head/lib/libc/net/getaddrinfo.c Sat Dec 31 19:59:31 2016 >> (r310983) >> +++ head/lib/libc/net/getaddrinfo.c Sat Dec 31 21:00:08 2016 >> (r310984) >> @@ -691,9 +691,8 @@ reorder(struct addrinfo *sentinel) >> return(n); >> >> /* allocate a temporary array for sort and initialization of it. */ >> -if ((aio = malloc(sizeof(*aio) * n)) == NULL) >> +if ((aio = calloc(1, sizeof(*aio) * n)) == NULL) >> return(n); /* give up reordering */ > > This should be calloc(n, sizeof(*aio))) > > FWIW, the other cases are not very useful. > Generally, replacing any malloc(x) with a calloc(1, x) doesn't bring any > advantage as it won't catch any overflow. Yeah, that would have been better. The goal was to reduce complexity. I found some memory leaks with valgrind with bsnmp* last night involving getaddrinfo that I’m trying to chase down, and I noticed these while “in the neighborhood”. Thanks! -Ngie signature.asc Description: Message signed with OpenPGP using GPGMail
svn commit: r310986 - head/usr.sbin/bsnmpd/tools/libbsnmptools
Author: ngie Date: Sat Dec 31 22:18:33 2016 New Revision: 310986 URL: https://svnweb.freebsd.org/changeset/base/310986 Log: snmp_output_resp: style(9): sort variables by alignment MFC after:3 days Modified: head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c Modified: head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c == --- head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c Sat Dec 31 21:31:58 2016(r310985) +++ head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c Sat Dec 31 22:18:33 2016(r310986) @@ -2034,10 +2034,10 @@ int32_t snmp_output_resp(struct snmp_toolinfo *snmptoolctx, struct snmp_pdu *pdu, struct asn_oid *root) { - int32_t error; + struct snmp_object object; char p[ASN_OIDSTRLEN]; + int32_t error; uint32_t i; - struct snmp_object object; i = error = 0; while (i < pdu->nbindings) { ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r310987 - head/usr.sbin/bsnmpd/tools/libbsnmptools
Author: ngie Date: Sat Dec 31 22:46:17 2016 New Revision: 310987 URL: https://svnweb.freebsd.org/changeset/base/310987 Log: snmp_output_err_resp, snmp_output_resp: allocate `object` using calloc, not on the stack Some of the callers try to determine whether or not `object` is valid by testing the value for NULL, which will never be true if it's a stack value, so in order to be clear and correct down the call stack, use a heap allocated object. This also addresses a Coverity issue by initializing all of `object` via calloc MFC after:1 week Reported by: Coverity CID: 1006392 Modified: head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c Modified: head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c == --- head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c Sat Dec 31 22:18:33 2016(r310986) +++ head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c Sat Dec 31 22:46:17 2016(r310987) @@ -2003,20 +2003,25 @@ snmp_output_object(struct snmp_toolinfo void snmp_output_err_resp(struct snmp_toolinfo *snmptoolctx, struct snmp_pdu *pdu) { + struct snmp_object *object; char buf[ASN_OIDSTRLEN]; - struct snmp_object object; if (pdu == NULL || (pdu->error_index > (int32_t) pdu->nbindings)) { - fprintf(stdout,"Invalid error index in PDU\n"); + fprintf(stdout, "Invalid error index in PDU\n"); + return; + } + + if ((object = calloc(1, sizeof(struct snmp_object))) != NULL) { + fprintf(stdout, "calloc: %s", strerror(errno)); return; } fprintf(stdout, "Agent %s:%s returned error \n", snmp_client.chost, snmp_client.cport); - if (!ISSET_NUMERIC(snmptoolctx) && (snmp_fill_object(snmptoolctx, &object, + if (!ISSET_NUMERIC(snmptoolctx) && (snmp_fill_object(snmptoolctx, object, &(pdu->bindings[pdu->error_index - 1])) > 0)) - snmp_output_object(snmptoolctx, &object); + snmp_output_object(snmptoolctx, object); else { asn_oid2str_r(&(pdu->bindings[pdu->error_index - 1].var), buf); fprintf(stdout,"%s", buf); @@ -2028,17 +2033,23 @@ snmp_output_err_resp(struct snmp_toolinf fprintf(stdout, "%s\n", error_strings[pdu->error_status].str); else fprintf(stdout,"%s\n", error_strings[SNMP_ERR_UNKNOWN].str); + + free(object); + object = NULL; } int32_t snmp_output_resp(struct snmp_toolinfo *snmptoolctx, struct snmp_pdu *pdu, struct asn_oid *root) { - struct snmp_object object; + struct snmp_object *object; char p[ASN_OIDSTRLEN]; int32_t error; uint32_t i; + if ((object = calloc(1, sizeof(struct snmp_object))) == NULL) + return (-1); + i = error = 0; while (i < pdu->nbindings) { if (root != NULL && !(asn_is_suboid(root, @@ -2047,18 +2058,22 @@ snmp_output_resp(struct snmp_toolinfo *s if (GET_OUTPUT(snmptoolctx) != OUTPUT_QUIET) { if (!ISSET_NUMERIC(snmptoolctx) && - (snmp_fill_object(snmptoolctx, &object, + (snmp_fill_object(snmptoolctx, object, &(pdu->bindings[i])) > 0)) - snmp_output_object(snmptoolctx, &object); + snmp_output_object(snmptoolctx, object); else { asn_oid2str_r(&(pdu->bindings[i].var), p); fprintf(stdout, "%s", p); } } - error |= snmp_output_numval(snmptoolctx, &(pdu->bindings[i]), object.info); + error |= snmp_output_numval(snmptoolctx, &(pdu->bindings[i]), + object->info); i++; } + free(object); + object = NULL; + if (error) return (-1); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r310988 - head/contrib/bsnmp/lib
Author: ngie Date: Sat Dec 31 23:20:57 2016 New Revision: 310988 URL: https://svnweb.freebsd.org/changeset/base/310988 Log: snmp_discover_engine: fix up req/resp (PDU object) handling a bit - Call snmp_pdu_free on req and resp when done with the objects - Call snmp_pdu_free on req before calling snmp_pdu_create on it again MFC after:1 week Modified: head/contrib/bsnmp/lib/snmpclient.c Modified: head/contrib/bsnmp/lib/snmpclient.c == --- head/contrib/bsnmp/lib/snmpclient.c Sat Dec 31 22:46:17 2016 (r310987) +++ head/contrib/bsnmp/lib/snmpclient.c Sat Dec 31 23:20:57 2016 (r310988) @@ -1793,12 +1793,14 @@ snmp_discover_engine(char *passwd) return (0); } + snmp_pdu_free(&req); + snmp_pdu_create(&req, SNMP_PDU_GET); req.engine.engine_boots = 0; req.engine.engine_time = 0; if (snmp_dialog(&req, &resp) == -1) -return (-1); + return (-1); if (resp.version != req.version) { seterr(&snmp_client, "wrong version"); @@ -1813,6 +1815,9 @@ snmp_discover_engine(char *passwd) snmp_client.engine.engine_boots = resp.engine.engine_boots; snmp_client.engine.engine_time = resp.engine.engine_time; + snmp_pdu_free(&req); + snmp_pdu_free(&resp); + return (0); } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r310989 - head/usr.sbin/bsnmpd/tools/bsnmptools
Author: ngie Date: Sun Jan 1 00:23:43 2017 New Revision: 310989 URL: https://svnweb.freebsd.org/changeset/base/310989 Log: Call snmp_pdu_free on req/resp with a consistent, correct pattern - snmp_pdu_free should be called before snmp_pdu_create is called again - snmp_pdu_free should be called on the resp to snmp_dialog when successful Tested with the following bsnmp commands: % export SNMPUSER=bsnmp SNMPPASSWD=bsnmptest % SNMP_ARGS="-A proto=sha -C context='' -K -P proto=des -v 3 -r 0" % bsnmpset $SNMP_ARGS sysLocation="MyAgent" % bsnmpget $SNMP_ARGS sysLocation % bsnmpwalk $SNMP_ARGS MFC after:12 days X-MFC with: r310729, r310892, r310894 Modified: head/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c Modified: head/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c == --- head/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.cSat Dec 31 23:20:57 2016(r310988) +++ head/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.cSun Jan 1 00:23:43 2017(r310989) @@ -400,13 +400,16 @@ snmptool_get(struct snmp_toolinfo *snmpt if (snmp_parse_resp(&resp, &req) >= 0) { snmp_output_resp(snmptoolctx, &resp, NULL); + snmp_pdu_free(&resp); break; } snmp_output_err_resp(snmptoolctx, &resp); if (GET_PDUTYPE(snmptoolctx) == SNMP_PDU_GETBULK || - !ISSET_RETRY(snmptoolctx)) + !ISSET_RETRY(snmptoolctx)) { + snmp_pdu_free(&resp); break; + } /* * Loop through the object list and set object->error to the @@ -414,8 +417,10 @@ snmptool_get(struct snmp_toolinfo *snmpt */ if (snmp_object_seterror(snmptoolctx, &(resp.bindings[resp.error_index - 1]), - resp.error_status) <= 0) + resp.error_status) <= 0) { + snmp_pdu_free(&resp); break; + } fprintf(stderr, "Retrying...\n"); snmp_pdu_free(&resp); @@ -423,7 +428,6 @@ snmptool_get(struct snmp_toolinfo *snmpt } snmp_pdu_free(&req); - snmp_pdu_free(&resp); return (0); } @@ -500,8 +504,10 @@ snmptool_walk(struct snmp_toolinfo *snmp outputs += rc; - if ((u_int)rc < resp.nbindings) + if ((u_int)rc < resp.nbindings) { + snmp_pdu_free(&resp); break; + } snmpwalk_nextpdu_create(op, &(resp.bindings[resp.nbindings - 1].var), &req); @@ -515,10 +521,11 @@ snmptool_walk(struct snmp_toolinfo *snmp if (outputs == 0) { snmpwalk_nextpdu_create(SNMP_PDU_GET, &root, &req); if (snmp_dialog(&req, &resp) == SNMP_CODE_OK) { - if (snmp_parse_resp(&resp,&req) < 0) + if (snmp_parse_resp(&resp, &req) < 0) snmp_output_err_resp(snmptoolctx, &resp); else - snmp_output_resp(snmptoolctx, &(resp), NULL); + snmp_output_resp(snmptoolctx, &resp, + NULL); snmp_pdu_free(&resp); } else warn("Snmp dialog"); @@ -534,7 +541,6 @@ snmptool_walk(struct snmp_toolinfo *snmp } snmp_pdu_free(&req); - snmp_pdu_free(&resp); if (rc == 0) return (0); @@ -1094,25 +1100,29 @@ snmptool_set(struct snmp_toolinfo *snmpt if (snmp_pdu_check(&req, &resp) > 0) { if (GET_OUTPUT(snmptoolctx) != OUTPUT_QUIET) snmp_output_resp(snmptoolctx, &resp, NULL); + snmp_pdu_free(&resp); break; } snmp_output_err_resp(snmptoolctx, &resp); - if (!ISSET_RETRY(snmptoolctx)) + if (!ISSET_RETRY(snmptoolctx)) { + snmp_pdu_free(&resp); break; + } if (snmp_object_seterror(snmptoolctx, &(resp.bindings[resp.error_index - 1]), - resp.error_status) <= 0) + resp.error_status) <= 0) { + snmp_pdu_free(&resp); break; + } fprintf(stderr, "Retrying...\n"); snmp_pdu_free(&req); - snmp_pdu_free(&resp);
svn commit: r310994 - head/tests/sys/vfs
Author: ngie Date: Sun Jan 1 04:01:27 2017 New Revision: 310994 URL: https://svnweb.freebsd.org/changeset/base/310994 Log: Make sys/vfs/lookup_cap_dotdot actually work with "kyua test" The tests don't work when reading/writing to file descriptors in the sandbox after entering capability mode (and wouldn't have, regardless of the framework), so adjust the tests so they function within the framework. For tests that enter capability mode over the course of the test, the following is now done: 1. Fork child process for capability mode test. 2. In child... i. Enter capability mode. ii. Test invariants. iii. Exit after calling test function. 3. Collect status for child and determine whether or not it completed successfully. In order to test the invariants in the child process, they now use assert(3) instead of ATF_REQUIRE*, as the atf-c-api functions right to results files in the directories in order to determine where and how tests fail. While in the area, fix several -Wshadow and -Wunused warnings found when I bumped WARNS up to 6, and fix some minor style(9) issues with indentation and type alignment. PR: 215690 Modified: head/tests/sys/vfs/lookup_cap_dotdot.c Modified: head/tests/sys/vfs/lookup_cap_dotdot.c == --- head/tests/sys/vfs/lookup_cap_dotdot.c Sun Jan 1 00:43:20 2017 (r310993) +++ head/tests/sys/vfs/lookup_cap_dotdot.c Sun Jan 1 04:01:27 2017 (r310994) @@ -31,23 +31,27 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include +#include #include #include #include #include "freebsd_test_suite/macros.h" -static int dirfd = -1; -static char *abspath; +static char*abspath; +static int dirfd = -1; + +typedefvoid (*child_test_fn_t)(void); static void -touchat(int dirfd, const char *name) +touchat(int _dirfd, const char *name) { int fd; - ATF_REQUIRE((fd = openat(dirfd, name, O_CREAT | O_TRUNC | O_WRONLY, + ATF_REQUIRE((fd = openat(_dirfd, name, O_CREAT | O_TRUNC | O_WRONLY, 0777)) >= 0); ATF_REQUIRE(close(fd) == 0); } @@ -78,10 +82,43 @@ prepare_dotdot_tests(void) static void check_capsicum(void) { + ATF_REQUIRE_FEATURE("security_capabilities"); ATF_REQUIRE_FEATURE("security_capability_mode"); } +static void +run_capsicum_test(child_test_fn_t test_func) +{ + int child_exit_code, child_status; + pid_t child_pid; + + check_capsicum(); + prepare_dotdot_tests(); + + ATF_REQUIRE_MSG((child_pid = fork()) != -1, + "fork failed: %s", strerror(errno)); + + if (child_pid == 0) { + test_func(); + _exit(0); + } + + ATF_REQUIRE_MSG(waitpid(child_pid, &child_status, 0) != -1, + "waitpid failed: %s", strerror(errno)); + if (WIFEXITED(child_status)) { + child_exit_code = WEXITSTATUS(child_status); + ATF_REQUIRE_MSG(child_exit_code == 0, + "child exited with non-zero exit code: %d", + child_exit_code); + } else if (WIFSIGNALED(child_status)) + atf_tc_fail("child exited with signal: %d", + WTERMSIG(child_status)); + else + atf_tc_fail("child exited with unexpected status: %d", + child_status); +} + /* * Positive tests */ @@ -93,6 +130,7 @@ ATF_TC_HEAD(openat__basic_positive, tc) ATF_TC_BODY(openat__basic_positive, tc) { + prepare_dotdot_tests(); ATF_REQUIRE(openat(dirfd, "d1/d2/d3/f3", O_RDONLY) >= 0); @@ -114,21 +152,22 @@ ATF_TC_HEAD(lookup_cap_dotdot__basic, tc "Validate cap-mode (testdir)/d1/.. lookup"); } -ATF_TC_BODY(lookup_cap_dotdot__basic, tc) +static void +lookup_cap_dotdot__basic_child(void) { cap_rights_t rights; - int fd; - - check_capsicum(); - prepare_dotdot_tests(); cap_rights_init(&rights, CAP_LOOKUP, CAP_READ); - ATF_REQUIRE(cap_rights_limit(dirfd, &rights) >= 0); - ATF_REQUIRE(cap_enter() >= 0); + assert(cap_rights_limit(dirfd, &rights) >= 0); + assert(cap_enter() >= 0); + assert(openat(dirfd, "d1/..", O_RDONLY) >= 0); +} + +ATF_TC_BODY(lookup_cap_dotdot__basic, tc) +{ - ATF_REQUIRE_MSG(openat(dirfd, "d1/..", O_RDONLY) >= 0, "%s", - strerror(errno)); + run_capsicum_test(lookup_cap_dotdot__basic_child); } ATF_TC(lookup_cap_dotdot__advanced); @@ -138,23 +177,26 @@ ATF_TC_HEAD(lookup_cap_dotdot__advanced, "Validate cap-mode (testdir)/d1/.. lookup"); } -ATF_TC_BODY(lookup_cap_dotdot__advanced, tc) +static void +lookup_cap_dotdot__advanced_child(void) { cap_rights_t rights; - int fd; - - check_capsicum(); - prepare_dotdot_tests(); cap_rights_init(&rights, CAP_LOOKUP, C
svn commit: r310995 - head/tests/sys/vfs
Author: ngie Date: Sun Jan 1 04:02:06 2017 New Revision: 310995 URL: https://svnweb.freebsd.org/changeset/base/310995 Log: Bump WARNS to 6 to catch simple QA issues like some of the ones I squashed in r310994 Modified: head/tests/sys/vfs/Makefile Modified: head/tests/sys/vfs/Makefile == --- head/tests/sys/vfs/Makefile Sun Jan 1 04:01:27 2017(r310994) +++ head/tests/sys/vfs/Makefile Sun Jan 1 04:02:06 2017(r310995) @@ -9,4 +9,6 @@ CFLAGS.lookup_cap_dotdot.c+=-I${SRCTOP} PLAIN_TESTS_SH+= trailing_slash +WARNS?=6 + .include ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r310996 - head/lib/libarchive/tests
Author: ngie Date: Sun Jan 1 04:13:24 2017 New Revision: 310996 URL: https://svnweb.freebsd.org/changeset/base/310996 Log: Look for list.h in ${.CURDIR} to unbreak the build with a ports-based copy of llvm38 on ^/stable/11 (oh, the bugs you find when you set CC,CXX,CPP manually and it skips the bootstrap stage for the toolchain...) Modified: head/lib/libarchive/tests/Makefile Modified: head/lib/libarchive/tests/Makefile == --- head/lib/libarchive/tests/Makefile Sun Jan 1 04:02:06 2017 (r310995) +++ head/lib/libarchive/tests/Makefile Sun Jan 1 04:13:24 2017 (r310996) @@ -12,7 +12,7 @@ BINDIR= ${TESTSDIR} PROGS+=libarchive_test -CFLAGS+= -I${.CURDIR:H} -I${.OBJDIR} +CFLAGS+= -I${.CURDIR} -I${.CURDIR:H} -I${.OBJDIR} CFLAGS+= -I${_LIBARCHIVEDIR}/libarchive -I${_LIBARCHIVEDIR}/test_utils CFLAGS+= -DHAVE_LIBLZMA=1 -DHAVE_LZMA_H=1 ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r310999 - head/contrib/bsnmp/lib
Author: ngie Date: Sun Jan 1 05:13:54 2017 New Revision: 310999 URL: https://svnweb.freebsd.org/changeset/base/310999 Log: bsnmpclient(3) also documents snmp_client_init, snmp_client_set_host, and snmp_client_set_port. Add them to the NAME section MFC after:3 days Modified: head/contrib/bsnmp/lib/bsnmpclient.3 Modified: head/contrib/bsnmp/lib/bsnmpclient.3 == --- head/contrib/bsnmp/lib/bsnmpclient.3Sun Jan 1 04:48:38 2017 (r310998) +++ head/contrib/bsnmp/lib/bsnmpclient.3Sun Jan 1 05:13:54 2017 (r310999) @@ -36,6 +36,9 @@ .Os .Sh NAME .Nm snmp_client , +.Nm snmp_client_init , +.Nm snmp_client_set_host , +.Nm snmp_client_set_port , .Nm snmp_send_cb_f , .Nm snmp_timeout_cb_f , .Nm snmp_timeout_start_f , ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r311000 - head/contrib/bsnmp/lib
Author: ngie Date: Sun Jan 1 05:14:58 2017 New Revision: 311000 URL: https://svnweb.freebsd.org/changeset/base/311000 Log: Fix spelling errors MFC after:3 days Reported by: igor Modified: head/contrib/bsnmp/lib/bsnmpclient.3 Modified: head/contrib/bsnmp/lib/bsnmpclient.3 == --- head/contrib/bsnmp/lib/bsnmpclient.3Sun Jan 1 05:13:54 2017 (r310999) +++ head/contrib/bsnmp/lib/bsnmpclient.3Sun Jan 1 05:14:58 2017 (r311000) @@ -211,13 +211,13 @@ The community name to be used for SET re The default is .Sq private . .It Va identifier -The message indentifier value to be used with SNMPv3 PDUs. Incremented with +The message identifier value to be used with SNMPv3 PDUs. Incremented with each transmitted PDU. .It Va security_model The security model to be used with SNMPv3 PDUs. Currently only User-Based Security model specified by RFC 3414 (value 3) is supported. .It Va engine -The authorative SNMP engine parameters to be used with SNMPv3 PDUs. +The authoritive SNMP engine parameters to be used with SNMPv3 PDUs. .It Va user The USM SNMP user credentials to be used with SNMPv3 PDUs. .It Va clen @@ -416,7 +416,7 @@ response is received. When a response is received or the retransmission count is exceeded the callback .Fa func -is called with the orignal request PDU, the response PDU and the user argument +is called with the original request PDU, the response PDU and the user argument .Fa uarg . If the retransmit count is exceeded, .Fa func @@ -651,7 +651,7 @@ If a response was received 0 is returned .Pp The function .Fn snmp_discover_engine -is used to discover the authorative snmpEngineId of a remote SNMPv3 agent. +is used to discover the authoritative snmpEngineId of a remote SNMPv3 agent. A request PDU with empty USM user name is sent and the client's engine parameters are set according to the snmpEngine parameters received in the response PDU. @@ -659,10 +659,10 @@ If the client is configured to use authe snmpEngineBoots and/or snmpEngineTime in the response had zero values, an additional request (possibly encrypted) with the appropriate user credentials is sent to fetch the missing values. -Note, that the function blocks until the discovery proccess is completed. +Note, that the function blocks until the discovery process is completed. If no response could be received after all timeouts and retries, or the response contained errors the function returns -1. -If the discovery proccess was completed 0 is returned. +If the discovery process was completed 0 is returned. .Pp The function .Fn snmp_parse_server ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r311001 - head/contrib/bsnmp/lib
Author: ngie Date: Sun Jan 1 05:16:24 2017 New Revision: 311001 URL: https://svnweb.freebsd.org/changeset/base/311001 Log: Bump .Dd for the spelling and .Nm updates MFC after:3 days Modified: head/contrib/bsnmp/lib/bsnmpclient.3 Modified: head/contrib/bsnmp/lib/bsnmpclient.3 == --- head/contrib/bsnmp/lib/bsnmpclient.3Sun Jan 1 05:14:58 2017 (r311000) +++ head/contrib/bsnmp/lib/bsnmpclient.3Sun Jan 1 05:16:24 2017 (r311001) @@ -31,7 +31,7 @@ .\" .\" $Begemot: bsnmp/lib/bsnmpclient.3,v 1.12 2005/10/04 08:46:50 brandt_h Exp $ .\" -.Dd September 9, 2010 +.Dd December 31, 2016 .Dt BSNMPCLIENT 3 .Os .Sh NAME ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r311002 - in head: lib/libbsnmp/libbsnmp tools/build/mk
Author: ngie Date: Sun Jan 1 05:21:08 2017 New Revision: 311002 URL: https://svnweb.freebsd.org/changeset/base/311002 Log: Install bsnmpclient(3) as snmp_client_{init,set_host,set_port}(3) MFC after:3 days X-MFC with: r310999 Modified: head/lib/libbsnmp/libbsnmp/Makefile head/tools/build/mk/OptionalObsoleteFiles.inc Modified: head/lib/libbsnmp/libbsnmp/Makefile == --- head/lib/libbsnmp/libbsnmp/Makefile Sun Jan 1 05:16:24 2017 (r311001) +++ head/lib/libbsnmp/libbsnmp/Makefile Sun Jan 1 05:21:08 2017 (r311002) @@ -77,6 +77,9 @@ MLINKS+= bsnmpagent.3tree_size.3 MLINKS+= bsnmpclient.3 snmp_add_binding.3 MLINKS+= bsnmpclient.3 snmp_client.3 +MLINKS+= bsnmpclient.3 snmp_client_init.3 +MLINKS+= bsnmpclient.3 snmp_client_set_host.3 +MLINKS+= bsnmpclient.3 snmp_client_set_port.3 MLINKS+= bsnmpclient.3 snmp_close.3 MLINKS+= bsnmpclient.3 snmp_dialog.3 MLINKS+= bsnmpclient.3 snmp_discover_engine.3 Modified: head/tools/build/mk/OptionalObsoleteFiles.inc == --- head/tools/build/mk/OptionalObsoleteFiles.inc Sun Jan 1 05:16:24 2017(r311001) +++ head/tools/build/mk/OptionalObsoleteFiles.inc Sun Jan 1 05:21:08 2017(r311002) @@ -824,6 +824,9 @@ OLD_FILES+=usr/share/man/man3/asn_slice_ OLD_FILES+=usr/share/man/man3/snmp_add_binding.3.gz OLD_FILES+=usr/share/man/man3/snmp_calc_keychange.3.gz OLD_FILES+=usr/share/man/man3/snmp_client.3.gz +OLD_FILES+=usr/share/man/man3/snmp_client_init.3.gz +OLD_FILES+=usr/share/man/man3/snmp_client_set_host.3.gz +OLD_FILES+=usr/share/man/man3/snmp_client_set_port.3.gz OLD_FILES+=usr/share/man/man3/snmp_close.3.gz OLD_FILES+=usr/share/man/man3/snmp_debug.3.gz OLD_FILES+=usr/share/man/man3/snmp_dep_commit.3.gz ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r311003 - head/contrib/bsnmp/lib
Author: ngie Date: Sun Jan 1 05:23:01 2017 New Revision: 311003 URL: https://svnweb.freebsd.org/changeset/base/311003 Log: Fix spelling errors; bump .Dd for the change MFC after:3 days Modified: head/contrib/bsnmp/lib/bsnmplib.3 Modified: head/contrib/bsnmp/lib/bsnmplib.3 == --- head/contrib/bsnmp/lib/bsnmplib.3 Sun Jan 1 05:21:08 2017 (r311002) +++ head/contrib/bsnmp/lib/bsnmplib.3 Sun Jan 1 05:23:01 2017 (r311003) @@ -37,7 +37,7 @@ .\" .\" $Begemot: bsnmp/lib/bsnmplib.3,v 1.9 2005/10/04 08:46:51 brandt_h Exp $ .\" -.Dd December 19, 2010 +.Dd December 31, 2016 .Dt BSNMPLIB 3 .Os .Sh NAME @@ -381,7 +381,7 @@ The function verifies the authentication parameter contained in the PDU (if present) and if the PDU is encrypted, decrypts the PDU contents pointed to by .Fa buf . -If successfull, a plain text scoped PDU is stored in the buffer. +If successful, a plain text scoped PDU is stored in the buffer. .Pp The function .Fn snmp_pdu_init_secparams @@ -477,7 +477,7 @@ The requested securityLevel contained in The PDU authentication parameter received in the PDU did not match the calculated message digest. .It Bq Er SNMP_CODE_EDECRYPT -Error occured while trying to decrypt the PDU. +Error occurred while trying to decrypt the PDU. .El .Pp .Fn snmp_pdu_encode ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"