Date: Sat, 14 May 2016 17:07:13 -0700 From: "Ngie Cooper (yaneurabeya)" <yaneurabeya@gmail.com> To: Bruce Evans <brde@optusnet.com.au> Cc: Garrett Cooper <ngie@freebsd.org>, src-committers <src-committers@freebsd.org>, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r299770 - head/usr.sbin/bsnmpd/tools/libbsnmptools Message-ID: <53C0F48B-50C4-4453-849E-B84DC5CC5D56@gmail.com> In-Reply-To: <20160515093254.R2601@besplex.bde.org> References: <201605142243.u4EMh75e071378@repo.freebsd.org> <20160515093254.R2601@besplex.bde.org>
next in thread | previous in thread | raw e-mail | index | archive | help
> On May 14, 2016, at 16:42, Bruce Evans <brde@optusnet.com.au> wrote: >=20 > On Sat, 14 May 2016, Garrett Cooper wrote: =E2=80=A6 > Er, this is pointier than before. nitems() is only valid on arrays. You=E2=80=99re 100% correct. I forgot that it isn=E2=80=99t a magic = silver bullet that works with scalar pointers :(=E2=80=A6 >> Modified: head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c >> = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D >> --- head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c Sat May = 14 22:40:35 2016 (r299769) >> +++ head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c Sat May = 14 22:43:07 2016 (r299770) >> @@ -264,7 +264,7 @@ add_filename(struct snmp_toolinfo *snmpt >>=20 >> if (cut !=3D NULL) >> asn_append_oid(&(entry->cut), cut); >> - strlcpy(fstring, filename, sizeof(fstring)); >> + strlcpy(fstring, filename, nitems(fstring)); >=20 > fstring is pointer to char, so nitems(fstring) =3D sizeof(char *) / 1 > sizeof(char *) =3D accidentally the same wrong value as before. >=20 > The old code using strlen() had a chance of being correct. The old and new code was implementing strdup in a longhand way. I just = converted everything to strdup.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?53C0F48B-50C4-4453-849E-B84DC5CC5D56>