vsnprintf patch

From: Adrian Reber
Date: Wed Aug 13 2003 - 06:56:35 EST



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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/