diff mbox series

[18/24] lnet: libcfs: set x->ls_len to 0 when x->ls_str is NULL

Message ID 1642124283-10148-19-git-send-email-jsimmons@infradead.org (mailing list archive)
State New, archived
Headers show
Series lustre: update to OpenSFS Jan 13, 2022 | expand

Commit Message

James Simmons Jan. 14, 2022, 1:37 a.m. UTC
From: Etienne AUJAMES <eaujames@ddn.com>

cfs_gettok() set next->ls_str to NULL if no delimiter is found but
it does not update next->ls_len to 0.

This patch fix cfs_gettok() to update "next->ls_len = 0;" if no
delimiter is found.

WC-bug-id: https://jira.whamcloud.com/browse/LU-15130
Lustre-commit: cec864b7938f1138d ("LU-15130 nrs: null pointer dereference in nrs_tbf_id_parse")
Signed-off-by: Etienne AUJAMES <eaujames@ddn.com>
Reviewed-on: https://review.whamcloud.com/45291
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Li Xi <lixi@ddn.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 net/lnet/libcfs/libcfs_string.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/net/lnet/libcfs/libcfs_string.c b/net/lnet/libcfs/libcfs_string.c
index 4259f8b8..0563c42 100644
--- a/net/lnet/libcfs/libcfs_string.c
+++ b/net/lnet/libcfs/libcfs_string.c
@@ -154,6 +154,7 @@  int cfs_str2mask(const char *str, const char *(*bit2str)(int bit),
 		/* there is no the delimeter in the string */
 		end = next->ls_str + next->ls_len;
 		next->ls_str = NULL;
+		next->ls_len = 0;
 	} else {
 		next->ls_str = end + 1;
 		next->ls_len -= (end - res->ls_str + 1);