Skip to contentSkip to conversation

libnfs.a: fix a bug when parse section's arg

PATCH In review Mi Jinlong 2 participants 6 messages Nov 5, 2010 – Nov 29, 2010

Subsystems (2)
lore
Share & tools
lore

Mi Jinlong

author
#0 lore raw

PATCH 1/1 libnfs.a: fix a bug when parse section's arg

When parsing section's arg at configure file, the pointer should stop when fetch ']', and give the warning message.

---
 support/nfs/conffile.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
support/nfs/conffile.c +2 -2
index 24640f4..798e5f3 100644
@@ -271,9 +271,9 @@ conf_parse_line(int trans, char *line, size_t sz)
 		if (ptr == NULL)
 			return;
 		line = ++ptr;
-		while (*ptr && *ptr != '"')
+		while (*ptr && *ptr != '"' && *ptr != ']')
 			ptr++;
-		if (*ptr == '\0') {
+		if (*ptr == '\0' || *ptr == ']') {
 			xlog_warn("config file error: line %d: "
  				"non-matched '\"', ignoring until next section", ln);
 		}  else {
Signature · 1 line
1.7.0.1
author
#1 lore raw

When parsing section's arg at configure file, the pointer should stop when fetch ']', and give the warning message.

---
 support/nfs/conffile.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
support/nfs/conffile.c +2 -2
index 24640f4..798e5f3 100644
@@ -271,9 +271,9 @@ conf_parse_line(int trans, char *line, size_t sz)
 		if (ptr == NULL)
 			return;
 		line = ++ptr;
-		while (*ptr && *ptr != '"')
+		while (*ptr && *ptr != '"' && *ptr != ']')
 			ptr++;
-		if (*ptr == '\0') {
+		if (*ptr == '\0' || *ptr == ']') {
 			xlog_warn("config file error: line %d: "
  				"non-matched '\"', ignoring until next section", ln);
 		}  else {

-- 1.7.0.1

#2 lore raw
Quoted 15 lines · Mi Jinlong

When parsing section's arg at configure file, the pointer should stop when fetch ']', and give the warning message.

---
 support/nfs/conffile.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
support/nfs/conffile.c +0 -0
index 24640f4..798e5f3 100644
@@ -271,9 +271,9 @@ conf_parse_line(int trans, char *line, size_t sz)
 		if (ptr == NULL)

support/nfs/conffile.c conf_parse_line(int trans, char *line, size_t sz) · line 279

Quoted 10 lines
support/nfs/conffile.c +2 -2
 			return;
 		line = ++ptr;
-		while (*ptr && *ptr != '"')
+		while (*ptr && *ptr != '"' && *ptr != ']')
 			ptr++;
-		if (*ptr == '\0') {
+		if (*ptr == '\0' || *ptr == ']') {
 			xlog_warn("config file error: line %d: "
  				"non-matched '\"', ignoring until next section", ln);
 		}  else {

I'm not seeing how this helps... I realize that with this patch we are saving the processing of a character or two... but what problem is this patch solving?

steved.

author
#3 lore raw

Steve Dickson :

Quoted 20 lines · Mi Jinlong
Quoted 19 lines

When parsing section's arg at configure file, the pointer should stop when fetch ']', and give the warning message.

---
 support/nfs/conffile.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
support/nfs/conffile.c +1 -1
index 24640f4..798e5f3 100644
@@ -271,9 +271,9 @@ conf_parse_line(int trans, char *line, size_t sz)
 		if (ptr == NULL)
 			return;
 		line = ++ptr;
-		while (*ptr && *ptr != '"')
+		while (*ptr && *ptr != '"' && *ptr != ']')
 			ptr++;
Quoted 8 lines

support/nfs/conffile.c conf_parse_line(int trans, char *line, size_t sz) · line 279

Quoted 5 lines
support/nfs/conffile.c +1 -1
-		if (*ptr == '\0') {
+		if (*ptr == '\0' || *ptr == ']') {
 			xlog_warn("config file error: line %d: "
  				"non-matched '\"', ignoring until next section", ln);
 		}  else {

I'm not seeing how this helps... I realize that with this patch we are saving the processing of a character or two... but what problem is this patch solving?

If user sets the section message as [ MountPoint "Mount_point ]" for some mistake, the function should print the warning message, but it continues with argument is "Mount_point ]".

After this patch, the function can process this problem correctly.

thanks,
Mi Jinlong

#4 lore raw
Quoted 32 lines · Mi Jinlong

Steve Dickson :

Quoted 20 lines · Mi Jinlong
Quoted 19 lines

When parsing section's arg at configure file, the pointer should stop when fetch ']', and give the warning message.

---
 support/nfs/conffile.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
support/nfs/conffile.c +1 -1
index 24640f4..798e5f3 100644
@@ -271,9 +271,9 @@ conf_parse_line(int trans, char *line, size_t sz)
 		if (ptr == NULL)
 			return;
 		line = ++ptr;
-		while (*ptr && *ptr != '"')
+		while (*ptr && *ptr != '"' && *ptr != ']')
 			ptr++;
Quoted 8 lines

support/nfs/conffile.c conf_parse_line(int trans, char *line, size_t sz) · line 279

Quoted 5 lines
support/nfs/conffile.c +1 -1
-		if (*ptr == '\0') {
+		if (*ptr == '\0' || *ptr == ']') {
 			xlog_warn("config file error: line %d: "
  				"non-matched '\"', ignoring until next section", ln);
 		}  else {

I'm not seeing how this helps... I realize that with this patch we are saving the processing of a character or two... but what problem is this patch solving?

Quoted 5 lines

If user sets the section message as [ MountPoint "Mount_point ]" for some mistake, the function should print the warning message, but it continues with argument is "Mount_point ]".

After this patch, the function can process this problem correctly.

Ok... I see the problem now... Thanks!

steved.

Quoted 4 lines

thanks,
Mi Jinlong

#5 lore raw
In reply to Mi Jinlong
Quoted 13 lines · Mi Jinlong

When parsing section's arg at configure file, the pointer should stop when fetch ']', and give the warning message.

---
 support/nfs/conffile.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
support/nfs/conffile.c +0 -0
index 24640f4..798e5f3 100644
@@ -271,9 +271,9 @@ conf_parse_line(int trans, char *line, size_t sz)
 		if (ptr == NULL)

support/nfs/conffile.c conf_parse_line(int trans, char *line, size_t sz) · line 279

Quoted 10 lines
support/nfs/conffile.c +2 -2
 			return;
 		line = ++ptr;
-		while (*ptr && *ptr != '"')
+		while (*ptr && *ptr != '"' && *ptr != ']')
 			ptr++;
-		if (*ptr == '\0') {
+		if (*ptr == '\0' || *ptr == ']') {
 			xlog_warn("config file error: line %d: "
  				"non-matched '\"', ignoring until next section", ln);
 		}  else {

Committed...

steved.