+2007-11-09 Bruno Haible <bruno@clisp.org>
+
+ * doc/functions/snprintf.texi: Mention BeOS deficiency.
+ * doc/functions/vsnprintf.texi: Likewise.
+ * lib/vasnprintf.c (VASNPRINTF): Ensure that we never call snprintf
+ with a size argument < 2.
+
2007-11-09 Bruno Haible <bruno@clisp.org>
* lib/vasnprintf.c (VASNPRINTF): Increase reallocation of snprintf
This function does not fully support the @samp{n} directive on some platforms:
HP-UX 11, mingw.
@item
+This function overwrites memory when a size = 1 argument is passed on some
+platforms:
+BeOS.
+@item
This function overwrites memory even when a zero size argument is passed on some
platforms:
OSF/1 5.1.
This function does not fully support the @samp{n} directive on some platforms:
HP-UX 11, mingw.
@item
+This function overwrites memory when a size = 1 argument is passed on some
+platforms:
+BeOS.
+@item
This function overwrites memory even when a zero size argument is passed on some
platforms:
HP-UX 11, OSF/1 5.1.
sizeof (TCHAR_T) divides sizeof (DCHAR_T) and
alignof (TCHAR_T) <= alignof (DCHAR_T). */
# define TCHARS_PER_DCHAR (sizeof (DCHAR_T) / sizeof (TCHAR_T))
+ /* Ensure that maxlen below will be >= 2. Needed on BeOS,
+ where an snprintf() with maxlen==1 acts like sprintf(). */
+ ENSURE_ALLOCATION (xsum (length,
+ (2 + TCHARS_PER_DCHAR - 1)
+ / TCHARS_PER_DCHAR));
/* Prepare checking whether snprintf returns the count
via %n. */
- ENSURE_ALLOCATION (xsum (length, 1));
*(TCHAR_T *) (result + length) = '\0';
#endif