Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 23 May 2023 01:20:02 GMT
From:      Enji Cooper <ngie@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 5a9c724847f9 - main - Correct size parameter to strncmp
Message-ID:  <202305230120.34N1K2iF016490@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by ngie:

URL: https://cgit.FreeBSD.org/src/commit/?id=5a9c724847f9b4e3831aa2c16276cc2ae20a99cc

commit 5a9c724847f9b4e3831aa2c16276cc2ae20a99cc
Author:     Rose <83477269+AtariDreams@users.noreply.github.com>
AuthorDate: 2023-05-08 23:08:18 +0000
Commit:     Enji Cooper <ngie@FreeBSD.org>
CommitDate: 2023-05-23 01:16:29 +0000

    Correct size parameter to strncmp
    
    The wrong value passed to strncmp meant that only enable and disable were being
    accepted. This change corrects the logic so enabled and disabled are also
    accepted.
    
    Pull Request: https://github.com/freebsd/freebsd-src/pull/739
    MFC after: 1 week
    Reviewed by: delphij, ngie
---
 usr.sbin/mptutil/mpt_volume.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/usr.sbin/mptutil/mpt_volume.c b/usr.sbin/mptutil/mpt_volume.c
index 9c160542f51c..04f69bcdf929 100644
--- a/usr.sbin/mptutil/mpt_volume.c
+++ b/usr.sbin/mptutil/mpt_volume.c
@@ -246,9 +246,9 @@ volume_cache(int ac, char **av)
 	Settings = volume->VolumeSettings.Settings;
 
 	NewSettings = Settings;
-	if (strncmp(av[2], "enable", sizeof("enable")) == 0)
+	if (strncmp(av[2], "enable", strlen("enable")) == 0)
 		NewSettings |= 0x01;
-	if (strncmp(av[2], "disable", sizeof("disable")) == 0)
+	else if (strncmp(av[2], "disable", strlen("disable")) == 0)
 		NewSettings &= ~0x01;
 
 	if (NewSettings == Settings) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202305230120.34N1K2iF016490>