Skip to contentSkip to conversation

main - cov: check strchr for NULL

PATCH Zdenek Kabelac 1 participant 1 message Sep 21, 2021

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=7bd55f8c152041101a27c83a96b794fdbb366460
Commit:        7bd55f8c152041101a27c83a96b794fdbb366460
Parent:        377e326156c74ef7aa7f5ac286bdabe3143a0b49
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Tue Sep 21 18:24:30 2021 +0200
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Tue Sep 21 21:03:47 2021 +0200

cov: check strchr for NULL

Although unlikely, ensuring coverity we not use NULL.

---
 daemons/lvmlockd/lvmlockd-dlm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
daemons/lvmlockd/lvmlockd-dlm.c +2 -1
index 68d18607c..1305c3dc2 100644
@@ -801,7 +801,8 @@ int lm_refresh_lv_start_dlm(struct action *act)
 	strncpy(path, act->path, PATH_MAX-1);
 
 	/* skip past dev */
-	p = strchr(path + 1, '/');
+	if (!(p = strchr(path + 1, '/')))
+		return -EINVAL;
 
 	/* skip past slashes */
 	while (*p == '/')