[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug in pre-html.cpp under IRIX
From: |
Jan Schaumann |
Subject: |
bug in pre-html.cpp under IRIX |
Date: |
Fri, 7 May 2004 17:58:56 -0400 |
User-agent: |
Mutt/1.4.1i |
Hi,
I realized that there appears to be a bug in
./src/preproc/html/pre-html.cpp of groff-1.19. The function
``make_message'' relies on vsnprintf to behave in a way that IRIX'
snprintf family does not. From the snprintf manual page under IRIX
(6.5.23):
snprintf places output, followed by a null character (\0), in
consecutive bytes starting at s. If more than len bytes of output
would be generated, the output is truncated at len bytes, including
the trailing null character.
make_message (const char *fmt, ...)
{
/* Guess we need no more than 100 bytes. */
int n, size = 100;
char *p;
char *np;
va_list ap;
if ((p = (char *)malloc (size)) == NULL)
return NULL;
while (1) {
/* Try to print in the allocated space. */
va_start(ap, fmt);
n = vsnprintf (p, size, fmt, ap);
va_end(ap);
/* If that worked, return the string. */
if (n > -1 && n < size) {
Here, if the string passed to make_message is larger than 100
characters, vsnprintf will return 99, thus truncating the string and
subsequent commands will fill (in particular `echo showpage | gs ...').
The attached patch fixes this, but there may be better, more elegant
solutions to this.
-Jan
--
Fate, it seems, is not without a sense of irony.
patch-af
Description: Text document
pgpwBVlULBdUm.pgp
Description: PGP signature
- bug in pre-html.cpp under IRIX,
Jan Schaumann <=