Patchwork [1/2] mount.cifs: check for NULL pointer before calling strchr()

login
register
mail settings
Submitter Jeff Layton
Date April 14, 2010, 6:08 p.m.
Message ID <1271268529-462-1-git-send-email-jlayton@samba.org>
Download mbox | patch
Permalink /patch/50174/
State New
Headers show

Comments

Jeff Layton - April 14, 2010, 6:08 p.m.
mount.cifs calls strchr on currentaddress, which may be a NULL pointer.

Signed-off-by: Jeff Layton <jlayton@samba.org>
---
 mount.cifs.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

Patch

diff --git a/mount.cifs.c b/mount.cifs.c
index acab8c8..f3aa464 100644
--- a/mount.cifs.c
+++ b/mount.cifs.c
@@ -1730,9 +1730,11 @@  mount_retry:
 		case ECONNREFUSED:
 		case EHOSTUNREACH:
 			currentaddress = nextaddress;
-			nextaddress = strchr(currentaddress, ',');
-			if (nextaddress)
-				*nextaddress++ = '\0';
+			if (currentaddress) {
+				nextaddress = strchr(currentaddress, ',');
+				if (nextaddress)
+					*nextaddress++ = '\0';
+			}
 			goto mount_retry;
 		case ENODEV:
 			fprintf(stderr,