Per the snprintf manpage, the correct means to check snprintf for an
insufficiently large buffer is to check if its return value is >= @size,
not > @size. Codex found this.
Cc: <linux-xfs@vger.kernel.org> # v6.17.0
Fixes: 8a4ea72724930c ("proto: add ability to populate a filesystem from a directory")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
/* Ensure we're within the limits of PATH_MAX. */
size_t avail = PATH_MAX - path_len;
size_t wrote = snprintf(path_buf + path_len, avail, "/%s", entry->d_name);
- if (wrote > avail)
+ if (wrote >= avail)
fail(path_buf, ENAMETOOLONG);
/*