patch-2.4.25 linux-2.4.25/lib/vsprintf.c
Next file: linux-2.4.25/mm/filemap.c
Previous file: linux-2.4.25/kernel/signal.c
Back to the patch index
Back to the overall index
- Lines: 37
- Date:
2004-02-18 05:36:32.000000000 -0800
- Orig file:
linux-2.4.24/lib/vsprintf.c
- Orig date:
2003-11-28 10:26:21.000000000 -0800
diff -urN linux-2.4.24/lib/vsprintf.c linux-2.4.25/lib/vsprintf.c
@@ -248,6 +248,18 @@
/* 'z' support added 23/7/1999 S.H. */
/* 'z' changed to 'Z' --davidm 1/25/99 */
+ /* Reject out-of-range values early */
+ if (unlikely((int) size < 0)) {
+ /* There can be only one.. */
+ static int warn = 1;
+ if (warn) {
+ printk(KERN_WARNING "improper call of vsnprintf!\n");
+ dump_stack();
+ warn = 0;
+ }
+ return 0;
+ }
+
str = buf;
end = buf + size - 1;
@@ -488,7 +500,7 @@
*/
int vsprintf(char *buf, const char *fmt, va_list args)
{
- return vsnprintf(buf, 0xFFFFFFFFUL, fmt, args);
+ return vsnprintf(buf, (~0U)>>1, fmt, args);
}
@@ -586,7 +598,7 @@
field_width = 1;
do {
*s++ = *str++;
- } while(field_width-- > 0 && *str);
+ } while (--field_width > 0 && *str);
num++;
}
continue;
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)