public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* vsnprintf patch
@ 2003-08-13 11:52 Adrian Reber
  2003-08-13 12:16 ` Andreas Schwab
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Adrian Reber @ 2003-08-13 11:52 UTC (permalink / raw)
  To: linux-kernel


When using the snprintf function from the kernel the length returned is
not the length written:

len = snprintf(test,1,"BLA 1"); 

len is 5 although test is "B"

the patch below fixes the symptom, but I am not sure if this is the real
solution for this problem.


--- linux-2.6.0-test3.orig/lib/vsprintf.c       2003-08-09 06:40:52.000000000 +0200
+++ linux-2.6.0-test3/lib/vsprintf.c    2003-08-13 13:41:15.000000000 +0200
@@ -455,7 +455,10 @@
        /* the trailing null byte doesn't count towards the total
        * ++str;
        */
-       return str-buf;
+       if (str-buf > size)
+               return size;
+       else
+               return str-buf;
 }
 
 /**



		Adrian

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-08-13 12:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-08-13 11:52 vsnprintf patch Adrian Reber
2003-08-13 12:16 ` Andreas Schwab
2003-08-13 12:19 ` viro
2003-08-13 12:21 ` Bernd Petrovitsch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox