git: 3e8d10f256d5 - stable/14 - inotify: Use memcmp() to compare embedded file names

Mark Johnston <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.src
Message-ID <6a7353d8.457fa.58b88193__16540.815720667$1785943214$gmane$org@gitrepo.freebsd.org>
The branch stable/14 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=3e8d10f256d5b2987370dbfefbca8c3f5f469113

commit 3e8d10f256d5b2987370dbfefbca8c3f5f469113
Author:     Mark Johnston <[email protected]>
AuthorDate: 2025-07-07 19:30:35 +0000
Commit:     Mark Johnston <[email protected]>
CommitDate: 2026-08-05 15:15:16 +0000

    inotify: Use memcmp() to compare embedded file names
    
    Otherwise gcc warns that strcmp() will read a byte from a zero-length
    array, though in practice we exclude that case with an explicit length
    check.
    
    Fixes:  f1f230439fa4 ("vfs: Initial revision of inotify")
    (cherry picked from commit bc6b526e2b71cf7e07806db5bc77926ed5c874f7)
---
 sys/kern/vfs_inotify.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/kern/vfs_inotify.c b/sys/kern/vfs_inotify.c
index 3542989c6a48..8c9e7599b888 100644
--- a/sys/kern/vfs_inotify.c
+++ b/sys/kern/vfs_inotify.c
@@ -500,7 +500,7 @@ inotify_can_coalesce(struct inotify_softc *sc, struct inotify_event *evp)
 	return (prev != NULL && prev->ev.mask == evp->mask &&
 	    prev->ev.wd == evp->wd && prev->ev.cookie == evp->cookie &&
 	    prev->ev.len == evp->len &&
-	    (evp->len == 0 || strcmp(prev->ev.name, evp->name) == 0));
+	    memcmp(prev->ev.name, evp->name, evp->len) == 0);
 }
 
 static void
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.