Skip to contentSkip to conversation

opensm/opensm/osm_subnet.c: adjust buffer to ensure a '\n' is printed

PATCH Applied Ira Weiny 2 participants 2 messages Oct 15, 2009 1 message not in the archive InfiniBand

lore
Share & tools
lore

Ira Weiny

author
#0 lore raw

PATCH 1/1 opensm/opensm/osm_subnet.c: adjust buffer to ensure a '\n' is printed

From: Ira Weiny <[email protected]>
Date: Wed, 14 Oct 2009 17:05:53 -0700
Subject: [PATCH] opensm/opensm/osm_subnet.c: adjust buffer to ensure a '\n' is printed

When printing cached options strings which fill the print buffer. Adjust the length so the final snprintf(..., "\n"); can succeed.

---
 opensm/opensm/osm_subnet.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
opensm/opensm/osm_subnet.c +2 -2
index 647950e..ab9c327 100644
@@ -105,8 +105,8 @@ static void log_config_value(char *name, const char *fmt, ...)
 	if (n > sizeof(buf))
 		n = sizeof(buf);
 	n += vsnprintf(buf + n, sizeof(buf) - n, fmt, args);
-	if (n > sizeof(buf))
-		n = sizeof(buf);
+	if (n >= sizeof(buf)-1)
+		n = sizeof(buf)-2;
 	snprintf(buf + n, sizeof(buf) - n, "\n");
 	va_end(args);
 	printf("%s", buf);
Signature · 7 lines
1.5.4.5


--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 9 lines · Ira Weiny

From: Ira Weiny <[email protected]>
Date: Wed, 14 Oct 2009 17:05:53 -0700
Subject: [PATCH] opensm/opensm/osm_subnet.c: adjust buffer to ensure a '\n' is printed

When printing cached options strings which fill the print buffer. Adjust the length so the final snprintf(..., "\n"); can succeed.

Applied. Thanks.

Quoted 9 lines
---
 opensm/opensm/osm_subnet.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
opensm/opensm/osm_subnet.c +0 -0
index 647950e..ab9c327 100644

opensm/opensm/osm_subnet.c static void log_config_value(char *name, const char *fmt, ...) · line 108

Quoted 6 lines
opensm/opensm/osm_subnet.c +1 -2
@@ -105,8 +105,8 @@ static void log_config_value(char *name, const char *fmt, ...)
 	if (n > sizeof(buf))
 		n = sizeof(buf);
 	n += vsnprintf(buf + n, sizeof(buf) - n, fmt, args);
-	if (n > sizeof(buf))
-		n = sizeof(buf);
+	if (n >= sizeof(buf)-1)

I'm changing this to 'n > sizeof(buf) - 2' to match below line.

opensm/opensm/osm_subnet.c static void log_config_value(char *name, const char *fmt, ...) · line 109

Quoted 1 line
opensm/opensm/osm_subnet.c +1 -0
+		n = sizeof(buf)-2;

Sasha

Quoted 7 lines
opensm/opensm/osm_subnet.c +0 -0
 	snprintf(buf + n, sizeof(buf) - n, "\n");
 	va_end(args);
 	printf("%s", buf);
Signature · 1 line
1.5.4.5

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html