Skip to contentSkip to conversation

don't dereference NULL for a hostdata string with no "="

PATCH New Jim Meyering 2 participants 3 messages Jun 29, 2009 – Jul 2, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 don't dereference NULL for a hostdata string with no "="

I didn't try to trigger this failure, but it looks like it'd be easy to do. Just use a "hostdata" option, but omit the "=".

From a4d5ba668ecdabc9cbeac7a8f6ce5d227edae6b7 Mon Sep 17 00:00:00 2001
From: Jim Meyering <[email protected]>
Date: Mon, 29 Jun 2009 17:58:16 +0200
Subject: [PATCH gfs2-utils] don't dereference NULL for a hostdata string with no "="

* gfs2/mount/util.c (lock_dlm_join): Instead, just ignore it.

---
 gfs2/mount/util.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
gfs2/mount/util.c +5 -3
index 57a432a..0e009bd 100644
@@ -492,9 +492,11 @@ int lock_dlm_join(struct mount_options *mo, struct gen_sb *sb)
 	if (!mo->hostdata[0])
 		snprintf(mo->hostdata, PATH_MAX, "%s", ma.hostdata);
 	else {
-		char *p = strstr(ma.hostdata, "=") + 1;
-		strcat(mo->hostdata, ":");
-		strcat(mo->hostdata, p);
+		const char *p = strstr(ma.hostdata, "=");
+		if (p) {
+			strcat(mo->hostdata, ":");
+			strcat(mo->hostdata, p + 1);
+		}
 	}
 
 	log_debug("lock_dlm_join: hostdata: \"%s\"", mo->hostdata);

--
1.6.3.3.467.g98a79

#1 lore raw

PATCH 1/1 don't dereference NULL for a hostdata string with no "="

Hi,

Looks good to me,

Steve.

Quoted 36 lines · Jim Meyering

I didn't try to trigger this failure, but it looks like it'd be easy to do. Just use a "hostdata" option, but omit the "=".

Quoted 1 line

From a4d5ba668ecdabc9cbeac7a8f6ce5d227edae6b7 Mon Sep 17 00:00:00 2001

From: Jim Meyering <[email protected]>
Date: Mon, 29 Jun 2009 17:58:16 +0200
Subject: [PATCH gfs2-utils] don't dereference NULL for a hostdata string with no "="

* gfs2/mount/util.c (lock_dlm_join): Instead, just ignore it.

---
 gfs2/mount/util.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
gfs2/mount/util.c +5 -4
index 57a432a..0e009bd 100644
@@ -492,9 +492,11 @@ int lock_dlm_join(struct mount_options *mo, struct gen_sb *sb)
 	if (!mo->hostdata[0])
 		snprintf(mo->hostdata, PATH_MAX, "%s", ma.hostdata);
 	else {
-		char *p = strstr(ma.hostdata, "=") + 1;
-		strcat(mo->hostdata, ":");
-		strcat(mo->hostdata, p);
+		const char *p = strstr(ma.hostdata, "=");
+		if (p) {
+			strcat(mo->hostdata, ":");
+			strcat(mo->hostdata, p + 1);
+		}
 	}
 
 	log_debug("lock_dlm_join: hostdata: \"%s\"", mo->hostdata);
--

1.6.3.3.467.g98a79

#2 lore raw

PATCH 1/1 don't dereference NULL for a hostdata string with no "="

Quoted 1 line · Steven Whitehouse

Looks good to me,

Thanks. Pushed.

Quoted 9 lines · Jim Meyering
Quoted 8 lines

I didn't try to trigger this failure, but it looks like it'd be easy to do. Just use a "hostdata" option, but omit the "=".

Quoted 1 line

From a4d5ba668ecdabc9cbeac7a8f6ce5d227edae6b7 Mon Sep 17 00:00:00 2001

From: Jim Meyering <[email protected]>
Date: Mon, 29 Jun 2009 17:58:16 +0200
Subject: [PATCH gfs2-utils] don't dereference NULL for a hostdata string with no "="