Skip to contentSkip to conversation

ARM: plat-samsung: using vsnprintf instead of vsprintf for the limit buffer length 256

PATCH New Chen Gang 3 participants 5 messages Jan 21, 2013 – Jan 22, 2013

Subsystems (3)
lore
Share & tools
lore

Chen Gang

author
#0 lore raw

PATCH 1/1 ARM: plat-samsung: using vsnprintf instead of vsprintf for the limit buffer length 256

the buff size is 256, so need use vsnprintf instead of vsprintf.

---
 arch/arm/plat-samsung/pm.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/plat-samsung/pm.c +1 -1
index 1507028..8d07b45 100644
@@ -51,7 +51,7 @@ void s3c_pm_dbg(const char *fmt, ...)
 	char buff[256];
 
 	va_start(va, fmt);
-	vsprintf(buff, fmt, va);
+	vsnprintf(buff, 256, fmt, va);
 	va_end(va);
 
 	printascii(buff);
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 1/1 ARM: plat-samsung: using vsnprintf instead of vsprintf for the limit buffer length 256

Quoted 13 lines · Chen Gang

the buff size is 256, so need use vsnprintf instead of vsprintf.

---
 arch/arm/plat-samsung/pm.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/plat-samsung/pm.c +0 -0
index 1507028..8d07b45 100644

arch/arm/plat-samsung/pm.c void s3c_pm_dbg(const char *fmt, ...) · line 54

Quoted 5 lines
arch/arm/plat-samsung/pm.c +1 -1
@@ -51,7 +51,7 @@ void s3c_pm_dbg(const char *fmt, ...)
 	char buff[256];
 
 	va_start(va, fmt);
-	vsprintf(buff, fmt, va);
+	vsnprintf(buff, 256, fmt, va);

How about: vsnprintf(buff, sizeof(buff), fmt, va);

It means we do not end up assuming the size of 'buff' and will be correct if the code is changed to declare 'buff' to be a different size.

Signature · 3 lines
Ben Dooks, ben at fluff.org, http://www.fluff.org/ben/

Large Hadron Colada: A large Pina Colada that makes the universe disappear.
#3 lore raw

PATCH 1/1 ARM: plat-samsung: using vsnprintf instead of vsprintf for the limit buffer length 256

In reply to Chen Gang
Quoted 13 lines · Chen Gang

the buff size is 256, so need use vsnprintf instead of vsprintf.

---
 arch/arm/plat-samsung/pm.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/plat-samsung/pm.c +0 -0
index 1507028..8d07b45 100644

arch/arm/plat-samsung/pm.c void s3c_pm_dbg(const char *fmt, ...) · line 54

Quoted 5 lines
arch/arm/plat-samsung/pm.c +1 -1
@@ -51,7 +51,7 @@ void s3c_pm_dbg(const char *fmt, ...)
 	char buff[256];
 
 	va_start(va, fmt);
-	vsprintf(buff, fmt, va);
+	vsnprintf(buff, 256, fmt, va);

sizeof(buff) would be better here so that it depends on the actual buffer size.

author
#2 lore raw

PATCH 1/1 ARM: plat-samsung: using vsnprintf instead of vsprintf for the limit buffer length 256

In reply to Ben Dooks
Quoted 4 lines · Ben Dooks

How about: vsnprintf(buff, sizeof(buff), fmt, va);

It means we do not end up assuming the size of 'buff' and will be correct if the code is changed to declare 'buff' to be a different size.

thank you, I will send patch v2.

:-)

Signature · 3 lines
Chen Gang

Asianux Corporation
author
#4 lore raw

PATCH 1/1 ARM: plat-samsung: using vsnprintf instead of vsprintf for the limit buffer length 256

In reply to Russell King - ARM Linux
Quoted 2 lines · Russell King - ARM Linux

sizeof(buff) would be better here so that it depends on the actual buffer size.

thank you, I will send patch v2.

:-)

Signature · 3 lines
Chen Gang

Asianux Corporation