Date: Mon, 13 Jan 2020 22:33:48 +0000 (UTC) From: Eric van Gyzen <vangyzen@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r356708 - head/usr.sbin/fstyp Message-ID: <202001132233.00DMXmMD067072@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: vangyzen Date: Mon Jan 13 22:33:48 2020 New Revision: 356708 URL: https://svnweb.freebsd.org/changeset/base/356708 Log: fstyp hammer: use strlcpy Use strlcpy to guarantee NUL termination. Due to this, there is no need for strncmp; simply use strcmp. Reported by: Coverity CID: 1412242 MFC after: 2 weeks Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D23159 Modified: head/usr.sbin/fstyp/hammer.c Modified: head/usr.sbin/fstyp/hammer.c ============================================================================== --- head/usr.sbin/fstyp/hammer.c Mon Jan 13 22:06:16 2020 (r356707) +++ head/usr.sbin/fstyp/hammer.c Mon Jan 13 22:33:48 2020 (r356708) @@ -76,7 +76,7 @@ __test_ondisk(const hammer_volume_ondisk_t ondisk) assert(count != 0); memcpy(&fsid, &ondisk->vol_fsid, sizeof(fsid)); memcpy(&fstype, &ondisk->vol_fstype, sizeof(fstype)); - strncpy(label, ondisk->vol_label, sizeof(label)); + strlcpy(label, ondisk->vol_label, sizeof(label)); } else { if (ondisk->vol_count != count) return (5); @@ -84,7 +84,7 @@ __test_ondisk(const hammer_volume_ondisk_t ondisk) return (6); if (memcmp(&ondisk->vol_fstype, &fstype, sizeof(fstype))) return (7); - if (strncmp(ondisk->vol_label, label, sizeof(label))) + if (strcmp(ondisk->vol_label, label)) return (8); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202001132233.00DMXmMD067072>